rust-lang / cargo-bisect-rustc

Bisects rustc, either nightlies or CI artifacts
https://rust-lang.github.io/cargo-bisect-rustc/
Apache License 2.0
178 stars 55 forks source link

can cargo-bisect-rustc respect the .cargo/config.toml? #284

Closed pnkfelix closed 8 months ago

pnkfelix commented 1 year ago

can cargo-bisect-rustc respect the .cargo/config.toml? (Should it already be doing so?)

As part of dissecting https://github.com/rust-lang/rust/issues/111888, I was looking into adding a linker flag to the rustc invocations via a .cargo/config.toml file, as described here: https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags

But it seems from my local experiments that while my manual invocations of cargo are pulling in the config settings, the invocations that cargo-bisect-rustc emits do not seem to be including the rustflags specified there.

ehuss commented 1 year ago

It should be working. Can you share your exact .cargo/config.toml file? Is your .cargo/config.toml in the project directory where you are running cargo-bisect-rustc? What is the output of cargo-bisect-rustc -vv -- build --verbose? Are you sure there aren't any environment variables (like RUSTFLAGS) that would take precedence over your config file?

pnkfelix commented 1 year ago

Since this involves a bunch of files, let me see if I can put it into a repo for the repro.

pnkfelix commented 1 year ago

(Hmm, I am now seeing evidence that it is doing something with the config file. Namely, when I added build.rustflags = "-Zwhoa" via the config file, all the builds fail, and when I remove it, then I see some builds succeed. So there must be something about the specific build flag I was trying to use, namely `rustflags="-Clink-arg=-Wl,--no-undefined-version", that was behaving in an unexpected fashion. That, or it was user error on my part. I'll figure out which case I'm in.)

pnkfelix commented 1 year ago

Here's the repository I'm using for reproduction of the problem I'm seeing: https://github.com/pnkfelix/cbr-issue-284-demo

When I run cargo bisect rustc, it ends up flagging a regression in nightly-2023-03-12 (and then tracks the problem down further from there). The problem is that the flagging of the regression there only happens if you are not passing the rustflags that I have requested. And I have confirmed that manually invoking cargo build for the nightlies in question, with that .cargo/config.toml in place, does show the regression continuing to earlier than 2023-03-12.

transcript ``` cbr-issue-284-demo$ cargo bisect-rustc --preserve --start 1.63.0 --end 1.71.0 --access github translating --start=1.63.0 to 2022-06-24 translating --end=1.71.0 to 2023-05-27 checking the start range to find a passing nightly installing nightly-2022-06-24 testing... RESULT: nightly-2022-06-24, ===> No checking the end range to verify it does not pass installing nightly-2023-05-27 testing... RESULT: nightly-2023-05-27, ===> Yes 169 versions remaining to test after this (roughly 7 steps) installing nightly-2022-12-09 testing... RESULT: nightly-2022-12-09, ===> No 85 versions remaining to test after this (roughly 6 steps) installing nightly-2023-03-03 testing... RESULT: nightly-2023-03-03, ===> No 43 versions remaining to test after this (roughly 6 steps) installing nightly-2023-04-14 testing... RESULT: nightly-2023-04-14, ===> Yes 21 versions remaining to test after this (roughly 5 steps) installing nightly-2023-03-24 testing... RESULT: nightly-2023-03-24, ===> Yes 11 versions remaining to test after this (roughly 4 steps) installing nightly-2023-03-13 testing... RESULT: nightly-2023-03-13, ===> Yes 5 versions remaining to test after this (roughly 3 steps) installing nightly-2023-03-08 testing... RESULT: nightly-2023-03-08, ===> No 3 versions remaining to test after this (roughly 2 steps) installing nightly-2023-03-10 testing... RESULT: nightly-2023-03-10, ===> No 2 versions remaining to test after this (roughly 1 steps) installing nightly-2023-03-11 testing... RESULT: nightly-2023-03-11, ===> No 1 versions remaining to test after this (roughly 1 steps) installing nightly-2023-03-12 testing... RESULT: nightly-2023-03-12, ===> Yes searched toolchains nightly-2022-06-24 through nightly-2023-05-27 ******************************************************************************** Regression in nightly-2023-03-12 ******************************************************************************** fetching https://static.rust-lang.org/dist/2023-03-11/channel-rust-nightly-git-commit-hash.txt nightly manifest 2023-03-11: 40 B / 40 B [=====================================================================================] 100.00 % 533.26 KB/s converted 2023-03-11 to ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13 fetching https://static.rust-lang.org/dist/2023-03-12/channel-rust-nightly-git-commit-hash.txt nightly manifest 2023-03-12: 40 B / 40 B [=======================================================================================] 100.00 % 1.56 MB/s converted 2023-03-12 to 8a73f50d875840b8077b8ec080fa41881d7ce40d looking for regression commit between 2023-03-11 and 2023-03-12 fetching (via remote github) commits from max(ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13, 2023-03-09) to 8a73f50d875840b8077b8ec080fa41881d7ce40d ending github query because we found starting sha: ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13 get_commits_between returning commits, len: 6 commit[0] 2023-03-10: Auto merge of #108974 - flip1995:clippyup, r=Manishearth commit[1] 2023-03-11: Auto merge of #104527 - ferrocene:pa-more-licenses, r=pnkfelix commit[2] 2023-03-11: Auto merge of #108998 - matthiaskrgr:rollup-sxbdulg, r=matthiaskrgr commit[3] 2023-03-11: Auto merge of #109001 - matthiaskrgr:rollup-a3agnwp, r=matthiaskrgr commit[4] 2023-03-11: Auto merge of #109015 - matthiaskrgr:rollup-xu2s31g, r=matthiaskrgr commit[5] 2023-03-11: Auto merge of #109019 - matthiaskrgr:rollup-ihjntil, r=matthiaskrgr validated commits found, specifying toolchains checking the start range to verify it passes installing ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13 testing... RESULT: ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13, ===> No checking the end range to verify it does not pass installing 8a73f50d875840b8077b8ec080fa41881d7ce40d testing... RESULT: 8a73f50d875840b8077b8ec080fa41881d7ce40d, ===> Yes 3 versions remaining to test after this (roughly 2 steps) installing 19c53768af6e48514238e4224b5bf5ecd51bc7b1 testing... RESULT: 19c53768af6e48514238e4224b5bf5ecd51bc7b1, ===> No 2 versions remaining to test after this (roughly 1 steps) installing e350fe4e608b653da47e8012d13ef701613e717b testing... RESULT: e350fe4e608b653da47e8012d13ef701613e717b, ===> Yes searched toolchains ff4b772f805ec1e1c1bd7e189ab8d5a4e3a6ef13 through 8a73f50d875840b8077b8ec080fa41881d7ce40d ******************************************************************************** Regression in e350fe4e608b653da47e8012d13ef701613e717b ******************************************************************************** [...] ``` The problem with all of the above is that when I manually run the same bisector builds directly, it *does* respect the rustflags I've fed in via the `.cargo/config.toml`, and thus I do not get the same bisection at all, as shown below. ``` cbr-issue-284-demo$ cargo +bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu build Compiling ext_lib v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/ext_lib) Compiling pm v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/pm) error: linking with `cc` failed: exit status: 1 | = note: LC_ALL="C" PATH="/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/ubuntu/.local/bin:/home/ubuntu/bin:/home/ubuntu/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/\ usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" VSLANG="1033" "cc" "-Wl,--version-script=/tmp/rustczrLCXw/list" "-Wl,--no-undefined-version" "-m64" "/tmp/rustczrLCXw/symbols.o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-2\ 84-demo/target/debug/deps/pm-a6fdaa95ba624adc.25m1du48ofwx9t78.rcgu.o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/pm-a6fdaa95ba624adc.aueuwdyf59ve1jf.rcgu.rmeta" "/home/ubuntu/Dev/Rust/Linking/issue_11188\ 8/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/pm-a6fdaa95ba624adc.whh49e3mqtk71q7.rcgu.o" "-Wl,--as-needed" "-L" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps" "-L" "/home/ubuntu/.rustup/toolchain\ s/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-f3e505f\ 6e0fe495a.rlib" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/libext_lib-35abe9072087b085.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknow\ n-linux-gnu/lib/libstd-8c5537594e196f18.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-62f45bff484152d4.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightl\ y-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-05da49d3cca73bff.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-616c9bd2710\ f0982.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d9df84ec1a8a7a8f.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu\ /lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-0242ef3eea1e9db2.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-127f477a16f3f8f8.rlib" "/home/ubuntu/.rus\ tup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-18a1148b43c51528.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-l\ inux-gnu/lib/libhashbrown-c5f20f2274212453.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4483c8bc4648568f.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nigh\ tly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-94da6a76998341a3.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspa\ ce_alloc-22a9646e8f27a6e4.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-c9ee17ad302be816.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-\ unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-323da837c64ef472.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-c165d64169f217c3.rlib" "/home/ubu\ ntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8212dcd77adfe144.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknow\ n-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/ubuntu/.rustup/toolchains/bi\ sector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b78d27aa9e5e005b.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/ho\ me/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-12-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/libpm-a6fdaa95ba624adc.so" "-Wl,\ --gc-sections" "-shared" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-Wl,--no-undefined-version" = note: /usr/bin/ld: add: undefined version: /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status error: could not compile `pm` (lib) due to previous error cbr-issue-284-demo$ cargo +bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu build Compiling ext_lib v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/ext_lib) Compiling pm v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/pm) error: linking with `cc` failed: exit status: 1 | = note: LC_ALL="C" PATH="/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/ubuntu/.local/bin:/home/ubuntu/bin:/home/ubuntu/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/\ usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" VSLANG="1033" "cc" "-Wl,--version-script=/tmp/rustcoyzLtU/list" "-m64" "/tmp/rustcoyzLtU/symbols.o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/pm-\ a6fdaa95ba624adc.5al9jrduxl99wxw2.rcgu.o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/pm-a6fdaa95ba624adc.nwsywfpb33y4i23.rcgu.rmeta" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue\ -284-demo/target/debug/deps/pm-a6fdaa95ba624adc.2dygysboqzzg2ryy.rcgu.o" "-Wl,--as-needed" "-L" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps" "-L" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-1\ 1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-f3e505f6e0fe495a.rlib" "/home/ubunt\ u/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/libext_lib-35abe9072087b085.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-8c553\ 7594e196f18.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-62f45bff484152d4.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-\ linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-05da49d3cca73bff.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-616c9bd2710f0982.rlib" "/home/ubuntu/.r\ ustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-d9df84ec1a8a7a8f.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-\ linux-gnu/lib/libgimli-0242ef3eea1e9db2.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-127f477a16f3f8f8.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nigh\ tly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-18a1148b43c51528.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-c5\ f20f2274212453.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-4483c8bc4648568f.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknow\ n-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-94da6a76998341a3.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-22a9646e8f27a6e4.rl\ ib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-c9ee17ad302be816.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustli\ b/x86_64-unknown-linux-gnu/lib/libcfg_if-323da837c64ef472.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-c165d64169f217c3.rlib" "/home/ubuntu/.rustup/toolchains/bisec\ tor-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-8212dcd77adfe144.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std\ _workspace_core-522518611024dce5.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2023-03-11-x8\ 6_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-b78d27aa9e5e005b.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/ubuntu/.rustup/toolchains\ /bisector-nightly-2023-03-11-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/libpm-a6fdaa95ba624adc.so" "-Wl,--gc-sections" "-shared" "-W\ l,-z,relro,-z,now" "-nodefaultlibs" "-Wl,--no-undefined-version" = note: /usr/bin/ld: add: undefined version: /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status error: could not compile `pm` (lib) due to previous error cbr-issue-284-demo$ cargo +bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu build Compiling ext_lib v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/ext_lib) Compiling pm v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/pm) error: linking with `cc` failed: exit status: 1 | = note: "cc" "-Wl,--version-script=/tmp/rustct0Ej9z/list" "-m64" "/tmp/rustct0Ej9z/symbols.o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/pm-a6fdaa95ba624adc.h78a8sw74ecqtbw.rcgu.o" "/home/ubuntu/Dev/Rus\ t/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/pm-a6fdaa95ba624adc.42b2doemlinbp6pa.rcgu.rmeta" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/pm-a6fdaa95ba624adc.5b382f78u2k6xo\ v6.rcgu.o" "-Wl,--as-needed" "-L" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps" "-L" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gn\ u/lib" "-Wl,-Bstatic" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-b92aa700084b5bc9.rlib" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-28\ 4-demo/target/debug/deps/libext_lib-35abe9072087b085.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-5edc694ff0621ed8.rlib" "/home/ubuntu/.rustup/toolchains/bisector-ni\ ghtly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-1118a539d55d2733.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1\ e16815c933606a0.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-7dda930da173cd7f.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-li\ nux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-7deef5f688bf2cd5.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-a1f236732a050fbb.rlib" "/home/ubuntu/.r\ ustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-2d0ddbffdb30be11.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unk\ nown-linux-gnu/lib/libstd_detect-681566937bcf15b7.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-d8b255130cf77303.rlib" "/home/ubuntu/.rustup/toolchains/bisector\ -nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-e79cc122e409037d.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-\ 6918a62ad5cae6e0.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-7737bd6c876aa5d1.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-\ 09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-5b1d741435bd8321.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-cb9ee6e5722842ca.rlib\ " "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-6d46d38f739892fe.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x8\ 6_64-unknown-linux-gnu/lib/liballoc-92ba89a1b07f23b1.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-522518611024dce5.rlib" "/home/ubuntu/.rustup/t\ oolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-05898138a596088a.rlib" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/li\ b/libcompiler_builtins-bc012bb1dd8faba2.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-L" "/home/ubuntu/.rustup/toolchains/bisector-nightly-2022-12-09-x86_64-unknown-linux-gnu/lib/rustl\ ib/x86_64-unknown-linux-gnu/lib" "-o" "/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/target/debug/deps/libpm-a6fdaa95ba624adc.so" "-Wl,--gc-sections" "-shared" "-Wl,-zrelro,-znow" "-nodefaultlibs" "-Wl,--no-undefined-version" = note: /usr/bin/ld: add: undefined version: /usr/bin/ld: failed to set dynamic section sizes: bad value collect2: error: ld returned 1 exit status error: could not compile `pm` due to previous error cbr-issue-284-demo$ cargo +bisector-nightly-2022-06-24-x86_64-unknown-linux-gnu build Compiling ext_lib v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/ext_lib) Compiling pm v0.1.0 (/home/ubuntu/Dev/Rust/Linking/issue_111888/demo_bisect_issue/cbr-issue-284-demo/pm) Finished dev [unoptimized + debuginfo] target(s) in 0.30s ```
pnkfelix commented 1 year ago

To be clear: At this point I am forced to acknowledge that something must be happening with the .cargo/config.toml, because when I put in nonsense as the rustflags setting (likerustflags=-Zwhoa), it causes the build to fail reliably via cargo-bisect-rustc.

So there must be some really weird interaction with the specific rustflags setting I happen to be using? It is goofy.

ehuss commented 1 year ago

The reason you are seeing different behavior when running manually is because you are not passing the --target flag. When you don't pass the --target flag, rustflags are passed to all rustc invocations. When you do pass the --target flag, rustflags are not passed to host invocations (proc-macros, build scripts, and their dependencies). cargo-bisect-rustc always passes --target.

This happens because cargo tries to share dependencies when --target is not specified to reduce build times.

ehuss commented 1 year ago

BTW, if you need to pass rustflags to proc-macros even when --target is used, you can do something like this:

[target.'x86_64-unknown-linux-gnu']
rustflags="-Clink-arg=-Wl,--no-undefined-version"
[host]
rustflags="-Clink-arg=-Wl,--no-undefined-version"

And pass the -Zhost-config -Ztarget-applies-to-host flags.

pnkfelix commented 1 year ago

Hmm, okay. I can totally understand how this arises now.

I'm trying to figure out what is the best way to address overall issue here.

In particular:


Here's the heart of my complaint: The usage model that I think we try to promote is: "If you're doing cargo build, you can just do cargo-bisect-rustc build to bisect the same experience. I can absolutely understand there being deviations between what actually happens versus the illusion we are trying to present to users.

... Maybe all I want here is some section of the doc where we spell out ways in which cargo CMD may deviate from cargo-bisect-rustc CMD ? Even as an FAQ entry or something?

ehuss commented 1 year ago

I think at least documenting it would be good. One place I forgot to mention this is in https://rust-lang.github.io/cargo-bisect-rustc/usage.html#scripting, where it should be mentioned that scripts don't need to specify --target because CARGO_BUILD_TARGET is set (similar to how the toolchain also doesn't need to be specified). If you want to add an FAQ, that would be good, too. I'm not sure how likely that is to help the general case, since I assume almost nobody is going to read the entire documentation and retain every nuance.

It seems a little strange to me that it unconditionally sets the target, but it looks like that was done in part for https://github.com/cross-rs/cross/issues/699, where cross would break because rustup does not support components for custom toolchains, and would error when cross ran rustup target list. That seems like a bit of a convoluted issue involving several other tools. I could see a reasonable alternative would be to stop unconditionally setting CARGO_BUILD_TARGET when --target is not specified, and document that cross users need to set it in a script (there could be another "Example" chapter on using cross). How does that sound?

pnkfelix commented 1 year ago

I'm not sure how likely that is to help the general case, since I assume almost nobody is going to read the entire documentation and retain every nuance.

I agree with this point. That is, we should adjust the documentation to reflect what the tool does (though that might itself change, as you outline in your second paragraph), but we cannot rely on people to read the docs.

However, that does lead me to this question: Is there any verbosity level at which cargo bisect rustc will print out the contextual parameters it is setting (i.e. what environment variables it is setting and what command line switches it is passing)? I think that could have helped me track this down, if I had thought to use it, but as far as I can tell no matter how many levels of --verbose I pass along, I don't get feedback about this --target/CARGO_BUILD_TARGET business...

I could see a reasonable alternative would be to stop unconditionally setting CARGO_BUILD_TARGET when --target is not specified, and document that cross users need to set it in a script (there could be another "Example" chapter on using cross).

I'll have to think about this. It sounds plausible on its surface. What's the migration path for helping current users deal with the changes here, it is just a matter of including it in the release notes for the new version, or are there more direct ways to give useful feedback to the people relying on the current behavior?

ehuss commented 1 year ago

However, that does lead me to this question: Is there any verbosity level at which cargo bisect rustc will print out the contextual parameters it is setting

I don't think so. Improving that also seems good to me.

What's the migration path for helping current users deal with the changes here, it is just a matter of including it in the release notes for the new version, or are there more direct ways to give useful feedback to the people relying on the current behavior?

I'm not sure. I don't have a sense of how often people are depending on the current behavior. I can't think of anything besides cross that would be affected, but I was surprised to see that it was affected.