Skip to content

rustbuild should compile rsbegin/rsend for TARGET not for HOST #36290

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

Closed
japaric opened this issue Sep 6, 2016 · 4 comments
Closed

rustbuild should compile rsbegin/rsend for TARGET not for HOST #36290

japaric opened this issue Sep 6, 2016 · 4 comments
Labels
T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Comments

@japaric
Copy link
Member

japaric commented Sep 6, 2016

Because that's what the old build system does:

LD_LIBRARY_PATH=/home/japaric/x86_64-unknown-linux-gnu/stage2/lib:/usr/lib:$LD_LIBRARY_PATH   x86_64-unknown-linux-gnu/stage2/bin/rustc --cfg stage2  -O --cfg rtopt -C rpath  --target=x86_64-pc-windows-gnu -C linker=x86_64-w64-mingw32-gcc -C ar=x86_64-w64-mingw32-ar   --emit=obj -o x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-pc-windows-gnu/lib/rsbegin.o /shared/rust/master/src/rtstartup/rsbegin.rs

but rustbuild doesn't pass the --target and rsbegin.o ends up being an ELF on linux:

$ file $(find -name rsbegin.o)
./build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-pc-windows-gnu/lib/rsbegin.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped

The fix should be simple in theory. You just have to pass --target $TARGET to the Command in the code linked above. But then you run in problems with the order of the operations: "core not found for $TARGET".

Meta

$ git rev-parse HEAD
e77d86c142ae668038dd43594d04022cbd6bf4d8

cc @alexcrichton

@japaric japaric added the T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) label Sep 6, 2016
@japaric
Copy link
Member Author

japaric commented Sep 6, 2016

FWIW, trying to cross compile to i686-pc-windows-gnu I get this:

   Compiling std v0.0.0 (file:///shared/rust/master/src/libstd)
error: linking with `i686-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "i686-w64-mingw32-gcc" "-Wl,--enable-long-section-names" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-Wl,--large-address-aware" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/dllcrt2.o" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o" "-L" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1-std/i686-pc-windows-gnu/release/deps/std-e2265790837cbaa9.0.o" "-o" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1-std/i686-pc-windows-gnu/release/deps/std-e2265790837cbaa9.dll" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1-std/i686-pc-windows-gnu/release/deps/std-e2265790837cbaa9.metadata.o" "-nodefaultlibs" "-L" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1-std/i686-pc-windows-gnu/release/deps" "-L" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1-std/i686-pc-windows-gnu/release/build/std-a76d8b43f160511e/out/.libs" "-L" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1-std/i686-pc-windows-gnu/release/build/alloc_jemalloc-b4a9fdd2a74b7a98/out/lib" "-L" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "backtrace" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-l" "advapi32" "-l" "ws2_32" "-l" "userenv" "-l" "shell32" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/libcollections-f1089b41bd63d58e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/libpanic_unwind-3976021b89fe79d0.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/liballoc-bc4e10ff5ace48d6.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/liballoc_system-0126d25e93e8a210.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/librustc_unicode-42e6477b8bd9d820.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/libunwind-7f3a35b0cd66ef0a.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/liblibc-6f0a493cfbc94393.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/librand-8de767ad0539476d.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.EO8OdN3FN33s/libcore-bf8588192495524e.rlib" "-Wl,--no-whole-archive" "-l" "gcc_eh" "-l" "gcc_eh" "-shared" "-l" "compiler-rt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "/home/japaric/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/rsend.o"
  = note: /home/japaric/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/i686-pc-windows-gnu/lib/rsbegin.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `std`.

Trying to cross compile to x86_64-pc-windows-gnu results in #36291

@alexcrichton
Copy link
Member

Yeah not passing --target would do it, should be easy to add though! (I think that's all that's necessary)

@japaric
Copy link
Member Author

japaric commented Sep 6, 2016

Yeah not passing --target would do it,

Actually, the solution is the opposite. rustbuild is building these startup files for linux but it should compile them for windows hence the --target $WINDOWSY_TARGET has to be added.

@alexcrichton
Copy link
Member

Oh right sorry "it" there was "would cause this problem", we should indeed pass --target!

alexcrichton added a commit to alexcrichton/rust that referenced this issue Sep 13, 2016
bors added a commit that referenced this issue Sep 16, 2016
rustbuild: Fix cross-compiles to MinGW on Linux

Closes #36290
Closes #36291
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

No branches or pull requests

2 participants