Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.10: regression for embedding Julia with CMake #54339

Open
jonathan-conder-sm opened this issue May 3, 2024 · 2 comments
Open

1.10: regression for embedding Julia with CMake #54339

jonathan-conder-sm opened this issue May 3, 2024 · 2 comments
Labels
domain:embedding Embedding Julia using the C API

Comments

@jonathan-conder-sm
Copy link
Contributor

jonathan-conder-sm commented May 3, 2024

With Julia 1.9 on Linux, it is possible to embed Julia using the -fPIE compiler option rather than -fPIC. I'm aware this goes against the docs, but CMake's POSITION_INDEPENDENT_CODE defaults to -fPIE for executables and -fPIC for libraries, so it's mildly annoying to work around.

outdated info below

For example, I built this program (using the docs):

#include <julia.h>
JULIA_DEFINE_FAST_TLS

const char code[] =
    "try\n"
    "    error(123)\n"
    "catch\n"
    "    Base.display_error(current_exceptions())\n"
    "end\n"
    "nothing";

int main() {
    jl_init();

    if (jl_eval_string(code) != jl_nothing) {
        return 1;
    }

    return 0;
}

With 1.10.3 it prints an error message and exits with code 0, and the same works if you replace -fPIC with -fPIE. With 1.11.0-beta1 it works for -fPIC but with -fPIE it exits with a nonzero status without printing the message.

I've bisected this to 2defa57, but that might be a red herring if display_error relies on something from REPL. However, it might be a while before I have time to investigate further.

julia> versioninfo()
Julia Version 1.11.0-beta1
Commit 08e1fc0abb9 (2024-04-10 08:40 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
Environment:
  JULIA_EDITOR = gvim --remote-tab-silent
@giordano giordano added domain:building Build system, or building Julia or its dependencies domain:embedding Embedding Julia using the C API and removed domain:building Build system, or building Julia or its dependencies labels May 3, 2024
@jonathan-conder-sm
Copy link
Contributor Author

jonathan-conder-sm commented May 6, 2024

This looks like it might actually be in 1.10 already. For example, this program works with -fPIC but not -fPIE on 1.10.0-alpha1. Working on bisecting now

#include <julia.h>
JULIA_DEFINE_FAST_TLS

int main() {
    jl_options.trace_compile = "stderr";

    jl_init();

    jl_eval_string("Base.JLOptions().use_compiled_modules == 1 || exit(1)");

    return 0;
}

@jonathan-conder-sm jonathan-conder-sm changed the title 1.11.0-beta1: regression for embedding Julia with CMake 1.10: regression for embedding Julia with CMake May 6, 2024
@jonathan-conder-sm
Copy link
Contributor Author

I've bisected it to 82c89c6 which makes more sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:embedding Embedding Julia using the C API
Projects
None yet
Development

No branches or pull requests

2 participants