Browse Source

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
thegeorg 3 years ago
parent
commit
207b28a602
3 changed files with 14 additions and 9 deletions
  1. 13 0
      build/ymake.core.conf
  2. 0 8
      util/CMakeLists.txt
  3. 1 1
      util/ya.make

+ 13 - 0
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) {
@@ -6327,6 +6333,13 @@ macro SRC_CPP_PIC(FILE, FLAGS...) {
     _SRC(cpp $FILE $PIC_CFLAGS $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.

+ 0 - 8
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

+ 1 - 1
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(