[PATCH] D52003: [WebAssembly] Add --export-default/--no-export-default options
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 25 14:51:49 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL343034: [WebAssembly] Add --export-default/--no-export-default options (authored by sbc, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D52003?vs=165147&id=166998#toc
Repository:
rL LLVM
https://reviews.llvm.org/D52003
Files:
lld/trunk/test/wasm/visibility-hidden.ll
lld/trunk/wasm/Config.h
lld/trunk/wasm/Driver.cpp
lld/trunk/wasm/Options.td
lld/trunk/wasm/Symbols.cpp
Index: lld/trunk/test/wasm/visibility-hidden.ll
===================================================================
--- lld/trunk/test/wasm/visibility-hidden.ll
+++ lld/trunk/test/wasm/visibility-hidden.ll
@@ -2,11 +2,17 @@
; RUN: llc -filetype=obj %S/Inputs/hidden.ll -o %t2.o
; RUN: rm -f %t2.a
; RUN: llvm-ar rcs %t2.a %t2.o
-; RUN: wasm-ld %t.o %t2.a -o %t.wasm
-; RUN: obj2yaml %t.wasm | FileCheck %s
; Test that hidden symbols are not exported, whether pulled in from an archive
; or directly.
+; RUN: wasm-ld %t.o %t2.a -o %t.wasm
+; RUN: obj2yaml %t.wasm | FileCheck %s
+
+; Test that symbols with default visitiblity are not exported when
+; --no-export-default is passed.
+; RUN: wasm-ld --no-export-default %t.o %t2.a -o %t.nodef.wasm
+; RUN: obj2yaml %t.nodef.wasm | FileCheck %s -check-prefix=NO-DEFAULT
+
target triple = "wasm32-unknown-unknown"
@@ -53,3 +59,11 @@
; CHECK-NEXT: Kind: FUNCTION
; CHECK-NEXT: Index: 5
; CHECK-NEXT: - Type:
+
+
+; NO-DEFAULT: - Type: EXPORT
+; NO-DEFAULT-NEXT: Exports:
+; NO-DEFAULT-NEXT: - Name: memory
+; NO-DEFAULT-NEXT: Kind: MEMORY
+; NO-DEFAULT-NEXT: Index: 0
+; NO-DEFAULT-NEXT: - Type:
Index: lld/trunk/wasm/Driver.cpp
===================================================================
--- lld/trunk/wasm/Driver.cpp
+++ lld/trunk/wasm/Driver.cpp
@@ -373,6 +373,8 @@
Config->DisableVerify = Args.hasArg(OPT_disable_verify);
Config->Entry = getEntry(Args, Args.hasArg(OPT_relocatable) ? "" : "_start");
Config->ExportAll = Args.hasArg(OPT_export_all);
+ Config->ExportDefault = Args.hasFlag(OPT_export_default,
+ OPT_no_export_default, true);
Config->ExportTable = Args.hasArg(OPT_export_table);
errorHandler().FatalWarnings =
Args.hasFlag(OPT_fatal_warnings, OPT_no_fatal_warnings, false);
Index: lld/trunk/wasm/Symbols.cpp
===================================================================
--- lld/trunk/wasm/Symbols.cpp
+++ lld/trunk/wasm/Symbols.cpp
@@ -105,6 +105,9 @@
if (ForceExport || Config->ExportAll)
return true;
+ if (!Config->ExportDefault)
+ return false;
+
return !isHidden();
}
Index: lld/trunk/wasm/Options.td
===================================================================
--- lld/trunk/wasm/Options.td
+++ lld/trunk/wasm/Options.td
@@ -30,6 +30,10 @@
"Demangle symbol names",
"Do not demangle symbol names">;
+defm export_default: B<"export-default",
+ "Export symbols marked as 'default' visibility (default)",
+ "Do not export symbols marked as 'default' visibility">;
+
def entry: S<"entry">, MetaVarName<"<entry>">,
HelpText<"Name of entry point symbol">;
Index: lld/trunk/wasm/Config.h
===================================================================
--- lld/trunk/wasm/Config.h
+++ lld/trunk/wasm/Config.h
@@ -24,6 +24,7 @@
bool Demangle;
bool DisableVerify;
bool ExportAll;
+ bool ExportDefault;
bool ExportTable;
bool GcSections;
bool ImportMemory;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52003.166998.patch
Type: text/x-patch
Size: 3062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180925/372e9849/attachment.bin>
More information about the llvm-commits
mailing list