Skip to content

Commit 36150a8

Browse files
committed
[Driver] Disallow -autolink-force-load with -incremental
6af333f changed the implementation of -autolink-force-load to only generate one symbol, but the /placement/ of that one symbol depends on the order of input files, and -incremental supports adding a file without rebuilding all other files. We don't have any need for these two to play nice together right now, so just disallow it.
1 parent 8353b4c commit 36150a8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

include/swift/AST/DiagnosticsDriver.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ ERROR(error_input_changed_during_build,none,
126126
ERROR(error_conflicting_options, none,
127127
"conflicting options '%0' and '%1'",
128128
(StringRef, StringRef))
129+
ERROR(error_option_not_supported, none,
130+
"'%0' is not supported with '%1'",
131+
(StringRef, StringRef))
129132

130133
WARNING(warn_ignore_embed_bitcode, none,
131134
"ignoring -embed-bitcode since no object file is being generated", ())

lib/Driver/Driver.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ ArrayRef<const char *> Driver::getArgsWithoutProgramNameAndDriverMode(
119119
return Args;
120120
}
121121

122+
/// Perform miscellaneous early validation of arguments.
122123
static void validateArgs(DiagnosticEngine &diags, const ArgList &Args) {
123124
if (Args.hasArgNoClaim(options::OPT_import_underlying_module) &&
124125
Args.hasArgNoClaim(options::OPT_import_objc_header)) {
@@ -199,6 +200,18 @@ static void validateArgs(DiagnosticEngine &diags, const ArgList &Args) {
199200
diags.diagnose(SourceLoc(), diag::invalid_conditional_compilation_flag,
200201
name);
201202
}
203+
204+
if (auto *forceLoadArg = Args.getLastArg(options::OPT_autolink_force_load)) {
205+
if (auto *incrementalArg = Args.getLastArg(options::OPT_incremental)) {
206+
// Note: -incremental can itself be overridden by other arguments later
207+
// on, but since -autolink-force-load is a rare and not-really-recommended
208+
// option it's not worth modeling that complexity here (or moving the
209+
// check somewhere else).
210+
diags.diagnose(SourceLoc(), diag::error_option_not_supported,
211+
forceLoadArg->getSpelling(),
212+
incrementalArg->getSpelling());
213+
}
214+
}
202215
}
203216

204217
std::unique_ptr<ToolChain>

test/Driver/options.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,7 @@
129129
// RUN: %swiftc_driver -driver-print-jobs -assume-single-threaded %s | %FileCheck -check-prefix=ASSUME_SINGLE_THREADED %s
130130
// ASSUME_SINGLE_THREADED: swift
131131
// ASSUME_SINGLE_THREADED: -frontend {{.*}} -assume-single-threaded
132+
133+
// RUN: not %swiftc_driver -incremental -autolink-force-load %s 2>&1 | %FileCheck -check-prefix=AUTOLINK_FORCE_LOAD %s
134+
// RUN: not %swiftc_driver -autolink-force-load -incremental %s 2>&1 | %FileCheck -check-prefix=AUTOLINK_FORCE_LOAD %s
135+
// AUTOLINK_FORCE_LOAD: error: '-autolink-force-load' is not supported with '-incremental'

0 commit comments

Comments
 (0)