diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 803b7d44f2..78b3faa2e5 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -43,6 +43,8 @@ jobs: CCACHE_DIR: ${GITHUB_WORKSPACE}/.ccache CCACHE_COMPRESS: true CCACHE_COMPRESSLEVEL: 5 + # Help ccache manage generated files and PCH (https://ccache.dev/manual/latest.html#_precompiled_headers) + CCACHE_SLOPPINESS: include_file_ctime,include_file_mtime,pch_defines,time_macros steps: - name: Setup Container @@ -127,6 +129,9 @@ jobs: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/openrobots/lib:/usr/local/lib:/usr/lib:/usr/lib/x86_64-linux-gnu export CMAKE_PREFIX_PATH=/opt/openrobots/lib + # Clear ccache statistics + ccache -z + mkdir build cd build cmake .. \ @@ -204,6 +209,11 @@ jobs: cd build make uninstall + - name: Display ccache statistics + run: | + # TODO: Add -v option when we drop ubuntu-20.04 + ccache -s + check: if: always() name: check-linux-apt diff --git a/.github/workflows/macos-linux-windows-pixi.yml b/.github/workflows/macos-linux-windows-pixi.yml index 6475502649..e65d1fca34 100644 --- a/.github/workflows/macos-linux-windows-pixi.yml +++ b/.github/workflows/macos-linux-windows-pixi.yml @@ -40,6 +40,9 @@ jobs: CCACHE_DIR: ${GITHUB_WORKSPACE}/.ccache CCACHE_COMPRESS: true CCACHE_COMPRESSLEVEL: 5 + # Since pixi will install a compiler, the compiler mtime will be changed. + # This can invalidate the cache (https://ccache.dev/manual/latest.html#config_compiler_check) + CCACHE_COMPILERCHECK: content BUILD_ADVANCED_TESTING: ${{ matrix.BUILD_ADVANCED_TESTING }} strategy: @@ -87,8 +90,8 @@ jobs: - uses: actions/cache@v4 with: path: .ccache - key: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.python-version }}-${{ github.sha }} - restore-keys: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.python-version }}- + key: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.environment }}_${{ github.sha }} + restore-keys: ccache-macos-linux-conda-${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.environment }}_ - uses: prefix-dev/setup-pixi@v0.8.3 with: @@ -118,6 +121,9 @@ jobs: CMAKE_BUILD_PARALLEL_LEVEL: 2 PINOCCHIO_BUILD_TYPE: ${{ matrix.build_type }} run: | + # Clear ccache statistics + pixi run -e ${{ matrix.environment }} ccache -z + # Launch configure but overwrite default options pixi run -e ${{ matrix.environment }} configure \ -DBUILD_ADVANCED_TESTING=${{ env.BUILD_ADVANCED_TESTING }} \ @@ -129,7 +135,12 @@ jobs: - name: Uninstall Pinocchio shell: bash -el {0} run: | - cmake --build build --target uninstall + pixi run -e ${{ matrix.environment }} cmake --build build --target uninstall + + - name: Display ccache statistics + shell: bash -el {0} + run: | + pixi run -e ${{ matrix.environment }} ccache -sv check: if: always() diff --git a/.github/workflows/ros_ci.yml b/.github/workflows/ros_ci.yml index dfd7203525..df9402ba67 100644 --- a/.github/workflows/ros_ci.yml +++ b/.github/workflows/ros_ci.yml @@ -62,8 +62,8 @@ jobs: - uses: actions/cache@v4 with: path: ${{ env.CCACHE_DIR }} - key: ccache-${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}-${{ github.sha }} - restore-keys: ccache-${{ matrix.env.ROS_DISTRO }}-${{ matrix.env.ROS_REPO }}- + key: ccache-${{ matrix.env.ROS_DISTRO }}-${{ github.sha }} + restore-keys: ccache-${{ matrix.env.ROS_DISTRO }}- # Run industrial_ci - uses: 'ros-industrial/industrial_ci@3e67ec54d63496e076267392148a26229740befc' env: ${{ matrix.env }} diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 6be443cb02..eea4f70262 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -61,8 +61,11 @@ function(PINOCCHIO_PYTHON_BINDINGS_SPECIFIC_TYPE scalar_name) # * -Wconversion as the BOOST_PYTHON_FUNCTION_OVERLOADS implicitly converts. # * -Wcomment as latex equations have multi-line comments. # * -Wself-assign-overloaded as bp::self operations trigger this (Clang only). + # * -Xclang=-fno-pch-timestamp to allow ccache to use pch + # (https://ccache.dev/manual/latest.html#_precompiled_headers). cxx_flags_by_compiler_frontend( - GNU -Wno-conversion -Wno-comment -Wno-self-assign-overloaded + GNU -Wno-conversion -Wno-comment -Wno-self-assign-overloaded -Xclang=-fno-pch-timestamp + MSVC -Xclang=-fno-pch-timestamp OUTPUT PRIVATE_OPTIONS FILTER) target_compile_options(${PYTHON_LIB_NAME} PRIVATE ${PRIVATE_OPTIONS}) diff --git a/development/scripts/pixi/activation.bat b/development/scripts/pixi/activation.bat index 0ad80ba3c6..b932553c61 100644 --- a/development/scripts/pixi/activation.bat +++ b/development/scripts/pixi/activation.bat @@ -7,6 +7,9 @@ set CMAKE_EXPORT_COMPILE_COMMANDS=1 :: Activate color output with Ninja set CMAKE_COLOR_DIAGNOSTICS=1 +:: Help ccache manage generated files and PCH (https://ccache.dev/manual/latest.html#_precompiled_headers) +set CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,pch_defines,time_macros + # Set default build value only if not previously set if not defined PINOCCHIO_BUILD_TYPE (set PINOCCHIO_BUILD_TYPE=Release) if not defined PINOCCHIO_PYTHON_STUBS (set PINOCCHIO_PYTHON_STUBS=ON) diff --git a/development/scripts/pixi/activation.sh b/development/scripts/pixi/activation.sh index 186724bd7c..cf2e2461bf 100644 --- a/development/scripts/pixi/activation.sh +++ b/development/scripts/pixi/activation.sh @@ -20,6 +20,10 @@ then # On GNU/Linux, I don't know if these flags are mandatory with g++ but # it allow to use clang++ as compiler export LDFLAGS="-Wl,-rpath,$CONDA_PREFIX/lib -Wl,-rpath-link,$CONDA_PREFIX/lib -L$CONDA_PREFIX/lib" + + # Conda compiler is named x86_64-conda-linux-gnu-c++, ccache can't resolve it + # (https://ccache.dev/manual/latest.html#config_compiler_type) + export CCACHE_COMPILERTYPE=gcc fi # Setup ccache @@ -31,6 +35,9 @@ export CMAKE_EXPORT_COMPILE_COMMANDS=1 # Activate color output with Ninja export CMAKE_COLOR_DIAGNOSTICS=1 +# Help ccache manage generated files and PCH (https://ccache.dev/manual/latest.html#_precompiled_headers) +export CCACHE_SLOPPINESS=include_file_ctime,include_file_mtime,pch_defines,time_macros + # Set default build value only if not previously set export PINOCCHIO_BUILD_TYPE=${PINOCCHIO_BUILD_TYPE:=Release} export PINOCCHIO_PYTHON_STUBS=${PINOCCHIO_PYTHON_STUBS:=ON} diff --git a/development/scripts/pixi/activation_clang.sh b/development/scripts/pixi/activation_clang.sh index 10f91fe3c1..d7422d1915 100644 --- a/development/scripts/pixi/activation_clang.sh +++ b/development/scripts/pixi/activation_clang.sh @@ -3,3 +3,6 @@ export CC=clang export CXX=clang++ + +# activation.sh set this variable to gcc, we must override it here +export CCACHE_COMPILERTYPE=clang