Skip to content

Commit 517ced4

Browse files
[ClangImporter][Tests] clang doesn't support the empty string as a path argument
SIL/verify_all_overlays.py is passing `-F ""` on non-Apple platforms. Swift handles that kind of, but clang doesn't support it and will get argument parsing errors. It's a pathological case, so fix SIL/verify_all_overlays.py to not do that, but also add a failsafe in ClangImporter to not pass on empty paths. rdar://142441042
1 parent 85faa52 commit 517ced4

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

lib/ClangImporter/ClangImporter.cpp

+14-10
Original file line numberDiff line numberDiff line change
@@ -937,20 +937,24 @@ importer::addCommonInvocationArguments(
937937
}
938938

939939
for (const auto &framepath : searchPathOpts.getFrameworkSearchPaths()) {
940-
if (framepath.IsSystem) {
941-
invocationArgStrs.push_back("-iframework");
942-
invocationArgStrs.push_back(framepath.Path);
943-
} else {
944-
invocationArgStrs.push_back("-F" + framepath.Path);
940+
if (!framepath.Path.empty()) {
941+
if (framepath.IsSystem) {
942+
invocationArgStrs.push_back("-iframework");
943+
invocationArgStrs.push_back(framepath.Path);
944+
} else {
945+
invocationArgStrs.push_back("-F" + framepath.Path);
946+
}
945947
}
946948
}
947949

948950
for (const auto &path : searchPathOpts.getImportSearchPaths()) {
949-
if (path.IsSystem) {
950-
invocationArgStrs.push_back("-isystem");
951-
invocationArgStrs.push_back(path.Path);
952-
} else {
953-
invocationArgStrs.push_back("-I" + path.Path);
951+
if (!path.Path.empty()) {
952+
if (path.IsSystem) {
953+
invocationArgStrs.push_back("-isystem");
954+
invocationArgStrs.push_back(path.Path);
955+
} else {
956+
invocationArgStrs.push_back("-I" + path.Path);
957+
}
954958
}
955959
}
956960
}

test/lit.cfg

+5-3
Original file line numberDiff line numberDiff line change
@@ -2928,10 +2928,12 @@ config.substitutions.insert(0, ('%platform-sdk-overlay-dir', platform_sdk_overla
29282928
config.substitutions.insert(0, ('%platform-dylib-dir', platform_dylib_dir))
29292929
config.substitutions.insert(0, ('%test-resource-dir', test_resource_dir))
29302930

2931-
if run_vendor != 'apple':
2932-
extra_frameworks_dir = ''
2931+
if run_vendor == 'apple':
2932+
extra_frameworks_search_path = '-F %r' % extra_frameworks_dir
2933+
else:
2934+
extra_frameworks_search_path = ''
29332935
extra_platform_search_paths = ''
2934-
config.substitutions.append(('%xcode-extra-frameworks-dir', extra_frameworks_dir))
2936+
config.substitutions.append(('%xcode-extra-frameworks-search-path', extra_frameworks_search_path))
29352937
config.substitutions.append(('%xcode-extra-platform-search-paths', extra_platform_search_paths))
29362938

29372939
config.substitutions.append(('%target-swiftmodule-name', target_specific_module_triple + '.swiftmodule'))

validation-test/SIL/verify_all_overlays.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
# RUN: %swift_src_root \
44
# RUN: %target-sil-opt -sdk %sdk -enable-sil-verify-all \
55
# RUN: -F %sdk/System/Library/PrivateFrameworks \
6-
# RUN: -F "%xcode-extra-frameworks-dir"
6+
# RUN: %xcode-extra-frameworks-search-path
77

88
# REQUIRES: rdar143050566
99
# REQUIRES: long_test
1010
# REQUIRES: nonexecutable_test
1111

12-
# rdar://142441042
13-
# UNSUPPORTED: OS=linux-gnu
1412

1513
import os
1614
import subprocess

0 commit comments

Comments
 (0)