diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -122,6 +122,7 @@ bool dataConst = false; bool dedupLiterals = true; bool omitDebugInfo = false; + bool warnStrict = false; uint32_t headerPad; uint32_t dylibCompatibilityVersion = 0; uint32_t dylibCurrentVersion = 0; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -1258,6 +1258,7 @@ config->icfLevel = getICFLevel(args); config->dedupLiterals = args.hasArg(OPT_deduplicate_literals) || config->icfLevel != ICFLevel::none; + config->warnStrict = args.hasArg(OPT_warn_strict); // FIXME: Add a commandline flag for this too. config->zeroModTime = getenv("ZERO_AR_DATE"); @@ -1274,7 +1275,7 @@ #endif if (const Arg *arg = args.getLastArg(OPT_install_name)) { - if (config->outputType != MH_DYLIB) + if (config->warnStrict && config->outputType != MH_DYLIB) warn(arg->getAsString(args) + ": ignored, only has effect with -dylib"); else config->installName = arg->getValue(); diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -73,6 +73,9 @@ Group; def O : JoinedOrSeparate<["-"], "O">, HelpText<"Optimize output file size">; +def warn_strict: Joined<["--"], "warn-strict">, + HelpText<"Warn on extra checks that ld64 does not perform">, + Group; // 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 diff --git a/lld/test/MachO/install-name.s b/lld/test/MachO/install-name.s --- a/lld/test/MachO/install-name.s +++ b/lld/test/MachO/install-name.s @@ -2,13 +2,17 @@ # 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-strict -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-strict -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