rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.81k stars 434 forks source link

1.0.88 breaks the Rust compile-ui tests for arm-android #990

Closed dpaoliello closed 6 months ago

dpaoliello commented 6 months ago

When trying to update cc-rs to 1.0.88 in the Rust repo, we hit an error with the compile-ui test for arm-android: https://github.com/rust-lang/rust/pull/121854#issuecomment-1973518078

2024-03-01T16:42:03.5816834Z ---- [ui] tests/ui/thread-local/tls.rs stdout ----
2024-03-01T16:42:03.5844499Z --- stderr -------------------------------
2024-03-01T16:42:03.5845537Z error: linking with `/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi19-clang` failed: exit status: 1
2024-03-01T16:42:03.5846544Z    |
2024-03-01T16:42:03.5854489Z    = note: LC_ALL="C" PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/android/sdk/emulator:/android/sdk/tools:/android/sdk/platform-tools" VSLANG="1033" "/android/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi19-clang" "/tmp/rustc0dOpvq/symbols.o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/thread-local/tls/a.tls.ca29c82538305dca-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/checkout/obj/build/arm-linux-androideabi/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/thread-local/tls/auxiliary" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-linux-androideabi/lib" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-linux-androideabi/lib" "-Wl,-Bdynamic" "-lstd-8e24d49e9c2a7cc4" "-Wl,-Bstatic" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-linux-androideabi/lib/libcompiler_builtins-23518b53a80b1f29.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-linux-androideabi/lib" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/thread-local/tls/a" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs" "-Wl,-rpath,$ORIGIN/../../../../stage2/lib/rustlib/arm-linux-androideabi/lib" "-Wl,--enable-new-dtags" "-Wl,-z,origin"
2024-03-01T16:42:03.5862557Z    = note: ld: error: undefined symbol: __atomic_load_4
2024-03-01T16:42:03.5863027Z            >>> referenced by emutls.c
2024-03-01T16:42:03.5864373Z            >>>               45c91108d938afe8-emutls.o:(__emutls_get_address) in archive /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-linux-androideabi/lib/libcompiler_builtins-23518b53a80b1f29.rlib
2024-03-01T16:42:03.5865772Z            
2024-03-01T16:42:03.5866209Z            ld: error: undefined symbol: __atomic_store_4
2024-03-01T16:42:03.5866677Z            >>> referenced by emutls.c
2024-03-01T16:42:03.5867943Z            >>>               45c91108d938afe8-emutls.o:(__emutls_get_address) in archive /checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/arm-linux-androideabi/lib/libcompiler_builtins-23518b53a80b1f29.rlib
2024-03-01T16:42:03.5869403Z            clang-14: error: linker command failed with exit code 1 (use -v to see invocation)

I've narrowed down the failure to https://github.com/rust-lang/cc-rs/commit/53564e00498156c9be00361c4b039952cbf7ff59

Using 53564e00498156c9be00361c4b039952cbf7ff59 reproduced the issue: https://github.com/rust-lang/rust/pull/121874#issuecomment-1974171096 The previous commit did not have the issue: https://github.com/rust-lang/rust/actions/runs/8145164818/job/22260797425?pr=121874 And reverting 53564e00498156c9be00361c4b039952cbf7ff59 from 1.0.88 also did not have the issue: https://github.com/rust-lang/rust/actions/runs/8145164818/job/22260797425?pr=121874