Skip to content

Commit 1cf374d

Browse files
authored
Merge pull request #3942 from swiftwasm/main
2 parents 41d7a51 + 836782b commit 1cf374d

File tree

9 files changed

+74
-16
lines changed

9 files changed

+74
-16
lines changed

lib/DependencyScan/ScanDependencies.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static void discoverCrosssImportOverlayDependencies(
336336
template <typename T>
337337
void writeJSONSingleField(llvm::raw_ostream &out, StringRef fieldName,
338338
const T &value, unsigned indentLevel,
339-
bool trailingComma);
339+
bool trailingComma, bool nested = false);
340340

341341
/// Write a string value as JSON.
342342
void writeJSONValue(llvm::raw_ostream &out, StringRef value,
@@ -442,11 +442,31 @@ void writeJSONValue(llvm::raw_ostream &out, const std::vector<T> &values,
442442
template <typename T>
443443
void writeJSONSingleField(llvm::raw_ostream &out, StringRef fieldName,
444444
const T &value, unsigned indentLevel,
445-
bool trailingComma) {
445+
bool trailingComma, bool nested) {
446446
out.indent(indentLevel * 2);
447447
writeJSONValue(out, fieldName, indentLevel);
448448
out << ": ";
449-
writeJSONValue(out, value, indentLevel);
449+
auto updatedIndentLevel = indentLevel;
450+
451+
if (nested) {
452+
// This is a hack to "fix" a format for a value that should be a nested
453+
// set of strings. Currently only capturedPCMArgs (clang) is expected to
454+
// in the nested format, which supposedly only contains one set of strings.
455+
// Adjust the indentation to account for the nested brackets.
456+
updatedIndentLevel += 1;
457+
out << "[\n";
458+
out.indent(updatedIndentLevel * 2);
459+
}
460+
461+
writeJSONValue(out, value, updatedIndentLevel);
462+
463+
if (nested) {
464+
// If nested, add an extra closing brack with a correct indentation.
465+
out << "\n";
466+
out.indent(indentLevel * 2);
467+
out << "]";
468+
}
469+
450470
if (trailingComma)
451471
out << ",";
452472
out << "\n";
@@ -720,7 +740,7 @@ static void writeJSON(llvm::raw_ostream &out,
720740

721741
// Captured PCM arguments.
722742
writeJSONSingleField(out, "capturedPCMArgs", clangDeps->captured_pcm_args, 5,
723-
/*trailingComma=*/false);
743+
/*trailingComma=*/false, /*nested=*/true);
724744
}
725745

726746
out.indent(4 * 2);

lib/Serialization/ModuleFile.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,15 @@ Status ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc,
165165
return error(status);
166166
}
167167

168-
for (const auto &searchPath : Core->SearchPaths) {
169-
ctx.addSearchPath(
168+
StringRef SDKPath = ctx.SearchPathOpts.SDKPath;
169+
if (SDKPath.empty() ||
170+
!Core->ModuleInputBuffer->getBufferIdentifier().startswith(SDKPath)) {
171+
for (const auto &searchPath : Core->SearchPaths) {
172+
ctx.addSearchPath(
170173
ctx.SearchPathOpts.SearchPathRemapper.remapPath(searchPath.Path),
171-
searchPath.IsFramework, searchPath.IsSystem);
174+
searchPath.IsFramework,
175+
searchPath.IsSystem);
176+
}
172177
}
173178

174179
auto clangImporter = static_cast<ClangImporter *>(ctx.getClangModuleLoader());

test/Concurrency/predates_concurrency_swift6.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %target-typecheck-verify-swift -disable-availability-checking -swift-version 6
22
// REQUIRES: concurrency
3+
// REQUIRES: asserts
34

45
@_predatesConcurrency func unsafelySendableClosure(_ closure: @Sendable () -> Void) { }
56

test/ScanDependencies/module_deps.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ import SubE
137137
// CHECK-NEXT: "C"
138138

139139
// CHECK: "capturedPCMArgs": [
140-
// CHECK-NEXT: "-Xcc",
141-
// CHECK-NEXT: "-fapinotes-swift-version=4"
140+
// CHECK-NEXT: [,
141+
// CHECK-NEXT: "-Xcc",
142+
// CHECK-NEXT: "-fapinotes-swift-version=4"
143+
// CHECK-NEXT: ]
142144
// CHECK-NEXT: ]
143145

144146
/// --------Swift module E
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// REQUIRES: VENDOR=apple
2+
// RUN: %empty-directory(%t)
3+
// RUN: %empty-directory(%t/mock-sdk/usr/lib/swift/SystemLibrary.swiftmodule)
4+
// RUN: %empty-directory(%t/secret)
5+
6+
// RUN: %target-swift-frontend -emit-module %S/../Inputs/empty.swift -o %t/secret/SecretLibrary.swiftmodule
7+
// RUN: %target-swift-frontend -emit-module %S/../Inputs/empty.swift -o %t/mock-sdk/usr/lib/swift/SystemLibrary.swiftmodule/%target-swiftmodule-name -module-name SystemLibrary -I %t/secret -serialize-debugging-options
8+
9+
// We pick up search paths from normal imports...
10+
// RUN: %target-swift-frontend -typecheck %s -I %t/mock-sdk/usr/lib/swift/
11+
12+
// ...but not from content in the SDK.
13+
// RUN: %target-swift-frontend -typecheck %s -sdk %t/mock-sdk -verify -show-diagnostics-after-fatal
14+
15+
import SystemLibrary
16+
import SecretLibrary // expected-error {{no such module 'SecretLibrary'}}

tools/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ include(CheckIncludeFiles)
22
check_include_files("xpc/xpc.h" HAVE_XPC_H)
33

44
if(HAVE_XPC_H AND SWIFT_BUILD_SOURCEKIT)
5-
set(BUILD_SOURCEKIT_XPC_SERVICE TRUE)
5+
set(BUILD_SOURCEKIT_XPC_SERVICE_default TRUE)
66
else()
7-
set(BUILD_SOURCEKIT_XPC_SERVICE FALSE)
7+
set(BUILD_SOURCEKIT_XPC_SERVICE_default FALSE)
88
endif()
99

10+
option(BUILD_SOURCEKIT_XPC_SERVICE
11+
"Whether or not the SourceKit XPC service should be built"
12+
${BUILD_SOURCEKIT_XPC_SERVICE_default})
13+
1014
# Add generated libSyntax headers to global dependencies.
1115
list(APPEND LLVM_COMMON_DEPENDS swift-syntax-generated-headers)
1216
if(SWIFT_BUILD_SOURCEKIT)

tools/SourceKit/cmake/modules/AddSwiftSourceKit.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ function(add_sourcekit_default_compiler_flags target)
1111
if(${SWIFT_HOST_VARIANT_SDK} STREQUAL WINDOWS)
1212
swift_windows_include_for_arch(${SWIFT_HOST_VARIANT_ARCH}
1313
${SWIFT_HOST_VARIANT_ARCH}_INCLUDE)
14+
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
15+
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-I")
16+
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-I")
17+
endif()
1418
target_include_directories(${target} SYSTEM PRIVATE
1519
${${SWIFT_HOST_VARIANT_ARCH}_INCLUDE})
1620
endif()

utils/build-script

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env python
22

33
# This source file is part of the Swift.org open source project
44
#
@@ -8,10 +8,14 @@
88
# See https://swift.org/LICENSE.txt for license information
99
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010

11+
1112
"""
1213
The ultimate tool for building Swift.
1314
"""
1415

16+
17+
from __future__ import absolute_import, print_function, unicode_literals
18+
1519
import json
1620
import os
1721
import platform
@@ -28,6 +32,8 @@ from build_swift.build_swift.constants import SWIFT_BUILD_ROOT
2832
from build_swift.build_swift.constants import SWIFT_REPO_NAME
2933
from build_swift.build_swift.constants import SWIFT_SOURCE_ROOT
3034

35+
import six
36+
3137
from swift_build_support.swift_build_support import build_script_invocation
3238
from swift_build_support.swift_build_support import shell
3339
from swift_build_support.swift_build_support import targets
@@ -113,7 +119,7 @@ class JSONDumper(json.JSONEncoder):
113119
def default(self, o):
114120
if hasattr(o, '__dict__'):
115121
return vars(o)
116-
return str(o)
122+
return six.text_type(o)
117123

118124

119125
def print_xcodebuild_versions(file=sys.stdout):
@@ -499,7 +505,7 @@ def main_preset():
499505
try:
500506
preset_parser.read_files(args.preset_file_names)
501507
except presets.PresetError as e:
502-
fatal_error(str(e))
508+
fatal_error(six.text_type(e))
503509

504510
if args.show_presets:
505511
for name in sorted(preset_parser.preset_names,
@@ -520,7 +526,7 @@ def main_preset():
520526
args.preset,
521527
vars=args.preset_substitutions)
522528
except presets.PresetError as e:
523-
fatal_error(str(e))
529+
fatal_error(six.text_type(e))
524530

525531
preset_args = migration.migrate_swift_sdks(preset.args)
526532

utils/swift_build_support/swift_build_support/productpipeline_list_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def infer(self):
141141

142142
# Filter out any of the pipelines that before inference were not
143143
# selected.
144-
enabled_pipeline = [p for p in pipeline if p is not None]
144+
enabled_pipeline = filter(lambda x: x is not None, pipeline)
145145

146146
if self.args.verbose_build:
147147
print("-- Build Graph Inference --")

0 commit comments

Comments
 (0)