-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Description
In the context of packaging Rust, we might need to add or remove CFLAGS/CXXFLAGS during compilation time.
AFAIK, they are currently hardcoded (and computed) in the binary downloaded during the first step of the build.
For example, the full command line on my system is this one:
rustc: x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin/rustc
error: linking with `cc` failed: exit code: 1
note: cc '-m64' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-o' 'x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin/rustc' 'x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin/rustc.o' '-lmorestack' '-nodefaultlibs' '-Wl,--gc-sections' '-Wl,--as-needed' '-Wl,-O1' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lnative-1fb5e2c0-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lrustc-d252d482-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lflate-92afea7e-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lgetopts-c94737d1-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lsyntax-555559ea-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lterm-4e4945a5-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-ltime-4bb3739b-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lserialize-0352aab7-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-llog-cd053230-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lsync-305341d2-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lfmt_macros-5125f3bd-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lgraphviz-7b3cf89d-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-larena-063bff73-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lcollections-d412c0c4-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-ldebug-1e940314-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lstd-59beb4f7-0.11.0-pre' '-L' '/home/sylvestre/dev/mozilla/rust/.rust' '-L' '/home/sylvestre/dev/mozilla/rust' '-Wl,-Bdynamic' '-lpthread' '-lffi' '-ltinfo' '-ldl' '-lm' '-lstdc++' '-lrt' '-ldl' '-lpthread' '-lgcc_s' '-lpthread' '-lc' '-lm' '-Wl,-rpath,$ORIGIN/../lib' '-Wl,-rpath,/usr/local/lib/rustlib/x86_64-unknown-linux-gnu/lib' '-lcompiler-rt'
note: /usr/bin/ld.bfd.real: cannot find -lcompiler-rt
collect2: error: ld returned 1 exit status
error: aborting due to previous error
/home/sylvestre/dev/mozilla/rust/mk/target.mk:172: recipe for target 'x86_64-unknown-linux-gnu/stage0/lib/rustlib/x86_64-unknown-linux-gnu/bin/rustc' failed
In this case, I would need to add a -L to point to the correct compiler-rt library (I know there are workaround for this, it is just an example). Adding or removing flags passed to the linker is also a common usage while packaging software.
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)