[lld] 46a3268 - [WebAssembly] Add warnings for -shared and -pie

Dan Gohman via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 25 15:59:22 PDT 2020


Author: Dan Gohman
Date: 2020-06-25T15:55:46-07:00
New Revision: 46a32683123a05b58302f10dc4c270519c80115a

URL: https://github.com/llvm/llvm-project/commit/46a32683123a05b58302f10dc4c270519c80115a
DIFF: https://github.com/llvm/llvm-project/commit/46a32683123a05b58302f10dc4c270519c80115a.diff

LOG: [WebAssembly] Add warnings for -shared and -pie

The meaning of -shared and -pie are expected to be changed in the
future when Module Linking-style libraries are implemented. Begin
issuing warnings to give people a heads-up that they will be changing.

For compatibility with Emscripten, add a --experimental-pic flag which
disables these warnings.

Differential Revision: https://reviews.llvm.org/D81760

Added: 
    

Modified: 
    lld/wasm/Config.h
    lld/wasm/Driver.cpp
    lld/wasm/Options.td

Removed: 
    


################################################################################
diff  --git a/lld/wasm/Config.h b/lld/wasm/Config.h
index 4a1f7a69d079..cae2852baf86 100644
--- a/lld/wasm/Config.h
+++ b/lld/wasm/Config.h
@@ -27,6 +27,7 @@ struct Configuration {
   bool compressRelocations;
   bool demangle;
   bool disableVerify;
+  bool experimentalPic;
   bool emitRelocs;
   bool exportAll;
   bool exportDynamic;

diff  --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 636aa6509b25..d0805bf3b303 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -332,6 +332,7 @@ static void readConfigs(opt::InputArgList &args) {
   config->demangle = args.hasFlag(OPT_demangle, OPT_no_demangle, true);
   config->disableVerify = args.hasArg(OPT_disable_verify);
   config->emitRelocs = args.hasArg(OPT_emit_relocs);
+  config->experimentalPic = args.hasArg(OPT_experimental_pic);
   config->entry = getEntry(args);
   config->exportAll = args.hasArg(OPT_export_all);
   config->exportTable = args.hasArg(OPT_export_table);
@@ -468,6 +469,23 @@ static void checkOptions(opt::InputArgList &args) {
     if (config->sharedMemory)
       error("-r and --shared-memory may not be used together");
   }
+
+  // To begin to prepare for Module Linking-style shared libraries, start
+  // warning about uses of `-shared` and related flags outside of Experimental
+  // mode, to give anyone using them a heads-up that they will be changing.
+  //
+  // Also, warn about flags which request explicit exports.
+  if (!config->experimentalPic) {
+    // -shared will change meaning when Module Linking is implemented.
+    if (config->shared) {
+      warn("creating shared libraries, with -shared, is not yet stable");
+    }
+
+    // -pie will change meaning when Module Linking is implemented.
+    if (config->pie) {
+      warn("creating PIEs, with -pie, is not yet stable");
+    }
+  }
 }
 
 // Force Sym to be entered in the output. Used for -u or equivalent.

diff  --git a/lld/wasm/Options.td b/lld/wasm/Options.td
index 241050922ea8..16c784f74828 100644
--- a/lld/wasm/Options.td
+++ b/lld/wasm/Options.td
@@ -200,3 +200,7 @@ def thinlto_cache_dir: J<"thinlto-cache-dir=">,
 defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
 def thinlto_jobs: J<"thinlto-jobs=">,
   HelpText<"Number of ThinLTO jobs. Default to --threads=">;
+
+// Experimental PIC mode.
+def experimental_pic: F<"experimental-pic">,
+  HelpText<"Enable Experimental PIC">;


        


More information about the llvm-commits mailing list