[PATCH] D113534: [lld-macho] Avoid warning on -install-name if -dylib is not provided
Vincent Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 16 23:57:58 PST 2021
thevinster updated this revision to Diff 387849.
thevinster added a comment.
Include both pos and neg form of the warning, default to neg
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113534/new/
https://reviews.llvm.org/D113534
Files:
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/install-name.s
Index: lld/test/MachO/install-name.s
===================================================================
--- lld/test/MachO/install-name.s
+++ lld/test/MachO/install-name.s
@@ -2,13 +2,22 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t.o %s
-# RUN: %no_fatal_warnings_lld -o %t.exec %t.o -install_name foo 2>&1 \
-# RUN: | FileCheck --check-prefix=WARN %s
+# RUN: %no_fatal_warnings_lld --warn-dylib-install-name -o %t.exec %t.o \
+# RUN: -install_name foo 2>&1 | FileCheck --check-prefix=WARN %s
# RUN: llvm-objdump --macho --all-headers %t.exec \
# RUN: | FileCheck --check-prefix=NO-ID %s
-# RUN: %no_fatal_warnings_lld -bundle -o %t.bundle %t.o -install_name foo 2>&1 \
-# RUN: | FileCheck --check-prefix=WARN %s
+# RUN: %no_fatal_warnings_lld --warn-dylib-install-name -bundle -o %t.bundle %t.o \
+# RUN: -install_name foo 2>&1 | FileCheck --check-prefix=WARN %s
+# RUN: llvm-objdump --macho --all-headers %t.bundle \
+# RUN: | FileCheck --check-prefix=NO-ID %s
+
+# RUN: %lld -bundle -o %t.bundle %t.o -install_name foo 2>&1
+# RUN: llvm-objdump --macho --all-headers %t.bundle \
+# RUN: | FileCheck --check-prefix=NO-ID %s
+
+# RUN: %lld -bundle --warn-dylib-install-name --warn-no-dylib-install-name \
+# RUN: -o %t.bundle %t.o -install_name foo 2>&1
# RUN: llvm-objdump --macho --all-headers %t.bundle \
# RUN: | FileCheck --check-prefix=NO-ID %s
@@ -16,7 +25,7 @@
# RUN: llvm-objdump --macho --all-headers %t.dylib \
# RUN: | FileCheck --check-prefix=ID %s
-# WARN: warning: -install_name foo: ignored, only has effect with -dylib
+# WARN: warning: -install_name foo: ignored, only has effect with -dylib [--warn-dylib-install-name]
# NO-ID-NOT: LC_ID_DYLIB
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -73,6 +73,12 @@
Group<grp_lld>;
def O : JoinedOrSeparate<["-"], "O">,
HelpText<"Optimize output file size">;
+def warn_no_dylib_install_name: Joined<["--"], "warn-no-dylib-install-name">,
+ HelpText<"Do not warn on -install-name if -dylib is not passed (default)">,
+ Group<grp_lld>;
+def warn_dylib_install_name: Joined<["--"], "warn-dylib-install-name">,
+ HelpText<"Warn on -install-name if -dylib is not passed">,
+ Group<grp_lld>;
// This is a complete Options.td compiled from Apple's ld(1) manpage
// dated 2018-03-07 and cross checked with ld64 source code in repo
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1262,6 +1262,8 @@
config->icfLevel = getICFLevel(args);
config->dedupLiterals = args.hasArg(OPT_deduplicate_literals) ||
config->icfLevel != ICFLevel::none;
+ config->warnDylibInstallName = args.hasFlag(
+ OPT_warn_dylib_install_name, OPT_warn_no_dylib_install_name, false);
// FIXME: Add a commandline flag for this too.
config->zeroModTime = getenv("ZERO_AR_DATE");
@@ -1278,8 +1280,10 @@
#endif
if (const Arg *arg = args.getLastArg(OPT_install_name)) {
- if (config->outputType != MH_DYLIB)
- warn(arg->getAsString(args) + ": ignored, only has effect with -dylib");
+ if (config->warnDylibInstallName && config->outputType != MH_DYLIB)
+ warn(
+ arg->getAsString(args) +
+ ": ignored, only has effect with -dylib [--warn-dylib-install-name]");
else
config->installName = arg->getValue();
} else if (config->outputType == MH_DYLIB) {
Index: lld/MachO/Config.h
===================================================================
--- lld/MachO/Config.h
+++ lld/MachO/Config.h
@@ -122,6 +122,7 @@
bool dataConst = false;
bool dedupLiterals = true;
bool omitDebugInfo = false;
+ bool warnDylibInstallName = false;
uint32_t headerPad;
uint32_t dylibCompatibilityVersion = 0;
uint32_t dylibCurrentVersion = 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113534.387849.patch
Type: text/x-patch
Size: 3973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211117/ed2bcae6/attachment.bin>
More information about the llvm-commits
mailing list