[PATCH] D118377: [LLVM][AIX] Prefer a 32-bit default target triple on AIX

David Tenty via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 27 08:19:44 PST 2022


daltenty created this revision.
daltenty added reviewers: hubert.reinterpretcast, stevewan.
Herald added subscribers: steven.zhang, mgorny.
daltenty requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If the user doesn't specify a default target triple, the LLVM CMake usually defaults us into the host triple. This is a problem when building Clang/LLVM on 64-bit AIX (i.e. powerpc64-ibm-aix), as the host toolchain (e.g. ar, ld, nm, dump) all expect the compiler to generate 32-bit objects by default (which both GCC and XL on the platform do) and will hard error if passed a 64-bit object without an explicit option or environment setting. This breaks downstream consumers, such as builds generated with build tools like CMake, which when they invoke clang, etc. without explicit bitmode flags also expect 32-bit mode.

This patch changes the default target selection when the host is `powerpc64-ibm-aix` to prefer `powerpc-ibm-aix` to avoid these issues. We don't update the `runtimes/CMakeList.txt` since the default is less meaningful as we assume runtimes will need to build for both targets anyways.


https://reviews.llvm.org/D118377

Files:
  llvm/CMakeLists.txt


Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -703,8 +703,15 @@
 include(config-ix)

 # By default, we target the host, but this can be overridden at CMake
-# invocation time.
-set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
+# invocation time. Except on 64-bit AIX, where the system toolchain
+# expect 32-bit objects by default.
+if("${LLVM_HOST_TRIPLE}" STREQUAL "powerpc64-ibm-aix")
+  set(LLVM_DEFAULT_TARGET_TRIPLE_default "powerpc-ibm-aix")
+else()
+  set(LLVM_DEFAULT_TARGET_TRIPLE_default "${LLVM_HOST_TRIPLE}")
+endif()
+
+set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE_default}" CACHE STRING
   "Default target for which LLVM will generate code." )
 set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
 message(STATUS "LLVM host triple: ${LLVM_HOST_TRIPLE}")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118377.403662.patch
Type: text/x-patch
Size: 901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220127/afe657d9/attachment.bin>


More information about the llvm-commits mailing list