diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index ec668e294d6d72d0d9dad5a34a62dc02366fc2be..9ee71601b5f88eb3d8fd017fc05c5fb60dec5439 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -818,7 +818,19 @@ if(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC) LINK_FLAGS ${COMPILER_RT_LIBATOMIC_LINK_FLAGS} DEPS ${BUILTIN_DEPS} PARENT_TARGET builtins-standalone-atomic) - endif() + # OHOS_LOCAL begin + if(OHOS) + # Build static atomic library also. + add_compiler_rt_runtime(clang_rt.atomic + STATIC + ARCHS ${arch} + SOURCES atomic.c + LINK_FLAGS ${COMPILER_RT_LIBATOMIC_LINK_FLAGS} + DEPS ${BUILTIN_DEPS} + PARENT_TARGET builtins-standalone-atomic) + endif() + # OHOS_LOCAL end + endif() endforeach() # FIXME: On AIX, we have to archive built shared libraries into a static # archive, i.e., libatomic.a. Once cmake adds support of such usage for AIX, diff --git a/llvm-build/build.py b/llvm-build/build.py index f754b1f85fcef4fe2b08d2e266726f4b60f22d20..a0819e14871841004ea6798cc47c60993fda72ea 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -1088,6 +1088,12 @@ class SysrootComposer(BuildUtils): self.check_copy_file(static_zlib, dest_usr_lib) + def copy_crt_lib_to_sysroot(self, crt_install, src_crt_name, dst_crt_name, llvm_triple, multilib_suffix): + src = os.path.join(crt_install, 'lib', llvm_triple, multilib_suffix, + 'libclang_rt.' + src_crt_name) + dst = self.merge_out_path('sysroot', llvm_triple, 'usr', 'lib', multilib_suffix, dst_crt_name) + self.check_copy_file(src, dst) + class LlvmLibs(BuildUtils): def __init__(self, build_config, sysroot_composer, llvm_package): @@ -1354,6 +1360,7 @@ class LlvmLibs(BuildUtils): crt_defines['COMPILER_RT_HWASAN_WITH_INTERCEPTORS'] = 'OFF' crt_defines['COMPILER_RT_BUILD_SANITIZERS'] = \ 'OFF' if llvm_triple == self.liteos_triple('arm') or first_time else 'ON' + crt_defines['COMPILER_RT_BUILD_STANDALONE_LIBATOMIC'] = 'OFF' if first_time else 'ON' crt_defines['COMPILER_RT_DEFAULT_TARGET_TRIPLE'] = llvm_triple crt_cmake_path = os.path.abspath(os.path.join(self.build_config.LLVM_PROJECT_DIR, 'compiler-rt')) self.rm_cmake_cache(crt_path) @@ -1368,6 +1375,16 @@ class LlvmLibs(BuildUtils): target=None, install=True) + # Install needed compiler-rt to sysroot + if not first_time: + if llvm_triple.endswith(self.build_config.OPENHOS_SFX): + self.sysroot_composer.copy_crt_lib_to_sysroot(crt_install, + 'atomic.a', 'libatomic.a', + llvm_triple, multilib_suffix) + self.sysroot_composer.copy_crt_lib_to_sysroot(crt_install, + 'atomic.so', 'libatomic.so', + llvm_triple, multilib_suffix) + def build_libomp(self, llvm_install, arch,