aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-25 00:23:54 +0300
committerthegeorg <thegeorg@yandex-team.ru>2022-02-25 00:23:54 +0300
commit207b28a6021793cec36893b859eb01c76434e6b1 (patch)
tree406ddff6e841c13450a4c798f68e4fbebb57c3b4
parent9e08dc29988aa927698e62abd83d0930c730c464 (diff)
downloadydb-207b28a6021793cec36893b859eb01c76434e6b1.tar.gz
Implement SRC_CPP_NO_LTO and use it util/
`-flto` / `-fno-lto` is not available in clang-cl, so we should not use it in order to prevent `-Wunknown-argument` from being triggered Raw CFLAGS are not user-friendly, we should define a better macro for thi (somewhat popular) case. ref:6f969138dc8b6fe4c420eb2ef4c0e50c2503d184
-rw-r--r--build/ymake.core.conf13
-rw-r--r--util/CMakeLists.txt8
-rw-r--r--util/ya.make2
3 files changed, 14 insertions, 9 deletions
diff --git a/build/ymake.core.conf b/build/ymake.core.conf
index b0c390dfc3..fadc1cbd07 100644
--- a/build/ymake.core.conf
+++ b/build/ymake.core.conf
@@ -1250,10 +1250,12 @@ module _BASE_UNIT: _BARE_UNIT {
when ($GCC) {
CFLAGS+=-flto -fno-fat-lto-objects
LDFLAGS+=-flto
+ NO_LTO_CFLAGS=-fno-lto
}
when ($CLANG) {
CFLAGS+=-flto
LDFLAGS+=-flto
+ NO_LTO_CFLAGS=-fno-lto
}
}
@@ -1261,10 +1263,12 @@ module _BASE_UNIT: _BARE_UNIT {
when ($GCC) {
CFLAGS+=-flto=thin
LDFLAGS+=-flto=thin
+ NO_LTO_CFLAGS=-fno-lto
}
when ($CLANG) {
CFLAGS+=-flto=thin
LDFLAGS+=-flto=thin
+ NO_LTO_CFLAGS=-fno-lto
}
}
@@ -5705,6 +5709,8 @@ SSE_CFLAGS=
SSE4_DEFINES=
SSE4_CFLAGS=
+NO_LTO_CFLAGS=
+
# tag:cpu
when (($ARCH_X86_64 || $ARCH_I386) && $DISABLE_INSTRUCTION_SETS != "yes") {
when ($CLANG || $CLANG_CL || $GCC) {
@@ -6328,6 +6334,13 @@ macro SRC_CPP_PIC(FILE, FLAGS...) {
}
# tag:cpu tag:src-processing
+### @uage SRC_CPP_NO_LTO(File)
+### Compile single .cpp file with link-time-optimization disabled
+macro SRC_CPP_NO_LTO(FILE) {
+ _SRC(cpp $FILE $NO_LTO_CFLAGS)
+}
+
+# tag:cpu tag:src-processing
### @usage SRC_CPP_SSE2(File Flags...)
### Compile single .cpp-file with SSE2 and extra Flags.
macro SRC_CPP_SSE2(FILE, FLAGS...) {
diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt
index f0d69c200d..bb98729654 100644
--- a/util/CMakeLists.txt
+++ b/util/CMakeLists.txt
@@ -19,14 +19,6 @@ target_sources(yutil PRIVATE
${CMAKE_SOURCE_DIR}/util/system/valgrind.cpp
${CMAKE_SOURCE_DIR}/util/system/mktemp_system.cpp
)
-set_property(
- SOURCE
- ${CMAKE_SOURCE_DIR}/util/system/compiler.cpp
- APPEND
- PROPERTY
- COMPILE_OPTIONS
- -fno-lto
-)
target_joined_source(yutil
all_datetime.cpp
${CMAKE_SOURCE_DIR}/util/datetime/base.cpp
diff --git a/util/ya.make b/util/ya.make
index ab34124774..523c80a17d 100644
--- a/util/ya.make
+++ b/util/ya.make
@@ -329,7 +329,7 @@ JOIN_SRCS(
system/yield.cpp
)
-SRC(system/compiler.cpp -fno-lto)
+SRC_CPP_NO_LTO(system/compiler.cpp)
IF (OS_WINDOWS)
SRCS(