forked from OSchip/llvm-project
[gn build] Add libclang_rt.ios.a, libclang_rt.iossim.a to the build
It's built with just-built clang, like all other compiler-rt parts in the GN build. This requires adding some cross build support to the mac toolchain. Also add explicit mmacosx-version-min and miphoneos-version-min flags to the build. ios.a is only built with the arm64 slice, iossim.a only with the x86_64 slice for now. (The latter should maybe become host_cpu when Arm Macs become a common iOS development platform.) With this, it's possible to build chromium/iOS with a GN-built LLVM. Differential Revision: https://reviews.llvm.org/D89260
This commit is contained in:
parent
fe145b66ec
commit
4a96b2e75f
|
@ -42,17 +42,36 @@ config("compiler_defaults") {
|
|||
cflags = target_flags
|
||||
ldflags = target_flags + target_ldflags
|
||||
|
||||
if (host_os == "mac" && clang_base_path != "") {
|
||||
if ((current_os == "ios" || current_os == "mac") && clang_base_path != "") {
|
||||
if (current_os == "ios" && current_cpu == "arm64") {
|
||||
sdk_path = ios_sdk_path
|
||||
} else if (current_os == "ios" && current_cpu == "x64") {
|
||||
sdk_path = iossim_sdk_path
|
||||
} else if (current_os == "mac") {
|
||||
sdk_path = mac_sdk_path
|
||||
}
|
||||
cflags += [
|
||||
"-isysroot",
|
||||
mac_sdk_path,
|
||||
sdk_path,
|
||||
]
|
||||
ldflags += [
|
||||
"-isysroot",
|
||||
mac_sdk_path,
|
||||
sdk_path,
|
||||
]
|
||||
}
|
||||
|
||||
# Mostly for compiler-rt, see compiler-rt/cmake/config-ix.cmake
|
||||
if (current_os == "ios") {
|
||||
asmflags += [ "-miphoneos-version-min=8.0" ]
|
||||
cflags += [ "-miphoneos-version-min=8.0" ]
|
||||
ldflags += [ "-miphoneos-version-min=8.0" ]
|
||||
}
|
||||
if (current_os == "mac") {
|
||||
asmflags += [ "-mmacosx-version-min=10.10" ]
|
||||
cflags += [ "-mmacosx-version-min=10.10" ]
|
||||
ldflags += [ "-mmacosx-version-min=10.10" ]
|
||||
}
|
||||
|
||||
if (host_os != "win") {
|
||||
if (is_debug) {
|
||||
cflags += [ "-g" ]
|
||||
|
@ -296,7 +315,7 @@ config("no_rtti") {
|
|||
# To make an archive that can be distributed, you need to remove this config and
|
||||
# set complete_static_lib.
|
||||
config("thin_archive") {
|
||||
if (current_os != "win" && current_os != "mac") {
|
||||
if (current_os != "ios" && current_os != "mac" && current_os != "win") {
|
||||
arflags = [ "-T" ]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,12 @@ declare_args() {
|
|||
# but that makes `gn gen` take twice as long and almost everyone has Xcode
|
||||
# installed. So require that people who don't have it installed set a gn arg.
|
||||
if (mac_use_commandline_tools_sdk) {
|
||||
ios_sdk_path = "/Library/Developer/CommandLineTools/SDKs/iPhoneOS.sdk"
|
||||
iossim_sdk_path =
|
||||
"/Library/Developer/CommandLineTools/SDKs/iPhoneSimulator.sdk"
|
||||
mac_sdk_path = "/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk"
|
||||
} else {
|
||||
ios_sdk_path = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk"
|
||||
iossim_sdk_path = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk"
|
||||
mac_sdk_path = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk"
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ template("unix_toolchain") {
|
|||
}
|
||||
|
||||
tool("alink") {
|
||||
if (current_os == "mac") {
|
||||
if (current_os == "ios" || current_os == "mac") {
|
||||
command = "libtool -D -static -no_warning_for_no_symbols {{arflags}} -o {{output}} {{inputs}}"
|
||||
} else {
|
||||
# Remove the output file first so that ar doesn't try to modify the
|
||||
|
@ -70,7 +70,7 @@ template("unix_toolchain") {
|
|||
default_output_dir = "{{root_out_dir}}/lib"
|
||||
}
|
||||
|
||||
if (current_os == "mac") {
|
||||
if (current_os == "ios" || current_os == "mac") {
|
||||
# gn < 1693 (e214b5d35898) doesn't support |frameworks|, requiring
|
||||
# frameworks to be listed in |libs|, but gn >= 1808 (3028c6a426a4) forbids
|
||||
# frameworks from appearing in |libs|. This assertion provides a helpful
|
||||
|
@ -89,7 +89,7 @@ template("unix_toolchain") {
|
|||
|
||||
tool("solink") {
|
||||
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
||||
if (current_os == "mac") {
|
||||
if (current_os == "ios" || current_os == "mac") {
|
||||
command = "$ld -shared {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}}"
|
||||
default_output_extension = ".dylib"
|
||||
} else {
|
||||
|
@ -105,7 +105,7 @@ template("unix_toolchain") {
|
|||
|
||||
tool("solink_module") {
|
||||
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
||||
if (current_os == "mac") {
|
||||
if (current_os == "ios" || current_os == "mac") {
|
||||
command = "$ld -shared {{ldflags}} -Wl,-flat_namespace -Wl,-undefined,suppress -o $outfile {{inputs}} {{libs}} {{frameworks}}"
|
||||
default_output_extension = ".dylib"
|
||||
} else {
|
||||
|
@ -120,7 +120,7 @@ template("unix_toolchain") {
|
|||
|
||||
tool("link") {
|
||||
outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
|
||||
if (current_os == "mac") {
|
||||
if (current_os == "ios" || current_os == "mac") {
|
||||
command =
|
||||
"$ld {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}}"
|
||||
} else {
|
||||
|
@ -141,7 +141,7 @@ template("unix_toolchain") {
|
|||
description = "COPY {{source}} {{output}}"
|
||||
}
|
||||
|
||||
if (current_os == "mac") {
|
||||
if (current_os == "ios" || current_os == "mac") {
|
||||
tool("copy_bundle_data") {
|
||||
# http://serverfault.com/q/209888/43689
|
||||
_copydir = "mkdir -p {{output}} && cd {{source}} && " +
|
||||
|
@ -164,7 +164,7 @@ template("unix_toolchain") {
|
|||
}
|
||||
|
||||
unix_toolchain("unix") {
|
||||
if (current_os != "mac") {
|
||||
if (current_os != "ios" && current_os != "mac") {
|
||||
ar = "ar"
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ template("stage2_unix_toolchain") {
|
|||
"//:clang($host_toolchain)",
|
||||
"//:lld($host_toolchain)",
|
||||
]
|
||||
if (current_os != "mac") {
|
||||
if (current_os != "ios" && current_os != "mac") {
|
||||
ar = "bin/llvm-ar"
|
||||
deps += [ "//:llvm-ar($host_toolchain)" ]
|
||||
}
|
||||
|
@ -219,6 +219,22 @@ if (android_ndk_path != "") {
|
|||
}
|
||||
}
|
||||
|
||||
if (host_os == "mac") {
|
||||
stage2_unix_toolchain("stage2_ios_aarch64") {
|
||||
toolchain_args = {
|
||||
current_os = "ios"
|
||||
current_cpu = "arm64"
|
||||
}
|
||||
}
|
||||
|
||||
stage2_unix_toolchain("stage2_iossim_x64") {
|
||||
toolchain_args = {
|
||||
current_os = "ios"
|
||||
current_cpu = "x64"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
toolchain("win") {
|
||||
cl = "cl"
|
||||
link = "link"
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
import("//llvm/triples.gni")
|
||||
import("//llvm/utils/gn/build/toolchain/compiler.gni")
|
||||
|
||||
# Flags in this file are passed both to the compiler that's building
|
||||
# compiler-rt at build time (via normal gn cflags/ldflags), as well as to the
|
||||
# compiler building compiler-rt test programs at test time (via
|
||||
# COMPILER_RT_TEST_COMPILER_CFLAGS).
|
||||
|
||||
target_flags = []
|
||||
target_ldflags = []
|
||||
|
||||
|
@ -14,6 +19,26 @@ if (current_os == "android") {
|
|||
if (current_cpu == "arm") {
|
||||
target_flags += [ "-march=armv7-a" ]
|
||||
}
|
||||
} else if (current_os == "ios") {
|
||||
if (current_cpu == "arm64") {
|
||||
target_flags += [
|
||||
"-arch",
|
||||
"arm64",
|
||||
]
|
||||
target_ldflags += [
|
||||
"-arch",
|
||||
"arm64",
|
||||
]
|
||||
} else if (current_cpu == "x64") {
|
||||
target_flags += [
|
||||
"-arch",
|
||||
"x86_64",
|
||||
]
|
||||
target_ldflags += [
|
||||
"-arch",
|
||||
"x86_64",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
if (current_cpu == "x86") {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import("//llvm/lib/Target/targets.gni")
|
||||
import("//llvm/utils/gn/build/toolchain/compiler.gni")
|
||||
|
||||
# In the GN build, compiler-rt is always built by just-built clang and lld.
|
||||
|
@ -10,10 +11,20 @@ if (android_ndk_path != "") {
|
|||
"//llvm/utils/gn/build/toolchain:stage2_android_arm",
|
||||
]
|
||||
}
|
||||
|
||||
group("compiler-rt") {
|
||||
deps = []
|
||||
foreach(toolchain, supported_toolchains) {
|
||||
deps += [ "//compiler-rt/lib($toolchain)" ]
|
||||
}
|
||||
|
||||
# FIXME: Do this only if a gn arg compiler_rt_enable_ios is set?
|
||||
# That would match the cmake build.
|
||||
if (host_os == "mac") {
|
||||
if (llvm_build_AArch64) {
|
||||
deps += [ "//compiler-rt/lib/builtins(//llvm/utils/gn/build/toolchain:stage2_ios_aarch64)" ]
|
||||
}
|
||||
if (llvm_build_X86) {
|
||||
deps += [ "//compiler-rt/lib/builtins(//llvm/utils/gn/build/toolchain:stage2_iossim_x64)" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ static_library("builtins") {
|
|||
output_dir = crt_current_out_dir
|
||||
if (current_os == "mac") {
|
||||
output_name = "clang_rt.osx"
|
||||
} else if (current_os == "ios" && current_cpu == "arm64") {
|
||||
output_name = "clang_rt.ios"
|
||||
} else if (current_os == "ios" && current_cpu == "x64") {
|
||||
output_name = "clang_rt.iossim"
|
||||
} else {
|
||||
output_name = "clang_rt.builtins$crt_current_target_suffix"
|
||||
}
|
||||
|
@ -177,7 +181,7 @@ static_library("builtins") {
|
|||
sources += [ "clear_cache.c" ]
|
||||
}
|
||||
|
||||
if (current_os == "mac") {
|
||||
if (current_os == "mac" || current_os == "ios") {
|
||||
sources += [
|
||||
"atomic_flag_clear.c",
|
||||
"atomic_flag_clear_explicit.c",
|
||||
|
@ -496,8 +500,7 @@ static_library("builtins") {
|
|||
}
|
||||
}
|
||||
|
||||
# Currently unused but necessary to make the sync_source_lists_from_cmake.py
|
||||
# happy.
|
||||
# Currently unused but necessary to make sync_source_lists_from_cmake.py happy.
|
||||
source_set("_unused") {
|
||||
sources = [
|
||||
# Thumb1
|
||||
|
|
|
@ -26,7 +26,7 @@ if (clang_enable_per_target_runtime_dir) {
|
|||
if (current_os == "android") {
|
||||
crt_current_target_suffix += "-android"
|
||||
}
|
||||
} else if (current_os == "mac") {
|
||||
} else if (current_os == "ios" || current_os == "mac") {
|
||||
crt_current_out_dir = "$clang_resource_dir/lib/darwin"
|
||||
} else {
|
||||
assert(false, "unimplemented current_os " + current_os)
|
||||
|
|
|
@ -7,7 +7,7 @@ if (current_cpu == "x86") {
|
|||
llvm_current_triple = "x86_64-unknown-freebsd"
|
||||
} else if (current_os == "linux") {
|
||||
llvm_current_triple = "x86_64-unknown-linux-gnu"
|
||||
} else if (current_os == "mac") {
|
||||
} else if (current_os == "ios" || current_os == "mac") {
|
||||
llvm_current_triple = "x86_64-apple-darwin"
|
||||
} else if (current_os == "win") {
|
||||
llvm_current_triple = "x86_64-pc-windows-msvc"
|
||||
|
@ -19,7 +19,7 @@ if (current_cpu == "x86") {
|
|||
} else if (current_cpu == "arm64") {
|
||||
if (current_os == "android") {
|
||||
llvm_current_triple = "aarch64-linux-android29"
|
||||
} else if (current_os == "mac") {
|
||||
} else if (current_os == "ios" || current_os == "mac") {
|
||||
llvm_current_triple = "arm64-apple-darwin"
|
||||
}
|
||||
} else if (current_cpu == "ppc64") {
|
||||
|
|
Loading…
Reference in New Issue