[PATCH] D26690: [Driver] Infer the correct option to ld64 for -fembed-bitcode
Steven Wu via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 15 12:28:15 PST 2016
steven_wu created this revision.
steven_wu added a reviewer: mehdi_amini.
steven_wu added a subscriber: cfe-commits.
-fembed-bitcode infers -bitcode_bundle to ld64 but it is not correctly
passed when using LTO. LTO is a special case of -fembed-bitcode which
it doesn't require embed the bitcode in a special section in the object
file but it requires linker to save that as part of the final executable.
rdar://problem/28461437
https://reviews.llvm.org/D26690
Files:
lib/Driver/Tools.cpp
test/Driver/embed-bitcode.c
Index: test/Driver/embed-bitcode.c
===================================================================
--- test/Driver/embed-bitcode.c
+++ test/Driver/embed-bitcode.c
@@ -41,3 +41,15 @@
// CHECK-MARKER: -fembed-bitcode=marker
// CHECK-MARKER-NOT: -cc1
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=6.0 %s -fembed-bitcode=all -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-LINKER
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=6.0 %s -fembed-bitcode=marker -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-LINKER
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=6.0 %s -flto=full -fembed-bitcode=bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-LINKER
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=6.0 %s -flto=thin -fembed-bitcode=bitcode -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-LINKER
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=6.0 %s -fembed-bitcode=off -fintegrated-as 2>&1 -### | FileCheck %s -check-prefix=CHECK-NO-LINKER
+// CHECK-LINKER: ld
+// CHECK-LINKER: -bitcode_bundle
+// CHECK-NO-LINKER-NOT: -bitcode_bundle
+
+// RUN: %clang -target armv7-apple-darwin -miphoneos-version-min=5.0 %s -fembed-bitcode -### 2>&1 | \
+// RUN: FileCheck %s -check-prefix=CHECK-PLATFORM-UNSUPPORTED
+// CHECK-PLATFORM-UNSUPPORTED: -fembed-bitcode is not supported on versions of iOS prior to 6.0
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -8321,14 +8321,17 @@
else
CmdArgs.push_back("-no_pie");
}
+
// for embed-bitcode, use -bitcode_bundle in linker command
- if (C.getDriver().embedBitcodeEnabled() ||
- C.getDriver().embedBitcodeMarkerOnly()) {
- // Check if the toolchain supports bitcode build flow.
- if (MachOTC.SupportsEmbeddedBitcode())
- CmdArgs.push_back("-bitcode_bundle");
- else
- D.Diag(diag::err_drv_bitcode_unsupported_on_toolchain);
+ if (Arg *A = Args.getLastArg(options::OPT_fembed_bitcode_EQ)) {
+ StringRef Value = A->getValue();
+ if (Value != "off") {
+ // Check if the toolchain supports bitcode build flow.
+ if (MachOTC.SupportsEmbeddedBitcode())
+ CmdArgs.push_back("-bitcode_bundle");
+ else
+ D.Diag(diag::err_drv_bitcode_unsupported_on_toolchain);
+ }
}
Args.AddLastArg(CmdArgs, options::OPT_prebind);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26690.78051.patch
Type: text/x-patch
Size: 2493 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161115/5ffa2090/attachment.bin>
More information about the cfe-commits
mailing list