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

Unresolved symbol small_typeof when jl_typeof is used on Windows with 1.10.0-beta1 #50714

Closed
Taaitaaiger opened this issue Jul 29, 2023 · 8 comments · Fixed by #50892
Closed
Assignees
Labels
domain:embedding Embedding Julia using the C API system:windows Affects only Windows
Milestone

Comments

@Taaitaaiger
Copy link
Contributor

If I try to compile code on Windows that uses jl_typeof compilation fails because small_typeof can't be resolved.

Reproducer:

#include <julia.h>

int main(int argc, char* argv[])
{
    jl_init();
    jl_value_t *v = jl_eval_string("print(sqrt(2.0))");
    jl_value_t *t = jl_typeof(v);
    jl_atexit_hook(0);
    return 0;
}
@giordano giordano added system:windows Affects only Windows domain:embedding Embedding Julia using the C API labels Jul 29, 2023
@giordano giordano added this to the 1.10 milestone Jul 29, 2023
@gbaraldi
Copy link
Member

gbaraldi commented Aug 2, 2023

@vtjnash do we need to annotate small_typeof in jl_exported_data.inc or should it just work?

@topolarity
Copy link
Member

Hmm, this doesn't reproduce for me in Cygwin:

$ export JULIA_PATH="/cygdrive/c/Users/cody/.julia/juliaup/julia-1.10.0-beta1+0.x64.w64.mingw32/"
$ x86_64-w64-mingw32-gcc main.c -fPIC -I$JULIA_PATH/include/julia -ljulia -L$JULIA_PATH/bin -o $JULIA_PATH/bin/test.exe       
$ $JULIA_PATH/bin/test.exe
1.4142135623730951

Can you share your build environment details, and the command-line invocations (or a build script) for the MWE?

@Taaitaaiger
Copy link
Contributor Author

I used MSVC, configured as mentioned here. I'll have to check which versions I've used specifically.

The problem originally arose in a Yggdrasil recipe that builds a static library, but that script is written in Rust (you can find it here if you're curious).

@giordano is it possible to view old build logs for Yggdrasil? I think there might be some useful info there about what flags were set, otherwise I can retry it locally.

@topolarity
Copy link
Member

Yep, reproduces for me with MSVC via cl.exe main.c /I %JULIA_PATH%\include\julia /TP /link /LIBPATH:%JULIA_PATH%\lib libjulia.dll.a /nologo:

main.c
C:\Users\cody\.julia\juliaup\julia-1.10.0-beta1+0.x64.w64.mingw32\include\julia\julia_assert.h(13): warning C4068: unknown pragma 'GCC'
C:\Users\cody\.julia\juliaup\julia-1.10.0-beta1+0.x64.w64.mingw32\include\julia\julia_assert.h(32): warning C4068: unknown pragma 'GCC'
main.obj : error LNK2019: unresolved external symbol small_typeof referenced in function jl_to_typeof
main.exe : fatal error LNK1120: 1 unresolved externals

@giordano
Copy link
Contributor

giordano commented Aug 11, 2023

is it possible to view old build logs for Yggdrasil?

https://buildkite.com/julialang/yggdrasil/builds/4371#01899da4-2877-4b36-af5a-851595227d91/644-987

@Taaitaaiger
Copy link
Contributor Author

Thanks! I think I might know why it failed in Yggdrasil but @topolarity couldn't reproduce it: the build script doesn't link julia when the yggdrasil feature is enabled. That feature was originally added because linkjulia.dll.a was absent in the build environment, IIRC.

topolarity added a commit to topolarity/julia that referenced this issue Aug 12, 2023
topolarity added a commit to topolarity/julia that referenced this issue Aug 12, 2023
@vtjnash
Copy link
Sponsor Member

vtjnash commented Aug 14, 2023

Yeah, when you explicitly instructed it not to link against libjulia, we can't really expect that to work: https://github.com/Taaitaaiger/jlrs/blob/f77241a18d93f16242356eae621b5656aaa9afe0/jl_sys/build.rs#L177-L180
Seems like that is a quick fix for your build script though.

@vtjnash vtjnash closed this as completed Aug 14, 2023
@topolarity
Copy link
Member

This reproduces with our standard build instructions for MSVC (and with the cl.exe invocation given above).

@topolarity topolarity reopened this Aug 14, 2023
topolarity added a commit to topolarity/julia that referenced this issue Aug 15, 2023
topolarity added a commit to topolarity/julia that referenced this issue Aug 31, 2023
vtjnash pushed a commit that referenced this issue Sep 1, 2023
KristofferC pushed a commit that referenced this issue Sep 15, 2023
Resolves #50714

(cherry picked from commit 91b8c9b)
nalimilan pushed a commit that referenced this issue Nov 5, 2023
Resolves #50714

(cherry picked from commit 91b8c9b)
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 system:windows Affects only Windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants