Skip to content

Commit 862cbcc

Browse files
authored
Merge pull request #3680 from swiftwasm/release/5.5
[pull] swiftwasm-release/5.5 from release/5.5
2 parents c1d9af2 + c177a16 commit 862cbcc

File tree

7 files changed

+43
-14
lines changed

7 files changed

+43
-14
lines changed

include/swift/Option/Options.td

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,13 @@ def experimental_cxx_stdlib :
588588

589589
def experimental_emit_module_separately:
590590
Flag<["-"], "experimental-emit-module-separately">,
591-
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
592-
HelpText<"Schedule a swift module emission job instead of a merge-modules job (new Driver only)">;
591+
Flags<[NoInteractiveOption, HelpHidden]>,
592+
HelpText<"Emit module files as a distinct job (new Driver only)">;
593+
594+
def no_emit_module_separately:
595+
Flag<["-"], "no-emit-module-separately">,
596+
Flags<[NoInteractiveOption, HelpHidden]>,
597+
HelpText<"Force using merge-module as the incremental build mode (new Driver only)">;
593598

594599
// Diagnostic control options
595600
def suppress_warnings : Flag<["-"], "suppress-warnings">,

lib/AST/Module.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,11 @@ void SourceLookupCache::populateMemberCache(const ModuleDecl &Mod) {
276276
"populate-module-class-member-cache");
277277

278278
for (const FileUnit *file : Mod.getFiles()) {
279-
auto &SF = *cast<SourceFile>(file);
280-
addToMemberCache(SF.getTopLevelDecls());
279+
assert(isa<SourceFile>(file) ||
280+
isa<SynthesizedFileUnit>(file));
281+
SmallVector<Decl *, 8> decls;
282+
file->getTopLevelDecls(decls);
283+
addToMemberCache(decls);
281284
}
282285

283286
MemberCachePopulated = true;

lib/Frontend/Frontend.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,10 +1147,10 @@ CompilerInstance::getSourceFileParsingOptions(bool forPrimary) const {
11471147
opts |= SourceFile::ParsingFlags::DisableDelayedBodies;
11481148
}
11491149

1150+
auto typeOpts = getASTContext().TypeCheckerOpts;
11501151
if (forPrimary || isWholeModuleCompilation()) {
11511152
// Disable delayed body parsing for primaries and in WMO, unless
11521153
// forcefully skipping function bodies
1153-
auto typeOpts = getASTContext().TypeCheckerOpts;
11541154
if (typeOpts.SkipFunctionBodies == FunctionBodySkipping::None)
11551155
opts |= SourceFile::ParsingFlags::DisableDelayedBodies;
11561156
} else {
@@ -1159,9 +1159,10 @@ CompilerInstance::getSourceFileParsingOptions(bool forPrimary) const {
11591159
opts |= SourceFile::ParsingFlags::SuppressWarnings;
11601160
}
11611161

1162-
// Enable interface hash computation for primaries, but not in WMO, as it's
1163-
// only currently needed for incremental mode.
1164-
if (forPrimary) {
1162+
// Enable interface hash computation for primaries or emit-module-separately,
1163+
// but not in WMO, as it's only currently needed for incremental mode.
1164+
if (forPrimary ||
1165+
typeOpts.SkipFunctionBodies == FunctionBodySkipping::NonInlinableWithoutTypes) {
11651166
opts |= SourceFile::ParsingFlags::EnableInterfaceHash;
11661167
}
11671168
return opts;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,9 +1549,19 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
15491549
SerializationOptions serializationOpts =
15501550
Invocation.computeSerializationOptions(outs, Instance.getMainModule());
15511551

1552+
// Infer if this is an emit-module job part of an incremental build,
1553+
// vs a partial emit-module job (with primary files) or other kinds.
1554+
// We may want to rely on a flag instead to differentiate them.
1555+
const bool isEmitModuleSeparately =
1556+
Action == FrontendOptions::ActionType::EmitModuleOnly &&
1557+
MSF.is<ModuleDecl *>() &&
1558+
Instance.getInvocation()
1559+
.getTypeCheckerOptions()
1560+
.SkipFunctionBodies == FunctionBodySkipping::NonInlinableWithoutTypes;
15521561
const bool canEmitIncrementalInfoIntoModule =
15531562
!serializationOpts.DisableCrossModuleIncrementalInfo &&
1554-
(Action == FrontendOptions::ActionType::MergeModules);
1563+
(Action == FrontendOptions::ActionType::MergeModules ||
1564+
isEmitModuleSeparately);
15551565
if (canEmitIncrementalInfoIntoModule) {
15561566
const auto alsoEmitDotFile =
15571567
Instance.getInvocation()

test/Driver/Dependencies/one-way-merge-module-fine.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: cp -r %S/Inputs/one-way-fine/* %t
55
// RUN: touch -t 201401240005 %t/*
66

7-
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path "%{python.unquoted};%S/Inputs/update-dependencies.py;%swift-dependency-tool" -output-file-map %t/output.json -incremental -driver-always-rebuild-dependents ./main.swift ./other.swift -emit-module-path %t/master.swiftmodule -module-name main -j1 -v 2>&1 | %FileCheck -check-prefix=CHECK-FIRST %s
7+
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path "%{python.unquoted};%S/Inputs/update-dependencies.py;%swift-dependency-tool" -output-file-map %t/output.json -incremental -driver-always-rebuild-dependents ./main.swift ./other.swift -emit-module-path %t/master.swiftmodule -module-name main -j1 -v -no-emit-module-separately 2>&1 | %FileCheck -check-prefix=CHECK-FIRST %s
88

99
// CHECK-FIRST-NOT: warning
1010
// CHECK-FIRST: Handled main.swift
@@ -14,7 +14,7 @@
1414
// swift-driver checks existence of all outputs
1515
// RUN: touch -t 201401240006 %t/{main,other,master}.swift{module,doc,sourceinfo}
1616

17-
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path "%{python.unquoted};%S/Inputs/update-dependencies.py;%swift-dependency-tool" -output-file-map %t/output.json -incremental -driver-always-rebuild-dependents ./main.swift ./other.swift -emit-module-path %t/master.swiftmodule -module-name main -j1 -v 2>&1 | %FileCheck -check-prefix=CHECK-SECOND %s
17+
// RUN: cd %t && %swiftc_driver -driver-use-frontend-path "%{python.unquoted};%S/Inputs/update-dependencies.py;%swift-dependency-tool" -output-file-map %t/output.json -incremental -driver-always-rebuild-dependents ./main.swift ./other.swift -emit-module-path %t/master.swiftmodule -module-name main -j1 -v -no-emit-module-separately 2>&1 | %FileCheck -check-prefix=CHECK-SECOND %s
1818

1919
// CHECK-SECOND-NOT: warning
2020
// CHECK-SECOND-NOT: Handled

test/InterfaceHash/added_function.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
// RUN: %target-swift-frontend -dump-interface-hash -primary-file %t/b.swift 2> %t/b.hash
55
// RUN: not cmp %t/a.hash %t/b.hash
66

7+
/// We should generate an interface hash for emit-module-separately jobs even
8+
/// with no primaries.
9+
// RUN: %target-swift-frontend -dump-interface-hash %t/b.swift -experimental-skip-non-inlinable-function-bodies-without-types 2> %t/b-emit-module.hash
10+
// RUN: cmp %t/b.hash %t/b-emit-module.hash
11+
712
// BEGIN a.swift
813
func f() {}
914

utils/build-windows.bat

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ call :build_swift %exitOnError%
7979

8080
call :build_lldb %exitOnError%
8181

82+
path %PATH%;C:\Program Files\Git\usr\bin
8283
call :build_libdispatch %exitOnError%
8384

84-
path %source_root%\icu-%icu_version%\bin64;%install_directory%\bin;%build_root%\swift\bin;%build_root%\swift\libdispatch-prefix\bin;%PATH%;C:\Program Files\Git\usr\bin
85+
path %source_root%\icu-%icu_version%\bin64;%install_directory%\bin;%build_root%\swift\bin;%build_root%\swift\libdispatch-prefix\bin;%PATH%
8586
call :test_swift %exitOnError%
8687
call :test_libdispatch %exitOnError%
8788

@@ -268,13 +269,15 @@ cmake^
268269
-DSWIFT_BUILD_SOURCEKIT:BOOL=YES^
269270
-DSWIFT_ENABLE_SOURCEKIT_TESTS:BOOL=YES^
270271
-DSWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY=YES^
272+
-DSWIFT_ENABLE_EXPERIMENTAL_DISTRIBUTED=YES^
271273
-DSWIFT_ENABLE_EXPERIMENTAL_DIFFERENTIABLE_PROGRAMMING=YES^
272274
-DSWIFT_INSTALL_COMPONENTS="autolink-driver;compiler;clang-resource-dir-symlink;stdlib;sdk-overlay;editor-integration;tools;sourcekit-inproc;swift-remote-mirror;swift-remote-mirror-headers"^
273275
-DSWIFT_PARALLEL_LINK_JOBS=8^
274276
-DPYTHON_EXECUTABLE:PATH=%PYTHON_HOME%\python.exe^
275277
-DCMAKE_CXX_FLAGS:STRING="/GS- /Oy"^
276278
-DCMAKE_EXE_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
277279
-DCMAKE_SHARED_LINKER_FLAGS:STRING=/INCREMENTAL:NO^
280+
-DSWIFT_LIT_ARGS="--time-tests"^
278281
-S "%source_root%\swift" %exitOnError%
279282

280283
cmake --build "%build_root%\swift" %exitOnError%
@@ -331,6 +334,8 @@ endlocal
331334
:: Configures, builds, and installs Dispatch
332335
setlocal enableextensions enabledelayedexpansion
333336

337+
for /f "delims=" %%O in ('cygpath -m %install_directory%\lib\swift') do set RESOURCE_DIR=%%O
338+
334339
cmake^
335340
-B "%build_root%\swift-corelibs-libdispatch"^
336341
-G Ninja^
@@ -350,8 +355,8 @@ cmake^
350355
-DCMAKE_EXE_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
351356
-DCMAKE_SHARED_LINKER_FLAGS:STRING="/INCREMENTAL:NO"^
352357
-DCMAKE_Swift_COMPILER_TARGET:STRING=x86_64-unknown-windows-msvc^
353-
-DCMAKE_Swift_FLAGS:STRING="-resource-dir \"%install_directory%\lib\swift\""^
354-
-DCMAKE_Swift_LINK_FLAGS:STRING="-resource-dir \"%install_directory%\lib\swift\""^
358+
-DCMAKE_Swift_FLAGS:STRING="-resource-dir \"%RESOURCE_DIR%\""^
359+
-DCMAKE_Swift_LINK_FLAGS:STRING="-resource-dir \"%RESOURCE_DIR%\""^
355360
-S "%source_root%\swift-corelibs-libdispatch" %exitOnError%
356361

357362
cmake --build "%build_root%\swift-corelibs-libdispatch" %exitOnError%

0 commit comments

Comments
 (0)