This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by hubert.reinterpretcast on May 11 2020, 2:56 PM.

Details

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.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2020, 2:56 PM
Herald added a subscriber: mgorny. · View Herald Transcript
daltenty added inline comments.May 12 2020, 9:42 AM
llvm/cmake/modules/HandleLLVMOptions.cmake
202

This seems more generally applicable on AIX. Could we promote this out of the XL specific block and just pass it as a general linker option?

hubert.reinterpretcast marked an inline comment as done.May 12 2020, 3:12 PM
hubert.reinterpretcast added inline comments.
llvm/cmake/modules/HandleLLVMOptions.cmake
202

I don't think we should move this out of the XL-specific block at this time. GCC does not use the same mechanism for static initialization on AIX.

daltenty added inline comments.May 15 2020, 1:04 PM
llvm/cmake/modules/HandleLLVMOptions.cmake
200

--whole-archive is used on Linux for building the shared libraries when -DLLVM_BUILD_LLVM_DYLIB=yes. Do we need to be concerned about this case?

daltenty accepted this revision.May 15 2020, 1:38 PM
daltenty marked an inline comment as done.

LGTM

llvm/cmake/modules/HandleLLVMOptions.cmake
200

Summary of offline discussion: AIX would use the export list mechanism in place of --whole-archive, and the export list would make those symbols referenced so we’d pull in the initialization even with -bcdtors:mbr

This revision is now accepted and ready to land.May 15 2020, 1:38 PM
This revision was automatically updated to reflect the committed changes.