Output of independent artefacts might differ depending on unrelated options
Existence or lack of --crate-type=bin may influence output of other crate-type outputs. In general libfoo.a output by --crate-type=bin,staticlib and --crate-type=staticlib might be completely different.
For example using this foo.rs, this is the list of a few first symbols when built with --crate-type=bin,staticlib and this, when bin crate-type is absent.
This is a quirk in rust’s entry point semantics and how current middle/entry.rs is implemented.
The check whether the entry point is necessary or not should occur elsewhere.
Simonas Kazlauskas at 2015-02-11 16:55:13
Triage: not aware of any changes here?
Steve Klabnik at 2016-03-04 17:57:28
I think that not much has changed here. The individual outputs are different, but the overall diff is the same: entry points are included in
staticlibwith--crate-type bin.--- no-bin 2017-04-30 18:10:53.442645721 -0600 +++ bin 2017-04-30 18:10:48.398648634 -0600 @@ -1,5 +1,8 @@ test.0.o: +0000000000000000 T main + U std::rt::lang_start::h8126425a59d3b4a0 +0000000000000000 t test::main::hf4d700377696cbb0 std-35ad9950c7e5074b.0.o: U abort$ nm -C libtest.a | head -n 15 test.0.o: std-35ad9950c7e5074b.0.o: U abort U accept U backtrace_create_state U backtrace_pcinfo U backtrace_syminfo U bind 0000000000000000 r byte_str.3f 0000000000000000 r byte_str.3r 0000000000000000 r byte_str.4B 0000000000000000 r byte_str.4D 0000000000000000 r byte_str.4f $ nm -C libtest-bin.a | head -n 15 test.0.o: 0000000000000000 T main U std::rt::lang_start::h8126425a59d3b4a0 0000000000000000 t test::main::hf4d700377696cbb0 std-35ad9950c7e5074b.0.o: U abort U accept U backtrace_create_state U backtrace_pcinfo U backtrace_syminfo U bind 0000000000000000 r byte_str.3f 0000000000000000 r byte_str.3rMark Rousskov at 2017-05-01 00:14:43
I'm not sure why this is marked as rustbuild, it seems to affect all binaries. Going to move this to T-compiler.
jyn at 2022-06-27 04:32:52