[gn build] Embed __TEXT __info_plist section into clang binary on macOS

Verified by comparing the output of `otool -P bin/clang` between the GN and the
CMake build.

Differential Revision: https://reviews.llvm.org/D55984

llvm-svn: 349992
This commit is contained in:
Nico Weber 2018-12-22 03:51:10 +00:00
parent 6399c5a3ba
commit 729e3c0c0e
1 changed files with 30 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import("//llvm/utils/gn/build/symlink_or_copy.gni") import("//llvm/utils/gn/build/symlink_or_copy.gni")
import("//llvm/version.gni")
symlinks = [ symlinks = [
# target_name, symlink_target pairs: GN doesn't support '+' in rule names. # target_name, symlink_target pairs: GN doesn't support '+' in rule names.
@ -33,6 +34,29 @@ group("symlinks") {
} }
} }
if (host_os == "mac") {
action("write_info_plist") {
script = "//llvm/utils/gn/build/write_cmake_config.py"
sources = [
"Info.plist.in",
]
outputs = [
"$target_gen_dir/Info.plist",
]
args = [
"-o",
rebase_path(outputs[0], root_out_dir),
rebase_path(sources[0], root_out_dir),
"TOOL_INFO_BUILD_VERSION=$llvm_version_major.$llvm_version_minor",
"TOOL_INFO_NAME=clang",
"TOOL_INFO_UTI=org.llvm.clang",
"TOOL_INFO_VERSION=$llvm_version",
]
}
}
executable("clang") { executable("clang") {
configs += [ "//llvm/utils/gn/build:clang_code" ] configs += [ "//llvm/utils/gn/build:clang_code" ]
deps = [ deps = [
@ -61,12 +85,16 @@ executable("clang") {
"//llvm/lib/Transforms/Utils", "//llvm/lib/Transforms/Utils",
"//llvm/lib/Transforms/Vectorize", "//llvm/lib/Transforms/Vectorize",
] ]
if (host_os == "mac") {
deps += [ ":write_info_plist" ]
plist = get_target_outputs(":write_info_plist")
ldflags = [ "-Wl,-sectcreate,__TEXT,__info_plist," +
rebase_path(plist[0], root_out_dir) ]
}
sources = [ sources = [
"cc1_main.cpp", "cc1_main.cpp",
"cc1as_main.cpp", "cc1as_main.cpp",
"cc1gen_reproducer_main.cpp", "cc1gen_reproducer_main.cpp",
"driver.cpp", "driver.cpp",
] ]
# FIXME: Info.plist embedding for mac builds.
} }