[clang] dc22182 - [darwin] build and link with a separate compiler-rt builtins library
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 29 15:34:29 PDT 2020
Author: Alex Lorenz
Date: 2020-07-29T15:32:30-07:00
New Revision: dc22182d1f7489239388f7bdd04170573c0652a3
URL: https://github.com/llvm/llvm-project/commit/dc22182d1f7489239388f7bdd04170573c0652a3
DIFF: https://github.com/llvm/llvm-project/commit/dc22182d1f7489239388f7bdd04170573c0652a3.diff
LOG: [darwin] build and link with a separate compiler-rt builtins library
for device simulators
This change separates out the iOS/tvOS/watchOS simulator slices from the "libclang_rt.<os>.a"
fat archive, by moving them out to their own "libclang_rt.<os>sim.a" static archive.
This allows us to build and to link with an arm64 device simulator slice for the simulators running
on Apple Silicons, and to distribute it in one archive alongside the Intel simulator slices.
Differential Revision: https://reviews.llvm.org/D84564
Added:
clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.iossim.a
Modified:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 325dcb7df545..cf8a3e6aee27 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1062,10 +1062,9 @@ void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,
DarwinLibName += Component;
if (!(Opts & RLO_IsEmbedded))
DarwinLibName += "_";
- DarwinLibName += getOSLibraryNameSuffix();
- } else
- DarwinLibName += getOSLibraryNameSuffix(true);
+ }
+ DarwinLibName += getOSLibraryNameSuffix();
DarwinLibName += IsShared ? "_dynamic.dylib" : ".a";
SmallString<128> Dir(getDriver().ResourceDir);
llvm::sys::path::append(
diff --git a/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.iossim.a b/clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.iossim.a
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index ea71142e88c1..82cd36d59f80 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -156,7 +156,7 @@
// RUN: FileCheck -check-prefix=LINK_IOSSIM_PROFILE %s < %t.log
// LINK_IOSSIM_PROFILE: {{ld(.exe)?"}}
// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
-// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
+// LINK_IOSSIM_PROFILE: libclang_rt.iossim.a
// RUN: %clang -target arm64-apple-tvos8.3 -mlinker-version=400 -mtvos-version-min=8.3 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
diff --git a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
index be8d7e733c7a..c37b5e98bcc6 100644
--- a/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -289,6 +289,15 @@ macro(darwin_add_builtin_library name suffix)
endforeach(cflag)
endif()
+ if ("${LIB_OS}" MATCHES ".*sim$")
+ # Pass an explicit -simulator environment to the -target option to ensure
+ # that we don't rely on the architecture to infer whether we're building
+ # for the simulator.
+ string(REGEX REPLACE "sim" "" base_os "${LIB_OS}")
+ list(APPEND builtin_cflags
+ -target "${LIB_ARCH}-apple-${base_os}${DARWIN_${LIBOS}_BUILTIN_MIN_VER}-simulator")
+ endif()
+
set_target_compile_flags(${libname}
${sysroot_flag}
${DARWIN_${LIB_OS}_BUILTIN_MIN_VER_FLAG}
@@ -449,16 +458,13 @@ macro(darwin_add_builtin_libraries)
endif()
endforeach()
- # We put the x86 sim slices into the archives for their base OS
foreach (os ${ARGN})
- if(NOT ${os} MATCHES ".*sim$")
- darwin_lipo_libs(clang_rt.${os}
- PARENT_TARGET builtins
- LIPO_FLAGS ${${os}_builtins_lipo_flags} ${${os}sim_builtins_lipo_flags}
- DEPENDS ${${os}_builtins_libs} ${${os}sim_builtins_libs}
- OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
- INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR})
- endif()
+ darwin_lipo_libs(clang_rt.${os}
+ PARENT_TARGET builtins
+ LIPO_FLAGS ${${os}_builtins_lipo_flags}
+ DEPENDS ${${os}_builtins_libs}
+ OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
+ INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR})
endforeach()
darwin_add_embedded_builtin_libraries()
endmacro()
More information about the cfe-commits
mailing list