Skip to content

Commit

Permalink
[AIX] Improve 32/64-bit build configuration
Browse files Browse the repository at this point in the history
Summary:
AIX supports both 32-bit and 64-bit environments (with 32-bit being the default). This patch improves support for building LLVM on AIX in both 32-bit and 64-bit mode.

  - Change host detection to return correct 32/64-bit triple as config_guess does not return the correct version on 64-bit. This can confuse JIT tests and other things that care about what the host triple is.
  - Remove manual setting of 64-bit flags on AIX. AIX provides OBJECT_MODE environment variable to enable the user to obtain a 64-bit development environment. CMake will properly set these flags provided the user sets the correct OBJECT_MODE before configuring and setting them manually will interfere with 32-bit builds.
  - Don't present the LLVM_BUILD_32_BITS option on AIX, users should use OBJECT_MODE when running CMake instead.

Reviewers: hubert.reinterpretcast, DiggerLin, stevewan

Reviewed By: DiggerLin, stevewan

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74256
  • Loading branch information
daltenty committed Feb 20, 2020
1 parent c7b54a1 commit 9e0c955
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion llvm/CMakeLists.txt
Expand Up @@ -473,7 +473,7 @@ option(LLVM_USE_SPLIT_DWARF

# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
# TODO: support other platforms and toolchains.
option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
endif()
Expand Down
10 changes: 8 additions & 2 deletions llvm/cmake/modules/GetHostTriple.cmake
Expand Up @@ -14,6 +14,13 @@ function( get_host_triple var )
else()
set( value "i686-pc-windows-gnu" )
endif()
elseif( CMAKE_HOST_SYSTEM_NAME STREQUAL AIX )
# We defer to dynamic detection of the host AIX version.
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( value "powerpc64-ibm-aix" )
else()
set( value "powerpc-ibm-aix" )
endif()
else( MSVC )
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows AND NOT MSYS)
message(WARNING "unable to determine host target triple")
Expand All @@ -26,8 +33,7 @@ function( get_host_triple var )
if( NOT TT_RV EQUAL 0 )
message(FATAL_ERROR "Failed to execute ${config_guess}")
endif( NOT TT_RV EQUAL 0 )
# Defer to dynamic detection of the host AIX version.
string(REGEX REPLACE "-aix[0-9][^-]*" "-aix" value ${TT_OUT})
set( value ${TT_OUT} )
endif()
endif( MSVC )
set( ${var} ${value} PARENT_SCOPE )
Expand Down
11 changes: 0 additions & 11 deletions llvm/cmake/modules/HandleLLVMOptions.cmake
Expand Up @@ -169,17 +169,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
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)
Expand Down

0 comments on commit 9e0c955

Please sign in to comment.