-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
-Zprofile and -Clink-dead-code enabled leads to the linking error on macOS #63047
Comments
I'm seeing this issue except I get:
Unlike in alexcrichton/curl-rust#279 I only get it when trying to build for grcov with |
I'm getting the same error
and I'm on nightly as well:
|
I'm also seeing a similar issue in an Ubuntu-based Docker container:
|
Interesting. Is there an example project that this fails for? It just works for me on a 2017 mbp with latest nightly (I'm using it on a small project though..). |
@gilescope unfortunately, I don't currently have a simplified project. I suspect it may be related to some of the way curl-rust is set up. But I can't say for certain. |
Ok so this could be a somewhat idiosyncratic error rather than being a general error affecting all osx users of grcov... Sent with GitHawk |
@gilescope definitely not unique to macOS since I saw something very similar in an Ubuntu Docker container. |
…t-type-id, r=jdm Fix for link error - undefined CFMutableAttributedStringGetTypeID ## Intention Fix for rust-lang/rust#63047 and intellij-rust/intellij-rust#4605 ## How to reproduce The following program fails to compile: ```rust use core_foundation::attributed_string::{CFAttributedString, CFMutableAttributedString}; use core_foundation::base::TCFType; fn main() { dbg!(<CFAttributedString as TCFType>::type_id()); dbg!(<CFMutableAttributedString as TCFType>::type_id()); } ``` ``` error: linking with `cc` failed: exit code: 1 | = note: "cc" "-m64" "-L" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.198s3ihm7i58x886.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.29tmhebao6ewa0ll.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.2d9bu5z2mybg821y.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.47seajd45h5x4xvx.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.4m5r63z1bomeava7.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.dyb0rm2k46lhkz1.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.ux6g43y1awzd3xm.rcgu.o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.ysgemo5b5rzmi6m.rcgu.o" "-o" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/foo-cef9f22f855ec251.25q0sul7ku3gti43.rcgu.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps" "-L" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/libcore_foundation-3b681be94f15488f.rlib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/liblibc-e84db2977ac0591b.rlib" "/Users/vbadanov/projects/tests/codecoverage-issue-testproject/target/debug/deps/libcore_foundation_sys-2e4eeadb22527df2.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libstd-c9ffd87d7c2bccdf.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libpanic_unwind-b6d1e628327abbae.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libhashbrown-760b1a8bb4bcc351.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_alloc-1660704e36532385.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace-c11c21cbed796daf.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libbacktrace_sys-6c38e3c045a3a71f.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_demangle-5bfb7cde712ed2a9.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libunwind-4540ebf06eb7e37e.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcfg_if-0a35227c3d306cf2.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liblibc-c976a950e872076f.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/liballoc-ef822b0e650993e5.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/librustc_std_workspace_core-172ea43efe468d24.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcore-4d87cbd247e9505f.rlib" "/Users/vbadanov/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib/libcompiler_builtins-3943751ba8f04dce.rlib" "-framework" "CoreFoundation" "-lSystem" "-lresolv" "-lc" "-lm" = note: Undefined symbols for architecture x86_64: "_CFMutableAttributedStringGetTypeID", referenced from: _$LT$core_foundation..attributed_string..CFMutableAttributedString$u20$as$u20$core_foundation..base..TCFType$GT$::type_id::h9f6f71bdd347aca0 in foo-cef9f22f855ec251.198s3ihm7i58x886.rcgu.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) error: aborting due to previous error ``` ## Root cause Core Foundation framework does not have `CFMutableAttributedStringGetTypeID()` function. 1. Documentation of [CFMutableAttributedString](https://developer.apple.com/documentation/corefoundation/cfmutableattributedstring-rqp) does not have function `CFMutableAttributedStringGetTypeID()` listed. 2. Documentation of [CFAttributedString](https://developer.apple.com/documentation/corefoundation/cfattributedstring-s1s) says that there is function `CFAttributedStringGetTypeID()` available (without word "Mutable"). 3. Documentation of [CFAttributedStringGetTypeID()](https://developer.apple.com/documentation/corefoundation/1541715-cfattributedstringgettypeid) says the following: > CFMutableAttributedString objects have the same type identifier as CFAttributedString objects. 4. As a double check - there is no `CFMutableAttributedStringGetTypeID()` function in C/C++ headers on MacOS, but `CFAttributedStringGetTypeID()` is available. C/C++ test program (similar to Rust above) does not compile as well. So, `CFAttributedStringGetTypeID()` must be used instead of `CFMutableAttributedStringGetTypeID()` ## Solution 1. In `core-foundation-sys`: Remove `extern CFMutableAttributedStringGetTypeID()` 2. In `core-foundation`: * Replace `CFMutableAttributedStringGetTypeID` with `CFAttributedStringGetTypeID` * Add test (compilation fails before the fix and is OK after the fix)
This issue was fixed in servo/core-foundation-rs#357 so now we should wait for a new release of |
@vbadanov that's great news. Thanks for the fix! |
OSX code corverage block on rust-lang/rust#63047, so add ubuntu support advance
OSX code corverage block on rust-lang/rust#63047, so add ubuntu support advance
test: Fuzz testing RPC #2422 Fuzzer to test RPC connections, by sending: - [x] Invalid methods - [ ] Correct method with invalid formatted data - [x] Correct method with validly formatted random data How to run fuzzing ------------------- ```bach $ cd chain/jsonrpc $ cargo install cargo-fuzz # (if not installed) $ cargo fuzz run fuzz_target_1 ``` **Note** there is some bug in Rust, already fixed but still not included in nightly release, somehow related to MacOS Catalina, so fuzzing is possible only in Linux (definitely) and probably on Windows (haven't check). References: rust-lang/rust#63047 (comment) servo/core-foundation-rs#357 Test plan --------- 1. test query methods with valid random data and ensure RPC response status is 200 and response contains `error` key instead of `result`. 2. test for valid methods with invalid format of data. Should return 200 and `error` in response. 3. test for invalid methods
I'm getting this issue now as well
active toolchainstable-x86_64-apple-darwin (default) |
EnvironmentmacOS Big Sur 11.1 |
There are still a lot of crates which depend on older version of core-foundation (e.g. 0.7). Test code (see above) with core-foundation = "0.9.1" and rustc 1.54.0-nightly works as expected without errors, coverage report is generated successfully. If you see errors, please check your crates dependencies, there should be an old core-foundation version somewhere in the tree. |
@vbadanov Does this mean that crates which depend on core-foundation should upgrade to the latest now? I imagine the situation will be similar to when Tokio went from 0.3 to 1.0, and it took a while for crates to upgrade. |
@seanpianka Yes. |
Triage: This was a bug in the |
I'm integrating grcov and have macOS build failures with a linkage error while both
-Zprofile
and-Clink-dead-code
flags enabled.Consider a cargo project with the following manifest:
and the
src/main.rs
file:Plain
cargo run
successfully compiles and run the binary (no additional env vars set):Now, as described in the
gcov
readme I add the necessary flags:With a
-Clink-dead-code
flag removed fromRUSTFLAGS
build successfully compiles:The same behavior applies to
cargo test
command.Meta
The text was updated successfully, but these errors were encountered: