-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AIX][compiler-rt] Build and install standalone libatomic
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. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D102155
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
include(CMakeParseArguments) | ||
include(CompilerRTUtils) | ||
|
||
function(get_aix_libatomic_default_link_flags link_flags export_list) | ||
set(${link_flags} | ||
"-Wl,-H512 -Wl,-D0 \ | ||
-Wl,-T512 -Wl,-bhalt:4 -Wl,-bernotok \ | ||
-Wl,-bnoentry -Wl,-bexport:${export_list} \ | ||
-Wl,-bmodtype:SRE -Wl,-lc" PARENT_SCOPE) | ||
endfunction() | ||
|
||
macro(archive_aix_libatomic name) | ||
cmake_parse_arguments(LIB | ||
"" | ||
"" | ||
"ARCHS;PARENT_TARGET" | ||
${ARGN}) | ||
set(shared_libraries_to_archive "") | ||
foreach (arch ${LIB_ARCHS}) | ||
if(CAN_TARGET_${arch}) | ||
set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/libatomic-${arch}.dir") | ||
# FIXME: Target name should be kept consistent with definition | ||
# in AddCompilerRT.cmake added by | ||
# add_compiler_rt_runtime(<name> SHARED ...) | ||
set(target ${name}-dynamic-${arch}) | ||
if(TARGET ${target}) | ||
file(MAKE_DIRECTORY ${output_dir}) | ||
add_custom_command(OUTPUT "${output_dir}/libatomic.so.1" | ||
POST_BUILD | ||
COMMAND ${CMAKE_COMMAND} -E | ||
copy "$<TARGET_FILE:${target}>" | ||
"${output_dir}/libatomic.so.1" | ||
DEPENDS ${target}) | ||
list(APPEND shared_libraries_to_archive "${output_dir}/libatomic.so.1") | ||
endif() | ||
endif() | ||
endforeach() | ||
if(shared_libraries_to_archive) | ||
set(output_dir "") | ||
set(install_dir "") | ||
get_compiler_rt_output_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} output_dir) | ||
get_compiler_rt_install_dir(${COMPILER_RT_DEFAULT_TARGET_ARCH} install_dir) | ||
add_custom_command(OUTPUT "${output_dir}/libatomic.a" | ||
COMMAND ${CMAKE_AR} -X32_64 r "${output_dir}/libatomic.a" | ||
${shared_libraries_to_archive} | ||
DEPENDS ${shared_libraries_to_archive}) | ||
install(FILES "${output_dir}/libatomic.a" | ||
DESTINATION ${install_dir}) | ||
add_custom_target(aix-libatomic | ||
DEPENDS "${output_dir}/libatomic.a") | ||
endif() | ||
add_dependencies(${LIB_PARENT_TARGET} aix-libatomic) | ||
endmacro() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
__atomic_compare_exchange | ||
__atomic_compare_exchange_1 | ||
__atomic_compare_exchange_2 | ||
__atomic_compare_exchange_4 | ||
__atomic_compare_exchange_8 | ||
__atomic_exchange | ||
__atomic_exchange_1 | ||
__atomic_exchange_2 | ||
__atomic_exchange_4 | ||
__atomic_exchange_8 | ||
__atomic_fetch_add_1 | ||
__atomic_fetch_add_2 | ||
__atomic_fetch_add_4 | ||
__atomic_fetch_add_8 | ||
__atomic_fetch_and_1 | ||
__atomic_fetch_and_2 | ||
__atomic_fetch_and_4 | ||
__atomic_fetch_and_8 | ||
__atomic_fetch_or_1 | ||
__atomic_fetch_or_2 | ||
__atomic_fetch_or_4 | ||
__atomic_fetch_or_8 | ||
__atomic_fetch_sub_1 | ||
__atomic_fetch_sub_2 | ||
__atomic_fetch_sub_4 | ||
__atomic_fetch_sub_8 | ||
__atomic_fetch_xor_1 | ||
__atomic_fetch_xor_2 | ||
__atomic_fetch_xor_4 | ||
__atomic_fetch_xor_8 | ||
__atomic_is_lock_free | ||
__atomic_load | ||
__atomic_load_1 | ||
__atomic_load_2 | ||
__atomic_load_4 | ||
__atomic_load_8 | ||
__atomic_store | ||
__atomic_store_1 | ||
__atomic_store_2 | ||
__atomic_store_4 | ||
__atomic_store_8 |