Skip to content

Commit 8d7b44b

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 fa0a6d8 commit 8d7b44b

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
@@ -634,7 +634,8 @@ ToolChain::constructInvocation(const CompileJobAction &job,
634634
if (context.Args.hasFlag(options::OPT_static_executable,
635635
options::OPT_no_static_executable, false) ||
636636
context.Args.hasFlag(options::OPT_static_stdlib,
637-
options::OPT_no_static_stdlib, false)) {
637+
options::OPT_no_static_stdlib, false) ||
638+
getTriple().isOSBinFormatWasm()) {
638639
Arguments.push_back("-use-static-resource-dir");
639640
}
640641

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

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

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

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

0 commit comments

Comments
 (0)