From 44dc5ea202ac43cd4f18c268e95143c2a23f5d26 Mon Sep 17 00:00:00 2001 From: Ellie Hermaszewska Date: Wed, 30 Oct 2024 10:15:14 +0800 Subject: Put debug symbols in releases (#5370) --- .github/actions/common-setup/action.yml | 12 ++++++--- .github/workflows/ci.yml | 22 ++++++++-------- .github/workflows/release-linux-glibc-2-17.yml | 12 ++++----- .github/workflows/release.yml | 12 ++++----- CMakePresets.json | 35 ++++++++++++++++++++++++-- cmake/CCacheDebugInfoWorkaround.cmake | 2 +- docs/building.md | 4 +-- 7 files changed, 68 insertions(+), 31 deletions(-) diff --git a/.github/actions/common-setup/action.yml b/.github/actions/common-setup/action.yml index a2e2edd94..a270b32e0 100644 --- a/.github/actions/common-setup/action.yml +++ b/.github/actions/common-setup/action.yml @@ -66,10 +66,16 @@ runs: # Some useful variables config=${{inputs.config}} - Config=$(echo "${{inputs.config}}" | sed 's/debug/Debug/;s/release/Release/') - bin_dir=$(pwd)/build/$Config/bin - lib_dir=$(pwd)/build/$Config/lib + cmake_config=$(echo "${{inputs.config}}" | sed ' + s/^debug$/Debug/ + s/^release$/Release/ + s/^releaseWithDebugInfo$/RelWithDebInfo/ + s/^minSizeRelease$/MinSizeRel/ + ') + bin_dir=$(pwd)/build/$cmake_config/bin + lib_dir=$(pwd)/build/$cmake_config/lib echo "config=$config" >> "$GITHUB_ENV" + echo "cmake_config=$cmake_config" >> "$GITHUB_ENV" echo "bin_dir=$bin_dir" >> "$GITHUB_ENV" echo "lib_dir=$lib_dir" >> "$GITHUB_ENV" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c32db8c6..6f0aa2d93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: [linux, macos, windows] - config: [debug, release] + config: [debug, releaseWithDebugInfo] compiler: [gcc, clang, cl] platform: [x86_64, aarch64, wasm] exclude: @@ -54,14 +54,14 @@ jobs: # quick or full conditionally otherwise - test-category: smoke - { os: windows, test-category: quick } - - { config: release, test-category: full } + - { config: releaseWithDebugInfo, test-category: full } # default not full gpu tests - full-gpu-tests: false # The runners don't have a GPU by default except for the self-hosted ones - has-gpu: false # Self-hosted aarch64 build - os: linux - config: release + config: releaseWithDebugInfo compiler: gcc platform: aarch64 test-category: smoke @@ -70,7 +70,7 @@ jobs: has-gpu: true # Self-hosted full gpu build - os: windows - config: release + config: releaseWithDebugInfo compiler: cl platform: x86_64 test-category: full @@ -109,13 +109,13 @@ jobs: cmake --workflow --preset generators --fresh mkdir generators cmake --install build --prefix generators --component generators - emcmake cmake -DSLANG_GENERATORS_PATH=generators/bin --preset emscripten -G "Ninja" -DSLANG_SLANG_LLVM_FLAVOR=DISABLE - cmake --build --preset emscripten --target slang - [ -f "build.em/Release/lib/libslang.a" ] - [ -f "build.em/Release/lib/libcompiler-core.a" ] - [ -f "build.em/Release/lib/libcore.a" ] + emcmake cmake -DSLANG_GENERATORS_PATH=generators/bin --preset emscripten -DSLANG_SLANG_LLVM_FLAVOR=DISABLE + cmake --build --preset emscripten --config "$cmake_config" --target slang + [ -f "build.em/$cmake_config/lib/libslang.a" ] + [ -f "build.em/$cmake_config/lib/libcompiler-core.a" ] + [ -f "build.em/$cmake_config/lib/libcore.a" ] else - if [[ "${{ matrix.os }}" =~ "windows" && "${{ matrix.config }}" != "release" ]]; then + if [[ "${{ matrix.os }}" =~ "windows" && "${{ matrix.config }}" != "release" && "${{ matrix.config }}" != "releaseWithDebugInfo" ]]; then # Doing a debug build will try to link against a release built llvm, this # is a problem on Windows, so make slang-llvm in release build and use # that as though it's a fetched binary via these presets. @@ -127,7 +127,7 @@ jobs: "-DCMAKE_COMPILE_WARNING_AS_ERROR=${{matrix.warnings-as-errors}}" cmake --workflow --preset "${{matrix.config}}" else - # Otherwise, use the system llvm we have just build or got from the + # Otherwise, use the "system" llvm we have just build or got from the # cache in the setup phase cmake --preset default --fresh \ -DSLANG_SLANG_LLVM_FLAVOR=USE_SYSTEM_LLVM \ diff --git a/.github/workflows/release-linux-glibc-2-17.yml b/.github/workflows/release-linux-glibc-2-17.yml index d147f38e1..e3f47d9a9 100644 --- a/.github/workflows/release-linux-glibc-2-17.yml +++ b/.github/workflows/release-linux-glibc-2-17.yml @@ -27,9 +27,9 @@ jobs: cd /home/app git config --global --add safe.directory /home/app cmake --preset default --fresh -DSLANG_SLANG_LLVM_FLAVOR=DISABLE -DSLANG_EMBED_STDLIB=1 - cmake --build --preset release - cpack --preset release -G ZIP - cpack --preset release -G TGZ + cmake --build --preset releaseWithDebugInfo + cpack --preset releaseWithDebugInfo -G ZIP + cpack --preset releaseWithDebugInfo -G TGZ - name: Package Slang id: package @@ -38,15 +38,15 @@ jobs: version=${triggering_ref#v} base=$(pwd)/slang-${version}-linux-x86_64-glibc-2.17 - sudo mv "$(pwd)/build/dist-release/slang.zip" "${base}.zip" + sudo mv "$(pwd)/build/dist-releaseWithDebugInfo/slang.zip" "${base}.zip" echo "SLANG_BINARY_ARCHIVE_ZIP=${base}.zip" >> "$GITHUB_OUTPUT" - sudo mv "$(pwd)/build/dist-release/slang.tar.gz" "${base}.tar.gz" + sudo mv "$(pwd)/build/dist-releaseWithDebugInfo/slang.tar.gz" "${base}.tar.gz" echo "SLANG_BINARY_ARCHIVE_TAR=${base}.tar.gz" >> "$GITHUB_OUTPUT" - name: File check run: | - find "build/dist-release" -print0 ! -iname '*.md' ! -iname '*.h' -type f | xargs -0 file + find "build/dist-releaseWithDebugInfo" -print0 ! -iname '*.md' ! -iname '*.h' -type f | xargs -0 file - name: UploadBinary uses: softprops/action-gh-release@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6681837b9..0f2375f44 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: os: [linux, macos, windows] - config: [release] + config: [releaseWithDebugInfo] platform: [x86_64, aarch64] test-category: [smoke] include: @@ -57,7 +57,7 @@ jobs: run: | cmake --workflow --preset generators --fresh mkdir build-platform-generators - cmake --install build --config Release --component generators --prefix build-platform-generators + cmake --install build --config $cmake_config --component generators --prefix build-platform-generators - name: Change dev tools to host arch (windows) uses: ilammy/msvc-dev-cmd@v1 @@ -80,8 +80,8 @@ jobs: - name: Build Slang run: | - if [[ "${{ matrix.os }}" == "windows" && "${{ matrix.config }}" != "release" ]]; then - echo "Please see ci.yml for the steps to make debug builds work on Windows" >&2 + if [[ "${{ matrix.os }}" == "windows" && "${{ matrix.config }}" != "release" && "${{ matrix.config }}" != "releaseWithDebugInfo" ]]; then + echo "Please see ci.yml for the steps to make non-release builds work on Windows" >&2 exit 1 fi @@ -169,8 +169,8 @@ jobs: mkdir ./ttmp unzip "${base}.zip" -d ./ttmp - /bin/cp -rf build/Release/bin/* ./ttmp/bin/ - /bin/cp -rf build/Release/lib/* ./ttmp/lib/ + /bin/cp -rf build/$cmake_config/bin/* ./ttmp/bin/ + /bin/cp -rf build/$cmake_config/lib/* ./ttmp/lib/ rm ${base}.zip rm ${base}.tar.gz cd ./ttmp diff --git a/CMakePresets.json b/CMakePresets.json index 47a733ee2..0e53295e7 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -18,7 +18,7 @@ { "name": "emscripten", "description": "Emscripten-based Wasm build", - "generator": "ninja", + "generator": "Ninja Multi-Config", "binaryDir": "${sourceDir}/build.em", "cacheVariables": { "SLANG_SLANG_LLVM_FLAVOR": "DISABLE", @@ -34,7 +34,8 @@ "description": "Options specific for MSVC", "cacheVariables": { "CMAKE_C_FLAGS_INIT": "-D_ITERATOR_DEBUG_LEVEL=0 /MP", - "CMAKE_CXX_FLAGS_INIT": "-D_ITERATOR_DEBUG_LEVEL=0 /MP" + "CMAKE_CXX_FLAGS_INIT": "-D_ITERATOR_DEBUG_LEVEL=0 /MP", + "CMAKE_DEFAULT_BUILD_TYPE": "RelWithDebInfo" } }, { @@ -86,6 +87,11 @@ "configurePreset": "default", "configuration": "Release" }, + { + "name": "releaseWithDebugInfo", + "configurePreset": "default", + "configuration": "RelWithDebInfo" + }, { "name": "emscripten", "configurePreset": "emscripten", @@ -132,6 +138,14 @@ ], "packageDirectory": "dist-release" }, + { + "name": "releaseWithDebugInfo", + "inherits": "base", + "configurations": [ + "RelWithDebInfo" + ], + "packageDirectory": "dist-releaseWithDebugInfo" + }, { "name": "debug", "inherits": "base", @@ -194,6 +208,23 @@ } ] }, + { + "name": "releaseWithDebugInfo", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "releaseWithDebugInfo" + }, + { + "type": "package", + "name": "releaseWithDebugInfo" + } + ] + }, { "name": "generators", "steps": [ diff --git a/cmake/CCacheDebugInfoWorkaround.cmake b/cmake/CCacheDebugInfoWorkaround.cmake index 82fb299e3..743b9b8ea 100644 --- a/cmake/CCacheDebugInfoWorkaround.cmake +++ b/cmake/CCacheDebugInfoWorkaround.cmake @@ -10,7 +10,7 @@ if( ) message( NOTICE - "Setting embedded debug info for MSVC to work around (s)ccache's inability to cache shared debug info files, Note that this requires CMake 3.25 or greater" + "Setting embedded debug info for MSVC to work around (s)ccache's inability to cache shared debug info files" ) cmake_minimum_required(VERSION 3.25) cmake_policy(GET CMP0141 cmp0141) diff --git a/docs/building.md b/docs/building.md index a6bbd080d..d74a65ac8 100644 --- a/docs/building.md +++ b/docs/building.md @@ -42,14 +42,14 @@ git clone https://github.com/shader-slang/slang --recursive For a Ninja based build system (all platforms) run: ```bash cmake --preset default -cmake --build --preset release # or --preset debug +cmake --build --preset releaseWithDebugInfo # or --preset debug, or --preset release ``` For Visual Studio run: ```bash cmake --preset vs2022 # or 'vs2019' or `vs2022-dev` start devenv ./build/slang.sln # to optionally open the project in Visual Studio -cmake --build --preset release # to build from the CLI +cmake --build --preset releaseWithDebugInfo # to build from the CLI, could also use --preset release or --preset debug ``` There also exists a `vs2022-dev` preset which turns on features to aid -- cgit v1.2.3