[llvm] e3e0367 - [CMake][AIX] Add `-bcdtors:mbr` option when building with IBM XL

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Fri May 15 14:34:14 PDT 2020


Author: Hubert Tong
Date: 2020-05-15T17:34:00-04:00
New Revision: e3e0367f9ba142b5a3d4c2362f11b3fcbacfc98d

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

LOG: [CMake][AIX] Add `-bcdtors:mbr` option when building with IBM XL

Summary:
The `-bcdtors:mbr` option causes processing for constructors and
destructors to omit otherwise-unreferenced members of static libraries,
matching the processing done on Linux, where `--whole-archive` is not
the default. Applying this option is desirable for reducing the
footprint of an installation.

Reviewed By: daltenty

Differential Revision: https://reviews.llvm.org/D79749

Added: 
    

Modified: 
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 7e612896cd0f..b50100f4d63a 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -196,6 +196,12 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
     # XL generates a small number of relocations not of the large model, -bbigtoc is needed.
     append("-Wl,-bbigtoc"
            CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+    # The default behaviour on AIX processes dynamic initialization of non-local variables with
+    # static storage duration even for archive members that are otherwise unreferenced.
+    # Since `--whole-archive` is not used by the LLVM build to keep such initializations for Linux,
+    # we can limit the processing for archive members to only those that are otherwise referenced.
+    append("-bcdtors:mbr"
+           CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
   endif()
 endif()
 


        


More information about the llvm-commits mailing list