refactor: use clear stdlib naming instead of force_libstdcpp

- Rename force_libstdcpp to stdlib with values libstdcxx/libcxx
- Make stdlib a required enum field with validation
- Update cache keys to be self-documenting (e.g. clang-14-libstdcxx)
- Cleaner, more intuitive configuration flow
This commit is contained in:
Nicholas Dudfield
2025-08-18 18:21:42 +07:00
parent 5286bae753
commit 0651332bb3
3 changed files with 31 additions and 25 deletions

View File

@@ -36,10 +36,13 @@ inputs:
description: 'Main branch name for restore keys' description: 'Main branch name for restore keys'
required: false required: false
default: 'dev' default: 'dev'
clang_use_libstdcpp: stdlib:
description: 'Force clang to use libstdc++ instead of libc++ (workaround for clang-16)' description: 'C++ standard library to use'
required: false required: true
default: 'false' type: choice
options:
- libstdcxx
- libcxx
runs: runs:
using: 'composite' using: 'composite'
@@ -85,12 +88,14 @@ runs:
CCACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" CCACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
fi fi
# Configure libstdc++ override for clang if requested # Configure C++ standard library if specified
# This works around clang-16 missing lexicographical_compare_three_way in libc++ # libstdcxx used for clang-14/16 to work around missing lexicographical_compare_three_way in libc++
# which is only available in LLVM 17+. Can be removed when upgrading to clang-17+ # libcxx can be used with clang-17+ which has full C++20 support
STDLIB_ARGS="" STDLIB_ARGS=""
if [ "${{ inputs.clang_use_libstdcpp }}" = "true" ] && [[ "${{ inputs.cxx }}" == *"clang"* ]]; then if [ "${{ inputs.stdlib }}" = "libstdcxx" ]; then
STDLIB_ARGS="-DCMAKE_CXX_FLAGS=-stdlib=libstdc++" STDLIB_ARGS="-DCMAKE_CXX_FLAGS=-stdlib=libstdc++"
elif [ "${{ inputs.stdlib }}" = "libcxx" ]; then
STDLIB_ARGS="-DCMAKE_CXX_FLAGS=-stdlib=libc++"
fi fi
# Run CMake configure # Run CMake configure

View File

@@ -25,10 +25,13 @@ inputs:
description: 'Main branch name for restore keys' description: 'Main branch name for restore keys'
required: false required: false
default: 'dev' default: 'dev'
stdlib_choice: stdlib:
description: 'Standard library choice (affects cache key for different stdlib builds)' description: 'C++ standard library - affects cache key'
required: false required: true
default: 'default' type: choice
options:
- libstdcxx
- libcxx
outputs: outputs:
cache-hit: cache-hit:
@@ -54,10 +57,10 @@ runs:
path: | path: |
~/.conan ~/.conan
~/.conan2 ~/.conan2
key: ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.stdlib_choice }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-${{ inputs.configuration }} key: ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.stdlib }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-${{ inputs.configuration }}
restore-keys: | restore-keys: |
${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.stdlib_choice }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}- ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.stdlib }}-${{ hashFiles('**/conanfile.txt', '**/conanfile.py') }}-
${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.stdlib_choice }}- ${{ runner.os }}-conan-v${{ inputs.cache_version }}-${{ inputs.compiler-id }}-${{ inputs.stdlib }}-
- name: Export custom recipes - name: Export custom recipes
shell: bash shell: bash

View File

@@ -27,19 +27,19 @@ jobs:
# cxx: g++-13 # cxx: g++-13
# compiler_id: gcc-13 # compiler_id: gcc-13
# compiler_version: 13 # compiler_version: 13
# force_libstdcpp: false # stdlib: libstdcxx
- compiler: clang - compiler: clang
cc: clang-14 cc: clang-14
cxx: clang++-14 cxx: clang++-14
compiler_id: clang-14 compiler_id: clang-14
compiler_version: 14 compiler_version: 14
force_libstdcpp: true # Required for clang-14 compatibility stdlib: libstdcxx # Required for clang-14 compatibility
- compiler: clang - compiler: clang
cc: clang-16 cc: clang-16
cxx: clang++-16 cxx: clang++-16
compiler_id: clang-16 compiler_id: clang-16
compiler_version: 16 compiler_version: 16
force_libstdcpp: true # Workaround for missing lexicographical_compare_three_way in libc++ stdlib: libstdcxx # Workaround for missing lexicographical_compare_three_way in libc++
env: env:
build_dir: .build build_dir: .build
# Bump this number to invalidate all caches globally. # Bump this number to invalidate all caches globally.
@@ -72,13 +72,11 @@ jobs:
conan profile new default --detect || true # Ignore error if profile exists conan profile new default --detect || true # Ignore error if profile exists
conan profile update settings.compiler.cppstd=20 default conan profile update settings.compiler.cppstd=20 default
conan profile update settings.compiler=${{ matrix.compiler }} default conan profile update settings.compiler=${{ matrix.compiler }} default
# Use libstdc++11 for clang when force_libstdcpp is enabled, otherwise use libc++ # Set the C++ standard library based on matrix configuration
if [ "${{ matrix.compiler }}" = "clang" ] && [ "${{ matrix.force_libstdcpp }}" = "true" ]; then if [ "${{ matrix.stdlib }}" = "libstdcxx" ]; then
conan profile update settings.compiler.libcxx=libstdc++11 default conan profile update settings.compiler.libcxx=libstdc++11 default
elif [ "${{ matrix.compiler }}" = "clang" ]; then elif [ "${{ matrix.stdlib }}" = "libcxx" ]; then
conan profile update settings.compiler.libcxx=libc++ default conan profile update settings.compiler.libcxx=libc++ default
else
conan profile update settings.compiler.libcxx=libstdc++11 default
fi fi
conan profile update env.CC=/usr/bin/${{ matrix.cc }} default conan profile update env.CC=/usr/bin/${{ matrix.cc }} default
conan profile update env.CXX=/usr/bin/${{ matrix.cxx }} default conan profile update env.CXX=/usr/bin/${{ matrix.cxx }} default
@@ -109,7 +107,7 @@ jobs:
compiler-id: ${{ matrix.compiler_id }} compiler-id: ${{ matrix.compiler_id }}
cache_version: ${{ env.CACHE_VERSION }} cache_version: ${{ env.CACHE_VERSION }}
main_branch: ${{ env.MAIN_BRANCH_NAME }} main_branch: ${{ env.MAIN_BRANCH_NAME }}
stdlib_choice: ${{ matrix.force_libstdcpp }} stdlib: ${{ matrix.stdlib }}
- name: Build - name: Build
uses: ./.github/actions/xahau-ga-build uses: ./.github/actions/xahau-ga-build
@@ -122,7 +120,7 @@ jobs:
compiler-id: ${{ matrix.compiler_id }} compiler-id: ${{ matrix.compiler_id }}
cache_version: ${{ env.CACHE_VERSION }} cache_version: ${{ env.CACHE_VERSION }}
main_branch: ${{ env.MAIN_BRANCH_NAME }} main_branch: ${{ env.MAIN_BRANCH_NAME }}
clang_use_libstdcpp: ${{ matrix.force_libstdcpp }} stdlib: ${{ matrix.stdlib }}
- name: Set artifact name - name: Set artifact name
id: set-artifact-name id: set-artifact-name