Skip to content

Commit 05e835e

Browse files
kateinoigakukunAnka
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 f46b5dc commit 05e835e

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
@@ -2403,7 +2403,8 @@ bool Driver::handleImmediateArgs(const ArgList &Args, const ToolChain &TC) {
24032403
if (Args.hasFlag(options::OPT_static_executable,
24042404
options::OPT_no_static_executable, false) ||
24052405
Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
2406-
false)) {
2406+
false) ||
2407+
TC.getTriple().isOSBinFormatWasm()) {
24072408
commandLine.push_back("-use-static-resource-dir");
24082409
}
24092410

lib/Driver/ToolChains.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,8 @@ ToolChain::constructInvocation(const CompileJobAction &job,
635635
if (context.Args.hasFlag(options::OPT_static_executable,
636636
options::OPT_no_static_executable, false) ||
637637
context.Args.hasFlag(options::OPT_static_stdlib,
638-
options::OPT_no_static_stdlib, false)) {
638+
options::OPT_no_static_stdlib, false) ||
639+
getTriple().isOSBinFormatWasm()) {
639640
Arguments.push_back("-use-static-resource-dir");
640641
}
641642

@@ -1163,7 +1164,13 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
11631164
context.Args.AddLastArg(Arguments, options::OPT_import_objc_header);
11641165

11651166
context.Args.AddLastArg(Arguments, options::OPT_disable_incremental_imports);
1166-
1167+
if (context.Args.hasFlag(options::OPT_static_executable,
1168+
options::OPT_no_static_executable, false) ||
1169+
context.Args.hasFlag(options::OPT_static_stdlib,
1170+
options::OPT_no_static_stdlib, false) ||
1171+
getTriple().isOSBinFormatWasm()) {
1172+
Arguments.push_back("-use-static-resource-dir");
1173+
}
11671174
Arguments.push_back("-module-name");
11681175
Arguments.push_back(context.Args.MakeArgString(context.OI.ModuleName));
11691176

@@ -1363,6 +1370,14 @@ ToolChain::constructInvocation(const GeneratePCHJobAction &job,
13631370
addInputsOfType(Arguments, context.InputActions, file_types::TY_ClangHeader);
13641371
context.Args.AddLastArg(Arguments, options::OPT_index_store_path);
13651372

1373+
if (context.Args.hasFlag(options::OPT_static_executable,
1374+
options::OPT_no_static_executable, false) ||
1375+
context.Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
1376+
false) ||
1377+
getTriple().isOSBinFormatWasm()) {
1378+
Arguments.push_back("-use-static-resource-dir");
1379+
}
1380+
13661381
if (job.isPersistentPCH()) {
13671382
Arguments.push_back("-emit-pch");
13681383
Arguments.push_back("-pch-output-dir");

0 commit comments

Comments
 (0)