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

Propagated coverage flags cause gcov link errors #1354

Closed
cuviper opened this issue Jan 10, 2025 · 3 comments · Fixed by #1363
Closed

Propagated coverage flags cause gcov link errors #1354

cuviper opened this issue Jan 10, 2025 · 3 comments · Fixed by #1363
Labels

Comments

@cuviper
Copy link
Member

cuviper commented Jan 10, 2025

When compiling code like the example and RUSTFLAGS=-Cprofile-generate=$PWD, it fails to link with errors like this:

foo.c:1:(.text._sub_I_00100_0+0xf): undefined reference to `__gcov_init'

(and many other __gcov_* symbols)

That's with a default CC that is GCC; it's okay with Clang because that uses the same profiling library as Rust.

Maybe -Cprofile-generate (and -Cprofile-use) should not be translated for ToolFamily::Gnu at all? It seems unlikely that someone would use this and try to juggle both LLVM profraw and GCC gcov files, even if the link error is fixed.

@madsmtm
Copy link
Collaborator

madsmtm commented Jan 11, 2025

CC @mrkajetanp.

Maybe -Cprofile-generate (and -Cprofile-use) should not be translated for ToolFamily::Gnu at all? It seems unlikely that someone would use this and try to juggle both LLVM profraw and GCC gcov files, even if the link error is fixed.

I think that'd be a reasonable fix.

@madsmtm madsmtm added the bug label Jan 11, 2025
@mrkajetanp
Copy link
Contributor

Huh interesting, I didn't realise gcc and clang actually used different formats for the profiling. Yeah in this case there's no point passing it to gcc I agree, would you like me to write up a PR?

@cuviper
Copy link
Member Author

cuviper commented Jan 11, 2025

@mrkajetanp If you're inclined, please go ahead! Otherwise I'll try to get to it later this weekend.

mrkajetanp added a commit to mrkajetanp/cc-rs that referenced this issue Jan 12, 2025
Clang and GNU use different PGO libraries, so PGO flags inherited
from rustc should not automatically be passed to GNU compilers.

Fixes rust-lang#1354
mrkajetanp added a commit to mrkajetanp/cc-rs that referenced this issue Jan 12, 2025
Clang and GNU use different PGO libraries, so PGO flags inherited
from rustc should not automatically be passed to GNU compilers.

Fixes rust-lang#1354
NobodyXu pushed a commit that referenced this issue Jan 12, 2025
Clang and GNU use different PGO libraries, so PGO flags inherited
from rustc should not automatically be passed to GNU compilers.

Fixes #1354
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants