Closed Bug 1509665 Opened 7 years ago Closed 6 years ago

Cannot build Firefox with Clang with code coverage enabled

Categories

(Firefox Build System :: General, defect)

defect
Not set
normal

Tracking

(firefox65 wontfix, firefox74 fixed)

RESOLVED FIXED
mozilla74
Tracking Status
firefox65 --- wontfix
firefox74 --- fixed

People

(Reporter: calixte, Assigned: marco)

References

Details

Attachments

(1 file)

With the following mozconfig: export CC=clang-7 export CXX=clang++-7 ac_add_options --enable-coverage export CFLAGS="--coverage" export CXXFLAGS="--coverage" export LDFLAGS="--coverage -lgcov" ac_add_options --disable-sandbox ac_add_options --disable-elf-hack mk_add_options MOZ_MAKE_FLAGS="-j24" mk_add_options AUTOCLOBBER=1 ac_add_options --enable-nodejs I got the following error: 4:43.73 Compiling baldrdash v0.1.0 (/home/calixte/dev/mozilla/mozilla-central.hg/js/src/wasm/cranelift) 4:45.16 error: linking with `/home/calixte/dev/mozilla/mozilla-central.hg/build/cargo-linker` failed: exit code: 1 4:45.16 | 4:45.16 = note: "/home/calixte/dev/mozilla/mozilla-central.hg/build/cargo-linker" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/build/baldrdash-1376596e98017066/build_script_build-1376596e98017066.build_script_build.6sishphd-cgu.0.rcgu.o" "-o" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/build/baldrdash-1376596e98017066/build_script_build-1376596e98017066" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps" "-L" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/build/libloading-bf33081488d66408/out" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libbindgen-e1edda037fd07c24.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libwhich-dcec22dcbb64efd8.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libregex-f816a940c78e50cd.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libutf8_ranges-6b29425c7cca6b7b.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libregex_syntax-774d970b6d6cd872.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libucd_util-11b8430e2b5e1a60.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libthread_local-1f4b66e019beaf66.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libunreachable-f4cfdfec103c3e85.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libvoid-f6c8ab737cf12a5b.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libaho_corasick-618b959d632a446e.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libquote-462d3ea79184d41a.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libproc_macro2-35093d334fffd6e6.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libunicode_xid-ae97c8e87fdc33fa.rlib" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-lproc_macro-fd1a90907d1551d9" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lsyntax-5b764911e69d642b" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_target-dc4ea4d304a73a2e" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_errors-72c60cff0cd7f086" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lsyntax_pos-6ee78f43e1dc9084" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-larena-89b4462c4eb6a01d" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_data_structures-5a8e7510f85bda50" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lrustc_cratesio_shim-a256605d26b5bc4f" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lgraphviz-f6e012a8cbee4ee0" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-lserialize-8141f33cd195ff03" "-Wl,-Bstatic" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libpeeking_take_while-f4f395033cdb012b.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/liblazy_static-ff3eb6dd827ad16f.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libclang_sys-7f78e48b6abbde5a.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/liblibloading-eebb59013d76a969.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libglob-27060db5462dfb52.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libcfg_if-bfddd26024bec3e9.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libcexpr-c906d2b2f2aafa85.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libnom-de676a5bc0841fe1.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libmemchr-1e4fa368504b9368.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/liblibc-5be27ccaada7de4c.rlib" "/home/calixte/dev/mozilla/mozilla-central.hg/obj-x86_64-pc-linux-gnu/release/deps/libbitflags-664081628834b1a7.rlib" "-Wl,--start-group" "-L" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bdynamic" "-lstd-ad2e157c73171bdf" "-Wl,--end-group" "-Wl,-Bstatic" "/home/calixte/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-647d55300071a641.rlib" "-Wl,-Bdynamic" "-lutil" "-lutil" "-ldl" "-lutil" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil" 4:45.16 = note: /usr/lib/llvm-7/lib/clang/7.0.0/lib/linux/libclang_rt.profile-x86_64.a(GCDAProfiling.c.o):fonctionllvm_gcov_init : erreur : référence à « atexit » non définie 4:45.16 /usr/lib/llvm-7/lib/clang/7.0.0/lib/linux/libclang_rt.profile-x86_64.a(GCDAProfiling.c.o):fonctionllvm_gcov_init : erreur : référence à « atexit » non définie 4:45.16 /usr/lib/llvm-7/lib/clang/7.0.0/lib/linux/libclang_rt.profile-x86_64.a(GCDAProfiling.c.o):fonctionllvm_gcov_init : erreur : référence à « atexit » non définie 4:45.16 clang: error: linker command failed with exit code 1 (use -v to see invocation) 4:45.16 4:45.16 error: aborting due to previous error 4:45.16 error: Could not compile `baldrdash`. 4:45.17 warning: build failed, waiting for other jobs to finish... :bbouvier, any idea ?
Flags: needinfo?(bbouvier)
Do you need to pass specific include/link flags to clang when compiling with coverage support? We'd need to pass them to bindgen too, in this case. Also, are WebRender / Stylo enabled when compiling with coverage? I'd assume the same error would happen there too, so if it's enabled then we could cargo-cult what's done there. (a workaround is to disable Cranelift at the moment with --disable-cranelift on Nightly builds; on non-Nightly it is disabled by default)
Flags: needinfo?(bbouvier) → needinfo?(cdenizet)
(In reply to Benjamin Bouvier [:bbouvier] from comment #1) > Do you need to pass specific include/link flags to clang when compiling with > coverage support? We'd need to pass them to bindgen too, in this case. "-lgcov" is the only unnecessary one, not sure if the result is different without it. I was able to build with a different mozconfig that I've shared with Calixte. > Also, are WebRender / Stylo enabled when compiling with coverage? I'd assume > the same error would happen there too, so if it's enabled then we could > cargo-cult what's done there. > > (a workaround is to disable Cranelift at the moment with --disable-cranelift > on Nightly builds; on non-Nightly it is disabled by default) I think the only difference for WebRender/Stylo is that we enable Rust coverage on CI (but in Calixte's mozconfig it is not enabled), which we should do for Cranelift too (basically, we just need to pass down the RUSTFLAGS which are defined in the mozconfig, similarly to bug 1322803).
(In reply to Marco Castelluccio [:marco] from comment #2) > (In reply to Benjamin Bouvier [:bbouvier] from comment #1) > > Also, are WebRender / Stylo enabled when compiling with coverage? I'd assume > > the same error would happen there too, so if it's enabled then we could > > cargo-cult what's done there. > > > > (a workaround is to disable Cranelift at the moment with --disable-cranelift > > on Nightly builds; on non-Nightly it is disabled by default) > > I think the only difference for WebRender/Stylo is that we enable Rust > coverage on CI (but in Calixte's mozconfig it is not enabled), which we > should do for Cranelift too (basically, we just need to pass down the > RUSTFLAGS which are defined in the mozconfig, similarly to bug 1322803). We probably just need to turn the option() for RUSTFLAGS into a js_option; want to see if that works?
Flags: needinfo?(cdenizet)

I've seen this too locally, and I've tried to track down the issue myself, but the chain from mozconfig to makefiles to cargo to linkers with half of everything passed through environment variables has proven difficult to actually narrow down the issue.

So far as I can tell (my analysis may be wrong!), the linking issue starts with the libloading crate. This crate includes a .c file that is compiled via the cc crate in the build.rs, which is happily built with the --coverage flag as requested by the CFLAGS. When the final linking for the gkrust-shared crate occurs, this pulls in libclang_rt.profile-x86_64.a symbols for gcov tracing. This requires the c library to be linked against for atexit, but the -nodefaultlibs prevents the c library from being used to resolve the symbol.

Blocks: 1499663

I still can't reproduce locally, but I was able to reproduce on CI: https://treeherder.mozilla.org/#/jobs?repo=try&revision=5af34468f4dbe660640e994b703e87df603b903a.

Summary: Cannot build firefox with clang-7 in enabling coverage → Cannot build Firefox with Clang with code coverage enabled

I got a bit closer modifying the rust.mk file to further support clang when coverage is enabled. Now it fails in testSymbolstore during make check. Perhaps that's enough for you to proceed?

I wonder why that's not needed in the fuzzing ccov builds which use Clang.

(In reply to Marco Castelluccio [:marco] from comment #7)

I wonder why that's not needed in the fuzzing ccov builds which use Clang.

Because in those builds, we triggering the FUZZING_INTERFACES part of this condition:

https://hg.mozilla.org/try/file/f8379d2cfaf97f693aa578d4a82790b8ac5dbf5e/config/makefiles/rust.mk#l113

See Also: → 1477305

:erahm, I just tryed your patch locally and it works.

(In reply to Eric Rahm [:erahm] from comment #6)

I got a bit closer modifying the rust.mk file to further support clang when coverage is enabled. Now it fails in testSymbolstore during make check. Perhaps that's enough for you to proceed?

I've filed bug 1608146 for this.

Assignee: nobody → mcastelluccio
Status: NEW → ASSIGNED
Pushed by mcastelluccio@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/9a223d507c94 Only pass the base compiler flags for all coverage builds. r=froydnj
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: