Browse Source

build: Enable -fno-semantic-interposition for GCC

This matches the more optimized clang behavior for -fPIC
rdb 3 years ago
parent
commit
5475084717
2 changed files with 11 additions and 0 deletions
  1. 7 0
      dtool/CompilerFlags.cmake
  2. 4 0
      makepanda/makepanda.py

+ 7 - 0
dtool/CompilerFlags.cmake

@@ -218,3 +218,10 @@ if(NOT MSVC)
     add_compile_options("-fvisibility=hidden")
   endif()
 endif()
+
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+  check_cxx_compiler_flag("-fno-semantic-interposition" COMPILER_SUPPORTS_FNO_SEMANTIC_INTERPOSITION)
+  if(COMPILER_SUPPORTS_FNO_SEMANTIC_INTERPOSITION)
+    add_compile_options("-fno-semantic-interposition")
+  endif()
+endif()

+ 4 - 0
makepanda/makepanda.py

@@ -1370,6 +1370,10 @@ def CompileCxx(obj,src,opts):
                 if 'NOARCH:' + arch.upper() not in opts:
                     cmd += " -arch %s" % arch
 
+        elif 'clang' not in GetCXX().split('/')[-1]:
+            # Enable interprocedural optimizations in GCC.
+            cmd += " -fno-semantic-interposition"
+
         if "SYSROOT" in SDK:
             if GetTarget() != "android":
                 cmd += ' --sysroot=%s' % (SDK["SYSROOT"])