Commit Graph

1731 Commits

Author SHA1 Message Date
Doug Gregor
6b586b6afd Merge pull request #61252 from DougGregor/cmake-link-swiftsyntax-consistently 2022-09-22 16:28:38 -07:00
Doug Gregor
c50b142a14 [Build] Ensure that we link in SwiftSyntax and Swift for all executables 2022-09-22 12:03:19 -07:00
buttaface
c4c48c0e84 [android] Update to LTS NDK 25b (#60938)
Also, remove `SWIFT_ANDROID_NDK_CLANG_VERSION` and just extract the
resource directory from the NDK using `file(GLOB)`.
2022-09-21 10:46:29 -07:00
Doug Gregor
27b83b0f02 [Unit tests] Use the rpaths determined for unit tests
The function that adds runtime link flags overrides RPATH settings via
`BUILD_WITH_INSTALL_RPATH`. Stop doing that for unit tests, because they
depend on host libraries built into `lib` not `lib/swift/${platformname}`.
2022-09-16 22:23:29 -07:00
Egor Zhdan
84a1ffcb33 [Shims] Include SwiftShims headers without ../
This replaces a number of `#include`-s like this:
```
#include "../../../stdlib/public/SwiftShims/Visibility.h"
```
with this:
```
#include "swift/shims/Visibility.h"
```

This is needed to allow SwiftCompilerSources to use C++ headers which include SwiftShims headers. Currently trying to do that results in errors:
```
swift/swift/include/swift/Demangling/../../../stdlib/public/SwiftShims/module.modulemap:1:8: error: redefinition of module 'SwiftShims'
module SwiftShims {
       ^
Builds.noindex/swift/swift/bootstrapping0/lib/swift/shims/module.modulemap:1:8: note: previously defined here
module SwiftShims {
       ^
```
This happens because the headers in both the source dir and the build dir refer to SwiftShims headers by relative path, and both the source root and the build root contain SwiftShims headers (which are equivalent, but since they are located in different dirs, Clang treats them as different modules).
2022-09-14 11:14:50 +01:00
Doug Gregor
b247c6d9f3 Enable build of Swift Swift parser even when bootstrapping is OFF.
The Swift Swift parser doesn't require any bootstrapping, so allow it to
be built even when bootstrapping is off.
2022-09-07 17:52:21 -07:00
Evan Wilde
0d1c33674c Merge pull request #60711 from etcwilde/ewilde/reapply-backdeploy56
Revert reverting the 5.6 backdeploy
2022-09-06 14:58:17 -07:00
Egor Zhdan
ba31ca4ea6 [build] Remove unused GLIBC_INCLUDE_PATH macro
This macro was previously substituted when generating `glibc.modulemap` file during the compiler build. Now Swift detects the location of Glibc dynamically and injects `glibc.modulemap` into it using LLVM VFS. The last usage of `GLIBC_INCLUDE_PATH` was removed in `78c0540b`.

This also removes `SWIFT_SDK_${sdk}_ARCH_${arch}_LIBC_INCLUDE_DIRECTORY` which doesn't have any usages left.
2022-09-05 18:57:29 +01:00
Doug Gregor
9e387148d1 Ensure to link unit tests against the Swift libraries when using the new parser 2022-09-01 11:57:35 -07:00
Evan Wilde
312d392d16 Include host compatibility library build directory
The SDK doesn't have the new compatibility library and the
crosscompile-with-hostlibs bootstrap configuration is failing.

This bootstrap configuration is the only one that does not fall back on
the host built compatibility libraries if it is not available in the
SDK.
2022-09-01 10:07:47 -07:00
Doug Gregor
5ea5f3b45d Optional support for round-trip testing the new Swift parser.
When enabled, compile in support for round-trip testing the new
SwiftSyntax-provided Swift parser alongside the existing parser. Right
now, this means parsing every source file with the new parser and
ensuring that the resulting syntax tree can reproduce the input source
precisely. Over time, this is expected to grow.

Opt in to this behavior by passing the following to build-script:

    build-script --early-swiftsyntax --extra-cmake-options=-DSWIFT_SWIFT_PARSER_MODE:STRING=ROUNDTRIP
2022-09-01 08:56:22 -07:00
Robert Widmann
f9cff13604 Move All the Gyb Support for Syntax out of Swift
Make libSyntax depend on swift-syntax: the new home for all
of this infrastructure. This greatly simplifies the addition and
amending of syntax nodes as only the swift-syntax paired with a
swift checkout will need to be changed. This is in contrast to
the existing build flow where a paired PR to both repos must be
made to change anything here.

Note that a paired PR may still be required if the legacy parser
needs to be adjusted in response to syntax nodes changing, but I
anticipate this to be a much more infrequent event now that
the C++ end of libSyntax is deprecated.
2022-08-31 13:10:24 -07:00
Saleem Abdulrasool
1eb294d95b Merge pull request #60823 from 3405691582/cross
Preliminary Linux-OpenBSD cross-compile support.
2022-08-31 08:28:02 -07:00
Eric Miotto
b6878ce752 Link all compatibility libraries when cross compiling and bootstrapping (#60728)
Refactor the logic so to have a single target to reference the
compatibility libraries for the host, and use that when needed.

The main driver for this change is supporting the cross-compilation of
x86-64 on Apple Silicon.

Supports rdar://90307965
2022-08-31 02:18:19 -07:00
3405691582
3740a207bd Apply suggestions from code review
Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2022-08-29 10:47:42 -04:00
3405691582
47ae4d9a53 Preliminary Linux-OpenBSD cross-compile support.
With a properly prepared sysroot and toolchain file, these changes permit
cross-compilation of Swift as well as LLVM, CMark, and Dispatch (picking,
as usual, apple/swift-corelibs-libdispatch#556) from a Linux host
generating OpenBSD binaries.

The toolchain file must be specified as an environment variable to
`build-script` and discussion on how to properly set up the sysroot and
toolchain file will be handled later.
2022-08-28 22:39:46 -04:00
Mishal Shah
196ee143c5 Xcode 14 beta 4 no longer supports iOS armv7, armv7s, and i386 architectures
> Building iOS projects with deployment targets for the armv7, armv7s, and i386 architectures is no longer supported. (92831716)
2022-08-02 20:42:08 -07:00
Alastair Houghton
1b34fa9c5c [Threading] Minor improvements to SWIFT_THREADING_PACKAGE support
Added a check that someone hasn't passed us an argument with too many
colons.  Also renamed `find_threading_package` to `get_threading_package`
to better reflect what it does.
2022-07-01 15:06:25 +01:00
Alastair Houghton
b5735559eb [Threading] Fix threading package defaults.
These are better done via the SwiftConfigureSDK mechanism rather than
how I was doing them previously.  Additionally, I've changed the way
that the swift-threading-package option works.  In addition to
specifying just a single package name, you can specify it as a CMake
list (i.e.  separate by semicolons) of colon-separated `sdk:package`
pairs, e.g.  `osx:darwin;linux:pthreads`.  You can also override it
for all SDKs and then specify for a given SDK; specifications for a
particular SDK take precedence over the global override.  For instance
`pthreads;osx:darwin` says to use `pthreads` except on the OS X SDK
where we should use `darwin`.
2022-06-30 16:07:00 +01:00
Daniel Rodríguez Troitiño
036e16810a [Cxx] Make C++ flags configurable for Linux SDK (#59764)
Allow Linux distributions to provide their own C++ flags to compile the
C++ overlay correctly. The default is kept the same for Ubuntu and
CentOS, but other distributions can provide other flags to use their own
distro GCC stdlibc++ or even libc++ if they choose.

This should not change the current compilation, but opens the door for
other maintainers to provide a different value that work on their
systems.
2022-06-29 08:54:56 -07:00
Alastair Houghton
a9fe9716da Merge pull request #59287 from al45tair/eng/PR-90776105-2
[Build][Runtime] Add a new threading library.
2022-06-09 02:41:53 -07:00
Rintaro Ishizaki
e1412a0978 Merge pull request #59209 from rintaro/syntaxparser-libswift
[SwiftCompilerModules] Link lib_InternalSwiftSyntaxParser to libswift
2022-06-08 15:36:21 -07:00
Alastair Houghton
f5bdb858e0 [Threading] Create new threading library and use it.
Moved all the threading code to one place.  Added explicit support for
Darwin, Linux, Pthreads, C11 threads and Win32 threads, including new
implementations of Once for Linux, Pthreads, C11 and Win32.

rdar://90776105
2022-06-07 07:39:51 +01:00
Alastair Houghton
0cf687aa2b [Build][Runtime] Replace SWIFT_STDLIB_SINGLE_THREADED_RUNTIME.
SWIFT_STDLIB_SINGLE_THREADED_RUNTIME is too much of a blunt instrument here.
It covers both the Concurrency runtime and the rest of the runtime, but we'd
like to be able to have e.g. a single-threaded Concurrency runtime while
the rest of the runtime is still thread safe (for instance).

So: rename it to SWIFT_STDLIB_SINGLE_THREADED_CONCURRENCY and make it just
control the Concurrency runtime, then add a SWIFT_STDLIB_THREADING_PACKAGE
setting at the CMake/build-script level, which defines
SWIFT_STDLIB_THREADING_xxx where xxx depends on the chosen threading package.

This is especially useful on systems where there may be a choice of threading
package that you could use.

rdar://90776105
2022-06-07 07:39:51 +01:00
Rintaro Ishizaki
9f4ce612a2 [SwiftCompilerModules] Link lib_InternalSwiftSyntaxParser to libswift
To use _RegexParser from SwiftSyntax.

* Create 'libswiftCompilerModules_SwiftSyntax.a' which is a subset of
  'libswiftCompilerModules.a'
* Link 'lib_InternalSwiftSyntaxParser' to
  'libswiftCompilerModules_SwiftSyntax.a'
* Factor out swift runtime linking logic in CMake so that dynamic
  libraries can link to Swift runtime, in addition to executables
* Link 'lib_InternalSwiftSyntaxParser' to swift runtime
2022-06-02 12:23:03 -07:00
Saleem Abdulrasool
b739394344 cmake: add android runtime build caches
These cache files allow building the runtime via cross-compilation for
Android ARMv7 and AArch64.
2022-05-31 08:17:30 -07:00
3405691582
5f7f7f5cdd [cmake] OpenBSD uses libc++.
Therefore, do not generate a libstdcxx.modulemap. See also #58497.
2022-05-13 15:15:28 -04:00
Egor Zhdan
6332edb98b Merge pull request #42297 from apple/egorzhdan/libswift-std-string
Reapply [cxx-interop][libswift] Use `std::string` instead of `BridgedStringRef`
2022-05-05 16:42:06 +01:00
Josh Soref
b5b33d42f0 Spelling cmake (#58569)
* spelling: and

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

* spelling: intentionally

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

* spelling: simulator is

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

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-04 19:23:16 -07:00
Egor Zhdan
67a28c78d5 [cxx-interop][SwiftCompilerSources] Enable libstdc++ on platforms that use it
Since libstdc++ doesn't come with a Clang modulemap, Swift provides its own modulemap for libstdc++. This change makes the modulemap available while building SwiftCompilerSources.
2022-05-03 19:48:14 +01:00
Mishal Shah
d292a852d8 Merge pull request #40188 from apple/QuietMisdreavus/cmark
use swift-cmark/gfm instead of /main
2022-05-02 10:20:23 -07:00
Saleem Abdulrasool
4dd4b61dc5 Merge pull request #58467 from compnerd/ndk-path
build: convert NDK path on Windows
2022-04-28 08:08:22 -07:00
Eric Miotto
c43f60a219 Use the correct platform toolchain folder... (#58416)
...when bootstrapping with hosttools.

This would align with how the SDK path is calculated.

Addresses rdar://92298536
2022-04-27 14:50:25 -07:00
Saleem Abdulrasool
cb3d578ddc build: convert NDK path on Windows
Convert the NDK path to allow the native path to be used when
configuring the Swift runtime but use the CMake spelling when
performing the inner configure.
2022-04-27 14:04:47 -07:00
Daniel Duan
1b85082424 [cmake] Remove Python 2 from build requirement (#42434)
In theory, this requirement is no longer necenssary. Let's see if CI
agrees.
2022-04-18 20:51:32 -07:00
Saleem Abdulrasool
699202656a caches: tweak the Windows toolchain build
Update the toolchain configuration to disable the python home embedding.
This should allow us to be more freestanding of the python location and
give us better control of the python library being used.
2022-04-10 21:39:11 -07:00
Victoria Mitchell
455cdbc5a7 use swift-cmark/gfm instead of /main 2022-03-16 14:56:21 -06:00
Vincent Lee
209c5c735b Prevent linker errors when building dispatch with instrumentation (#41819)
When building Swift with IRPGO, libdispatch needs the CMAKE_*_LINKER_FLAGS in order to properly statically link to the clang runtimes library.
2022-03-16 11:16:34 -07:00
Robert Widmann
7cd3541c62 Merge pull request #41656 from MillerTechnologyPeru/feature/ppc32
[stdlib] Added PowerPC 32-bit support
2022-03-07 15:08:26 -08:00
Alsey Coleman Miller
b85e673a78 [stdlib] Added Armv5 support 2022-03-06 00:56:32 -05:00
Alsey Coleman Miller
0ab3eec987 Added PowerPC 32-bit support 2022-03-03 22:21:33 -05:00
Artem Chikin
a64f04e88f Merge pull request #41205 from artemcm/StandaloneStaticMirror
Build `libSwiftStaticMirror` as a standalone library with minimal required dependencies.
2022-02-10 08:32:14 -08:00
Artem Chikin
d24e15812b Build libSwiftStaticMirror as a standalone library with minimal required dependencies.
This separates it from `libSwiftScan` and allows us to build this library without building much of the rest of the compiler.

Also refactor `utils/build-parser-lib` into `utils/build-tooling-libs` which builds both SwiftSyntaxParser and SwiftStaticMirror.
2022-02-09 12:28:21 -08:00
Eric Miotto
f417630054 Add option to reduce build times when using ThinLTO and ld64 (#41058)
Internal configurations targeting Darwin employ ThinLTO to
improve compiler performance, however using it on all executable
causes build time to increase with no matching benefit.

To reduce build times in such configurations, we allow some
ancillary targets to opt out of LLVM IR optimizations when linking
ThinLTO with ld64 (e.g. tools used for bootstrapping or debugging the
Swift compiler) -- this behaviour is opt in through a new flag
`--swift-tools-ld64-lto-codegen-only-for-supporting-targets`.

Addresses rdar://76702687
2022-02-09 08:22:02 -08:00
Kuba (Brecka) Mracek
c257709223 On Darwin, pass LIBLTO_PATH to 'ar' and 'lipo' commands from CMake (#41243) 2022-02-08 04:51:50 -08:00
Eric Miotto
64bc16abd5 [CMake] set target architecture for Darwin idiomatically (#41059)
Previously we were setting `-arch` explicitly and unsetting
`CMAKE_OSX_ARCHITECTURES`; however this approach does not work when
building on Apple Silicon, since in there CMake 3.19+ enforces a default
value
(https://gitlab.kitware.com/cmake/cmake/-/merge_requests/5291/diffs),
and this would result in the inability to compile code for x86_64.

This is a similar approach used for stdlib targets in #38415

Addresses rdar://88100025
2022-01-31 12:46:53 -08:00
Alexander Smarus
4cc528d844 [cmake] Add support for external clang/clang-cl
We need an option to pass external host clang location in case
we can't use just-built clang, e.g. when we are building for
different target architecture.

Also, this adds target options for clang-cl, enabling us to
build for arm64 on Windows@amd64.
2022-01-17 16:50:06 +02:00
Butta
0cf765adf4 [build] Remove SWIFT_SDK_${OS}_ARCH_${ARCH}_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY CMake variable 2022-01-09 13:27:27 +05:30
Eric Miotto
127528a3d0 Move more Standard Library options to dedicated file (#40723)
This addresses most of the options with computed defaults.

Addresses rdar://86723940
2022-01-06 07:12:18 -08:00
Erik Eckstein
3d33f11e6c cmake/build-script: rename the libswift option to "bootstrapping"
In cmake, rename LIBSWIFT_BUILD_MODE to BOOTSTRAPPING_MODE.
Also, rename the lit feature "libswift" to "swift_in_compiler".
2021-12-22 11:31:52 +01:00