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

base_dir does not play well with Clang relocatable PCH #1322

Open
vient opened this issue Aug 18, 2023 · 3 comments
Open

base_dir does not play well with Clang relocatable PCH #1322

vient opened this issue Aug 18, 2023 · 3 comments
Labels
bug Does not work as intended/documented compiler: clang Related to Clang

Comments

@vient
Copy link

vient commented Aug 18, 2023

How to reproduce

  1. touch pch.h
  2. clang-16 -isysroot ${PWD} --relocatable-pch -x c++-header pch.h -o pch1.pch
  3. CCACHE_BASEDIR=${PWD} ccache clang-16 -isysroot ${PWD} --relocatable-pch -x c++-header pch.h -o pch2.pch

Actual behavior

pch1.pch is relocatable relative to current directory, i.e. it contains relative path pch.h. pch2.pch is not relocatable because ccache modified isysroot argument to . which Clang then failed to match header path against.

$ grep -r "$(realpath pch.h)" .
Binary file ./pch2.pch matches

I am not 100% sure that this is ccache's fault instead of clang's. I think there might be situations where you may want PCH to be relocated against relative path, will clarify it with LLVM devs.

Expected behavior

Produced PCH files are binary identical (which they are if you do not pass CCACHE_BASEDIR).

Environment

ccache version 4.8

@vient
Copy link
Author

vient commented Aug 19, 2023

LLVM confirmed that isysroot is not resolved in any way so ccache should not modify it when "relocatable-pch" is seen.

It seems that proper way would be to use relative isysroot in caching key though, so the same PCH will get a cache hit when compiled from different folder but changing isysroot will not result in false cache hit.

@jrosdahl jrosdahl added the compiler: clang Related to Clang label Aug 24, 2023
@jrosdahl
Copy link
Member

Would you be interested in working on a proposed fix?

@vient
Copy link
Author

vient commented Aug 24, 2023

Yes, I'm already doing it but it may take some time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Does not work as intended/documented compiler: clang Related to Clang
Projects
None yet
Development

No branches or pull requests

2 participants