[llvm] r356104 - [AIX][CMake] Changes for building on AIX with XL and GCC
Jason Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 13 14:50:25 PDT 2019
Author: jasonliu
Date: Wed Mar 13 14:50:25 2019
New Revision: 356104
URL: http://llvm.org/viewvc/llvm-project?rev=356104&view=rev
Log:
[AIX][CMake] Changes for building on AIX with XL and GCC
Summary:
In support of IBM's efforts to produce a viable C and C++ LLVM compiler for AIX
(ref: RFC at http://lists.llvm.org/pipermail/llvm-dev/2019-February/130175.html),
this patch adds customizations to the CMake files in order to properly
invoke the host toolchain for the build on AIX.
Additional changes to enable a successful build will follow.
Patch by Xing Xue
Reviewers: hubert.reinterpretcast, jasonliu, sfertile
Reviewed by: hubert.reinterpretcast
Differential Revision: https://reviews.llvm.org/D58250
Modified:
llvm/trunk/cmake/modules/AddLLVM.cmake
llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
llvm/trunk/include/llvm/Config/abi-breaking.h.cmake
Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=356104&r1=356103&r2=356104&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Wed Mar 13 14:50:25 2019
@@ -221,7 +221,8 @@ function(add_link_opts target_name)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z -Wl,discard-unused=sections")
- elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
+ elseif(NOT WIN32 AND NOT LLVM_LINKER_IS_GOLD AND
+ NOT ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD|AIX")
# Object files are compiled with -ffunction-data-sections.
# Versions of bfd ld < 2.23.1 have a bug in --gc-sections that breaks
# tools that use plugins. Always pass --gc-sections once we require
@@ -229,6 +230,11 @@ function(add_link_opts target_name)
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--gc-sections")
endif()
+ else() #LLVM_NO_DEAD_STRIP
+ if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ set_property(TARGET ${target_name} APPEND_STRING PROPERTY
+ LINK_FLAGS " -Wl,-bnogc")
+ endif()
endif()
endif()
endfunction(add_link_opts)
Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=356104&r1=356103&r2=356104&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Wed Mar 13 14:50:25 2019
@@ -135,12 +135,32 @@ if(APPLE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
endif()
+if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
+ if(NOT LLVM_BUILD_32_BITS)
+ if (CMAKE_CXX_COMPILER_ID MATCHES "XL")
+ append("-q64" CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
+ else()
+ append("-maix64" CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
+ endif()
+ set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -X64 qc <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> -X64 q <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -X64 <TARGET>")
+ set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -X64 <TARGET>")
+ endif()
+ # -fPIC does not enable the large code model for GCC on AIX but does for XL.
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ append("-mcmodel=large" CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
+ elseif(CMAKE_CXX_COMPILER_ID MATCHES "XL")
+ # 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)
+ endif()
+endif()
+
# Pass -Wl,-z,defs. This makes sure all symbols are defined. Otherwise a DSO
# 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" OR
- ${CMAKE_SYSTEM_NAME} MATCHES "DragonFly") AND
+if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin|FreeBSD|OpenBSD|DragonFly|AIX" OR
+ WIN32 OR CYGWIN) AND
NOT LLVM_USE_SANITIZER)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,defs")
endif()
@@ -220,8 +240,9 @@ if( LLVM_ENABLE_PIC )
endif()
endif()
-if(NOT WIN32 AND NOT CYGWIN)
+if(NOT WIN32 AND NOT CYGWIN AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
# MinGW warns if -fvisibility-inlines-hidden is used.
+ # GCC on AIX warns if -fvisibility-inlines-hidden is used.
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)
endif()
Modified: llvm/trunk/include/llvm/Config/abi-breaking.h.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/abi-breaking.h.cmake?rev=356104&r1=356103&r2=356104&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Config/abi-breaking.h.cmake (original)
+++ llvm/trunk/include/llvm/Config/abi-breaking.h.cmake Wed Mar 13 14:50:25 2019
@@ -34,15 +34,27 @@
#elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch
// FIXME: Implement checks without weak.
#elif defined(__cplusplus)
+#if !(defined(_AIX) && defined(__GNUC__) && !defined(__clang__))
+#define LLVM_HIDDEN_VISIBILITY __attribute__ ((visibility("hidden")))
+#else
+// GCC on AIX does not support visibility attributes. Symbols are not
+// exported by default on AIX.
+#define LLVM_HIDDEN_VISIBILITY
+#endif
namespace llvm {
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
extern int EnableABIBreakingChecks;
-__attribute__((weak, visibility ("hidden"))) int *VerifyEnableABIBreakingChecks = &EnableABIBreakingChecks;
+LLVM_HIDDEN_VISIBILITY
+__attribute__((weak)) int *VerifyEnableABIBreakingChecks =
+ &EnableABIBreakingChecks;
#else
extern int DisableABIBreakingChecks;
-__attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks;
+LLVM_HIDDEN_VISIBILITY
+__attribute__((weak)) int *VerifyDisableABIBreakingChecks =
+ &DisableABIBreakingChecks;
#endif
}
+#undef LLVM_HIDDEN_VISIBILITY
#endif // _MSC_VER
#endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING
More information about the llvm-commits
mailing list