From da5c9e1e30e7eeef21a72cfbce09dcf5a82dac91 Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Sat, 16 Jul 2016 10:08:11 -0400 Subject: [PATCH] Update embeding flags * Include threading flags. Fix #16868 * Add document about exporting symbols from main executable. Fix #17451 --- contrib/julia-config.jl | 13 +++++++++++-- doc/manual/embedding.rst | 4 ++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/contrib/julia-config.jl b/contrib/julia-config.jl index a3abff9d3a21f1..bed86198098f71 100755 --- a/contrib/julia-config.jl +++ b/contrib/julia-config.jl @@ -8,6 +8,14 @@ const options = "--ldlibs" ]; +function threadingOn() + try + return cglobal(:jl_tls_states) == C_NULL + catch + return true + end +end + function imagePath() opts = Base.JLOptions() unsafe_string(opts.image_file) @@ -57,10 +65,11 @@ end function cflags() arg1 = replace(initDir(),"\\","\\\\\\\\") arg2 = replace(includeDir(),"\\","\\\\") + threading_def = threadingOn() ? "-DJULIA_ENABLE_THREADING=1 " : "" if is_unix() - return """-fPIC -DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""" + return """$(threading_def)-fPIC -DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""" else - return """-DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""" + return """$(threading_def)-DJULIA_INIT_DIR=\\"$arg1\\" -I$arg2""" end end diff --git a/doc/manual/embedding.rst b/doc/manual/embedding.rst index dd943f19a21422..637f06b3cf5d46 100644 --- a/doc/manual/embedding.rst +++ b/doc/manual/embedding.rst @@ -56,6 +56,10 @@ Before the program terminates, it is strongly recommended to call ``jl_atexit_ho >>> julia.jl_init('.') 250593296 +.. note:: + + If the julia program needs to access symbols from the main executable, it may be necessary to add ``-Wl,--export-dynamic`` linker flag at compile time on Linux in additional to the ones generated by ``julia-config.jl`` described below. This is not necessary when compiling a shared library. + Using julia-config to automatically determine build parameters --------------------------------------------------------------