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

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 21 19:54:46 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL349992: [gn build] Embed __TEXT __info_plist section into clang binary on macOS (authored by nico, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55984?vs=179237&id=179408#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55984/new/

https://reviews.llvm.org/D55984

Files:
  llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn


Index: llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
===================================================================
--- llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/tools/driver/BUILD.gn
@@ -1,4 +1,5 @@
 import("//llvm/utils/gn/build/symlink_or_copy.gni")
+import("//llvm/version.gni")
 
 symlinks = [
   # target_name, symlink_target pairs: GN doesn't support '+' in rule names.
@@ -33,6 +34,29 @@
   }
 }
 
+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") {
   configs += [ "//llvm/utils/gn/build:clang_code" ]
   deps = [
@@ -61,12 +85,16 @@
     "//llvm/lib/Transforms/Utils",
     "//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 = [
     "cc1_main.cpp",
     "cc1as_main.cpp",
     "cc1gen_reproducer_main.cpp",
     "driver.cpp",
   ]
-
-  # FIXME: Info.plist embedding for mac builds.
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55984.179408.patch
Type: text/x-patch
Size: 1627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181222/e344bd6d/attachment-0001.bin>


More information about the cfe-commits mailing list