[PATCH] D159095: [lld-macho]Add an option to suppress warnings when autohide symbols are in the list of exported_symbols.
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 29 07:20:12 PDT 2023
oontvoo updated this revision to Diff 554324.
oontvoo added a comment.
refactor
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159095/new/
https://reviews.llvm.org/D159095
Files:
lld/MachO/Driver.cpp
lld/MachO/Options.td
lld/test/MachO/export-options.s
Index: lld/test/MachO/export-options.s
===================================================================
--- lld/test/MachO/export-options.s
+++ lld/test/MachO/export-options.s
@@ -153,6 +153,9 @@
# RUN: not %lld -dylib -exported_symbol "_foo" %t/autohide-private-extern.o \
# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=AUTOHIDE-PRIVATE
+## Test that the warning/error message can be suppressed.
+# RUN: %lld -dylib -exported_symbol "_foo" %t/autohide-private-extern.o -no_warn_export_hidden -o %t/autohide-pe-no-warn.out
+
# RUN: not %lld -dylib -exported_symbol "_foo" %t/autohide.o \
# RUN: %t/glob-private-extern.o -o /dev/null 2>&1 | \
# RUN: FileCheck %s --check-prefix=AUTOHIDE-PRIVATE
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -684,6 +684,10 @@
HelpText<"Suppress warnings for static initializers in the output">,
Flags<[HelpHidden]>,
Group<grp_rare>;
+def no_warn_export_hidden : Flag<["-"], "no_warn_export_hidden">,
+ HelpText<"Suppress warnings for exporting weakdef-can-be-hidden symbols in the output">,
+ Flags<[HelpHidden]>,
+ Group<grp_rare>;
def unaligned_pointers : Separate<["-"], "unaligned_pointers">,
MetaVarName<"<treatment>">,
HelpText<"Handle unaligned pointers in __DATA segments according to <treatment>: warning, error, or suppress (default for arm64e is error, otherwise suppress)">,
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -1354,7 +1354,7 @@
}
}
-static void handleExplicitExports() {
+static void handleExplicitExports(bool warnExportHidden) {
if (config->hasExplicitExports) {
parallelForEach(symtab->getSymbols(), [](Symbol *sym) {
if (auto *defined = dyn_cast<Defined>(sym)) {
@@ -1366,7 +1366,7 @@
// it is explicitly exported.
// The former can be exported but the latter cannot.
defined->privateExtern = false;
- } else {
+ } else if (warnExportHidden) {
warn("cannot export hidden symbol " + toString(*defined) +
"\n>>> defined in " + toString(defined->getFile()));
}
@@ -1903,10 +1903,12 @@
addSynthenticMethnames();
createAliases();
+ const bool warnExportHidden =
+ !args.hasFlag(OPT_no_warn_export_hidden, false);
// If we are in "explicit exports" mode, hide everything that isn't
// explicitly exported. Do this before running LTO so that LTO can better
// optimize.
- handleExplicitExports();
+ handleExplicitExports(warnExportHidden);
bool didCompileBitcodeFiles = compileBitcodeFiles();
@@ -1923,7 +1925,7 @@
// cross-module references to hidden symbols under ThinLTO. Thus, if we
// compiled any bitcode files, we must redo the symbol hiding.
if (didCompileBitcodeFiles)
- handleExplicitExports();
+ handleExplicitExports(warnExportHidden);
replaceCommonSymbols();
StringRef orderFile = args.getLastArgValue(OPT_order_file);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159095.554324.patch
Type: text/x-patch
Size: 3180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230829/c344eacb/attachment.bin>
More information about the llvm-commits
mailing list