Skip to content

🇫🇷 Bastille branch 🇫🇷 [darwin] build and link with a separate compiler-rt builtins library for device simulators #1553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,10 +1104,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(
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion clang/test/Driver/darwin-ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,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 x86_64-apple-ios13-macabi -mlinker-version=400 -fprofile-instr-generate -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_MACABI_PROFILE %s < %t.log
Expand Down
31 changes: 29 additions & 2 deletions compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -449,15 +458,33 @@ macro(darwin_add_builtin_libraries)
endif()
endforeach()

# We put the x86 sim slices into the archives for their base OS
foreach (os ${ARGN})
# We put the x86 sim slices into the archives for their base OS
# FIXME: Stop doing that in upstream Phab review (blocked by swift side
# support as well).
if(NOT ${os} MATCHES ".*sim$")
set(sim_flags ${${os}sim_builtins_lipo_flags})
# Do not include the arm64 slice in the `lipo` invocation for the device
# libclang_rt.<os>.a . This ensures that `lipo` uses the device arm64
# slice in libclang_rt.<os>.a. The simulator arm64 slice is present only
# in libclang_rt.<os>sim.a .
if (NOT "${sim_flags}" STREQUAL "")
string(REGEX REPLACE ";-arch;arm64.*" "" sim_flags "${sim_flags}")
message(STATUS "adjusted simulator flags for non-sim builtin lib: ${sim_flags}")
endif()
darwin_lipo_libs(clang_rt.${os}
PARENT_TARGET builtins
LIPO_FLAGS ${${os}_builtins_lipo_flags} ${${os}sim_builtins_lipo_flags}
LIPO_FLAGS ${${os}_builtins_lipo_flags} ${sim_flags}
DEPENDS ${${os}_builtins_libs} ${${os}sim_builtins_libs}
OUTPUT_DIR ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
INSTALL_DIR ${COMPILER_RT_LIBRARY_INSTALL_DIR})
else()
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})
endif()
endforeach()
darwin_add_embedded_builtin_libraries()
Expand Down