[PATCH] D16506: [cmake/AIX] Enhance cmake files to support compiling with gcc on AIX
Kai Nacke via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 23 06:31:29 PST 2016
Kai created this revision.
Kai added a reviewer: chandlerc.
Kai added a subscriber: llvm-commits.
This PR allows compiling LLVM on AIX using gcc. Additions are:
- Pass -allow-shlib-undefined to linker
- Export functions with -Wl,-bE:
- Do not pass -O3 and -z defs to linker
- Use -bgc to garbage collect unused code sections
http://reviews.llvm.org/D16506
Files:
CMakeLists.txt
cmake/modules/AddLLVM.cmake
cmake/modules/HandleLLVMOptions.cmake
Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -141,7 +141,8 @@
# build might work on ELF but fail on MachO/COFF.
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR WIN32 OR CYGWIN OR
${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR
- ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") AND
+ ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD" OR
+ ${CMAKE_SYSTEM_NAME} MATCHES "AIX") AND
NOT LLVM_USE_SANITIZER)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
endif()
Index: cmake/modules/AddLLVM.cmake
===================================================================
--- cmake/modules/AddLLVM.cmake
+++ cmake/modules/AddLLVM.cmake
@@ -85,6 +85,9 @@
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
+ elseif (${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-bE:${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
else()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
@@ -156,7 +159,7 @@
# Pass -O3 to the linker. This enabled different optimizations on different
# linkers.
- if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|SunOS" OR WIN32))
+ if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|SunOS|AIX" OR WIN32))
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-O3")
endif()
@@ -177,6 +180,9 @@
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z -Wl,discard-unused=sections")
+ elseif(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-bgc")
elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD)
# Object files are compiled with -ffunction-data-sections.
# Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -588,7 +588,7 @@
# check its symbols. This is wasteful (the check was done when foo.so
# was created) and can fail since it is not the dynamic linker and
# doesn't know how to handle search paths correctly.
-if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
+if (UNIX AND NOT APPLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "SunOS|AIX")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16506.45790.patch
Type: text/x-patch
Size: 2978 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160123/653c8f98/attachment.bin>
More information about the llvm-commits
mailing list