This is an archive of the discontinued LLVM Phabricator instance.

[libc++/abi/unwind][AIX] Add scripts and cache file for building libc++/libc++abi/libunwind
AbandonedPublic

Authored by daltenty on May 5 2021, 4:23 PM.

Details

Reviewers
jasonliu
ldionne
lei
nemanjai
Group Reviewers
Restricted Project
Restricted Project
Summary

The script follows the pattern of the existing apple-install-libcxx.sh, and allows creating the combined 32/64-bit library archives
required for the C++ runtime on AIX.

Sample invocation

$./libcxx/utils/ci/aix-install-libcxx.sh --llvm-root  $PWD --build-dir ~/build-libcxx --install-dir ~/install-libcxx --cache ./libcxx/cmake/caches/AIX.cmake

Diff Detail

Event Timeline

daltenty created this revision.May 5 2021, 4:23 PM
daltenty requested review of this revision.May 5 2021, 4:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2021, 4:23 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
jsji added a reviewer: Restricted Project.May 5 2021, 8:05 PM

It would help if we could put the sample invocation in the summary.

libcxx/utils/ci/aix-install-libcxx.sh
105–106

Could we check if these two settings are needed? i.e. are they on by default already in the current cmake config?

108

If a build did not complete successfully, for the ease of find out where it fails, do we want to have an early exit whenever there is an error on setting up cmake and during building?

jasonliu added inline comments.May 6 2021, 12:11 PM
libcxx/utils/ci/aix-install-libcxx.sh
108

For developers who invokes this script: do we want to detect if we already have a config build so that we don't need to run the cmake config every time? And provide a --clobber option if people wants to reconfig an existing config?

daltenty edited the summary of this revision. (Show Details)May 6 2021, 1:14 PM
lei added inline comments.May 6 2021, 1:54 PM
libcxx/utils/ci/aix-install-libcxx.sh
50

Missing doc of this option in usage()

95–96
113–114
115
118–125

All these should be quoted.

ldionne added a subscriber: phosek.May 7 2021, 11:14 AM

Hmm, this one hurts. The thing here is that I completely understand why you followed the lead of apple-install-libcxx.sh, however the truth is that that script is a hack for not being able to do what we want from CMake. It would be awesome if we could find a less ad-hoc way of doing this (both for you folks and for the Apple version).

@phosek, using the Runtimes build, would it be possible to build libc++ for 64 and 32 bits, and merge those? And is it possible to use the runtimes build without bootstrapping Clang first, i.e. with the system compiler?

phosek added a subscriber: beanz.May 7 2021, 3:14 PM

Hmm, this one hurts. The thing here is that I completely understand why you followed the lead of apple-install-libcxx.sh, however the truth is that that script is a hack for not being able to do what we want from CMake. It would be awesome if we could find a less ad-hoc way of doing this (both for you folks and for the Apple version).

@phosek, using the Runtimes build, would it be possible to build libc++ for 64 and 32 bits, and merge those? And is it possible to use the runtimes build without bootstrapping Clang first, i.e. with the system compiler?

Yes, it's something I'm actively looking into right now for Apple platforms since we want to ship libc++ as universal library in our toolchain. @beanz suggested using CMAKE_OSX_ARCHITECTURES and after some experimentation, I'm convinced that it's possible with a bit of CMake refactoring. Right now the blocker is some of the post-processing like the support for merging libc++abi and libc++ archives since utils/merge_archives.py doesn't work for universal archives, but that can be solved by using object libraries.

Unfortunately, CMake as far as I'm aware doesn't have any support for XCOFF or AIX so it's unlikely to help in this case. We could consider implementing a more general support in the runtimes build where you could run multiple target builds and then combine their results, but it's still likely going to require some platform-specific logic since there's no standard way of creating universal binaries.

To your second question, yes it's possible. If you build ${LLVM_MONOREPO}/runtimes as your CMake project, you can use arbitrary host compiler.

daltenty added a comment.EditedMay 10 2021, 1:13 PM

Hmm, this one hurts. The thing here is that I completely understand why you followed the lead of apple-install-libcxx.sh, however the truth is that that script is a hack for not being able to do what we want from CMake. It would be awesome if we could find a less ad-hoc way of doing this (both for you folks and for the Apple version).

@phosek, using the Runtimes build, would it be possible to build libc++ for 64 and 32 bits, and merge those? And is it possible to use the runtimes build without bootstrapping Clang first, i.e. with the system compiler?

Yes, it's something I'm actively looking into right now for Apple platforms since we want to ship libc++ as universal library in our toolchain. @beanz suggested using CMAKE_OSX_ARCHITECTURES and after some experimentation, I'm convinced that it's possible with a bit of CMake refactoring. Right now the blocker is some of the post-processing like the support for merging libc++abi and libc++ archives since utils/merge_archives.py doesn't work for universal archives, but that can be solved by using object libraries.

When reviews open on this refactoring, we'd definitely be interested reviewing. Hopefully we'd be able to re-use some of that setup to solve this problem as well.

Unfortunately, CMake as far as I'm aware doesn't have any support for XCOFF or AIX so it's unlikely to help in this case. We could consider implementing a more general support in the runtimes build where you could run multiple target builds and then combine their results, but it's still likely going to require some platform-specific logic since there's no standard way of creating universal binaries.

Yes, this is something we always wish there was better native CMake support for 🙂 Maybe getting a CMake property setup similar to CMAKE_OSX_ARCHITECTURES is worth investigating. Refactoring the runtimes build is possible but IIUC if Apple targets end up using CMAKE_OSX_ARCHITECTURES instead seems like AIX would be the only interested target?

I think a side question is, there is definitely a desire to do something better here, but both of the above options seem like they are going to require a larger refactoring. Should this script still proceed so there is something available within the LLVM 13 timeframe?

daltenty added inline comments.May 10 2021, 1:58 PM
libcxx/utils/ci/aix-install-libcxx.sh
50

Ah, this got moved to the cache file to be consistent with the existing setup, so I'll drop the option.

daltenty updated this revision to Diff 344210.May 10 2021, 2:32 PM
  • Address review comments
daltenty marked 5 inline comments as done.May 10 2021, 2:33 PM
daltenty marked an inline comment as done.May 10 2021, 2:35 PM
daltenty added inline comments.
libcxx/utils/ci/aix-install-libcxx.sh
108

If a build did not complete successfully, for the ease of find out where it fails, do we want to have an early exit whenever there is an error on setting up cmake and during building?

The set -e should hopefully take care of that for us.

daltenty updated this revision to Diff 344403.May 11 2021, 7:45 AM
  • Address comments #2
daltenty updated this revision to Diff 344414.May 11 2021, 8:31 AM
  • Add clobber option
daltenty marked an inline comment as done.May 11 2021, 8:32 AM
daltenty updated this revision to Diff 344583.May 11 2021, 4:12 PM
  • Cleanup script style
daltenty updated this revision to Diff 344996.May 12 2021, 5:53 PM
  • Adjust cxxabi header install location to be consistent with previous install path on AIX
  • Reindent file and do other minor cleanups
daltenty planned changes to this revision.Sep 1 2021, 7:09 AM
daltenty abandoned this revision.Oct 6 2021, 12:32 PM

Abandoned in favour of D111244