134 Commits

Author SHA1 Message Date
Saleem Abdulrasool
19c7bb5a22 Driver: add support for baremetal targets
This allows building the Swift standard library for targets which may
not have an actual OS running.  This is identified by the OS field in
the target triple being set to `none`.
2023-03-20 17:59:13 -04:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Saleem Abdulrasool
0a2b10b777 Merge pull request #61815 from MillerTechnologyPeru/trunk/riscv64
[stdlib] Add RISCV64 support
2022-11-02 09:53:34 -07:00
Alsey Coleman Miller
62b7be4e9c [stdlib] Add RISCV64 support 2022-11-01 23:59:42 -07:00
Pavel Yaskevich
f779f8059f [Basic] Make it possible to access some experimental features in production compilers
Resolves: rdar://99884335
2022-11-01 10:15:51 -07:00
Doug Gregor
2b87836a0a Enable valid-parse checking with the new parser
Ensure that any time the existing parser accepts a source file,
the new parser produces a valid parse (no unexpected/missing nodes) for
that same source file.
2022-09-30 21:47:07 -07:00
Doug Gregor
3708c6649f [New parser] Enable round-trip testing of the new parser in +Asserts builds 2022-09-24 12:49:02 -07:00
Doug Gregor
9df77e9932 Add a stub constructor for LangOptions.
Having an out-of-line definition for the LangOptions constructor makes
it easier to enable experimental features one at a time for a build,
without rebuilding everything.
2022-09-07 18:14:07 -07:00
swift-ci
da96ee6bd2 Merge remote-tracking branch 'origin/main' into rebranch 2022-07-20 12:38:23 -07:00
Doug Gregor
a317fad88d Add -enable-upcoming-feature X command-line argument.
Introduce the `-enable-upcoming-feature X` command-line argument to
allow one to opt into features that will be enabled in an upcoming language
mode. Stage in several features this way (`ConciseMagicFile`,
`ForwardTrailingClosures`, `BareSlashRegexLiterals`).
2022-07-19 21:20:12 -07:00
swift-ci
d32d3311ab Merge remote-tracking branch 'origin/main' into rebranch 2022-05-30 11:14:36 -07:00
Doug Gregor
2cc91d04c9 Temporarily reinstate LangOptions::EnableBareSlashRegexLiterals for LLDB 2022-05-30 08:33:47 -07:00
Doug Gregor
2fbe202146 Introduce FUTURE_FEATURE definitions for features staged in Swift 6.
Using the same feature set logic as experimental features, provide
feature names for "future" features, which are changes that will
become available with Swift 6. Use the feature check when determining
whether to implementation the feature instead of a language version
check, and map existing flags for these features (when available) over
to the feature set.

As an internal implementation detail, this makes it easier to reason
about when specific features are enabled (or not). If we decide to go
with piecemeal adoption support for features, it can provide an
alternative path to enabling features that feeds this mechanism.
2022-05-30 08:32:56 -07:00
swift-ci
4ee528a886 Merge remote-tracking branch 'origin/main' into rebranch 2022-05-27 15:14:25 -07:00
Doug Gregor
6d82448dc8 Add -enable-experimental-feature X for experimental features.
Experimental features can only be enabled in non-production (+Asserts)
builds. They can be detected with `hasFeature` in the same manner as
"future" features.

The `-enable-experimental-feature X` flag will also look for future
features by that name, so that when an experimental feature becomes an
accepted future feature, it will still be enabled in the same manner.

Switch variadic generics over to this approach, eliminating the
specific LangOption for it.
2022-05-26 11:50:39 -07:00
Ben Barham
114b4d96e4 [next] Use new VersionTuple API
The `VersionTuple` API was changed llvm/llvm-project
219672b8dd06c4765185fa3161c98437d49b4a1b to return `VersionTuple`
from `get*Version` rather than pass in major, minor, and subminor output
parameters. Update uses to the new API.

Note that `getMacOSXVersion` is slightly different in that it returns a
boolean while taking a `VersionTuple` output parameter to match its
previous behaviour. There doesn't seem to be any use that actually
checks this value though, so we should either update the API to return
an `Optional` and actually check it *or* remove the "failure" case and
return a `VersionTuple` like all the others.
2022-05-05 16:25:10 -07:00
Alsey Coleman Miller
0ab3eec987 Added PowerPC 32-bit support 2022-03-03 22:21:33 -05:00
John McCall
54c38cbb71 Fix and generalize the printing of suppressible features,
and make `@_unsafeInheritExecutor` a suppressible feature.

Some language features are required in order to parse a
declaration correctly, but some can safely be ignored.
For the latter, we'd like the module interface to simply
contain the declaration twice, once with the feature and
once without.  Some basic support for that was already
added for the SpecializeAttributeWithAvailability feature,
but it didn't interact correctly with required features
that might be checked in the same `#if` clause (it simply
introduced an `#else`), and it wasn't really set up to
allow multiple features to be handled this way.  There
were also a few other places that weren't updated to
handle this, presumably because they never coincided
with a `@_specialize` attribute.

Introduce the concept of a suppressible feature, which
is anything that the ASTPrinter can modify the current
PrintOptions in order to suppress.  Restructure the
printing of compatibility checks so that we can print
the body multiple times with different settings.
Print required feature checks in an outer `#if...#endif`,
then perform a separate `#if...#else...#endif` within
if we have suppressible features.  If there are multiple
suppressible features, check for the most recent first,
on the assumption that it will imply the rest; then
perform subsequent checks with an `#elsif` clause.

This should be a far more solid foundation on which to
build compatibility checks in the future.

`@_unsafeInheritExecutor` needs to be suppressible
because it's been added to some rather important
existing APIs.  Simply suppressing the entire decl will
effectively block old tools from using a new SDK to
build many existing projects (if they've adopted
`async`).  Dropping the attribute changes the semantics
of these functions, but only if the compiler features
the SE-0338 scheduling change; this is a very narrow
window of main-branch development builds of the tools,
none of which were officially released.
2022-02-16 16:58:56 -05:00
Richard Howell
140c02466a Add -prefix-serialized-debugging-options (#39555)
This commit adds a new frontend flag that applies debug path prefixing to the
paths serialized in swiftmodule files. This makes it possible to use swiftmodule
files that have been built on different machines by applying the inverse map
when debugging, in a similar fashion to source path prefixing.

The inverse mapping in LLDB will be handled in a follow up PR.

Second pass at #39138

Tests updated to handle windows path separators.

This reverts commit f5aa95b381.
2021-10-04 22:41:32 -07:00
Saleem Abdulrasool
f5aa95b381 Revert "Add -prefix-serialized-debugging-options" (#39544)
Reverts #39138

This is causing a failure on Windows: https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019/6659/consoleText
2021-10-01 11:19:44 -07:00
Richard Howell
58d67be645 Add ClangImporterOptions::getRemappedExtraArgs
This commit adds a function to remap the clang arguments passed
during compilation. This is intented to be shared across the
Swift compiler and LLDB to apply path remapping for debug info
paths.
2021-09-30 08:13:28 -07:00
Saleem Abdulrasool
25f437e17d mark some switches as covered (NFCI)
Unfortunately, MSVC does not detect covered switches as clang.  Mark
some of the switches as covered to avoid an unnecessary warning from
MSVC.
2021-06-05 15:30:25 -07:00
Becca Royal-Gordon
a6a9dfede0 Add option to control access note diagnostics
This will allow teams writing access notes to use -Raccess-note=all-validate to check that their access notes are correct, or teams working around problems to use -Raccess-note=failures or -Raccess-note=none to suppress diagnostics.
2021-05-22 13:01:29 -07:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Doug Gregor
aa139a101c [Module interface] Use features in module interface generation.
When generating a module interface, emit `#if` around any declarations
that are tied to specific, named language features. This allows module
interfaces to be processed by older Swift compilers that do not
support these newer features, such as async/await or actors.

The amount of effort required to correctly handle a new kind of
feature varies somewhat drastically based on the feature itself. The
"simple" case is where a particular declaration can only exist if a
feature is available. For example, and `async` declaration is fairly
easy to handle; a `@_marker` protocol's conformances are not.

Fixes rdar://73326633.
2021-02-08 16:01:39 -08:00
Doug Gregor
2e3b220d44 [Basic] Remove swift::tripleIsAnySimulator().
It's just Triple::isSimulatorEnvironment() now.
2020-04-20 08:50:34 -07:00
Saleem Abdulrasool
fbbf61f297 Revert "[Darwin] Further restrict inference of the simulator environment" 2020-04-19 16:43:22 -07:00
Doug Gregor
992ca5651a [Basic] Remove swift::tripleIsAnySimulator().
It's just Triple::isSimulatorEnvironment() now.
2020-04-16 11:42:07 -07:00
Kuba Mracek
acfc4a98b1 Fixup for 3904fe83f (AST: Centralize ABI-related deployment target checks) 2020-03-04 16:30:07 -08:00
Kuba (Brecka) Mracek
5d918e5ee1 Merge branch 'master' into mracek/arm64e 2020-03-03 08:28:01 -08:00
Kuba Mracek
84c4864911 [arm64e] Add Swift compiler support for arm64e pointer authentication 2020-02-27 16:10:31 -08:00
3405691582
0d3b92dfb1 Swift Basic/Driver recognizes OpenBSD.
Add the platform conditional and set up other basics for the toolchain.

The ConditionalCompilation tests are updated to match, since otherwise
they seem to trip when building on non-OpenBSD platforms. The
Driver/linker test is updated to ensure lld is passed on this platform.
Note that OpenBSD calls "x86_64" as "amd64", so we use that name for the
architecture instead of trying to alias one to the other, as this makes
things simpler.
2020-02-27 17:14:22 -05:00
Devin Coughlin
8c5c5ec802 [Parse] Support macCatalyst conditional compilation
Add support for conditional compilation under macCatalyst

Developers can now detect whether they are compiling for macCatalyst at
compile time with:

  #if targetEnvironment(macCatalyst)
    // Code only compiled under macCatalyst.
  #end
2020-01-21 18:28:17 -08:00
Saleem Abdulrasool
15869aceaa wasm: add support for wasm32-unknown-wasi
This adds the initial conditional compilation support for the WASM32
"architecture" assuming that WASI is used as the "OS".  Support for
baremetal targets in Swift needs more work still, but this gives enough
infrastructure to start playing with WASM.
2019-12-04 22:31:53 -08:00
Saleem Abdulrasool
13eb4813ea Basic: simplify runtime type selection (NFC)
Rather than an if repeating the condition, simplify using a ternary for
the value.  NFC.
2019-11-24 10:12:07 -08:00
Saleem Abdulrasool
108630d209 Basic: simplify endianness classification (NFC)
Collapse the cases into a single set rather than adding a case for each
entry.  This is easier to read/follow.  NFC.
2019-11-24 10:12:07 -08:00
Saleem Abdulrasool
b6db7844e9 Basic: convert cascading ifs to switch (NFC)
Switch over `Triple::getOS` instead of a series of cascading `if`s.
This simplifies the handling of adding new entries.  It also makes the
precedence ordering more explicit.
2019-11-24 10:12:07 -08:00
Jordan Rose
171ff440fc Remove swift::reversed in favor of llvm::reverse (#27610)
The former predates the latter, but we don't need it anymore! The
latter has more features anyway.

No functionality change.
2019-10-10 17:16:09 -07:00
Sasha Krassovsky
c5bfa450ee Fix warnings in Basic 2019-09-13 09:57:48 -07:00
Roopesh Chander
cf9bb32527 Simplify code using ArrayRef 2019-08-21 20:09:53 +00:00
Roopesh Chander
5e01b55a04 [Parser][QoI] Suppress fixits to underscored platform condition kinds
"_endian" and "_runtime" aren't officially supported platform condition
kinds, so don't suggest changing to one of those.
2019-08-21 19:52:03 +00:00
Roopesh Chander
b75711c2d2 Make a .def file for PlatformConditionKind 2019-08-21 19:52:00 +00:00
Roopesh Chander
34fec7f1d4 [Parser][QoI] Offer fixit for changing the platform condition kind
For example, for "#if os(simulator)", offer a fixit to change
"os" to "targetEnvironment", instead of offering to change "simulator".

Resolves SR-11037.
2019-08-21 19:51:47 +00:00
mishal_shah
1e38fc3030 Update master to build with Xcode 11 beta, macOS 10.15, iOS 13, tvOS 13, and watchOS 6 SDKs 2019-06-03 22:50:02 -07:00
Slava Pestov
6d7d13fceb IRGen: Disable eager initialization of NSCoding adopters on newer targets
If a class does not have a custom @objc name, objc_getClass() can find
it at runtime by calling the Swift runtime's metadata demangler hook.

This avoids the static initializer on startup. If the class has a
custom runtime name we still need the static initializer unfortunately.

Fixes <rdar://problem/49660515>.
2019-05-01 17:43:58 -04:00
Slava Pestov
3b6ec6c651 IRGen: Move some deployment target checks to LangOptions 2019-05-01 15:13:12 -04:00
Han Sang-jin
859f144b75 [LangOptions] os(Cygwin) is not true on Cygwin
`Target.isOSWindows()` and `Target.isWindowsCygwinEnvironment()` are both true in Cygwin.
We should check the `os(Cygwin)` before `os(Windows)`.
2018-11-10 11:23:00 +09:00
Sho Ikeda
2a3b3483f7 [LangOptions] Avoid using a std::moved value 2018-03-08 13:34:35 +09:00
Graydon Hoare
dd81583b1a [Parse] Fix a couple typos in PR #12964 2017-11-29 11:27:21 -08:00
Graydon Hoare
3807b3fa1e [Parse] Add platform conditional targetEnvironment(simulator) 2017-11-28 13:51:01 -08:00