Could not cross-compile to Windows from ubuntu
sztomi opened this issue · comments
# sudo apt install gcc-mingw-w64-x86-64-posix
rustup target add x86_64-pc-windows-gnu
cargo build --release --target=x86_64-pc-windows-gnu
Yields
Compiling jemallocator v0.3.2
Running `rustc --crate-name jemallocator /home/tamas/.cargo/registry/src/github.com-1ecc6299db9ec823/jemallocator-0.3.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 --cfg 'feature="background_threads_runtime_support"' --cfg 'feature="default"' -C metadata=c1aa0409bbfdcf4d -C extra-filename=-c1aa0409bbfdcf4d --out-dir /home/tamas/src/n2/target/x86_64-pc-windows-gnu/debug/deps --target x86_64-pc-windows-gnu -L dependency=/home/tamas/src/n2/target/x86_64-pc-windows-gnu/debug/deps -L dependency=/home/tamas/src/n2/target/debug/deps --extern jemalloc_sys=/home/tamas/src/n2/target/x86_64-pc-windows-gnu/debug/deps/libjemalloc_sys-f9a3d890e565352c.rmeta --extern libc=/home/tamas/src/n2/target/x86_64-pc-windows-gnu/debug/deps/liblibc-d6282ed627c45757.rmeta --cap-lints allow -L native=/home/tamas/src/n2/target/x86_64-pc-windows-gnu/debug/build/jemalloc-sys-caac9a3b2c7387ed/out/build/lib`
error: could not find native static library `jemalloc`, perhaps an -L flag is missing?
error: could not compile `jemalloc-sys` due to previous error
It looks like this is an issue with the jemallocator crate. The crate does seem to build all the way but perhaps the linker path is not set correctly when linking to the C library.
I don't really know if this is easily solvable on the n2 side (apart from switching to a different allocator).
I don't really understand this area of Rust builds, so if anyone else would like to figure this out I welcome it.
I had introduced jemalloc earlier because it was a big performance win, but since then I have been a bit more careful about memory allocation so it's possible it's not as important anymore.
I think the intent of this code (which is copy-pasted from the jemalloc instructions) is to not use jemalloc on Windows, so maybe that logic just needs to be adjusted to cover this case.