There are a handful of things in the Swift ecosystem that we say are "not for general use, and we reserve the right to break you if you use them". Most of these start with underscores (or for initializers or subscripts, have an argument label that starts with an underscore). However, there's a place we don't follow that convention: the compiler driver itself.
swiftc is used in build systems (and
#! lines), it's important that we don't break people's command lines—a very similar problem to source compatibility. But in order to do that in good faith, we need to clearly delineate which options are okay to rely on and which aren't. Options.td in the Swift repo sort of does this by marking some options
HelpHidden, but that's not really a very strong check. Let's see what kind of options are there:
Some options with an
-enable-experimental-dependencies. That's pretty clear.
Some options with a
-no-prefix, where "no" is the default.
-incremental. Okay, this one just has a comment "Unhide this once it doesn't depend on an output file map". Anyone want to pick up SR-6079?
-disable-batch-mode. These should probably not be hidden any longer!
-enable-testing. This probably ought to be public.
-lldb-repl. Explicit ways to say things you can get without typing anything special. (Kind of surprised
-deprecated-integrated-replis not hidden, given that we keep making it less and less functional.)
-autolink-force-load. There's no real reason not to make this public, but there's also not much demand: it's only useful for people building libraries whose clients are going to be linked with swiftc or Apple's ld64. Most Apple people build frameworks, which get autolinking for free, and on Linux SwiftPM handles linking.
-typo-correction-limit. Mostly for testing, but setting it to 0 can work around compiler bugs sometimes, so "hidden but without a forbidding name" might be the right balance.
-Oplayground. Ooh, a secret optimization mode! Actually just hidden so that no one tries to use it for anything but playgrounds…but we probably can't take it out.
-update-code. Part but not all of the Xcode migrator implementation. I know we've posted publicly about it before, so it's also probably here to stay.
-warn-swift3-objc-inference. Mostly for dealing with migration from Swift-3-era code…but there's nothing that forces you off of this mode.
-enable-private-imports. This one's hidden because it's under development. They should probably have
-experimental-in the name.
-disable-swift-bridge-attrare both feature flags for things that used to be under development; I think they can be removed now.
-assume-single-threadedis a feature flag for something no one is actually working on
-value-recursion-thresholdare options for testing the type checker. I don't know if they're supposed to be in the driver at all. @rudkx, @xedin?
-profile-stats-entities. These are hidden from
-helpbecause the stats format is unstable, but they're not meant to be secret or anything. They're just not so useful to a normal developer.
-Xfrontend, which prompted this post. Every frontend argument is considered unstable. All of them. Even the ones that are the same as driver options. I'd really like to rename this but I don't know what to rename it too. (And to make matters worse, Xcode currently uses it for something. You don't want to know.)
-Xclang-linker. Hidden because it only works on some platforms, but it's also not intended to be a secret long-term. Part of this involves whether we'll change
clangto link even on Apple platforms.
-Xllvm. Hidden because it's not a normal feature, but I also don't think anything passed here counts as "supported". Maybe it's more like -Xfrontend than -Xcc.
-resource-dir. Supported but not actually that useful for anything, since the stdlib in the resource directory you pass still has to be compatible with the compiler.
A bunch of items with a
-driver-show-incremental. These are all intended for testing the driver, but some of them are also useful for general verbose output, if not necessarily so well designed (or integrated;
-driver-show-incrementalbreaks Xcode's output parsing because it's not compatible with
-parseable-output). There's also
-###in this set, which is basically public (it's even mentioned in docs/Driver.md).
-parse-stdlib. Not something normal people should be using, and definitely not supported, but…not secret either. I don't have a good name to use for this.
-disable-bridging-pch. These are "hidden" because they aren't really supported in command-line builds (and we don't want them to get used on Linux), but Xcode knows how to use them, so we can't change them around. Should we have a name for this kind of option?
Can we do anything to make it clearer which of these are "unstable" or "off-limits"?
P.S. I realize by making a list of "interesting options" that more people are going to try them out, so keep in mind that I made a list of options that might break in the future.