diff --git a/.github/workflows/release-linux-glibc-2-17.yml b/.github/workflows/release-linux-glibc-2-17.yml index 29f6c9bf50..4c9485d1e4 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 - cmake --build --preset releaseWithDebugInfo - cpack --preset releaseWithDebugInfo -G ZIP - cpack --preset releaseWithDebugInfo -G TGZ + cmake --build --preset release + cpack --preset release -G ZIP + cpack --preset release -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-releaseWithDebugInfo/slang.zip" "${base}.zip" + sudo mv "$(pwd)/build/dist-release/slang.zip" "${base}.zip" echo "SLANG_BINARY_ARCHIVE_ZIP=${base}.zip" >> "$GITHUB_OUTPUT" - sudo mv "$(pwd)/build/dist-releaseWithDebugInfo/slang.tar.gz" "${base}.tar.gz" + sudo mv "$(pwd)/build/dist-release/slang.tar.gz" "${base}.tar.gz" echo "SLANG_BINARY_ARCHIVE_TAR=${base}.tar.gz" >> "$GITHUB_OUTPUT" - name: File check run: | - find "build/dist-releaseWithDebugInfo" -print0 ! -iname '*.md' ! -iname '*.h' -type f | xargs -0 file + find "build/dist-release" -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 1d435bed86..36e30bec03 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: strategy: matrix: os: [linux, macos, windows] - config: [releaseWithDebugInfo] + config: [release] platform: [x86_64, aarch64] test-category: [smoke] include: diff --git a/CMakeLists.txt b/CMakeLists.txt index 436f8e69d5..b6f68b4271 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,6 +185,12 @@ enum_option( "Build slang as a static library" ) +option( + SLANG_ENABLE_RELEASE_DEBUG_INFO + "Generate debug info for Release builds" + ON +) + option( SLANG_ENABLE_SPLIT_DEBUG_INFO "Generate split debug info for debug builds" diff --git a/cmake/SlangTarget.cmake b/cmake/SlangTarget.cmake index 59d12ab7a0..45e7cf1e1d 100644 --- a/cmake/SlangTarget.cmake +++ b/cmake/SlangTarget.cmake @@ -168,7 +168,9 @@ function(slang_add_target dir type) # See: https://cmake.org/cmake/help/latest/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.html set_target_properties( ${target} - PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE + PROPERTIES + INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE + INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE ) # @@ -200,12 +202,26 @@ function(slang_add_target dir type) PDB_OUTPUT_DIRECTORY "${output_dir}/${runtime_subdir}" ) - if(NOT MSVC) - set_target_properties( + set(debug_configs "Debug,RelWithDebInfo") + if(SLANG_ENABLE_RELEASE_DEBUG_INFO) + set(debug_configs "Debug,RelWithDebInfo,Release") + endif() + + set_target_properties( + ${target} + PROPERTIES + MSVC_DEBUG_INFORMATION_FORMAT + "$<$:Embedded>" + ) + if(MSVC) + target_link_options( + ${target} + PRIVATE "$<$:/DEBUG>" + ) + else() + target_compile_options( ${target} - PROPERTIES - COMPILE_OPTIONS - "$<$:-fdebug-prefix-map=${CMAKE_CURRENT_BINARY_DIR}=${output_dir}>" + PRIVATE "$<$:-g>" ) endif() @@ -234,70 +250,13 @@ function(slang_add_target dir type) if(generate_split_debug_info) if(MSVC) - get_target_property( - c_compiler_launcher - ${target} - C_COMPILER_LAUNCHER - ) - get_target_property( - cxx_compiler_launcher - ${target} - CXX_COMPILER_LAUNCHER - ) - - if( - c_compiler_launcher MATCHES "ccache" - OR cxx_compiler_launcher MATCHES "ccache" - ) - message( - WARNING - "(s)ccache detected for target ${target}. Removing launcher as it's incompatible with split debug info compiled with MSVC." - ) - set_target_properties( - ${target} - PROPERTIES C_COMPILER_LAUNCHER "" CXX_COMPILER_LAUNCHER "" - ) - endif() - - get_target_property( - msvc_debug_information_format - ${target} - MSVC_DEBUG_INFORMATION_FORMAT - ) - if( - NOT msvc_debug_information_format - MATCHES - "(ProgramDatabase|EditAndContinue)" - ) - message( - WARNING - "Debug format must be ProgramDatabase or EditAndContinue to generate split debug info with MSVC" - ) - endif() - set_target_properties( ${target} PROPERTIES - # While it would be nice to set this here, we don't know if - # the user wants ProgramDatabase or EditAndContinue, so - # just check above - # MSVC_DEBUG_INFORMATION_FORMAT - # "$<$:ProgramDatabase>" COMPILE_PDB_NAME "${target}" COMPILE_PDB_OUTPUT_DIRECTORY "${output_dir}" ) else() - # Common debug flags for GCC/Clang - target_compile_options( - ${target} - PRIVATE - $<$: - -g - -fdebug-prefix-map=${CMAKE_SOURCE_DIR}=. - -fdebug-prefix-map=${CMAKE_BINARY_DIR}=. - > - ) - if(CMAKE_SYSTEM_NAME MATCHES "Darwin") # macOS - use dsymutil with --flat to create separate debug file add_custom_command( @@ -582,7 +541,6 @@ function(slang_add_target dir type) install( FILES ${debug_file} DESTINATION ${debug_dest} - CONFIGURATIONS Debug RelWithDebInfo COMPONENT ${debug_component} EXCLUDE_FROM_ALL OPTIONAL diff --git a/docs/building.md b/docs/building.md index cc7ac6eda7..f3b7e9d292 100644 --- a/docs/building.md +++ b/docs/building.md @@ -163,6 +163,7 @@ See the [documentation on testing](../tools/slang-test/README.md) for more infor | `SLANG_ENABLE_TESTS` | `TRUE` | Enable test targets, requires SLANG_ENABLE_GFX, SLANG_ENABLE_SLANGD and SLANG_ENABLE_SLANGRT | | `SLANG_ENABLE_EXAMPLES` | `TRUE` | Enable example targets, requires SLANG_ENABLE_GFX | | `SLANG_LIB_TYPE` | `SHARED` | How to build the slang library | +| `SLANG_ENABLE_RELEASE_DEBUG_INFO` | `TRUE` | Enable generating debug info for Release configs | | `SLANG_ENABLE_SPLIT_DEBUG_INFO` | `TRUE` | Enable generating split debug info for Debug and RelWithDebInfo configs | | `SLANG_SLANG_LLVM_FLAVOR` | `FETCH_BINARY_IF_POSSIBLE` | How to set up llvm support | | `SLANG_SLANG_LLVM_BINARY_URL` | System dependent | URL specifying the location of the slang-llvm prebuilt library |