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

Fix: fix sccache bug for dwo file generate #2271

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

zhouronghua
Copy link
Contributor

@zhouronghua zhouronghua commented Oct 9, 2024

When output dir changed, and -g -gsplit-dwarf is enabled,
because the object file have link to the dwo file (include directories),
the new object file should be gererated, but not old cached object.
In this patch, we add a new precompile macro, for example, "-D_gsplit_dwarf_path=foo.dwo", to force sccache to generate new object file depend on the output directories.

we can check if it work by this case:
case:

echo "int test(){}" > test.cc
mkdir o1 o2
sccache g++ -c -g -gsplit-dwarf test.cc -o o1/test.o
sccache g++ -c -g -gsplit-dwarf test.cc -o o2/test.o
strings o2/test.o |grep o2/test.dwo

The new o2/test.o should contains new link to o2/test.dwo, but not cached o1/test.dwo

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 94.11765% with 3 lines in your changes missing coverage. Please review.

Project coverage is 40.85%. Comparing base (0cc0c62) to head (baca926).
Report is 85 commits behind head on main.

Files with missing lines Patch % Lines
src/compiler/gcc.rs 66.66% 0 Missing and 2 partials ⚠️
tests/system.rs 97.77% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2271      +/-   ##
==========================================
+ Coverage   30.91%   40.85%   +9.94%     
==========================================
  Files          53       54       +1     
  Lines       20112    20803     +691     
  Branches     9755     9678      -77     
==========================================
+ Hits         6217     8499    +2282     
- Misses       7922     8153     +231     
+ Partials     5973     4151    -1822     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sylvestre
Copy link
Collaborator

Could you please add a test to make sure we don't regress in the future? thanks

@zhouronghua
Copy link
Contributor Author

"test_parse_arguments_split_dwarf" this case has been modified to make it work all the time

@sylvestre
Copy link
Collaborator

this isn't enough. I would like to see a test reproducing:

echo "int test(){}" > test.cc
mkdir o1 o2
sccache g++ -c -g -gsplit-dwarf test.cc -o o1/test.o
sccache g++ -c -g -gsplit-dwarf test.cc -o o2/test.o
strings o2/test.o |grep o2/test.dwo

also, you didn't updated the clang.rs file, is that expected ?

@zhouronghua
Copy link
Contributor Author

ok, I will add another test for it, but it need time.

parse_arguments in clang.rs will call parse_arguments in gcc.rs, so no need to change them all.

@sylvestre
Copy link
Collaborator

@zhouronghua
Copy link
Contributor Author

thanks, that's really help.

@sylvestre
Copy link
Collaborator

Needs rustfmt

@zhouronghua
Copy link
Contributor Author

done

@sylvestre sylvestre merged commit 9ddf659 into mozilla:main Nov 8, 2024
56 checks passed
@sylvestre
Copy link
Collaborator

Thanks

trxcllnt pushed a commit to trxcllnt/sccache that referenced this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants