Skip to content

1.10: regression for embedding Julia with CMake #54339

Open
@jonathan-conder-sm

Description

@jonathan-conder-sm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    embeddingEmbedding Julia using the C API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions