[llvm] d63016a - [CMake] Revert -Wl,-O3

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 24 15:42:02 PST 2021


Author: Fangrui Song
Date: 2021-12-24T15:41:56-08:00
New Revision: d63016a86548e8231002a760bbe9eb817cd1eb00

URL: https://github.com/llvm/llvm-project/commit/d63016a86548e8231002a760bbe9eb817cd1eb00
DIFF: https://github.com/llvm/llvm-project/commit/d63016a86548e8231002a760bbe9eb817cd1eb00.diff

LOG: [CMake] Revert -Wl,-O3

This reverts 8cb7876cb366b5803ca35d92313ea00eadf29b78 and follow-ups.

GNU ld/gold/ld.lld -O has nothing to do with any code related linker optimizations.
It has very small benefit (save 144Ki (.hash, .gnu_hash) with GNU ld, save 0.7%
.debug_str with gold/ld.lld) while it makes gold/ld.lld significantly slower
when linking RelWithDebInfo clang (gold: 16.437 vs 19.488; ld.lld: 1.882 vs 4.881).

Added: 
    

Modified: 
    llvm/cmake/modules/AddLLVM.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 1d97626d69ccc..327b8e0ba2e73 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -254,14 +254,6 @@ function(add_link_opts target_name)
   # Don't use linker optimizations in debug builds since it slows down the
   # linker in a context where the optimizations are not important.
   if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
-
-    # Pass -O3 to the linker. This enabled 
diff erent optimizations on 
diff erent
-    # linkers.
-    if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin|SunOS|AIX|OS390" OR WIN32) AND in_distribution)
-      set_property(TARGET ${target_name} APPEND_STRING PROPERTY
-                   LINK_FLAGS " -Wl,-O3")
-    endif()
-
     if(NOT LLVM_NO_DEAD_STRIP)
       if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
         # ld64's implementation of -dead_strip breaks tools that use plugins.


        


More information about the llvm-commits mailing list