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

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 15:07:52 PDT 2020


hubert.reinterpretcast created this revision.
hubert.reinterpretcast added reviewers: daltenty, jasonliu, xingxue, stevewan.
Herald added a subscriber: mgorny.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79749

Files:
  llvm/cmake/modules/HandleLLVMOptions.cmake


Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -195,6 +195,12 @@
     # 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()
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79749.263289.patch
Type: text/x-patch
Size: 966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200511/7b28e060/attachment.bin>


More information about the llvm-commits mailing list