On AIX, we have to ship libatomic.a for compatibility. First, a new clang_rt.atomic is added. Second, use added cmake modules for AIX, we are able to build a compatible libatomic.a for AIX. The second step can't be perfectly implemented with cmake now since AIX's archive approach is kinda unique, i.e., archiving shared libraries into a static archive file.
Details
- Reviewers
jsji daltenty ldionne phosek xingxue cebowleratibm nemanjai howard.hinnant samsonov efriedma - Group Reviewers
Restricted Project - Commits
- rGd56729b4a439: [AIX][compiler-rt] Build and install standalone libatomic
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks @lkail ! In general, I think we can try to make the Modules platform dependent.
compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake | ||
---|---|---|
4 | Can we make *ALL* the code in this file platform independent? Although there are NO other users in other platform, we can make it reusable in case there are similar requests from other platform. So, please remove AIX_ prefix here. | |
48 | Same, remove _aix_ here, also pass down compile_flag and link flag. | |
61 | Why this has to be OFF? Isn't SHARED needs PIC? Also AIX defaults to PIC. | |
62 | Can we pass the flag into this functions instead of hardcoding them here. | |
63 | Same as above, these flags should be passed down from CMakeLists.txt , not hardcoding them here. | |
75 | Remove _aix_, also add options to control building 32 bit only, 64 bit only, or both. | |
81 | Can we make this another function like generate_export_list? | |
100 | ar flags should be passed down, or can have default, and can be overwritten by args. | |
compiler-rt/lib/builtins/CMakeLists.txt | ||
757 | Set the compile flags, linker flags, ar flags here. |
compiler-rt/lib/builtins/CMakeLists.txt | ||
---|---|---|
755 | Maybe a more generic CMake option (e.g. COMPILER_RT_BUILD_LIBATOMIC) with an appropriate default for AIX would be better here? |
Address comments by following method introduced by @daltenty in https://reviews.llvm.org/D101959. Now compiling shared atomic library is platform independent.
I like the part in compiler-rt/lib/builtins/CMakeLists.txt -- it is essentially the same principle of what we suggested yesterday -- make the code platform independent,
but I don't like the overall fact that we need to invoke compiler-rt/utils/aix-install-libatomic.sh as an additional step, and call cmake again...
I know CMake can NOT handle AIX archives well for now, I believe we can just implement that part using ar and add TODO to fix it once CMake support is ready.
What do you think?
compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake | ||
---|---|---|
55 | Why not just store this as an .exp file in the source tree if we are just going to write it out? (That would similar to what's in libcxx I believe) |
compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake | ||
---|---|---|
63 | nit: don't some of these duplicate the driver default link flags for building a shared library? |
compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake | ||
---|---|---|
63 | I've checked generated build.ninja LANGUAGE_COMPILE_FLAGS = -O3 -DNDEBUG LINK_FLAGS = -Wl,-brtl -m64 -Wl,-H512 -Wl,-D0 -Wl,-T512 -Wl,-bhalt:4 -Wl,-bernotok -Wl,-bnoentry -Wl,-bexport:/home/lkail/llvm/dev/llvm-project/compiler-rt/lib/builtins/atomic.exp -Wl,-bmodtype:SRE -Wl,-lc LINK_LIBRARIES = -Wl,-blibpath:/usr/lib:/lib OBJECT_DIR = lib/builtins/CMakeFiles/clang_rt.atomic-dynamic-powerpc64.dir POST_BUILD = : PRE_LINK = : Looks no duplicated item in flags. |
- Introduce COMPILER_RT_LIBATOMIC_LINK_FLAGS
- New file atomic.exp under compiler-rt/lib/builtins
- Minor tweak of dependencies
LGTM. Thanks. Please wait one or two days in case there are other feedback.
compiler-rt/lib/builtins/CMakeLists.txt | ||
---|---|---|
764 | Maybe put atomic.exp into ppc subdir would be better. |
Can we make *ALL* the code in this file platform independent? Although there are NO other users in other platform, we can make it reusable in case there are similar requests from other platform.
So, please remove AIX_ prefix here.