Skip to content

Commit f0a924e

Browse files
porting Clickhouse #48671, Remove GCC remainders
1 parent c2a26c6 commit f0a924e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+57
-381
lines changed

CMakeLists.txt

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if (ENABLE_CHECK_HEAVY_BUILDS)
5959
set (RLIMIT_CPU 1000)
6060

6161
# gcc10/gcc10/clang -fsanitize=memory is too heavy
62-
if (SANITIZE STREQUAL "memory" OR COMPILER_GCC)
62+
if (SANITIZE STREQUAL "memory")
6363
set (RLIMIT_DATA 30000000000) # 30G
6464
endif()
6565

@@ -290,35 +290,31 @@ set (CMAKE_C_STANDARD 11)
290290
set (CMAKE_C_EXTENSIONS ON)
291291
set (CMAKE_C_STANDARD_REQUIRED ON)
292292

293-
if (COMPILER_GCC OR COMPILER_CLANG)
293+
# Compiler-specific coverage flags e.g. -fcoverage-mapping for gcc
294+
option(WITH_COVERAGE "Profile the resulting binary/binaries" OFF)
295+
296+
if (COMPILER_CLANG)
294297
# Enable C++14 sized global deallocation functions. It should be enabled by setting -std=c++14 but I'm not sure.
295298
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsized-deallocation")
296-
endif ()
297299

298-
# falign-functions=32 prevents from random performance regressions with the code change. Thus, providing more stable
299-
# benchmarks.
300-
if (COMPILER_GCC OR COMPILER_CLANG)
300+
# falign-functions=32 prevents from random performance regressions with the code change. Thus, providing more stable
301+
# benchmarks.
301302
set(COMPILER_FLAGS "${COMPILER_FLAGS} -falign-functions=32")
302-
endif ()
303-
304-
if (COMPILER_GCC)
305-
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines")
306-
endif ()
307303

308-
# Compiler-specific coverage flags e.g. -fcoverage-mapping for gcc
309-
option(WITH_COVERAGE "Profile the resulting binary/binaries" OFF)
304+
if (ARCH_AMD64)
305+
# align branches within a 32-Byte boundary to avoid the potential performance loss when code layout change,
306+
# which makes benchmark results more stable.
307+
set(BRANCHES_WITHIN_32B_BOUNDARIES "-mbranches-within-32B-boundaries")
308+
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${BRANCHES_WITHIN_32B_BOUNDARIES}")
309+
endif()
310310

311-
if (WITH_COVERAGE AND COMPILER_CLANG)
312-
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
313-
# If we want to disable coverage for specific translation units
314-
set(WITHOUT_COVERAGE "-fno-profile-instr-generate -fno-coverage-mapping")
315-
endif()
311+
if (WITH_COVERAGE)
312+
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
313+
# If we want to disable coverage for specific translation units
314+
set(WITHOUT_COVERAGE "-fno-profile-instr-generate -fno-coverage-mapping")
315+
endif()
316316

317-
if (WITH_COVERAGE AND COMPILER_GCC)
318-
set(COMPILER_FLAGS "${COMPILER_FLAGS} -fprofile-arcs -ftest-coverage")
319-
set(COVERAGE_OPTION "-lgcov")
320-
set(WITHOUT_COVERAGE "-fno-profile-arcs -fno-test-coverage")
321-
endif()
317+
endif ()
322318

323319
set(COMPILER_FLAGS "${COMPILER_FLAGS}")
324320

cmake/darwin/default_libs.cmake

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@ set (DEFAULT_LIBS "-nodefaultlibs")
22

33
set (DEFAULT_LIBS "${DEFAULT_LIBS} ${COVERAGE_OPTION} -lc -lm -lpthread -ldl")
44

5-
if (COMPILER_GCC)
6-
set (DEFAULT_LIBS "${DEFAULT_LIBS} -lgcc_eh")
7-
if (ARCH_AARCH64)
8-
set (DEFAULT_LIBS "${DEFAULT_LIBS} -lgcc")
9-
endif ()
10-
endif ()
11-
125
message(STATUS "Default libraries: ${DEFAULT_LIBS}")
136

147
set(CMAKE_CXX_STANDARD_LIBRARIES ${DEFAULT_LIBS})

cmake/freebsd/default_libs.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
set (DEFAULT_LIBS "-nodefaultlibs")
22

3-
if (NOT COMPILER_CLANG)
4-
message (FATAL_ERROR "FreeBSD build is supported only for Clang")
5-
endif ()
6-
73
if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL "amd64")
84
execute_process (COMMAND ${CMAKE_CXX_COMPILER} --print-file-name=libclang_rt.builtins-x86_64.a OUTPUT_VARIABLE BUILTINS_LIBRARY OUTPUT_STRIP_TRAILING_WHITESPACE)
95
else ()

cmake/linux/default_libs.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ if (COMPILER_CLANG)
1111
if (NOT EXISTS "${BUILTINS_LIBRARY}")
1212
set (BUILTINS_LIBRARY "-lgcc")
1313
endif ()
14-
else ()
15-
set (BUILTINS_LIBRARY "-lgcc")
1614
endif ()
1715

1816
if (OS_ANDROID)

cmake/sanitize.cmake

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ option (SANITIZE "Enable one of the code sanitizers" "")
88

99
set (SAN_FLAGS "${SAN_FLAGS} -g -fno-omit-frame-pointer -DSANITIZER")
1010

11-
# gcc with -nodefaultlibs does not add sanitizer libraries
12-
# with -static-libasan and similar
13-
macro(add_explicit_sanitizer_library lib)
14-
target_link_libraries(global-libs INTERFACE "-Wl,-static -l${lib} -Wl,-Bdynamic")
15-
endmacro()
16-
1711
if (SANITIZE)
1812
if (SANITIZE STREQUAL "address")
1913
# LLVM-15 has a bug in Address Sanitizer, preventing the usage of 'sanitize-address-use-after-scope',
@@ -28,9 +22,6 @@ if (SANITIZE)
2822
if (USE_STATIC_LIBRARIES AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
2923
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libasan")
3024
endif ()
31-
if (COMPILER_GCC)
32-
add_explicit_sanitizer_library(asan)
33-
endif()
3425

3526
elseif (SANITIZE STREQUAL "memory")
3627
# MemorySanitizer flags are set according to the official documentation:
@@ -58,11 +49,6 @@ if (SANITIZE)
5849
set (TSAN_FLAGS "-fsanitize=thread")
5950
if (COMPILER_CLANG)
6051
set (TSAN_FLAGS "${TSAN_FLAGS} -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/tests/tsan_suppressions.txt")
61-
else()
62-
set (MESSAGE "TSAN suppressions was not passed to the compiler (since the compiler is not clang)\n")
63-
set (MESSAGE "${MESSAGE}Use the following command to pass them manually:\n")
64-
set (MESSAGE "${MESSAGE} export TSAN_OPTIONS=\"$TSAN_OPTIONS suppressions=${CMAKE_SOURCE_DIR}/tests/tsan_suppressions.txt\"")
65-
message (WARNING "${MESSAGE}")
6652
endif()
6753

6854

@@ -74,9 +60,6 @@ if (SANITIZE)
7460
if (USE_STATIC_LIBRARIES AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
7561
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libtsan")
7662
endif ()
77-
if (COMPILER_GCC)
78-
add_explicit_sanitizer_library(tsan)
79-
endif()
8063

8164
elseif (SANITIZE STREQUAL "undefined")
8265
set (UBSAN_FLAGS "-fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=float-divide-by-zero")
@@ -91,11 +74,6 @@ if (SANITIZE)
9174
endif()
9275
if (COMPILER_CLANG)
9376
set (UBSAN_FLAGS "${UBSAN_FLAGS} -fsanitize-blacklist=${CMAKE_SOURCE_DIR}/tests/ubsan_suppressions.txt")
94-
else()
95-
set (MESSAGE "UBSAN suppressions was not passed to the compiler (since the compiler is not clang)\n")
96-
set (MESSAGE "${MESSAGE}Use the following command to pass them manually:\n")
97-
set (MESSAGE "${MESSAGE} export UBSAN_OPTIONS=\"$UBSAN_OPTIONS suppressions=${CMAKE_SOURCE_DIR}/tests/ubsan_suppressions.txt\"")
98-
message (WARNING "${MESSAGE}")
9977
endif()
10078

10179
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SAN_FLAGS} ${UBSAN_FLAGS}")
@@ -106,9 +84,6 @@ if (SANITIZE)
10684
if (USE_STATIC_LIBRARIES AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
10785
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libubsan")
10886
endif ()
109-
if (COMPILER_GCC)
110-
add_explicit_sanitizer_library(ubsan)
111-
endif()
11287

11388
# llvm-tblgen, that is used during LLVM build, doesn't work with UBSan.
11489
set (ENABLE_EMBEDDED_COMPILER 0 CACHE BOOL "")

cmake/tools.cmake

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Compiler
22

3-
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
4-
set (COMPILER_GCC 1)
5-
elseif (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
3+
if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
64
set (COMPILER_CLANG 1) # Safe to treat AppleClang as a regular Clang, in general.
75
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
86
set (COMPILER_CLANG 1)
@@ -18,16 +16,8 @@ message (STATUS "Using compiler:\n${COMPILER_SELF_IDENTIFICATION}")
1816
set (CLANG_MINIMUM_VERSION 15)
1917
set (XCODE_MINIMUM_VERSION 12.0)
2018
set (APPLE_CLANG_MINIMUM_VERSION 12.0.0)
21-
set (GCC_MINIMUM_VERSION 11)
2219

23-
if (COMPILER_GCC)
24-
message (FATAL_ERROR "Compilation with GCC is unsupported. Please use Clang instead.")
25-
26-
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${GCC_MINIMUM_VERSION} AND NOT CMAKE_VERSION VERSION_LESS 2.8.9)
27-
message (FATAL_ERROR "Compilation with GCC version ${CMAKE_CXX_COMPILER_VERSION} is unsupported, the minimum required version is ${GCC_MINIMUM_VERSION}.")
28-
endif ()
29-
30-
elseif (COMPILER_CLANG)
20+
if (COMPILER_CLANG)
3121
if (CMAKE_CXX_COMPILER_ID MATCHES "AppleClang")
3222
# (Experimental!) Specify "-DALLOW_APPLECLANG=ON" when running CMake configuration step, if you want to experiment with using it.
3323
if (NOT ALLOW_APPLECLANG AND NOT DEFINED ENV{ALLOW_APPLECLANG})
@@ -58,19 +48,14 @@ if (LINKER_NAME MATCHES "gold")
5848
endif ()
5949

6050
if (NOT LINKER_NAME)
61-
if (COMPILER_GCC)
62-
find_program (LLD_PATH NAMES "ld.lld")
63-
elseif (COMPILER_CLANG)
51+
if (COMPILER_CLANG)
6452
if (OS_LINUX)
6553
find_program (LLD_PATH NAMES "ld.lld-${COMPILER_VERSION_MAJOR}" "lld-${COMPILER_VERSION_MAJOR}" "ld.lld" "lld")
6654
endif ()
6755
endif ()
6856
if (OS_LINUX)
6957
if (LLD_PATH)
70-
if (COMPILER_GCC)
71-
# GCC driver requires one of supported linker names like "lld".
72-
set (LINKER_NAME "lld")
73-
else ()
58+
if (COMPILER_CLANG)
7459
# Clang driver simply allows full linker path.
7560
set (LINKER_NAME ${LLD_PATH})
7661
endif ()
@@ -89,8 +74,6 @@ if (LINKER_NAME)
8974
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/cmake/ld.lld.in" "${LLD_WRAPPER}" @ONLY)
9075

9176
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --ld-path=${LLD_WRAPPER}")
92-
else ()
93-
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${LINKER_NAME}")
9477
endif ()
9578

9679
endif ()
@@ -103,9 +86,7 @@ endif()
10386

10487
# Archiver
10588

106-
if (COMPILER_GCC)
107-
find_program (LLVM_AR_PATH NAMES "llvm-ar" "llvm-ar-15" "llvm-ar-14" "llvm-ar-13" "llvm-ar-12")
108-
else ()
89+
if (COMPILER_CLANG)
10990
find_program (LLVM_AR_PATH NAMES "llvm-ar-${COMPILER_VERSION_MAJOR}" "llvm-ar")
11091
endif ()
11192

@@ -117,9 +98,7 @@ message(STATUS "Using archiver: ${CMAKE_AR}")
11798

11899
# Ranlib
119100

120-
if (COMPILER_GCC)
121-
find_program (LLVM_RANLIB_PATH NAMES "llvm-ranlib" "llvm-ranlib-15" "llvm-ranlib-14" "llvm-ranlib-13" "llvm-ranlib-12")
122-
else ()
101+
if (COMPILER_CLANG)
123102
find_program (LLVM_RANLIB_PATH NAMES "llvm-ranlib-${COMPILER_VERSION_MAJOR}" "llvm-ranlib")
124103
endif ()
125104

@@ -131,9 +110,7 @@ message(STATUS "Using ranlib: ${CMAKE_RANLIB}")
131110

132111
# Install Name Tool
133112

134-
if (COMPILER_GCC)
135-
find_program (LLVM_INSTALL_NAME_TOOL_PATH NAMES "llvm-install-name-tool" "llvm-install-name-tool-15" "llvm-install-name-tool-14" "llvm-install-name-tool-13" "llvm-install-name-tool-12")
136-
else ()
113+
if (COMPILER_CLANG)
137114
find_program (LLVM_INSTALL_NAME_TOOL_PATH NAMES "llvm-install-name-tool-${COMPILER_VERSION_MAJOR}" "llvm-install-name-tool")
138115
endif ()
139116

@@ -145,9 +122,7 @@ message(STATUS "Using install-name-tool: ${CMAKE_INSTALL_NAME_TOOL}")
145122

146123
# Objcopy
147124

148-
if (COMPILER_GCC)
149-
find_program (OBJCOPY_PATH NAMES "llvm-objcopy" "llvm-objcopy-15" "llvm-objcopy-14" "llvm-objcopy-13" "llvm-objcopy-12" "objcopy")
150-
else ()
125+
if (COMPILER_CLANG)
151126
find_program (OBJCOPY_PATH NAMES "llvm-objcopy-${COMPILER_VERSION_MAJOR}" "llvm-objcopy" "objcopy")
152127
endif ()
153128

@@ -159,9 +134,7 @@ endif ()
159134

160135
# Strip
161136

162-
if (COMPILER_GCC)
163-
find_program (STRIP_PATH NAMES "llvm-strip" "llvm-strip-15" "llvm-strip-14" "llvm-strip-13" "llvm-strip-12" "strip")
164-
else ()
137+
if (COMPILER_CLANG)
165138
find_program (STRIP_PATH NAMES "llvm-strip-${COMPILER_VERSION_MAJOR}" "llvm-strip" "strip")
166139
endif ()
167140

0 commit comments

Comments
 (0)