Skip to content

Commit de5c3e2

Browse files
authored
Merge pull request #2627 from jorisv/topic/fix-ccache-key
Fix PCH and ccache build
2 parents 786cf5d + ec5f853 commit de5c3e2

File tree

7 files changed

+43
-6
lines changed

7 files changed

+43
-6
lines changed

.github/workflows/linux.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
CCACHE_DIR: ${GITHUB_WORKSPACE}/.ccache
4444
CCACHE_COMPRESS: true
4545
CCACHE_COMPRESSLEVEL: 5
46+
# Help ccache manage generated files and PCH (https://ccache.dev/manual/latest.html#_precompiled_headers)
47+
CCACHE_SLOPPINESS: include_file_ctime,include_file_mtime,pch_defines,time_macros
4648

4749
steps:
4850
- name: Setup Container
@@ -127,6 +129,9 @@ jobs:
127129
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/openrobots/lib:/usr/local/lib:/usr/lib:/usr/lib/x86_64-linux-gnu
128130
export CMAKE_PREFIX_PATH=/opt/openrobots/lib
129131
132+
# Clear ccache statistics
133+
ccache -z
134+
130135
mkdir build
131136
cd build
132137
cmake .. \
@@ -204,6 +209,11 @@ jobs:
204209
cd build
205210
make uninstall
206211
212+
- name: Display ccache statistics
213+
run: |
214+
# TODO: Add -v option when we drop ubuntu-20.04
215+
ccache -s
216+
207217
check:
208218
if: always()
209219
name: check-linux-apt

.github/workflows/macos-linux-windows-pixi.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
CCACHE_DIR: ${GITHUB_WORKSPACE}/.ccache
4141
CCACHE_COMPRESS: true
4242
CCACHE_COMPRESSLEVEL: 5
43+
# Since pixi will install a compiler, the compiler mtime will be changed.
44+
# This can invalidate the cache (https://ccache.dev/manual/latest.html#config_compiler_check)
45+
CCACHE_COMPILERCHECK: content
4346
BUILD_ADVANCED_TESTING: ${{ matrix.BUILD_ADVANCED_TESTING }}
4447

4548
strategy:
@@ -87,8 +90,8 @@ jobs:
8790
- uses: actions/cache@v4
8891
with:
8992
path: .ccache
90-
key: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.python-version }}-${{ github.sha }}
91-
restore-keys: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.python-version }}-
93+
key: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.environment }}_${{ github.sha }}
94+
restore-keys: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.environment }}_
9295

9396
- uses: prefix-dev/[email protected]
9497
with:
@@ -118,6 +121,9 @@ jobs:
118121
CMAKE_BUILD_PARALLEL_LEVEL: 2
119122
PINOCCHIO_BUILD_TYPE: ${{ matrix.build_type }}
120123
run: |
124+
# Clear ccache statistics
125+
pixi run -e ${{ matrix.environment }} ccache -z
126+
121127
# Launch configure but overwrite default options
122128
pixi run -e ${{ matrix.environment }} configure \
123129
-DBUILD_ADVANCED_TESTING=${{ env.BUILD_ADVANCED_TESTING }} \
@@ -129,7 +135,12 @@ jobs:
129135
- name: Uninstall Pinocchio
130136
shell: bash -el {0}
131137
run: |
132-
cmake --build build --target uninstall
138+
pixi run -e ${{ matrix.environment }} cmake --build build --target uninstall
139+
140+
- name: Display ccache statistics
141+
shell: bash -el {0}
142+
run: |
143+
pixi run -e ${{ matrix.environment }} ccache -sv
133144
134145
check:
135146
if: always()

.github/workflows/ros_ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ jobs:
6262
- uses: actions/cache@v4
6363
with:
6464
path: ${{ env.CCACHE_DIR }}
65-
key: ccache-${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}-${{ github.sha }}
66-
restore-keys: ccache-${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}-
65+
key: ccache-${{ matrix.env.ROS_DISTRO }}-${{ github.sha }}
66+
restore-keys: ccache-${{ matrix.env.ROS_DISTRO }}-
6767
# Run industrial_ci
6868
- uses: 'ros-industrial/industrial_ci@3e67ec54d63496e076267392148a26229740befc'
6969
env: ${{ matrix.env }}

bindings/python/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ function(PINOCCHIO_PYTHON_BINDINGS_SPECIFIC_TYPE scalar_name)
6161
# * -Wconversion as the BOOST_PYTHON_FUNCTION_OVERLOADS implicitly converts.
6262
# * -Wcomment as latex equations have multi-line comments.
6363
# * -Wself-assign-overloaded as bp::self operations trigger this (Clang only).
64+
# * -Xclang=-fno-pch-timestamp to allow ccache to use pch
65+
# (https://ccache.dev/manual/latest.html#_precompiled_headers).
6466
cxx_flags_by_compiler_frontend(
65-
GNU -Wno-conversion -Wno-comment -Wno-self-assign-overloaded
67+
GNU -Wno-conversion -Wno-comment -Wno-self-assign-overloaded -Xclang=-fno-pch-timestamp
68+
MSVC -Xclang=-fno-pch-timestamp
6669
OUTPUT PRIVATE_OPTIONS
6770
FILTER)
6871
target_compile_options(${PYTHON_LIB_NAME} PRIVATE ${PRIVATE_OPTIONS})

development/scripts/pixi/activation.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ set CMAKE_EXPORT_COMPILE_COMMANDS=1
77
:: Activate color output with Ninja
88
set CMAKE_COLOR_DIAGNOSTICS=1
99

10+
:: Help ccache manage generated files and PCH (https://ccache.dev/manual/latest.html#_precompiled_headers)
11+
set CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,pch_defines,time_macros
12+
1013
# Set default build value only if not previously set
1114
if not defined PINOCCHIO_BUILD_TYPE (set PINOCCHIO_BUILD_TYPE=Release)
1215
if not defined PINOCCHIO_PYTHON_STUBS (set PINOCCHIO_PYTHON_STUBS=ON)

development/scripts/pixi/activation.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ then
2020
# On GNU/Linux, I don't know if these flags are mandatory with g++ but
2121
# it allow to use clang++ as compiler
2222
export LDFLAGS="-Wl,-rpath,$CONDA_PREFIX/lib -Wl,-rpath-link,$CONDA_PREFIX/lib -L$CONDA_PREFIX/lib"
23+
24+
# Conda compiler is named x86_64-conda-linux-gnu-c++, ccache can't resolve it
25+
# (https://ccache.dev/manual/latest.html#config_compiler_type)
26+
export CCACHE_COMPILERTYPE=gcc
2327
fi
2428

2529
# Setup ccache
@@ -31,6 +35,9 @@ export CMAKE_EXPORT_COMPILE_COMMANDS=1
3135
# Activate color output with Ninja
3236
export CMAKE_COLOR_DIAGNOSTICS=1
3337

38+
# Help ccache manage generated files and PCH (https://ccache.dev/manual/latest.html#_precompiled_headers)
39+
export CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,pch_defines,time_macros
40+
3441
# Set default build value only if not previously set
3542
export PINOCCHIO_BUILD_TYPE=${PINOCCHIO_BUILD_TYPE:=Release}
3643
export PINOCCHIO_PYTHON_STUBS=${PINOCCHIO_PYTHON_STUBS:=ON}

development/scripts/pixi/activation_clang.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
export CC=clang
55
export CXX=clang++
6+
7+
# activation.sh set this variable to gcc, we must override it here
8+
export CCACHE_COMPILERTYPE=clang

0 commit comments

Comments
 (0)