summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-12-06 20:24:43 +0800
committerGitHub <noreply@github.com>2024-12-06 13:24:43 +0100
commit27b7ac0e8ae02a41f748cccd76d617bb3b9d9734 (patch)
tree87f1bfc28463e81e89f87dbdee1c1f4b7fa94e2a
parent8ce7c6f6958f9f5ed750ef1a823b9e9ed8c042d8 (diff)
Emit debug info for Release builds (#5783)
* Remove unnecessary warnings on windows * Correctly set debug flags on gcc * Emit debug info for Release builds * Perform LTO for relwithdebinfo builds * Release from release builds not relwithdebinfo
-rw-r--r--.github/workflows/release-linux-glibc-2-17.yml12
-rw-r--r--.github/workflows/release.yml2
-rw-r--r--CMakeLists.txt6
-rw-r--r--cmake/SlangTarget.cmake86
-rw-r--r--docs/building.md1
5 files changed, 36 insertions, 71 deletions
diff --git a/.github/workflows/release-linux-glibc-2-17.yml b/.github/workflows/release-linux-glibc-2-17.yml
index 29f6c9bf5..4c9485d1e 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 1d435bed8..36e30bec0 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 436f8e69d..b6f68b427 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -186,6 +186,12 @@ enum_option(
)
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"
ON
diff --git a/cmake/SlangTarget.cmake b/cmake/SlangTarget.cmake
index 59d12ab7a..45e7cf1e1 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
+ "$<$<CONFIG:${debug_configs}>:Embedded>"
+ )
+ if(MSVC)
+ target_link_options(
+ ${target}
+ PRIVATE "$<$<CONFIG:${debug_configs}>:/DEBUG>"
+ )
+ else()
+ target_compile_options(
${target}
- PROPERTIES
- COMPILE_OPTIONS
- "$<$<CONFIG:Debug,RelWithDebInfo>:-fdebug-prefix-map=${CMAKE_CURRENT_BINARY_DIR}=${output_dir}>"
+ PRIVATE "$<$<CONFIG:${debug_configs}>:-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
- # "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>"
COMPILE_PDB_NAME "${target}"
COMPILE_PDB_OUTPUT_DIRECTORY "${output_dir}"
)
else()
- # Common debug flags for GCC/Clang
- target_compile_options(
- ${target}
- PRIVATE
- $<$<CONFIG:Debug,RelWithDebInfo>:
- -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 cc7ac6eda..f3b7e9d29 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 |