Conversation
Author
|
Ah well removing TAKES_PATH probably broke the WIN32 path conversion, it was indeed suspicious from the start. Maybe adding a new compopt flag would be necessary, I'll have a look. |
jrosdahl
reviewed
Dec 21, 2025
lbonn
force-pushed
the
basedir-pch
branch
2 times, most recently
from
December 22, 2025 11:09
35523da to
4824065
Compare
Clang uses the .pch extension by default, but the tests were written to use the .gch extension. None of the suite was running with clang due to this issue
Author
|
I've noticed that the pch tests actually did not run at all with clang due to some default extension mix-up (maybe it was updated in a more recent clang version). Additionally, the 2 parts of the change: do not rewrite -isysroot and cache it as relative with --relocatable-pch; have also been split. |
Even with BASEDIR, compilers should not be given a relative -isysroot directory as argument. Clang for example just ignores it in this case.
Clang recommends using -isysroot with relocatable-pch but it needs to be passed as an absolute path. However, we can use the relative path as a cache key in this case to actually make a use of the relocatable pch feature.
jrosdahl
reviewed
Jan 19, 2026
Comment on lines
+1263
to
+1264
| if (compopt_takes_path_abs(arg)) { | ||
| // some paths should not be made relative (eg -isysroot) |
Member
There was a problem hiding this comment.
I'm not confident that we can ignore rewriting -isysroot unconditionally like this.
Consider this test script:
#!/bin/sh
set -eu
compiler=gcc
rm -rf pr-1661-test
mkdir pr-1661-test
cd pr-1661-test
mkdir -p example/arch1/sysroot/usr/include
touch example/arch1/sysroot/usr/include/h.h
cp -a example/arch1 example/arch2
cat <<EOF >example/arch1/c.c
#include <h.h>
EOF
cp example/arch1/c.c example/arch2
dir=$PWD
export CCACHE_BASEDIR=$dir
export CCACHE_DIR=$dir/ccache
export CCACHE_DEBUG=1
cd example/arch1
ccache $compiler -isysroot $dir/example/arch1/sysroot -c c.c
grep Executing c.o.*ccache-log || true
grep Result: c.o.*ccache-log || true
echo
cd ../..
cd example/arch2
ccache $compiler -isysroot $dir/example/arch2/sysroot -c c.c
grep Executing c.o.*ccache-log || true
grep Result: c.o.*ccache-log || trueWithout this PR the second compilation is a cache hit:
[2026-01-19T20:28:11.063512 3688461] Executing /usr/bin/gcc -isysroot sysroot -E -o /run/user/1000/ccache-tmp/cpp_stdout.tmp.oxOKwJ.i c.c
[2026-01-19T20:28:11.067772 3688461] Executing /usr/bin/gcc -isysroot sysroot -fdiagnostics-color -c -o c.o c.c
[2026-01-19T20:28:11.073773 3688461] Result: cache_miss
[2026-01-19T20:28:11.073774 3688461] Result: direct_cache_miss
[2026-01-19T20:28:11.073775 3688461] Result: local_storage_miss
[2026-01-19T20:28:11.073775 3688461] Result: local_storage_read_miss
[2026-01-19T20:28:11.073776 3688461] Result: local_storage_read_miss
[2026-01-19T20:28:11.073776 3688461] Result: local_storage_write
[2026-01-19T20:28:11.073777 3688461] Result: local_storage_write
[2026-01-19T20:28:11.073777 3688461] Result: preprocessed_cache_miss
[2026-01-19T20:28:11.078599 3688469] Result: direct_cache_hit
[2026-01-19T20:28:11.078600 3688469] Result: local_storage_hit
[2026-01-19T20:28:11.078600 3688469] Result: local_storage_read_hit
[2026-01-19T20:28:11.078601 3688469] Result: local_storage_read_hit
But with this PR it's a miss:
[2026-01-19T20:28:18.669134 3688663] Executing /usr/bin/gcc -isysroot /home/joel/[...]/pr-1661-test/example/arch1/sysroot -E -o /run/user/1000/ccache-tmp/cpp_stdout.tmp.8xlFDp.i c.c
[2026-01-19T20:28:18.672752 3688663] Executing /usr/bin/gcc -isysroot /home/joel/[...]/pr-1661-test/example/arch1/sysroot -fdiagnostics-color -c -o c.o c.c
[2026-01-19T20:28:18.679678 3688663] Result: cache_miss
[2026-01-19T20:28:18.679680 3688663] Result: direct_cache_miss
[2026-01-19T20:28:18.679682 3688663] Result: local_storage_miss
[2026-01-19T20:28:18.679683 3688663] Result: local_storage_read_miss
[2026-01-19T20:28:18.679685 3688663] Result: local_storage_read_miss
[2026-01-19T20:28:18.679686 3688663] Result: local_storage_write
[2026-01-19T20:28:18.679687 3688663] Result: local_storage_write
[2026-01-19T20:28:18.679688 3688663] Result: preprocessed_cache_miss
[2026-01-19T20:28:18.684241 3688671] Executing /usr/bin/gcc -isysroot /home/joel/[...]/pr-1661-test/example/arch2/sysroot -E -o /run/user/1000/ccache-tmp/cpp_stdout.tmp.m4Dned.i c.c
[2026-01-19T20:28:18.688607 3688671] Executing /usr/bin/gcc -isysroot /home/joel/[...]/pr-1661-test/example/arch2/sysroot -fdiagnostics-color -c -o c.o c.c
[2026-01-19T20:28:18.702156 3688671] Result: cache_miss
[2026-01-19T20:28:18.702163 3688671] Result: direct_cache_miss
[2026-01-19T20:28:18.702167 3688671] Result: local_storage_miss
[2026-01-19T20:28:18.702170 3688671] Result: local_storage_read_miss
[2026-01-19T20:28:18.702174 3688671] Result: local_storage_read_miss
[2026-01-19T20:28:18.702177 3688671] Result: local_storage_write
[2026-01-19T20:28:18.702180 3688671] Result: local_storage_write
[2026-01-19T20:28:18.702183 3688671] Result: preprocessed_cache_miss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here is an attempt to solve #1322 with one of the proposed approaches from the thread.
To reduce risk, I thought about restricting this behavior to invocations with
--relocatable-pchbut it would probably lead to bigger changes ashash_argumentis collecting everything in one pass.Fixes #1322