Skip to content

Commit bf56620

Browse files
kateinoigakukunrunner
authored andcommitted
[wasm][Driver] HACK: Add -use-static-resource-dir by default for wasm target
Currently, wasm target only supports static linking mode, so we add `-use-static-resource-dir` by default for wasm target. This patch is not an essential change because we can also add `-use-static-resource-dir` in the driver invocation. But it is a convenient change for users.
1 parent 1fa77ab commit bf56620

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,7 +2391,8 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) {
23912391
if (Args.hasFlag(options::OPT_static_executable,
23922392
options::OPT_no_static_executable, false) ||
23932393
Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
2394-
false)) {
2394+
false) ||
2395+
TC.getTriple().isOSBinFormatWasm()) {
23952396
commandLine.push_back("-use-static-resource-dir");
23962397
}
23972398

lib/Driver/ToolChains.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,8 @@ ToolChain::constructInvocation(const CompileJobAction &job,
638638
if (context.Args.hasFlag(options::OPT_static_executable,
639639
options::OPT_no_static_executable, false) ||
640640
context.Args.hasFlag(options::OPT_static_stdlib,
641-
options::OPT_no_static_stdlib, false)) {
641+
options::OPT_no_static_stdlib, false) ||
642+
getTriple().isOSBinFormatWasm()) {
642643
Arguments.push_back("-use-static-resource-dir");
643644
}
644645

@@ -1160,7 +1161,13 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
11601161
context.Args.AddLastArg(Arguments, options::OPT_import_objc_header);
11611162

11621163
context.Args.AddLastArg(Arguments, options::OPT_disable_incremental_imports);
1163-
1164+
if (context.Args.hasFlag(options::OPT_static_executable,
1165+
options::OPT_no_static_executable, false) ||
1166+
context.Args.hasFlag(options::OPT_static_stdlib,
1167+
options::OPT_no_static_stdlib, false) ||
1168+
getTriple().isOSBinFormatWasm()) {
1169+
Arguments.push_back("-use-static-resource-dir");
1170+
}
11641171
Arguments.push_back("-module-name");
11651172
Arguments.push_back(context.Args.MakeArgString(context.OI.ModuleName));
11661173

@@ -1360,6 +1367,14 @@ ToolChain::constructInvocation(const GeneratePCHJobAction &job,
13601367
addInputsOfType(Arguments, context.InputActions, file_types::TY_ClangHeader);
13611368
context.Args.AddLastArg(Arguments, options::OPT_index_store_path);
13621369

1370+
if (context.Args.hasFlag(options::OPT_static_executable,
1371+
options::OPT_no_static_executable, false) ||
1372+
context.Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
1373+
false) ||
1374+
getTriple().isOSBinFormatWasm()) {
1375+
Arguments.push_back("-use-static-resource-dir");
1376+
}
1377+
13631378
if (job.isPersistentPCH()) {
13641379
Arguments.push_back("-emit-pch");
13651380
Arguments.push_back("-pch-output-dir");

0 commit comments

Comments
 (0)