Skip to content

Commit 75afaa9

Browse files
[WASM] Make -use-static-resource-dir default flag for wasm target
We should handle -no-static-stdlib when wasm will support dynamic linking. But currently, it's ok to always link stdlib statically when wasm target.
1 parent 02f1e02 commit 75afaa9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,8 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) {
22492249
if (Args.hasFlag(options::OPT_static_executable,
22502250
options::OPT_no_static_executable, false) ||
22512251
Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
2252-
false)) {
2252+
false) ||
2253+
TC.getTriple().isOSBinFormatWasm()) {
22532254
commandLine.push_back("-use-static-resource-dir");
22542255
}
22552256

lib/Driver/ToolChains.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,8 @@ ToolChain::constructInvocation(const CompileJobAction &job,
528528
if (context.Args.hasFlag(options::OPT_static_executable,
529529
options::OPT_no_static_executable, false) ||
530530
context.Args.hasFlag(options::OPT_static_stdlib,
531-
options::OPT_no_static_stdlib, false)) {
531+
options::OPT_no_static_stdlib, false) ||
532+
getTriple().isOSBinFormatWasm()) {
532533
Arguments.push_back("-use-static-resource-dir");
533534
}
534535

@@ -1023,7 +1024,8 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
10231024
if (context.Args.hasFlag(options::OPT_static_executable,
10241025
options::OPT_no_static_executable, false) ||
10251026
context.Args.hasFlag(options::OPT_static_stdlib,
1026-
options::OPT_no_static_stdlib, false)) {
1027+
options::OPT_no_static_stdlib, false) ||
1028+
getTriple().isOSBinFormatWasm()) {
10271029
Arguments.push_back("-use-static-resource-dir");
10281030
}
10291031

@@ -1191,6 +1193,14 @@ ToolChain::constructInvocation(const GeneratePCHJobAction &job,
11911193
addInputsOfType(Arguments, context.InputActions, file_types::TY_ObjCHeader);
11921194
context.Args.AddLastArg(Arguments, options::OPT_index_store_path);
11931195

1196+
if (context.Args.hasFlag(options::OPT_static_executable,
1197+
options::OPT_no_static_executable, false) ||
1198+
context.Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
1199+
false) ||
1200+
getTriple().isOSBinFormatWasm()) {
1201+
Arguments.push_back("-use-static-resource-dir");
1202+
}
1203+
11941204
if (job.isPersistentPCH()) {
11951205
Arguments.push_back("-emit-pch");
11961206
Arguments.push_back("-pch-output-dir");

0 commit comments

Comments
 (0)