PackageCompiler.jl icon indicating copy to clipboard operation
PackageCompiler.jl copied to clipboard

create_app crashes with 'Error: export ordinal too large: 73406' on Julia v1.10-rc1

Open dustyirwin opened this issue 2 years ago • 6 comments

Hello, I am experiencing an error when attempting to run:

create_app("MyProj","MyProjCompiled", precompile_statements_file="precompile.jl", include_lazy_artifacts=false, incremental=false)

which eventually throws the error below on (what appears to be) one of the final steps of the compilation process:

... /.julia/artifacts/fdff308295487f361ef6e8dc2d27f5abe8a6eee9/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: Error: export ordinal too large: 73406 collect2.exe: error: ld returned 1 exit status

I do not get this error when incremental=true and the process completes successfully. After some Googling, it appears this error has something to do with exporting too many symbols for a 32-bit Int. I don't know if this is related, but I was not getting this error before installing MSYS2 and Glade3 for Windows for some Gtk development related to this project....

Any ideas?

Julia Version 1.10.0-rc1 Commit 5aaa948543 (2023-11-03 07:44 UTC) Build Info: Official https://julialang.org/ release Platform Info: OS: Windows (x86_64-w64-mingw32)
CPU: 12 × Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz WORD_SIZE: 64 LIBM: libopenlibm LLVM: libLLVM-15.0.7 (ORCJIT, skylake) Threads: 1 on 12 virtual cores

dustyirwin avatar Nov 12 '23 04:11 dustyirwin

it appears this error has something to do with exporting too many symbols for a 32-bit Int.

I'm not sure, the number 73406 obviously may come from Int32 or Int64, possibly more likely, but will not fit into UInt16:

https://stackoverflow.com/questions/47135973/error-export-ordinal-too-large-104116

The maximum ordinal number is defined by the Microsoft PE and COFF format. It is a 16-bit integer with a maximum of 65535.

I don't know the workaround here, other than incremental=true. At least that always works until you have a really huge project? I think it's simply not possible to make huge EXE files, i.e. with many methods, then you need to split projects up into DLLs. etc.

I think it's just an inherent limitation of Windows .exe programs, and I'm not sure if there's a similar limitation for other platforms e.g. Linux too, ELF format. You could try to compile a Linux program, and those actually work in Windows under WSL2...

PallHaraldsson avatar Nov 19 '23 13:11 PallHaraldsson

Thanks for your response--UInt16 makes more sense :)

I'm targeting Windows for distribution since this is a gaming project using SimpleDirectMediaLayer.jl, but I may try compiling on Linux as a test. For the time being, I'll try trimming out any libs that aren't absolutely necessary.

dustyirwin avatar Nov 21 '23 21:11 dustyirwin

I have the same issue here trying to compile an app for Windows with CImGui and ImPlot deps. Didn't check if it compiles in previous versions.

sairus7 avatar Jun 17 '24 19:06 sairus7

Could you try on 1.11, I'm curious if it makes a difference. There were some changes in and around this. You will also need a very new C compiler/binutils.

gbaraldi avatar Jun 26 '24 16:06 gbaraldi

What should I do for this test? Should I just add Julia 1.11-beta and update env with PackageCompiler? I'm confused with "very new C compiler/binutils" - what does that mean? Aren't all compilers already included in Julia binaries?

sairus7 avatar Jun 26 '24 16:06 sairus7

Yeah so first thing I would do is the same workflow you were doing and hitting the error and do it with julia 1.11-beta. Though I think the compiler that PackageCompiler ships with windows is likely too old.

gbaraldi avatar Jun 26 '24 16:06 gbaraldi