Skip to content

Commit 27b7ac0

Browse files
authored
Emit debug info for Release builds (shader-slang#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
1 parent 8ce7c6f commit 27b7ac0

File tree

5 files changed

+36
-71
lines changed

5 files changed

+36
-71
lines changed

.github/workflows/release-linux-glibc-2-17.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ jobs:
2727
cd /home/app
2828
git config --global --add safe.directory /home/app
2929
cmake --preset default --fresh -DSLANG_SLANG_LLVM_FLAVOR=DISABLE
30-
cmake --build --preset releaseWithDebugInfo
31-
cpack --preset releaseWithDebugInfo -G ZIP
32-
cpack --preset releaseWithDebugInfo -G TGZ
30+
cmake --build --preset release
31+
cpack --preset release -G ZIP
32+
cpack --preset release -G TGZ
3333
3434
- name: Package Slang
3535
id: package
@@ -38,15 +38,15 @@ jobs:
3838
version=${triggering_ref#v}
3939
base=$(pwd)/slang-${version}-linux-x86_64-glibc-2.17
4040
41-
sudo mv "$(pwd)/build/dist-releaseWithDebugInfo/slang.zip" "${base}.zip"
41+
sudo mv "$(pwd)/build/dist-release/slang.zip" "${base}.zip"
4242
echo "SLANG_BINARY_ARCHIVE_ZIP=${base}.zip" >> "$GITHUB_OUTPUT"
4343
44-
sudo mv "$(pwd)/build/dist-releaseWithDebugInfo/slang.tar.gz" "${base}.tar.gz"
44+
sudo mv "$(pwd)/build/dist-release/slang.tar.gz" "${base}.tar.gz"
4545
echo "SLANG_BINARY_ARCHIVE_TAR=${base}.tar.gz" >> "$GITHUB_OUTPUT"
4646
4747
- name: File check
4848
run: |
49-
find "build/dist-releaseWithDebugInfo" -print0 ! -iname '*.md' ! -iname '*.h' -type f | xargs -0 file
49+
find "build/dist-release" -print0 ! -iname '*.md' ! -iname '*.h' -type f | xargs -0 file
5050
5151
- name: UploadBinary
5252
uses: softprops/action-gh-release@v1

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
matrix:
2222
os: [linux, macos, windows]
23-
config: [releaseWithDebugInfo]
23+
config: [release]
2424
platform: [x86_64, aarch64]
2525
test-category: [smoke]
2626
include:

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ enum_option(
185185
"Build slang as a static library"
186186
)
187187

188+
option(
189+
SLANG_ENABLE_RELEASE_DEBUG_INFO
190+
"Generate debug info for Release builds"
191+
ON
192+
)
193+
188194
option(
189195
SLANG_ENABLE_SPLIT_DEBUG_INFO
190196
"Generate split debug info for debug builds"

cmake/SlangTarget.cmake

+22-64
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ function(slang_add_target dir type)
168168
# See: https://cmake.org/cmake/help/latest/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.html
169169
set_target_properties(
170170
${target}
171-
PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
171+
PROPERTIES
172+
INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
173+
INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE
172174
)
173175

174176
#
@@ -200,12 +202,26 @@ function(slang_add_target dir type)
200202
PDB_OUTPUT_DIRECTORY "${output_dir}/${runtime_subdir}"
201203
)
202204

203-
if(NOT MSVC)
204-
set_target_properties(
205+
set(debug_configs "Debug,RelWithDebInfo")
206+
if(SLANG_ENABLE_RELEASE_DEBUG_INFO)
207+
set(debug_configs "Debug,RelWithDebInfo,Release")
208+
endif()
209+
210+
set_target_properties(
211+
${target}
212+
PROPERTIES
213+
MSVC_DEBUG_INFORMATION_FORMAT
214+
"$<$<CONFIG:${debug_configs}>:Embedded>"
215+
)
216+
if(MSVC)
217+
target_link_options(
218+
${target}
219+
PRIVATE "$<$<CONFIG:${debug_configs}>:/DEBUG>"
220+
)
221+
else()
222+
target_compile_options(
205223
${target}
206-
PROPERTIES
207-
COMPILE_OPTIONS
208-
"$<$<CONFIG:Debug,RelWithDebInfo>:-fdebug-prefix-map=${CMAKE_CURRENT_BINARY_DIR}=${output_dir}>"
224+
PRIVATE "$<$<CONFIG:${debug_configs}>:-g>"
209225
)
210226
endif()
211227

@@ -234,70 +250,13 @@ function(slang_add_target dir type)
234250

235251
if(generate_split_debug_info)
236252
if(MSVC)
237-
get_target_property(
238-
c_compiler_launcher
239-
${target}
240-
C_COMPILER_LAUNCHER
241-
)
242-
get_target_property(
243-
cxx_compiler_launcher
244-
${target}
245-
CXX_COMPILER_LAUNCHER
246-
)
247-
248-
if(
249-
c_compiler_launcher MATCHES "ccache"
250-
OR cxx_compiler_launcher MATCHES "ccache"
251-
)
252-
message(
253-
WARNING
254-
"(s)ccache detected for target ${target}. Removing launcher as it's incompatible with split debug info compiled with MSVC."
255-
)
256-
set_target_properties(
257-
${target}
258-
PROPERTIES C_COMPILER_LAUNCHER "" CXX_COMPILER_LAUNCHER ""
259-
)
260-
endif()
261-
262-
get_target_property(
263-
msvc_debug_information_format
264-
${target}
265-
MSVC_DEBUG_INFORMATION_FORMAT
266-
)
267-
if(
268-
NOT msvc_debug_information_format
269-
MATCHES
270-
"(ProgramDatabase|EditAndContinue)"
271-
)
272-
message(
273-
WARNING
274-
"Debug format must be ProgramDatabase or EditAndContinue to generate split debug info with MSVC"
275-
)
276-
endif()
277-
278253
set_target_properties(
279254
${target}
280255
PROPERTIES
281-
# While it would be nice to set this here, we don't know if
282-
# the user wants ProgramDatabase or EditAndContinue, so
283-
# just check above
284-
# MSVC_DEBUG_INFORMATION_FORMAT
285-
# "$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>"
286256
COMPILE_PDB_NAME "${target}"
287257
COMPILE_PDB_OUTPUT_DIRECTORY "${output_dir}"
288258
)
289259
else()
290-
# Common debug flags for GCC/Clang
291-
target_compile_options(
292-
${target}
293-
PRIVATE
294-
$<$<CONFIG:Debug,RelWithDebInfo>:
295-
-g
296-
-fdebug-prefix-map=${CMAKE_SOURCE_DIR}=.
297-
-fdebug-prefix-map=${CMAKE_BINARY_DIR}=.
298-
>
299-
)
300-
301260
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
302261
# macOS - use dsymutil with --flat to create separate debug file
303262
add_custom_command(
@@ -582,7 +541,6 @@ function(slang_add_target dir type)
582541
install(
583542
FILES ${debug_file}
584543
DESTINATION ${debug_dest}
585-
CONFIGURATIONS Debug RelWithDebInfo
586544
COMPONENT ${debug_component}
587545
EXCLUDE_FROM_ALL
588546
OPTIONAL

docs/building.md

+1
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ See the [documentation on testing](../tools/slang-test/README.md) for more infor
163163
| `SLANG_ENABLE_TESTS` | `TRUE` | Enable test targets, requires SLANG_ENABLE_GFX, SLANG_ENABLE_SLANGD and SLANG_ENABLE_SLANGRT |
164164
| `SLANG_ENABLE_EXAMPLES` | `TRUE` | Enable example targets, requires SLANG_ENABLE_GFX |
165165
| `SLANG_LIB_TYPE` | `SHARED` | How to build the slang library |
166+
| `SLANG_ENABLE_RELEASE_DEBUG_INFO` | `TRUE` | Enable generating debug info for Release configs |
166167
| `SLANG_ENABLE_SPLIT_DEBUG_INFO` | `TRUE` | Enable generating split debug info for Debug and RelWithDebInfo configs |
167168
| `SLANG_SLANG_LLVM_FLAVOR` | `FETCH_BINARY_IF_POSSIBLE` | How to set up llvm support |
168169
| `SLANG_SLANG_LLVM_BINARY_URL` | System dependent | URL specifying the location of the slang-llvm prebuilt library |

0 commit comments

Comments
 (0)