This is an archive of the discontinued LLVM Phabricator instance.

[AIX] Improve 32/64-bit build configuration
ClosedPublic

Authored by daltenty on Feb 7 2020, 2:08 PM.

Details

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.

Event Timeline

daltenty created this revision.Feb 7 2020, 2:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2020, 2:08 PM
This revision is now accepted and ready to land.Feb 10 2020, 8:36 AM
stevewan added inline comments.Feb 10 2020, 8:38 AM
llvm/cmake/modules/GetHostTriple.cmake
29

Since the added code implies the same, I'd suggest that we keep and move this comment to the new code.

daltenty updated this revision to Diff 243898.Feb 11 2020, 9:09 AM
  • Don't set -q64 in the CMakeLists, we should use OBJECT_MODE instead on AIX if we are planning to build 64-bit so CMake knows what we are up to.
  • Restore comment
stevewan added inline comments.Feb 11 2020, 11:31 AM
llvm/cmake/modules/HandleLLVMOptions.cmake
174 ↗(On Diff #243898)

Is this change somewhat out of scope here and fits better in a separate patch?

daltenty marked an inline comment as done.Feb 11 2020, 1:37 PM
daltenty added inline comments.
llvm/cmake/modules/HandleLLVMOptions.cmake
174 ↗(On Diff #243898)

The reason I'd included in this patch is it affects your ability to test this change. CMake won't set CMAKE_SIZEOF_VOID_P to the 64-bit case unless you have OBJECT_MODE=64 set, but these options override the OBJECT_MODE setting.

Maybe the best option is to split this patch and land this bit first.

stevewan added inline comments.Feb 12 2020, 11:58 AM
llvm/cmake/modules/HandleLLVMOptions.cmake
174 ↗(On Diff #243898)

How's the value of LLVM_BUILD_32_BITS determined? I found in llvm/CMakeLists.txt that,

if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
  # TODO: support other platforms and toolchains.
  option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
endif()

which suggests that LLVM_BUILD_32_BITS depends on CMAKE_SIZEOF_VOID_P, but then that means there is a circular dependency? Did I misunderstand something?

Given this piece of code is related to topic, I'm fine with either spliting or keeping it. If we do decide to include it, we'll need to expand the description of this patch.

daltenty marked an inline comment as done.Feb 13 2020, 11:27 AM
daltenty added inline comments.
llvm/cmake/modules/HandleLLVMOptions.cmake
174 ↗(On Diff #243898)

I appears to be user configurable setting in you want to build a 32-bit version on a 64-bit host (which is why it only gets enabled if CMAKE_SIZEOF_VOID_P is 8). This option is probably not relevant on AIX (since you can just configure with CMake in 32-bit or 64-bit object modes and things should work as normal).

We should probably not show this option on AIX either same as WIN32 (in many ways the AIX CMake setup is most similar to WIN32).

I will broaden the patch description, it makes sense to include this all as a single change

daltenty retitled this revision from [AIX] Change host detection to return correct 32/64-bit triple to [AIX] Improve 32/64-bit build configuration.Feb 13 2020, 11:43 AM
daltenty edited the summary of this revision. (Show Details)
daltenty edited the summary of this revision. (Show Details)
stevewan added inline comments.Feb 13 2020, 1:02 PM
llvm/cmake/modules/HandleLLVMOptions.cmake
174 ↗(On Diff #243898)

Yea, I agree that we should drop this option for AIX as it made the way of setting the object mode unnecessarily complex (more than one way of setting up the same thing), and introduced ambiguity (one approach would interfere with the other).

daltenty updated this revision to Diff 244680.Feb 14 2020, 8:22 AM
daltenty edited the summary of this revision. (Show Details)
  • Don't present the LLVM_BUILD_32_BITS option on AIX
daltenty edited the summary of this revision. (Show Details)Feb 14 2020, 8:24 AM
daltenty edited the summary of this revision. (Show Details)
daltenty marked an inline comment as done.
stevewan accepted this revision.Feb 14 2020, 9:02 AM

LGTM. Thanks.

This revision was automatically updated to reflect the committed changes.