Skip to content

Commit 6c0d957

Browse files
committed
[Driver] Execute the frontend when invoked via swift-frontend.
This obviates the need for "-frontend", although we still accept it for backward compatibility. Switch lit's %target-swift-frontend et al over to calling swift-frontend.
1 parent ade21a3 commit 6c0d957

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

test/Driver/frontend.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %swiftc_driver %s -### 2>&1 | %FileCheck %s
2+
3+
// CHECK: swift-frontend
4+

test/Frontend/crash.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Check that we see the contents of the input file list in the crash log.
55
// CHECK-LABEL: Stack dump
6-
// CHECK-NEXT: Program arguments: {{.*swift(c?)(\.exe)?}} -frontend
6+
// CHECK-NEXT: Program arguments: {{.*swift(-frontend)?(c?)(\.exe)?}}
77
// CHECK-NEXT: Swift version
88
// CHECK-NEXT: Contents of {{.*}}.filelist.txt:
99
// CHECK-NEXT: ---

test/lit.cfg

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ if 'gmalloc' in lit_config.params:
238238
config.environment['MALLOC_LOG_FILE'] = '/dev/null'
239239
config.available_features.add('gmalloc')
240240

241+
config.swift_frontend = inferSwiftBinary('swift-frontend')
241242
config.swift = inferSwiftBinary('swift')
242243
config.swiftc = inferSwiftBinary('swiftc')
243244
config.sil_opt = inferSwiftBinary('sil-opt')
@@ -432,8 +433,8 @@ config.substitutions.append( ('%swift-path', config.swift) )
432433
# This must come after all substitutions containing "%swift".
433434
config.substitutions.append(
434435
('%swift',
435-
"%r -frontend %s -disable-objc-attr-requires-foundation-module %s %s"
436-
% (config.swift, mcp_opt, config.swift_test_options, config.swift_frontend_test_options)) )
436+
"%r %s -disable-objc-attr-requires-foundation-module %s %s"
437+
% (config.swift_frontend, mcp_opt, config.swift_test_options, config.swift_frontend_test_options)) )
437438

438439
config.clang_include_dir = make_path(config.swift, '..', '..', 'include')
439440
config.substitutions.append( ('%clang-include-dir', config.clang_include_dir) )
@@ -970,12 +971,12 @@ if run_vendor == 'apple':
970971
if run_os == 'maccatalyst':
971972
maccatalyst_extra_frameworks = "-F {}/System/iOSSupport/System/Library/Frameworks".format(config.variant_sdk)
972973
config.target_swift_frontend = (
973-
"%s -frontend %s -sdk %r %s %s %s" %
974-
(config.swiftc, target_options, config.variant_sdk, maccatalyst_extra_frameworks,
974+
"%s %s -sdk %r %s %s %s" %
975+
(config.swift_frontend, target_options, config.variant_sdk, maccatalyst_extra_frameworks,
975976
config.swift_test_options, config.swift_frontend_test_options))
976977
subst_target_swift_frontend_mock_sdk = (
977-
"%s -frontend %s -sdk %r %s %s" %
978-
(config.swiftc, target_options_for_mock_sdk, config.variant_sdk,
978+
"%s %s -sdk %r %s %s" %
979+
(config.swift_frontend, target_options_for_mock_sdk, config.variant_sdk,
979980
config.swift_test_options, config.swift_frontend_test_options))
980981
config.target_swift_modulewrap = (
981982
'%s -modulewrap -target %s' %
@@ -1049,7 +1050,7 @@ elif run_os in ['windows-msvc']:
10491050
config.target_run = ''
10501051

10511052
config.target_swift_frontend = \
1052-
('%r -frontend -target %s %s %s %s %s' % (config.swiftc, \
1053+
('%r -target %s %s %s %s %s' % (config.swift_frontend, \
10531054
config.variant_triple, \
10541055
resource_dir_opt, mcp_opt, \
10551056
config.swift_test_options, \
@@ -1174,8 +1175,8 @@ elif (run_os in ['linux-gnu', 'linux-gnueabihf', 'freebsd', 'openbsd', 'windows-
11741175
% (config.target_build_swift))
11751176
config.target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
11761177
config.target_swift_frontend = (
1177-
'%s -frontend -target %s %s %s %s %s '
1178-
% (config.swift, config.variant_triple, resource_dir_opt, mcp_opt,
1178+
'%s -target %s %s %s %s %s '
1179+
% (config.swift_frontend, config.variant_triple, resource_dir_opt, mcp_opt,
11791180
config.swift_test_options, config.swift_frontend_test_options))
11801181
subst_target_swift_frontend_mock_sdk = config.target_swift_frontend
11811182
subst_target_swift_frontend_mock_sdk_after = ""
@@ -1293,8 +1294,7 @@ elif run_os == 'linux-androideabi' or run_os == 'linux-android':
12931294
'-o', "'\\1'"])
12941295
config.target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
12951296
config.target_swift_frontend = ' '.join([
1296-
config.swift,
1297-
'-frontend',
1297+
config.swift_frontend,
12981298
'-target', config.variant_triple,
12991299
android_include_paths_opt, android_link_paths_opt,
13001300
resource_dir_opt, mcp_opt, config.swift_test_options,
@@ -1370,8 +1370,7 @@ elif run_os == 'wasi':
13701370
% (config.target_build_swift))
13711371
config.target_add_rpath = ''
13721372
config.target_swift_frontend = ' '.join([
1373-
config.swift,
1374-
'-frontend',
1373+
config.swift_frontend,
13751374
'-target', config.variant_triple,
13761375
'-Xcc', '--sysroot=%s' % config.variant_sdk,
13771376
resource_dir_opt, mcp_opt,

tools/driver/driver.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ static int run_driver(StringRef ExecName,
142142
}
143143
}
144144

145+
// Run the integrated Swift frontend when called as "swift-frontend" but
146+
// without a leading "-frontend".
147+
if (ExecName == "swift-frontend") {
148+
return performFrontend(llvm::makeArrayRef(argv.data()+1,
149+
argv.data()+argv.size()),
150+
argv[0], (void *)(intptr_t)getExecutablePath);
151+
}
152+
145153
std::string Path = getExecutablePath(argv[0]);
146154

147155
PrintingDiagnosticConsumer PDC;

0 commit comments

Comments
 (0)