Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add #[no_coverage] to the test harness's fn main #111042

Merged
merged 1 commit into from
May 2, 2023

Conversation

Zalathar
Copy link
Contributor

There are two main motivations for adding #[no_coverage] to the test harness's entry point:

  • The entry point is trivial compiler-generated code that doesn't correspond to user source, and it always runs, so there's no value in instrumenting it for coverage.
  • Because it has dummy spans, it causes the instrumentor implementation to emit invalid coverage mappings that confuse llvm-cov and result in strange coverage reports.

Fixes #110749.

@rustbot
Copy link
Collaborator

rustbot commented Apr 30, 2023

r? @cjgillot

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 30, 2023
@Zalathar
Copy link
Contributor Author

Ideally the instrumentor would also be fixed to not emit invalid/confusing mappings. (For example, #97368 managed to fix one problem, but ended up exposing a more subtle problem.)

But I think adding #[no_coverage] is something that makes sense in its own right, even if the instrumentor were perfect.

@rust-log-analyzer

This comment has been minimized.

@Zalathar
Copy link
Contributor Author

Zalathar commented May 1, 2023

@rustbot label +A-code-coverage +A-libtest

@rustbot rustbot added A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) A-libtest Area: `#[test]` / the `test` library labels May 1, 2023
@wesleywiser
Copy link
Member

Thanks @Zalathar!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 1, 2023

📌 Commit 77af67a has been approved by wesleywiser

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 1, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request May 1, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#109540 (std docs: edit `PathBuf::set_file_name` example)
 - rust-lang#110093 (Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`)
 - rust-lang#110987 (update wasi_clock_time_api ref.)
 - rust-lang#111038 (Leave promoteds untainted by errors when borrowck fails)
 - rust-lang#111042 (Add `#[no_coverage]` to the test harness's `fn main`)
 - rust-lang#111057 (Make sure the implementation of TcpStream::as_raw_fd is fully inlined)
 - rust-lang#111065 (Explicitly document how Send and Sync relate to references)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 0a2562b into rust-lang:master May 2, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 2, 2023
@Zalathar Zalathar deleted the no-coverage branch May 2, 2023 01:46
@ComputerDruid
Copy link
Contributor

In the fuchsia build, I'm seeing a new error pop up that I think is caused by this PR:

[21418/207373](69) RUST x64-coverage-rust/no_rust_tests x64-coverage-rust/exe.unstripped/no_rust_tests x64-coverage-rust/no_rust_tests.build-id.stamp
FAILED: x64-coverage-rust/no_rust_tests x64-coverage-rust/exe.unstripped/no_rust_tests x64-coverage-rust/no_rust_tests.build-id.stamp
mkdir -p x64-coverage-rust/exe.unstripped && ../../build/tracer/output_cacher_local_wrapper.sh ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/tracer/restat_cacher.py --outputs x64-coverage-rust/no_rust_tests x64-coverage-rust/exe.unstripped/no_rust_tests x64-coverage-rust/no_rust_tests.build-id.stamp x64-coverage-rust/no_rust_tests.d -- ../../prebuilt/third_party/pyth...
error: linking with `../../prebuilt/third_party/clang/linux-x64/bin/lld` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="../../prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "../../prebuilt/third_party/clang/linux-x64/bin/lld" "-flavor" "gnu" "--build-id" "--hash-style=gnu" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "--pack-dyn-relocs=rel...

  = note: lld: error: undefined hidden symbol: __llvm_profile_counter_bias
          >>> referenced by InstrProfilingPlatformFuchsia.c:183 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/profiler_builtins/../../src/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c:183)

that's truncated a bit, but I also have the full output

Details

[21418/207373](69) RUST x64-coverage-rust/no_rust_tests x64-coverage-rust/exe.unstripped/no_rust_tests x64-coverage-rust/no_rust_tests.build-id.stamp
FAILED: x64-coverage-rust/no_rust_tests x64-coverage-rust/exe.unstripped/no_rust_tests x64-coverage-rust/no_rust_tests.build-id.stamp
mkdir -p x64-coverage-rust/exe.unstripped && ../../build/tracer/output_cacher_local_wrapper.sh ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/tracer/restat_cacher.py --outputs x64-coverage-rust/no_rust_tests x64-coverage-rust/exe.unstripped/no_rust_tests x64-coverage-rust/no_rust_tests.build-id.stamp x64-coverage-rust/no_rust_tests.d -- ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/rbe/rustc_remote_wrapper.py --exec_strategy=remote --preserve_unchanged_output_mtime --  RUST_BACKTRACE=1 ../../prebuilt/third_party/rust/linux-x64/bin/rustc --color=always --crate-name no_rust_tests ../../src/sys/test_runners/rust/test_data/no-rust-tests/src/lib.rs --crate-type bin --emit=dep-info=x64-coverage-rust/no_rust_tests.d,link -Zdep-info-omit-d-target -C link-args=--Map="x64-coverage-rust/exe.unstripped/no_rust_tests.map" --remote-flag=--label=\'//src/sys/test_runners/rust/test_data/no-rust-tests:test.actual\(//build/toolchain/fuchsia:x64-coverage-rust\)\' --cfg=fidl_rust_transition_step=\"initial\" --test --cfg=__rust_toolchain=\"GnFdrk39P4reeuBGLhjAhuLIUH8fkovvTKtfjOpv9TIC\" -L x64-coverage-rust/gen/zircon/public/sysroot/cpp/lib -Clinker=../../prebuilt/third_party/clang/linux-x64/bin/lld -Clink-arg=--sysroot=x64-coverage-rust/gen/zircon/public/sysroot/cpp -Clink-arg=-L../../prebuilt/third_party/clang/linux-x64/bin/../lib/x86_64-unknown-fuchsia -Clink-arg=-L../../prebuilt/third_party/clang/linux-x64/lib/clang/17/lib/x86_64-unknown-fuchsia -Clink-arg=--pack-dyn-relocs=relr -Clink-arg=-dynamic-linker=ld.so.1 -Clink-arg=--icf=all -Clink-arg=-zrel -Ccodegen-units=1 -Zremap-cwd-prefix=. -Cforce-frame-pointers -Copt-level=1 -Cdebuginfo=2 -Zallow-features= --target x86_64-fuchsia --cap-lints=deny -Wrust-2018-idioms -Dderef-nullptr -Dinvalid-value -Dunused-must-use -Awhere_clauses_object_safety -Dwarnings -Cdebug-assertions=yes -Cprefer-dynamic -Clink-args=-zstack-size=0x200000 -Cpanic=abort -Cforce-unwind-tables=yes -Zpanic_abort_tests -Csymbol-mangling-version=v0 -Cinstrument-coverage -Clink-arg=-dynamic-linker=coverage-rust/ld.so.1 -Dunused_crate_dependencies -Dunused_results -Aunused_results --edition=2021 --remote-flag=--canonicalize_working_dir=false -o "x64-coverage-rust/exe.unstripped/no_rust_tests" -Lnative=x64-coverage-rust/obj/sdk/lib/syslog/cpp -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/hlcpp/fuchsia/diagnostics/stream/cpp -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/c -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/hlcpp/fuchsia/diagnostics/cpp -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/c -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/hlcpp/fuchsia/inspect/cpp -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/c -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/hlcpp/fuchsia/mem/cpp -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/c -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/zircon/vdso/zx/zx/c -Lnative=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal -Lnative=x64-coverage-rust/obj/sdk/lib/fidl/cpp -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/hlcpp/fuchsia/logger/cpp -Lnative=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/c -Lnative=x64-coverage-rust/obj/sdk/lib/syslog/streams/cpp -Lnative=x64-coverage-rust/obj/sdk/lib/syslog/structured_backend -Lnative=user.libc_x64-coverage-rust/obj/zircon/system/ulib/c -Lnative=x64-coverage-rust-shared/link_stub -Lnative=x64-coverage-rust/obj/sdk/lib/fit-promise -Lnative=x64-coverage-rust/obj/sdk/lib/fit -Lnative=x64-coverage-rust/obj/sdk/lib/stdcompat -Lnative=x64-coverage-rust/obj/zircon/system/ulib/zx -Lnative=x64-coverage-rust/obj/sdk/lib/fidl_base -Lnative=x64-coverage-rust/obj/sdk/lib/utf-utils -Lnative=x64-coverage-rust/obj/sdk/lib/fidl -Lnative=x64-coverage-rust/obj/zircon/system/ulib/async -Lnative=x64-coverage-rust/obj/zircon/system/ulib/async-loop -Lnative=x64-coverage-rust/obj/zircon/system/ulib/sync -Lnative=x64-coverage-rust/obj/zircon/system/ulib/zircon-internal -Clink-arg=-Bdynamic -Clink-arg=x64-coverage-rust/obj/sdk/lib/syslog/cpp/backend_fuchsia_lib.fx_log_api.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/syslog/cpp/backend_fuchsia_lib.logging_backend_fuchsia.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/syslog/cpp/cpp.log_settings.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/syslog/cpp/cpp.macros.cc.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/hlcpp/fuchsia/diagnostics/stream/cpp/fuchsia.diagnostics.stream_hlcpp.fidl.cc.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/c/fuchsia.diagnostics.stream_tables.fuchsia.diagnostics.stream.fidl.tables.c.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/hlcpp/fuchsia/diagnostics/cpp/fuchsia.diagnostics_hlcpp.fidl.cc.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/c/fuchsia.diagnostics_tables.fuchsia.diagnostics.fidl.tables.c.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/hlcpp/fuchsia/inspect/cpp/fuchsia.inspect_hlcpp.fidl.cc.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/c/fuchsia.inspect_tables.fuchsia.inspect.fidl.tables.c.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/hlcpp/fuchsia/mem/cpp/fuchsia.mem_hlcpp.fidl.cc.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/c/fuchsia.mem_tables.fuchsia.mem.fidl.tables.c.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/zircon/vdso/zx/zx/c/zx_tables.zx.fidl.tables.c.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.message_handler.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.message_reader.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.pending_response.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.proxy.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.proxy_controller.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.stub.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.stub_controller.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.unknown_interactions_table.c.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.weak_stub_controller.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp.unknown_interactions_hlcpp.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp_sync.logging.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp_sync.message_sender.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp_sync.synchronous_proxy.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.clone.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.decoder.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.encoder.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.message.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.message_buffer.cc.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/hlcpp/fuchsia/logger/cpp/fuchsia.logger_hlcpp.fidl.cc.o -Clink-arg=x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/c/fuchsia.logger_tables.fuchsia.logger.fidl.tables.c.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/syslog/streams/cpp/streams-encoder.encode.cc.o -Clink-arg=x64-coverage-rust/obj/sdk/lib/syslog/structured_backend/structured_backend.fuchsia_syslog.cc.o -Clink-arg=user.libc_x64-coverage-rust/obj/zircon/system/ulib/c/crt1.Scrt1.cc.o -Clink-arg=x64-coverage-rust-shared/link_stub/libfdio.so -Clink-arg=x64-coverage-rust-shared/link_stub/libbackend_fuchsia_globals.so -Clink-arg=x64-coverage-rust/obj/sdk/lib/fit-promise/libfit-promise.a -Clink-arg=x64-coverage-rust/obj/sdk/lib/fit/libfit.a -Clink-arg=x64-coverage-rust/obj/sdk/lib/stdcompat/libstdcompat.a -Clink-arg=x64-coverage-rust/obj/zircon/system/ulib/zx/libzx.a -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl_base/libfidl_base.a -Clink-arg=x64-coverage-rust/obj/sdk/lib/utf-utils/libutf-utils.a -Clink-arg=x64-coverage-rust/obj/sdk/lib/fidl/libfidl.a -Clink-arg=x64-coverage-rust/obj/zircon/system/ulib/async/libasync.a -Clink-arg=x64-coverage-rust-shared/link_stub/libasync-default.so -Clink-arg=x64-coverage-rust/obj/zircon/system/ulib/async/libasync-cpp.a -Clink-arg=x64-coverage-rust/obj/zircon/system/ulib/async-loop/libasync-loop-cpp.a -Clink-arg=x64-coverage-rust/obj/zircon/system/ulib/async-loop/libasync-loop.a -Clink-arg=x64-coverage-rust/obj/zircon/system/ulib/sync/libsync.a -Clink-arg=x64-coverage-rust/obj/zircon/system/ulib/zircon-internal/libzircon-internal.a -Lnative=gen/src/zircon/lib/zircon/zircon.x86_64 -Lnative=gen/zircon/system/ulib/c/c.x86_64 -Lnative=../../build/config/zircon/libc-dummy -Clink-arg=gen/src/zircon/lib/zircon/zircon.x86_64/libzircon.so -Clink-arg=gen/zircon/system/ulib/c/c.x86_64/libc.so  && ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 -S ../../build/gn/verify_depfile.py -t "//src/sys/test_runners/rust/test_data/no-rust-tests:test.actual(//build/toolchain/fuchsia:x64-coverage-rust)" -d x64-coverage-rust/no_rust_tests.d ../../src/sys/test_runners/rust/test_data/no-rust-tests/src/lib.rs ../../prebuilt/proprietary/third_party/reclient/linux-x64/bootstrap ../../prebuilt/proprietary/third_party/reclient/linux-x64/reproxy ../../prebuilt/proprietary/third_party/reclient/linux-x64/rewrapper ../../build/rbe/fuchsia-reproxy-wrap.sh ../../build/rbe/remote_action.py ../../build/rbe/cl_utils.py ../../build/rbe/fuchsia.py ../../build/rbe/rustc.py ../../build/rbe/rustc_remote_wrapper.py ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 ../../build/tracer/restat_cacher.py ../../build/tracer/output_cacher_local_wrapper.sh ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 ../../build/tracer/restat_cacher.py ../../build/tracer/output_cacher_local_wrapper.sh ../../prebuilt/third_party/python3/linux-x64/bin/python3.8 ../../build/tracer/restat_cacher.py ../../build/tracer/output_cacher_local_wrapper.sh && ../../prebuilt/third_party/clang/linux-x64/bin/llvm-objcopy --strip-sections --keep-section=.rustc "x64-coverage-rust/exe.unstripped/no_rust_tests" "x64-coverage-rust/no_rust_tests" && ../../prebuilt/tools/buildidtool/linux-x64/buildidtool -build-id-dir .build-id -stamp "x64-coverage-rust/no_rust_tests.build-id.stamp" -entry "=x64-coverage-rust/no_rust_tests" -entry ".debug=x64-coverage-rust/exe.unstripped/no_rust_tests"
error: linking with `../../prebuilt/third_party/clang/linux-x64/bin/lld` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="../../prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" VSLANG="1033" "../../prebuilt/third_party/clang/linux-x64/bin/lld" "-flavor" "gnu" "--build-id" "--hash-style=gnu" "-z" "max-page-size=4096" "-z" "now" "-z" "rodynamic" "-z" "separate-loadable-segments" "--pack-dyn-relocs=relr" "x64-coverage-rust/gen/zircon/public/sysroot/cpp/lib/Scrt1.o" "/tmp/rustc1a2hre/symbols.o" "x64-coverage-rust/exe.unstripped/no_rust_tests.no_rust_tests.b924bb75de3e713b-cgu.0.rcgu.o" "--as-needed" "-L" "x64-coverage-rust/gen/zircon/public/sysroot/cpp/lib" "-L" "x64-coverage-rust/obj/sdk/lib/syslog/cpp" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/hlcpp/fuchsia/diagnostics/stream/cpp" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/c" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/hlcpp/fuchsia/diagnostics/cpp" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/c" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/hlcpp/fuchsia/inspect/cpp" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/c" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/hlcpp/fuchsia/mem/cpp" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/c" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/zircon/vdso/zx/zx/c" "-L" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal" "-L" "x64-coverage-rust/obj/sdk/lib/fidl/cpp" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/hlcpp/fuchsia/logger/cpp" "-L" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/c" "-L" "x64-coverage-rust/obj/sdk/lib/syslog/streams/cpp" "-L" "x64-coverage-rust/obj/sdk/lib/syslog/structured_backend" "-L" "user.libc_x64-coverage-rust/obj/zircon/system/ulib/c" "-L" "x64-coverage-rust-shared/link_stub" "-L" "x64-coverage-rust/obj/sdk/lib/fit-promise" "-L" "x64-coverage-rust/obj/sdk/lib/fit" "-L" "x64-coverage-rust/obj/sdk/lib/stdcompat" "-L" "x64-coverage-rust/obj/zircon/system/ulib/zx" "-L" "x64-coverage-rust/obj/sdk/lib/fidl_base" "-L" "x64-coverage-rust/obj/sdk/lib/utf-utils" "-L" "x64-coverage-rust/obj/sdk/lib/fidl" "-L" "x64-coverage-rust/obj/zircon/system/ulib/async" "-L" "x64-coverage-rust/obj/zircon/system/ulib/async-loop" "-L" "x64-coverage-rust/obj/zircon/system/ulib/sync" "-L" "x64-coverage-rust/obj/zircon/system/ulib/zircon-internal" "-L" "gen/src/zircon/lib/zircon/zircon.x86_64" "-L" "gen/zircon/system/ulib/c/c.x86_64" "-L" "../../build/config/zircon/libc-dummy" "-L" "../../prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-fuchsia/lib" "-Bstatic" "/b/f/w/prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-fuchsia/lib/libprofiler_builtins-d39381d41c6388b4.rlib" "-L" "/b/f/w/prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-fuchsia/lib" "-Bdynamic" "-ltest-590f7e6b4f197d09" "-L" "/b/f/w/prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-fuchsia/lib" "-lstd-d2f5aa466a31f3b6" "-Bstatic" "/b/f/w/prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-fuchsia/lib/libcompiler_builtins-ed1ebbedf72fa3cf.rlib" "-Bdynamic" "-lzircon" "-lfdio" "-lc" "-lfdio" "--dynamic-linker=ld.so.1" "--eh-frame-hdr" "-z" "noexecstack" "-L" "../../prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-fuchsia/lib" "-o" "x64-coverage-rust/exe.unstripped/no_rust_tests" "--gc-sections" "-pie" "-u" "__llvm_profile_runtime" "--Map=x64-coverage-rust/exe.unstripped/no_rust_tests.map" "--sysroot=x64-coverage-rust/gen/zircon/public/sysroot/cpp" "-L../../prebuilt/third_party/clang/linux-x64/bin/../lib/x86_64-unknown-fuchsia" "-L../../prebuilt/third_party/clang/linux-x64/lib/clang/17/lib/x86_64-unknown-fuchsia" "--pack-dyn-relocs=relr" "-dynamic-linker=ld.so.1" "--icf=all" "-zrel" "-zstack-size=0x200000" "-dynamic-linker=coverage-rust/ld.so.1" "-Bdynamic" "x64-coverage-rust/obj/sdk/lib/syslog/cpp/backend_fuchsia_lib.fx_log_api.cc.o" "x64-coverage-rust/obj/sdk/lib/syslog/cpp/backend_fuchsia_lib.logging_backend_fuchsia.cc.o" "x64-coverage-rust/obj/sdk/lib/syslog/cpp/cpp.log_settings.cc.o" "x64-coverage-rust/obj/sdk/lib/syslog/cpp/cpp.macros.cc.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/hlcpp/fuchsia/diagnostics/stream/cpp/fuchsia.diagnostics.stream_hlcpp.fidl.cc.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics.stream/fuchsia.diagnostics.stream/c/fuchsia.diagnostics.stream_tables.fuchsia.diagnostics.stream.fidl.tables.c.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/hlcpp/fuchsia/diagnostics/cpp/fuchsia.diagnostics_hlcpp.fidl.cc.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.diagnostics/fuchsia.diagnostics/c/fuchsia.diagnostics_tables.fuchsia.diagnostics.fidl.tables.c.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/hlcpp/fuchsia/inspect/cpp/fuchsia.inspect_hlcpp.fidl.cc.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.inspect/fuchsia.inspect/c/fuchsia.inspect_tables.fuchsia.inspect.fidl.tables.c.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/hlcpp/fuchsia/mem/cpp/fuchsia.mem_hlcpp.fidl.cc.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.mem/fuchsia.mem/c/fuchsia.mem_tables.fuchsia.mem.fidl.tables.c.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/zircon/vdso/zx/zx/c/zx_tables.zx.fidl.tables.c.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.message_handler.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.message_reader.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.pending_response.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.proxy.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.proxy_controller.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.stub.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.stub_controller.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.unknown_interactions_table.c.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp.weak_stub_controller.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp.unknown_interactions_hlcpp.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp_sync.logging.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp_sync.message_sender.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/internal/cpp_sync.synchronous_proxy.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.clone.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.decoder.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.encoder.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.message.cc.o" "x64-coverage-rust/obj/sdk/lib/fidl/cpp/cpp_base.message_buffer.cc.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/hlcpp/fuchsia/logger/cpp/fuchsia.logger_hlcpp.fidl.cc.o" "x64-coverage-rust/obj/BUILD_DIR/fidling/gen/sdk/fidl/fuchsia.logger/fuchsia.logger/c/fuchsia.logger_tables.fuchsia.logger.fidl.tables.c.o" "x64-coverage-rust/obj/sdk/lib/syslog/streams/cpp/streams-encoder.encode.cc.o" "x64-coverage-rust/obj/sdk/lib/syslog/structured_backend/structured_backend.fuchsia_syslog.cc.o" "user.libc_x64-coverage-rust/obj/zircon/system/ulib/c/crt1.Scrt1.cc.o" "x64-coverage-rust-shared/link_stub/libfdio.so" "x64-coverage-rust-shared/link_stub/libbackend_fuchsia_globals.so" "x64-coverage-rust/obj/sdk/lib/fit-promise/libfit-promise.a" "x64-coverage-rust/obj/sdk/lib/fit/libfit.a" "x64-coverage-rust/obj/sdk/lib/stdcompat/libstdcompat.a" "x64-coverage-rust/obj/zircon/system/ulib/zx/libzx.a" "x64-coverage-rust/obj/sdk/lib/fidl_base/libfidl_base.a" "x64-coverage-rust/obj/sdk/lib/utf-utils/libutf-utils.a" "x64-coverage-rust/obj/sdk/lib/fidl/libfidl.a" "x64-coverage-rust/obj/zircon/system/ulib/async/libasync.a" "x64-coverage-rust-shared/link_stub/libasync-default.so" "x64-coverage-rust/obj/zircon/system/ulib/async/libasync-cpp.a" "x64-coverage-rust/obj/zircon/system/ulib/async-loop/libasync-loop-cpp.a" "x64-coverage-rust/obj/zircon/system/ulib/async-loop/libasync-loop.a" "x64-coverage-rust/obj/zircon/system/ulib/sync/libsync.a" "x64-coverage-rust/obj/zircon/system/ulib/zircon-internal/libzircon-internal.a" "gen/src/zircon/lib/zircon/zircon.x86_64/libzircon.so" "gen/zircon/system/ulib/c/c.x86_64/libc.so"WARNING: no system SSL certs found. SSL verification may fail.

  = note: lld: error: undefined hidden symbol: __llvm_profile_counter_bias
          >>> referenced by InstrProfilingPlatformFuchsia.c:183 (/b/s/w/ir/x/w/fuchsia-third_party-rust/library/profiler_builtins/../../src/llvm-project/compiler-rt/lib/profile/InstrProfilingPlatformFuchsia.c:183)
          >>>               InstrProfilingPlatformFuchsia.o:(__llvm_profile_initialize) in archive /b/f/w/prebuilt/third_party/rust/linux-x64/lib/rustlib/x86_64-fuchsia/lib/libprofiler_builtins-d39381d41c6388b4.rlib


error: aborting due to previous error

The test it's trying to compile is https://cs.opensource.google/fuchsia/fuchsia/+/main:src/sys/test_runners/rust/test_data/no-rust-tests/src/lib.rs (an empty file) so it sort of intuitively makes sense how adding #[no_coverage] to the test harness could result in an undefined symbol, but I'm not at all familiar with the details.

Is that something that's obvious to you? I wasn't able to reproduce this for Linux, and something about the upstream-distributed libstd for fuchsia seems to be incompatible with coverage (not sure what that's about, the fuchsia-built toolchain before this PR works fine for coverage). And for some reason -Zbuild-std seems broken with coverage, too. So I don't really have a great way to share reproduction instructions. But I figured I'd ask in case the problem was obvious to someone with more context

@Zalathar
Copy link
Contributor Author

Zalathar commented May 4, 2023

This doesn't ring any bells, unfortunately.

My best guess is that some Fuchsia-specific code in the compiler accidentally assumes that every instrumented build contains at least one instrumented function. Now that the test entry point is not instrumented, it's possible for an empty test file to have no instrumented functions, exposing a latent bug in that Fuchsia-specific code.

@Zalathar
Copy link
Contributor Author

Zalathar commented May 4, 2023

For example, there might be a loop (explicit or implicit) over all instrumented functions that has a side-effect of properly setting up the profiler runtime for the resulting binary.

Now that there are zero instrumented functions, that setup would no longer happen, so the binary ends up in an unlinkable state.

@tmandry
Copy link
Member

tmandry commented May 4, 2023

Also related: #102900

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) A-libtest Area: `#[test]` / the `test` library S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

-Cinstrument-coverage produces invalid coverage mapping for the test harness's entry point
8 participants