tshort / StaticCompiler.jl

Compiles Julia code to a standalone library (experimental)
Other
494 stars 31 forks source link

undefined reference to `jl_n_threads' on Windows #6

Closed aminya closed 4 years ago

aminya commented 4 years ago

When running test/ccalls.jl

test.o: In function `call':

C:\Users\travis\.julia\packages\Cassette\YCOeN\src/context.jl:447: undefined reference to `jl_n_threads'

collect2.exe: error: ld returned 1 exit status

https://travis-ci.com/tshort/StaticCompiler.jl/jobs/261775338#L137

aminya commented 4 years ago

Caused by unsafe_load() in f()

aminya commented 4 years ago

By removing unsafe_load() we get: image

aminya commented 4 years ago

Happens when the shell command runs. image

tshort commented 4 years ago

Interesting. I thought jl_n_threads would be universal. There's probably another function that will suffice for this test. Will have to look.

aminya commented 4 years ago

It is not just this one. Running test/globals.jl gives a lot of similar errors: image

tshort commented 4 years ago

Interesting. Must be a deeper bug. I can look, but probably not for a couple of days.

tshort commented 4 years ago

I think the problem is that the macro jlrun cannot find libjulia. It should try to link to lib/libjulia.dll.a. It has a different name on Linux (and probably MacOS, too). This line probably needs to splice in a different library name, depending on the platform.

aminya commented 4 years ago

I addressed this in the PR now, but still doesn't work.

tshort commented 4 years ago

I played around with this locally for a bit and couldn't find a gcc command that would work.

aminya commented 4 years ago

There are some stuff to test from the documentation: https://docs.julialang.org/en/v1/manual/embedding/#

tshort commented 4 years ago

I hate compiling on Windows. Looks like it might be an ordering issue (hint here). So, the compile statement needs to have test.o -ljulia.dll instead of -ljulia.dll test.o.

aminya commented 4 years ago

image Yay, I think it is solved

aminya commented 4 years ago

Closed by https://github.com/aminya/StaticCompiler.jl/commit/64ef80b5bd407403fd77b7319c53120b239eab46