Commit Graph

650 Commits

Author SHA1 Message Date
Anthony Latsis
2920ea84d1 Address llvm::(Mutable)ArrayRef ctor deprecations
See:
- https://github.com/llvm/llvm-project/pull/146113
- https://github.com/llvm/llvm-project/pull/146011
2025-07-21 12:36:53 +01:00
Artem Chikin
10cd7baef0 [Legacy Driver] Obsolete and remove batch compilation mode from the legacy driver
It is a maintenance burden and having the legacy driver exist in a simplified state reduces the possibility of things going wrong and hitting old bugs.
2025-06-06 09:51:00 -07:00
Tony Allevato
2cfcdd8ed1 Add a new driver tool/mode to print the synthesized Swift interface for a module.
This mode is similar to `swift-symbolgraph-extract`; it takes a subset of compiler
flags to configure the invocation for module loading, as well as a module name
whose contents should be extracted. It does not take any other input files. The
output is a single text file specified by `-o` (or `stdout` if not specified).

While the most common use case for this would be viewing the synthesized Swift
interface for a Clang module, since the implementation simply calls
`swift::ide::printModuleInterface` under the hood, it's usable for any module
that Swift can import. Thus, it could also be used to view a synthesized textual
representation of, say, a compiled `.swiftmodule`.

One could imagine that in the future, we might add more flags to
`swift-synthesize-interface` to modify various `PrintOptions` used when
generating the output, if we think those would be useful.
2024-10-10 15:30:41 -04:00
Saleem Abdulrasool
6443619126 Remove swift-indent tool
This removes the implementation of the `swift-indent` tool, its
associated documentation, and utilities. This tool was never completed
and has much better alternatives with `swift-format` which is more
flexible and actually maintained.
2024-09-19 11:21:59 -07:00
Daniel Rodríguez Troitiño
5280cea889 [Macros] In-process plugin server library tied to compiler host, not target (#74785)
PR #73725 introduced the in-process plugin server library, but the
selection of the library depends on the selected toolchain, which
depends on the compiler target, not the host. When cross-compiling (for
example from macOS to a embedded Unix target), the compiler will
incorrectly chose the `.so` file, not find it, and fail to compile
things like the `@debugDescription` macro.

Move the in-process plugin server library code from the platform
toolchains into the parent type, and code it so it uses the right name
depending on the compiler host at compilation time. This discards the
target and only relies on the compiler host for selecting the right
library.
2024-07-01 08:50:54 -07:00
Allan Shortlidge
470baff865 Driver: Remove swift-api-extract.
Now that API descriptions are emitted during module build jobs when
`-emit-api-descriptor-path` is specified and the build system has been updated
to pass that flag when the output is needed, the `swift-api-extract` frontend
alias is no longer used. Delete it and the tests that were specific to invoking
`swift-api-extract`.

Resolves rdar://116537394.
2024-06-27 17:05:32 -07:00
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
1de479d4c1 Remove the last few llvm::Optional
Not sure how I missed these in the previous lot, but actually remove all
this time.
2024-02-23 16:42:30 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Ben Barham
e17598324c Add a couple missing Optional includes
To avoid synced PRs, add some temporary `Optional.h` includes so that
the move from `llvm::Optional` -> `std::optional` in LLVM can be merged.

Once the LLVM change is in we can merge the Swift move. Then we'll need
one final PR to fully remove `Optional.h` and `None.h` (this will likely
have to be a synced PR since optional references keep being added).
2024-02-12 18:20:35 -08:00
Artem Chikin
73b01dccfc Remove incremental builds from the Legacy driver
The C++-based driver is deprecated and this will help reduce the code surface that requires maintenance as the legacy driver is fully sunset.
2024-01-16 16:34:51 -08:00
usama
3053fe01b5 [Sanitizers] Add new sanitize-stable-abi flag for libsanitizers.
This patch adds a new flag sanitize-stable-abi to support linking
against the Sanitizers stable ABI added recently in compiler-rt. The
patch also passes extra options for the ASan pass when using this flag
to outline instrumentation code and remove version check.

rdar://112915278
2023-12-16 14:13:00 -08:00
Ellie Shin
aba3b6c24e Introduce a package interface.
It has an extension .package.swiftinterface and contains package decls
as well as SPIs and public/inlinable decls. When a module is loaded
from interface, it now looks up the package-name in the interface
and checks if the importer is in the same package. If so, it uses
that package interface found to load the module. If not, uses the existing
logic to load modules.

Resolves rdar://104617854
2023-11-08 14:56:20 -08:00
Rintaro Ishizaki
22592d22fc Merge pull request #69470 from rintaro/swift-parse-test
[swift-parse-test] A parser performance check utility
2023-10-30 15:35:57 -07:00
Rintaro Ishizaki
e01df929c2 [swift-parse-test] A parser performance check utility
```
% swift-parse-test -swift-parser -lib-parse -n 20 ../swift-syntax/Sources
files count: 228
total bytes: 5662399
total lines: 158428
iteration: 20
----
parser:  SwiftParser
wall clock time (ms): 3848
cpu time (ms): 3843
throughput (byte/sec): 355824
throughput (line/sec): 41225
----
parser:  libParse
wall clock time (ms): 296
cpu time (ms): 290
throughput (byte/sec): 4715281
throughput (line/sec): 546303
```
2023-10-28 20:23:26 -07:00
Adrian Prantl
5d978b44ca Revert "Revert "Make the DWARF version emitted by the Swift compiler configurable."" 2023-10-26 12:29:18 -07:00
Adrian Prantl
2a32ca5944 Revert "Make the DWARF version emitted by the Swift compiler configurable." 2023-10-25 13:28:28 -07:00
Adrian Prantl
a26bbb0baf Make the DWARF version emitted by the Swift compiler configurable.
Previously it was hardcoded to version 4 on all platforms.
This patch introduces a driver and frontend option -dwarf-version to configure it if needed.
2023-10-24 12:30:16 -07:00
swift-ci
d7622b5963 Merge remote-tracking branch 'origin/main' into rebranch 2023-09-04 18:36:48 -07:00
Saleem Abdulrasool
fcd7b9e533 Driver: virtualise the plugin path handling
The plugin layouts are different across platforms.  Move this into a
virtual method and allow replacement.  On Windows, the plugins are
placed into the `bin` directory as the DLLs should always be co-located
to ensure that the proper DLLs are found (there is no concept of RPATH).
2023-09-04 15:21:39 -07:00
swift-ci
b3d440d3a1 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-11 11:54:02 -07:00
Paolo Tranquilli
5b755228c3 Fix Compilation::Result constructor 2023-08-11 12:34:05 +02:00
Paolo Tranquilli
3b8597ca25 Merge branch 'main' into c++20-compatibility 2023-08-10 09:51:53 +02:00
Becca Royal-Gordon
3eebc6dddb Merge branch 'main' into rebranch
# Conflicts:
#	lib/SILOptimizer/Differentiation/Common.cpp
2023-08-04 15:09:50 -07:00
Tony Allevato
79935f9720 Add explicit ctors for aggregation for types that default or delete ctors.
In C++20, types that declare or delete their default/copy/move constructors are no longer aggregates, so the aggregate uses of these types will not compile under C++20. Adding them fixes this, without affecting older language modes.
2023-08-02 14:22:32 -04:00
Paolo Tranquilli
e13a85c8f1 NFC: make headers compatible with C++20
In a downstream project we are using the Swift code as a library and
compiling with C++20. This mostly works except for two backward
incompatibilities introduced by C++20:

* [P1008] disallows aggregate initialization when defaulted or deleted
  constructors are specified. This lead to a compilation error for
  aggregate initialization of `swift::Compilation::Result`. The backward
  and forward compatible fix for that is to provide a constructor
  turning aggregate initializations into a normal constructor call.
* [P1185] introduces more candidates for overload resolution of
  comparison operator calls. As explained in [P1630], this leads in some
  cases to ambiguity compilation errors in C++20, which is exactly the
  case with `swift::ValueOwnershipKind`. The fix in this case is to
  remove some redundant operator calls conditionally on the
  `__cpp_impl_three_way_comparison` feature test macro, which [includes
  the papers mentioned above][feature_test].

[P1008]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf
[P1185]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1185r2.html
[P1630]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1630r1.html
[feature_test]: https://en.cppreference.com/w/cpp/feature_test
2023-07-31 17:34:05 +02:00
Evan Wilde
26a974e772 [NFC] Headers headers headers!
Including headers that were being transitively included from LLVM
before. Also pointing them at the new locations for some of them.
2023-07-17 10:55:55 -07:00
Evan Wilde
41d59b215a Update Triple.h location
Triple moved from ADT to TargetParser. Updating includes to reflect
that.
2023-07-17 10:53:42 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Doug Gregor
1ec900e2a0 [Macros] Add default plugin paths for Darwin SDKs and platforms.
Corresponding to https://github.com/apple/swift-driver/pull/1377, this
adds some default plugin paths for Darwin SDKs and platforms.
Fixes rdar://110819604.
2023-06-16 14:55:20 -07:00
Steven Wu
86927ef39c Merge pull request #65288 from cachemeifyoucan/eng/PR-swift-cache-backend
[CAS] Teach swift compiler to compute cache key and store outputs into CAS
2023-04-25 09:23:15 -07:00
Steven Wu
c153210505 [CAS] Add test case for cache key computation
Add tool swift-cache-tool for caching related testing and inspection.
2023-04-24 13:56:33 -07:00
Erik Eckstein
e7af73e2de Replace the swift-llvm-opt binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:53:12 +02:00
Erik Eckstein
2b2bc45e08 Replace the swift-dependency-tool binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:51:04 +02:00
Erik Eckstein
8ce6038a42 Replace the sil-passpipeline-dumper binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:49:33 +02:00
Erik Eckstein
e3a174b85e Replace the sil-llvm-gen binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:48:23 +02:00
Erik Eckstein
bc7b632d3e Replace the sil-nm binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:47:13 +02:00
Erik Eckstein
b6132d10e5 Replace the sil-func-extractor binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:45:22 +02:00
Erik Eckstein
2e9c241034 Replace the sil-opt binary with a symlink to swift-frontend
rdar://76551283
2023-04-24 13:44:04 +02:00
Rintaro Ishizaki
3517db4c3b [SourceKit] Pass 'swiftc' path to Driver when creating frontend args
Driver uses its path to derive the plugin paths (i.e.
'lib/swift/host/plugins' et al.) Previously it was a constant string
'swiftc' that caused SourceKit failed to find dylib plugins in the
toolchain. Since 'SwiftLangSupport' knows the swift-frontend path,
use it, but replacing the filename with 'swiftc', to derive the plugin
paths.

rdar://107849796
2023-04-12 09:53:43 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08: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
Josh Soref
66d267e6ff Spelling driver (#42516)
* spelling: associated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: change

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: declaration

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: dependents

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: deterministically

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: embedded

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exclude

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: filesystem

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: given

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: grained

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: incrementality

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: invoke

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: locals

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: preexisting

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: should

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: supplementary

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: suppress

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 09:10:43 -07:00
Adrian Prantl
5956b6b226 Darwin: introduce a global override for debug prefix map entries
This patch adds a new Darwin Swift driver environment variable in the spirit of
RC_DEBUG_OPTIONS, called RC_DEBUG_PREFIX_MAP, which allows a meta build tool to
add one additional -fdebug-prefix-map entry without the knowledge of the build
system.

See also https://reviews.llvm.org/D119850

rdar://85224717
2022-02-15 15:36:15 -08:00
Rajagopalan-Gangadharan
48de17d140 Address review comments for reusable function 2021-08-11 10:08:59 +05:30
Rajagopalan-Gangadharan
90637aa8ee Take care of OPT_linker_option_Group to produce desired behaviour
The -l args values are handled by OPT_l and OPT_linker_option_Group,
to do this have created a helper method under Toolchain
2021-08-07 16:23:08 +05:30
Jeremy Legendre
35735e7d0c [LTO] Driver support for -lto_library flag
This commit adds support for the -lto_library flag, allowing users to specify a custom LTO library on Darwin. This also fixes an issue where the default LTO library is used even if Driver is run from inside an alternate toolchain.
2021-07-05 18:01:40 -04:00
Alex Hoppen
44f8e195ef [SourceKit] Recover if compiler arguments have errors
If the compiler arguments have errors in them (e.g. because a file with the same name is used twice), we can often still fulfill SourceKit requests because the compiler argument errors are only relevant for later stages of the compilation process.

Instead of bailing out early, do a best effor retrieving the compiler arguments that are valid and ignoring the errors.

Fixes rdar://77618144
2021-05-19 22:31:15 +02:00