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

Cross compiling for windows from linux with lto doesn't work with nightly #65

Closed
lilizoey opened this issue Sep 29, 2022 · 3 comments
Closed

Comments

@lilizoey
Copy link

lilizoey commented Sep 29, 2022

Terminal output:

> cargo zigbuild --target x86_64-pc-windows-gnu --release
   Compiling mini v0.1.0 (/home/<name>/Development/rust/mini)
error: linking with `/home/<name>/.cache/cargo-zigbuild/0.12.3/zigcc-x86_64-pc-windows-gnu.sh` failed: exit status: 1
  |
  = note: "/home/<name>/.cache/cargo-zigbuild/0.12.3/zigcc-x86_64-pc-windows-gnu.sh" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "/home/<name>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsbegin.o" "/tmp/rustc1jh004/symbols.o" "/home/<name>/Development/rust/mini/target/x86_64-pc-windows-gnu/release/deps/mini-8047c42c6d704752.mini.382c5343-cgu.2.rcgu.o" "-L" "/home/<name>/Development/rust/mini/target/x86_64-pc-windows-gnu/release/deps" "-L" "/home/<name>/Development/rust/mini/target/release/deps" "-L" "/home/<name>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "-Wl,-Bstatic" "/home/<name>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcompiler_builtins-1749d80d0a5949a6.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "/home/<name>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "-o" "/home/<name>/Development/rust/mini/target/x86_64-pc-windows-gnu/release/deps/mini-8047c42c6d704752.exe" "-Wl,--gc-sections" "-no-pie" "-Wl,-O1" "-nodefaultlibs" "/home/<name>/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsend.o"
  = note: warning: unsupported linker arg: --disable-auto-image-base
          lld-link: error: undefined symbol: rust_oom
          >>> referenced by /tmp/rustc1jh004/symbols.o
          
          lld-link: error: undefined symbol: rust_begin_unwind
          >>> referenced by /tmp/rustc1jh004/symbols.o

Code:

fn main() {
    println!("Hello, world!");
}

Cargo.toml:

[package]
name = "mini"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[profile.release]
lto = true

[dependencies]
@messense
Copy link
Member

Does it work on stable?

@lilizoey
Copy link
Author

it does work on stable

@messense
Copy link
Member

Possibly related to this change rust-lang/rust#100404, see also rust-lang/rust#102290

@messense messense closed this as not planned Won't fix, can't repro, duplicate, stale Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants