Skip to content

Commit 7ccbc75

Browse files
committed
Use -gline-tables-only from CMAKE_CXX_FLAGS_... too
1 parent 6612d8c commit 7ccbc75

File tree

4 files changed

+9
-25
lines changed

4 files changed

+9
-25
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,14 @@ if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQU
629629
set(SWIFT_COMPILER_IS_MSVC_LIKE TRUE)
630630
endif()
631631

632+
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
633+
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
634+
if(_lto_flag_out)
635+
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_RELEASE} -gline-tables-only")
636+
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -gline-tables-only")
637+
endif()
638+
endif()
639+
632640
#
633641
# Configure SDKs.
634642
#

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function(_add_host_variant_c_compile_flags target)
132132
is_build_type_optimized("${CMAKE_BUILD_TYPE}" optimized)
133133
is_build_type_with_debuginfo("${CMAKE_BUILD_TYPE}" debuginfo)
134134

135-
# Add -O0/-O2/-O3/-Os based on CMAKE_BUILD_TYPE.
135+
# Add -O0/-O2/-O3/-Os/-g/-momit-leaf-frame-pointer/... based on CMAKE_BUILD_TYPE.
136136
target_compile_options(${target} PRIVATE "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
137137

138138
if(optimized)
@@ -149,16 +149,6 @@ function(_add_host_variant_c_compile_flags target)
149149
endif()
150150
endif()
151151

152-
# CMake automatically adds the flags for debug info if we use MSVC/clang-cl.
153-
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
154-
if(debuginfo)
155-
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)
156-
if(_lto_flag_out)
157-
target_compile_options(${target} PRIVATE -gline-tables-only)
158-
endif()
159-
endif()
160-
endif()
161-
162152
if(SWIFT_HOST_VARIANT_SDK STREQUAL WINDOWS)
163153
# MSVC/clang-cl don't support -fno-pic or -fms-compatibility-version.
164154
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,6 @@ function(_add_target_variant_c_compile_flags)
204204
endif()
205205
endif()
206206

207-
# CMake automatically adds the flags for debug info if we use MSVC/clang-cl.
208-
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)
209-
if(debuginfo)
210-
_compute_lto_flag("${CFLAGS_ENABLE_LTO}" _lto_flag_out)
211-
if(_lto_flag_out)
212-
list(APPEND result "-gline-tables-only")
213-
endif()
214-
endif()
215-
endif()
216-
217207
if("${CFLAGS_SDK}" STREQUAL "WINDOWS")
218208
# MSVC/clang-cl don't support -fno-pic or -fms-compatibility-version.
219209
if(NOT SWIFT_COMPILER_IS_MSVC_LIKE)

utils/build-script-impl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,8 +1574,6 @@ for host in "${ALL_HOSTS[@]}"; do
15741574
"${cmake_options[@]}"
15751575
-DCMAKE_C_FLAGS="$(llvm_c_flags ${host})"
15761576
-DCMAKE_CXX_FLAGS="$(llvm_c_flags ${host})"
1577-
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
1578-
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG"
15791577
-DCMAKE_BUILD_TYPE:STRING="${LLVM_BUILD_TYPE}"
15801578
-DLLVM_TOOL_SWIFT_BUILD:BOOL=NO
15811579
-DLLVM_TOOL_LLD_BUILD:BOOL=TRUE
@@ -1754,8 +1752,6 @@ for host in "${ALL_HOSTS[@]}"; do
17541752
"${cmake_options[@]}"
17551753
-DCMAKE_C_FLAGS="$(swift_c_flags ${host})"
17561754
-DCMAKE_CXX_FLAGS="$(swift_c_flags ${host})"
1757-
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-O2 -DNDEBUG"
1758-
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-O2 -g -DNDEBUG"
17591755
-DCMAKE_BUILD_TYPE:STRING="${SWIFT_BUILD_TYPE}"
17601756
-DLLVM_ENABLE_ASSERTIONS:BOOL=$(true_false "${SWIFT_ENABLE_ASSERTIONS}")
17611757
-DSWIFT_ANALYZE_CODE_COVERAGE:STRING=$(toupper "${SWIFT_ANALYZE_CODE_COVERAGE}")

0 commit comments

Comments
 (0)