Skip to content

Commit 7efedba

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 54fcce3 commit 7efedba

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

lib/Driver/ToolChains.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,8 @@ ToolChain::constructInvocation(const CompileJobAction &job,
660660
if (context.Args.hasFlag(options::OPT_static_executable,
661661
options::OPT_no_static_executable, false) ||
662662
context.Args.hasFlag(options::OPT_static_stdlib,
663-
options::OPT_no_static_stdlib, false)) {
663+
options::OPT_no_static_stdlib, false) ||
664+
getTriple().isOSBinFormatWasm()) {
664665
Arguments.push_back("-use-static-resource-dir");
665666
}
666667

@@ -1188,7 +1189,13 @@ ToolChain::constructInvocation(const MergeModuleJobAction &job,
11881189
context.Args.AddLastArg(Arguments, options::OPT_import_objc_header);
11891190

11901191
context.Args.AddLastArg(Arguments, options::OPT_disable_incremental_imports);
1191-
1192+
if (context.Args.hasFlag(options::OPT_static_executable,
1193+
options::OPT_no_static_executable, false) ||
1194+
context.Args.hasFlag(options::OPT_static_stdlib,
1195+
options::OPT_no_static_stdlib, false) ||
1196+
getTriple().isOSBinFormatWasm()) {
1197+
Arguments.push_back("-use-static-resource-dir");
1198+
}
11921199
Arguments.push_back("-module-name");
11931200
Arguments.push_back(context.Args.MakeArgString(context.OI.ModuleName));
11941201

@@ -1388,6 +1395,14 @@ ToolChain::constructInvocation(const GeneratePCHJobAction &job,
13881395
addInputsOfType(Arguments, context.InputActions, file_types::TY_ClangHeader);
13891396
context.Args.AddLastArg(Arguments, options::OPT_index_store_path);
13901397

1398+
if (context.Args.hasFlag(options::OPT_static_executable,
1399+
options::OPT_no_static_executable, false) ||
1400+
context.Args.hasFlag(options::OPT_static_stdlib, options::OPT_no_static_stdlib,
1401+
false) ||
1402+
getTriple().isOSBinFormatWasm()) {
1403+
Arguments.push_back("-use-static-resource-dir");
1404+
}
1405+
13911406
if (job.isPersistentPCH()) {
13921407
Arguments.push_back("-emit-pch");
13931408
Arguments.push_back("-pch-output-dir");

0 commit comments

Comments
 (0)