Skip to content

Commit 46a3268

Browse files
committed
[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
1 parent b9a539c commit 46a3268

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lld/wasm/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct Configuration {
2727
bool compressRelocations;
2828
bool demangle;
2929
bool disableVerify;
30+
bool experimentalPic;
3031
bool emitRelocs;
3132
bool exportAll;
3233
bool exportDynamic;

lld/wasm/Driver.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ static void readConfigs(opt::InputArgList &args) {
332332
config->demangle = args.hasFlag(OPT_demangle, OPT_no_demangle, true);
333333
config->disableVerify = args.hasArg(OPT_disable_verify);
334334
config->emitRelocs = args.hasArg(OPT_emit_relocs);
335+
config->experimentalPic = args.hasArg(OPT_experimental_pic);
335336
config->entry = getEntry(args);
336337
config->exportAll = args.hasArg(OPT_export_all);
337338
config->exportTable = args.hasArg(OPT_export_table);
@@ -468,6 +469,23 @@ static void checkOptions(opt::InputArgList &args) {
468469
if (config->sharedMemory)
469470
error("-r and --shared-memory may not be used together");
470471
}
472+
473+
// To begin to prepare for Module Linking-style shared libraries, start
474+
// warning about uses of `-shared` and related flags outside of Experimental
475+
// mode, to give anyone using them a heads-up that they will be changing.
476+
//
477+
// Also, warn about flags which request explicit exports.
478+
if (!config->experimentalPic) {
479+
// -shared will change meaning when Module Linking is implemented.
480+
if (config->shared) {
481+
warn("creating shared libraries, with -shared, is not yet stable");
482+
}
483+
484+
// -pie will change meaning when Module Linking is implemented.
485+
if (config->pie) {
486+
warn("creating PIEs, with -pie, is not yet stable");
487+
}
488+
}
471489
}
472490

473491
// Force Sym to be entered in the output. Used for -u or equivalent.

lld/wasm/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,7 @@ def thinlto_cache_dir: J<"thinlto-cache-dir=">,
200200
defm thinlto_cache_policy: Eq<"thinlto-cache-policy", "Pruning policy for the ThinLTO cache">;
201201
def thinlto_jobs: J<"thinlto-jobs=">,
202202
HelpText<"Number of ThinLTO jobs. Default to --threads=">;
203+
204+
// Experimental PIC mode.
205+
def experimental_pic: F<"experimental-pic">,
206+
HelpText<"Enable Experimental PIC">;

0 commit comments

Comments
 (0)