Skip to content

Commit

Permalink
Update embeding flags
Browse files Browse the repository at this point in the history
* Include threading flags. Fix #16868
* Add document about exporting symbols from main executable. Fix #17451
  • Loading branch information
yuyichao committed Jul 16, 2016
1 parent 1fd440e commit da5c9e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions contrib/julia-config.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions doc/manual/embedding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------------------------------------------

Expand Down

0 comments on commit da5c9e1

Please sign in to comment.