[PATCH] D84564: [darwin] build and link with a separate compiler-rt builtins library for device simulators
Alex Lorenz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 24 16:12:13 PDT 2020
arphaman created this revision.
arphaman added reviewers: steven_wu, dexonsmith.
Herald added subscribers: Sanitizers, ributzka, jkorous, kristof.beyls, mgorny, dberris.
Herald added projects: clang, Sanitizers.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D84564
Files:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/Inputs/resource_dir/lib/darwin/libclang_rt.iossim.a
clang/test/Driver/darwin-ld.c
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===================================================================
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -289,6 +289,15 @@
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 @@
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()
Index: clang/test/Driver/darwin-ld.c
===================================================================
--- clang/test/Driver/darwin-ld.c
+++ 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
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1062,10 +1062,9 @@
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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84564.280612.patch
Type: text/x-patch
Size: 3096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200724/37e4a398/attachment-0001.bin>
More information about the cfe-commits
mailing list