Commit Graph

70 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Brent Royal-Gordon
5f523fee66 Add flag to verify just-emitted module interfaces
The driver can now schedule jobs which typecheck just-emitted module interfaces to ensure that they can be consumed later. This can be enabled manually by passing `-verify-emitted-module-interface` to the driver.
2020-08-07 17:45:03 -07:00
martinboehme
40104ba8b1 Link against the C++ standard library when C++ interop is enabled (#30914)
This doesn't yet allow including C++ headers on platforms where libc++
isn't the default; see comments in UnixToolChains.cpp for details.

However, it does, for example, allow throwing and catching exceptions in C++
code used through interop, unblocking
https://github.com/apple/swift/pull/30674/files.

The flags (-enable-experimental-cxx-interop and -experimental-cxx-stdlib) carry
"experimental" in the name to emphasize that C++ interop is still an
experimental feature.

Co-authored-by: Michael Forster <forster@google.com>
2020-07-09 15:59:26 +02:00
Doug Gregor
548e28170a [Driver/Frontend] Thread the target SDK version through to the IR.
Teach the driver to pass the SDK version it computes (from the SDK
settings JSON in a Darwin-based platform's SDK) down into the frontend.
The frontend then sets that SDK version in the LLVM module, which
eventually makes its way into the Mach-O file.

Last part of rdar://problem/60332732.
2020-04-15 21:42:28 -07:00
Doug Gregor
970ff6b818 [Driver] Read SDK version information to pass to the Darwin linker.
Recent-ish SDKs for Darwin platforms include an SDKSettings.json
file with version information and Catalyst SDK version mappings. Read
these (when available) and use them to pass the appropriate SDK
version down to the Darwin linker via `-platform_version`.

Finishes rdar://problem/55972144.
2020-04-02 21:07:26 -07:00
Francis Visoiu Mistrih
e724ebab6b [Remarks] Add a specialized RemarkStreamer for SIL remarks
This allows the usage of the whole remark infrastructure developed in
LLVM, which includes a new binary format, metadata in object files, etc.

This gets rid of the YAMLTraits-based remark serialization and does the
plumbing for hooking to LLVM's main remark streamer.

For more about the idea behind LLVM's main remark streamer, see the
docs/Remarks.rst changes in https://reviews.llvm.org/D73676.

The flags are now:

* -save-optimization-record: enable remarks, defaults to YAML
* -save-optimization-record=<format>: enable remarks, use <format> for
serialization
* -save-optimization-record-passes <regex>: only serialize passes that
match <regex>.

The YAMLTraits in swift had a different `flow` setting for the debug
location, resulting in some test changes.
2020-03-02 18:33:20 -08:00
Devin Coughlin
655d89b146 [Driver/Frontend] Add Driver support for macCatalyst and library search paths
Add support in the driver and frontend for macCatalyst target
targets and library search paths.

The compiler now adds two library search paths for overlays when compiling
for macCatalyst: one for macCatalyst libraries and one for zippered macOS
libraries. The macCatalyst path must take priority over the normal macOS path
so that in the case of 'unzippered twins' the macCatalyst library is
found instead of the macOS library.

To support 'zippered' builds, also add support for a new -target-variant
flag. For zippered libraries, the driver invocation takes both a -target and a
-target-variant flag passes them along to the frontend. We support builds both
when the target is a macOS triple and the target variant is macCatalyst and
also the 'reverse zippered' configuration where the target is macCatalyst and the
target-variant is macOS.
2020-01-21 18:28:17 -08:00
Jordan Rose
419e97d7db Merge pull request #26136 from LucianoPAlmeida/patch-sr11015
[Driver] DarwinToolChain should explicitly reject -static-stdlib
2019-07-16 08:55:25 -07:00
Luciano Almeida
83ede1f3cc Forward declaring and improvement on warning. 2019-07-15 22:20:00 -03:00
Luciano Almeida
217887ae91 Fixing nitpicks. 2019-07-15 22:12:51 -03:00
Luciano Almeida
c95f28c9dc Moving -static-stdlib validation to Darwin toolchain. 2019-07-15 21:02:39 -03:00
Harlan Haskins
21bd24a150 Revert "[Driver] Load the standard library before starting parallel frontend invocations"
This failed the source compat suite, it seems we need more driver
changes for this.
2019-07-12 21:38:23 -07:00
Harlan Haskins
7022110a05 [Driver] Load the standard library before starting parallel frontend invocations
Add a new action, LoadModuleJobAction, that the driver can use to schedule a
load of a given module before we fan out and invoke the frontend multiple
times. This gives the module interface loader a chance to compile it from a
module interface before we start with parallel invocations, avoiding starting
potentially dozens of redundant compiles of a large module. Start by using this
on the standard library.

Quick fix for rdar://52839445
2019-07-12 14:53:25 -07:00
Brent Royal-Gordon
1e81ced48d Revert "Revert "Look up runtime libraries in SDK"" 2019-07-03 14:18:48 -07:00
Xi Ge
fdd41aeb68 Revert "Look up runtime libraries in SDK (#25740)"
This reverts commit b818b441f2.
2019-06-25 17:48:41 -07:00
Brent Royal-Gordon
b818b441f2 Look up runtime libraries in SDK (#25740)
In #23175, we started looking in the SDK for swiftmodules, but we want to look for the dylibs there too. Fixes <rdar://problem/52059706>.
2019-06-25 15:39:03 -07:00
Thomas Roughton
e5ea42d774 Driver: renamic LinkJob to DynamicLinkJob and ArchiveJob to StaticLinkJob
# Conflicts:
#	lib/Driver/DarwinToolChains.cpp
2019-06-17 12:49:17 +12:00
Thomas Roughton
b34a1cbbc6 Driver: add -static flag for generating static archives 2019-06-17 12:49:03 +12:00
Tony Allevato
6d7223023d Fix response file support for batch jobs. 2019-04-13 10:06:30 -07:00
Jordan Rose
67a6a4ff18 Move swift/Frontend/FileTypes.h down to Basic
The next commit will take advantage of this, but this is just a
mechanical change.
2018-07-25 22:23:00 -07:00
Jordan Rose
7d8e40b0bb Merge pull request #16362 from dabelknap/frontend_responsefile
Wrap Command Line Arguments in a Response File if System Limits are Exceeded

https://bugs.swift.org/browse/SR-4517
2018-06-21 16:31:20 -07:00
Austin Belknap
f6b5cf5b7c Further clarify the purpose of "allowsResponseFiles" flag. 2018-06-15 16:14:07 -07:00
Tony Allevato
0acc73ae4c Update flag name to -debug-info-store-invocation. 2018-06-12 18:32:35 -07:00
Tony Allevato
22ac700154 Make DWARF debug flag behavior match Clang.
Only write the compilation flags to debug info for Mach-O targets, and only
if the RC_DEBUG_OPTIONS environment variable is set.
2018-06-09 20:05:06 -07:00
Austin Belknap
fe4f21d3ca Elaborate on the allowsResponseFiles flag. 2018-05-16 13:42:28 -07:00
Austin Belknap
2297f75c4a Move the "allowsResponseFiles" flag to the ToolChain. 2018-05-11 15:21:25 -07:00
Graydon Hoare
39fdf5d4e5 [BatchMode] <rdar://39981525> Emit parseable output for each job, using quasi-PIDs. 2018-05-10 20:34:33 -07:00
Thomas Roughton
0506ccc244 Refactor ToolChains into separate files. (#16091)
Format the code and factor together some common functionality at the same time.
2018-05-02 11:11:54 -07:00
Nathan Hawes
0a4204e99f [Driver] Add -driver-filelist-threshold to set the number of inputs beyond which filelists are used
When generating a compiler invocation in driver::createCompilerInvocation()
we end up using filelists if the number of inputs is > 128 (to work around
command line arg limits). We never actually write them out though, and so
fail when parsing the frontend arguments that reference them.

As this function is called frequently by SourceKit and command line limits
aren't a concern here, this patch makes the 128 threshold value configurable
via a new -driver-filelist-threshold option. This is set to its maximum value
in driver::createCompilerInvocation() to ensure filelists aren't used. This
new option makes the existing -driver-use-filelists (that forces filelists to
be used) redundant as it's now equivalent to -driver-filelist-threshold=0.

Resolves rdar://problem/38231888
2018-04-12 05:24:03 -07:00
David Ungar
807dd5864e Renamed swift::types to swift::file_types. 2018-03-22 08:40:06 -07:00
David Ungar
90773d298c Write out filemaps for supplementary outputs.
Add -driver-force-one-batch-repartition and enhance  batch_mode-overlong_argv test.
2018-03-20 09:42:13 -07:00
George Karpenkov
a65da887f2 Determine whether a given sanitizer is available based on the presenc… (#14919)
Determine whether a given sanitizer is available based on the presence of the library.

rdar://37192887
2018-03-02 16:57:45 -08:00
Graydon Hoare
2bf7a7967a [BatchMode] Add batch-mode support methods to ToolChain. 2018-02-15 15:38:09 -08:00
Graydon Hoare
d74c1a512a [BatchMode] Make InvocationInfo and Job support multiple FilelistInfos, NFC. 2018-01-19 15:15:08 -08:00
Brian Gesiak
3f8e8084ff [Driver] Remove unused input type code (NFCI)
Summary:
When the Swift driver executable was first added in
ed2038585f,
the code included a FIXME to support input types, like Clang's
`-x <language>` option. Perhaps as a first step in implementing this
functionality, it also included dead code that manipulated an input type
argument, even though the variable for storing the argument was never
written to.

Remove the unused input type code, and the FIXME. The FIXME is now
tracked with a Swift bug URL, so that a discussion on next steps can be had:
https://bugs.swift.org/browse/SR-6054

Test plan: `utils/build-script --release --test`
2017-10-04 13:53:14 -04:00
Jordan Rose
4934c57491 [Driver] Remove ActionList typedef, improve const correctness.
No functionality change.
2017-08-11 21:09:34 -07:00
George Karpenkov
479aeca88c Addressing code review comments. 2017-06-16 13:26:46 -07:00
George Karpenkov
9637bd2c36 Change driver logic for sanitizers support.
With this patch different sanitizers (tsan/asan) will be enabled or
disabled on the driver level on a particular OS depending on whether
the required library is present.

The current patch only supports Darwin architectures, but Linux support
should not be hard to add.
2017-06-16 13:26:46 -07:00
Matthew Carroll
d12daa736a [Driver] SR-2396: Driver should have a -verify-debug-info option
Add a -verify-debug-info option that invokes dwarfdump --verify as the last step after running dsymutil. dwarfdump is invoked with same options clang 802.0.35 uses to invoke it:

dwarfdump --verify --debug-info --eh-frame --quiet

A warning is produced if -verify-debug-info is set and no debug option is also set.

dwarfdump is failing to validate the debug info in the test verify-debug-info.swift. The failure is:
error: .debug_line[0x0000007d].row[0].file = 1 is not a valid index

https://bugs.swift.org/browse/SR-2396
2017-03-24 16:42:39 -04:00
Graydon Hoare
3b0b8c3270 [Bridging PCH] Auto-generate and use temporary bridging PCHs from driver. 2017-01-13 15:18:40 -08:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00