Commit Graph

934 Commits

Author SHA1 Message Date
Alastair Houghton
2056b26258 [Build] Move the .cfg file generation to a new product.
We need to move the `.cfg` file generation to a new product so that we can
land it in the default toolchain for Xcode.

rdar://128612098
2024-05-24 08:27:17 +01:00
Yuta Saito
1148e26ae4 build: Build Swift SDK earlier than SwiftPM to allow SwiftPM to use it
Just built Swift SDK would be useful for SwiftPM to perform integration
tests. All of those products do not depend on just built SwiftPM
(WasmKit is built using host tools), so it is safe to build them earlier.
2024-05-22 14:14:12 +00:00
Yuta Saito
f9a14b8f10 build: Build Swift SDK for WebAssembly
This change adds a new product, WasmSwiftSDK, to build the Swift SDK for
WebAssembly. The product is built using the swift-sdk-generator package
and takes just built WebAssembly stdlib, clang runtime libraries,
and wasi-sysroot as input, and produces a Swift SDK artifactbundle under
swift-sdk-generator/Bundles.
2024-05-22 14:14:12 +00:00
Yuta Saito
c7dfc48dd7 [wasm] Enable Distributed module build for Wasm target 2024-05-22 08:51:41 +00:00
Yuta Saito
0f50aca4e9 [test] Move embedded wasm tests to a separate directory
The `classes-wasm.swift` test was the only executable test for
WebAssembly that requires wasm runtime at test-time. Other tests
in the `embedded` directory run only on the macOS / Linux host toolchain
builds and some of them are incompatible with SWIFT_SHOULD_BUILD_EMBEDDED_STDLIB=OFF.
Given that the `classes-wasm.swift` test is the only test we want to run
during WasmStdlib build, move it to a separate directory `embedded/wasm`.
2024-05-20 11:55:10 +00:00
Yuta Saito
a06dc0e12e [wasm] Repair build for recent SwiftDriver linkage changes
- Before f34d388bf2, the EarlySwiftDriver used Dispatch/Foundation from
old host toolchain at the initial "build" step, and then re-linked the just
built Dispatch/Foundation at "install" step.
- WasmStdlib product incorrectly set `BOOTSTRAPPING_MODE` to `HOSTTOOLS`
and it makes `SwiftSource.cmake` set `LD_LIBRARY_PATH` to load the
Dispatch/Foundation from the just built toolchain (SWIFT_NATIVE_SWIFT_TOOLS_PATH).

After f34d388bf2, the EarlySwiftDriver always uses the corelibs of
the old host toolchain, so setting `LD_LIBRARY_PATH` leads to loading
incompatible corelibs of the old host toolchain, and the build fails.

This change tells the CMake build system to use CROSSCOMPILE mode.
We already built the toolchain for the current host from the revision
being built for the target, so we don't need to inject the lib library
of the old host toolchain.
2024-05-20 06:29:45 +00:00
Eric Miotto
ce0e620d1a [CMake] allow custom options when building the compiler with debug info
Currently those are hardcoded to `-g`, but in some Apple internal
configurations we would like to change them.

There are other part of the build system that hardcode `-g`
(e.g. in `SwiftCompilerSources` and `AddSwiftStdlib.cmake`),
but we are not interested in those at the moment -- we will address those
in the future if need be.

Supports rdar://127503136
2024-05-14 08:42:35 -07:00
Kuba Mracek
921c0e530e Simplify lld selection logic in build_script_invocation.py 2024-05-09 09:40:33 -07:00
Kuba Mracek
30a5986a21 [lld] Allow opt-out from building lld via --skip-build-lld 2024-05-09 09:18:51 -07:00
Alastair Houghton
9e2c13bd10 Merge pull request #71839 from al45tair/eng/PR-123503470
[Build] Add the new fully-static Linux SDK.
2024-05-06 17:34:22 +01:00
Alastair Houghton
62c80a1073 [Build] A couple more Python fixes.
Remove unused import of `importlib.resources`.

Set `test_linux_static` to `False` if tests are disabled.

rdar://123503470
2024-05-03 10:46:22 +01:00
Alastair Houghton
3627507eb1 [Build] Further static Linux SDK support changes.
Fix some indentation issues.

Change `build-script-impl` to make `build-linux-static` a positive argument.

Fix documentation for `--linux-archs` and `--linux-static-archs` (the options
are comma separated for `build-script`, but semicolon separated for
`build-script-impl`).

Set the default for `linux-static-archs` to `x86_64, aarch64` so that we
install the expected content in the toolchain.

Add missing default for `test_linux_static`.

Make sure to pass down `--skip-build-linux` and `--build-linux-static`.

Factor out config file generation and call it from the install step in `llvm.py`
as well as from the build step.

rdar://123503470
2024-05-03 09:12:49 +01:00
Evan Wilde
f34d388bf2 Build: EarlySwiftDriver: Use consistent Foundation/Dispatch
The early swift driver build would switch the Dispatch and Foundation
build used while building between an initial clean build and an
incremental rebuild. The early swift driver should consistently use the
same Foundation and Dispatch for each build.

This change tells the early swift driver stops build-script from telling
the early driver build to use the Foundation and Dispatch that it built.
2024-05-02 13:56:49 -07:00
Alastair Houghton
68598514c2 [Build] Fix Python linting issues.
The Python linter was complaining about import orders.

rdar://123503470
2024-05-02 14:56:18 +01:00
Alastair Houghton
29e38af1fe [Build] Fix a conflict resolution mistake.
Apparently I accidentally removed a `]` while resolving a conflict in
`build_script_invocation.py.`

rdar://123503470
2024-05-02 14:56:18 +01:00
Alastair Houghton
fdc8ffd36f [Build] Updated following initial comments from Eric.
Change the `--linux[-static]-arch` option to `--linux[-static]-archs`, on the
basis that it supports multiple values.

Other tidying.

rdar://123503470
2024-05-02 14:56:18 +01:00
Alastair Houghton
ae1c0455f3 [Build] Add the new fully-static Linux SDK.
Declare a new `LINUX_STATIC` SDK and configure it.

Add options to set the build architectures for the `LINUX` and
`LINUX_STATIC` SDKs, similar to what we have for Darwin, because
we'll be cross-compiling.

Also add an option to point the build system at the sources for
the musl C library, which we're using for `LINUX_STATIC`.

rdar://123503470
2024-05-02 14:56:18 +01:00
Byoungchan Lee
c31f1f5245 [python] Replace deprecated assertEquals with assertEqual in build graph test
`unitest.assertEquals` is deprecated in Python 3.2 and finally removed in
Python 3.12 [1]. Due to this, this test files in recent Linux distros,
like Ubuntu 24.04 or Fedora 38+. This patch replaces the deprecated
function with `assertEqual`.

[1] https://docs.python.org/3/whatsnew/3.12.html
2024-04-29 08:17:15 +09:00
Yuta Saito
e20e1c6be9 Merge pull request #73077 from kateinoigakukun/yt/split-wasi-sysroot-for-targets
[wasm] Split wasi-sysroot for wasi and wasip1-threads
2024-04-18 06:21:15 +09:00
Yuta Saito
1136d50969 [wasm] Split wasi-sysroot for wasi and wasip1-threads
libclang_rt.builtins library is placed in the clang resource directory
per OS and architecture, so "environment" field is not used to find the
library (except for android). wasi and wasip1-threads require different
target features, so we need to split wasi-sysroot for them.

Before
```
wasi-sysroot
├── include
├── lib
│   ├── wasi
│   │   └── libclang_rt.builtins-wasm32.a
│   ├── wasm32-wasi
│   │   ├── ...
│   │   └── libc.a
│   ├── wasip1
│   │   └── libclang_rt.builtins-wasm32.a
│   └── wasm32-wasip1-threads
│       ├── ...
│       └── libc.a
└── share
```

After
```
wasi-sysroot
├── wasm32-wasi
│   ├── include
│   ├── lib
│   │   ├── wasi ---------- (will be renamed to wasip1)
│   │   │   └── libclang_rt.builtins-wasm32.a
│   │   └── wasm32-wasi --- (will be renamed to wasm32-wasip1)
│   │       ├── ...
│   │       └── libc.a
│   └── share
└── wasm32-wasip1-threads
    ├── include
    ├── lib
    │   ├── wasip1
    │   │   └── libclang_rt.builtins-wasm32.a
    │   └── wasm32-wasip1-threads
    │       ├── ...
    │       └── libc.a
    └── share
```
2024-04-17 17:45:37 +00:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
Rintaro Ishizaki
a16ad9c274 Merge pull request #71173 from rintaro/cmake-parservalidatoin
[CMake] Add option to perform SwiftParser validation by default
2024-04-12 15:03:31 -07:00
Yuta Saito
9582f5d960 Merge pull request #72998 from kateinoigakukun/yt/fix-wasm-build-on-machost
[wasm] Define CMake options for stdlib explicitly for Darwin host build
2024-04-12 15:15:03 +09:00
Yuta Saito
135f78ea08 [wasm] Define CMake options for stdlib explicitly for Darwin host build
The stdlib build for wasm target is failing on Darwin host due to
default values of some CMake options on Darwin host. We need to
explicitly define these options to make the build pass.
2024-04-12 03:06:02 +00:00
Yuta Saito
4508229a4e [wasm] Enable Cxx module build 2024-04-11 16:22:06 +00:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Yuta Saito
067806c727 [wasm] Enable Synchronization module build 2024-04-10 14:47:42 +00:00
Yuta Saito
6ddf6833cb build: Use llvm-ranlib from the toolchain when building the wasm stdlib
llvm-ranlib is now installed in the toolchain, so we can use it instead of
the one in the build directory.

https://github.com/apple/swift/pull/72212
2024-03-30 12:36:40 +00:00
Yuta Saito
c8b1dc7ed0 test: Disable executable lit tests with WASI threads for now
We should enable them once WasmKit supports WASI threads.
2024-03-29 15:35:14 +00:00
Yuta Saito
ca5e7a6bdd build: Rename wasi-threads to wasip1-threads
The WASI community is transitioning to a new naming for the "preview"
version in the target triple: wasm32-wasi -> wasm32-wasip1.
At this moment, we keep the old triple wasm32-wasi because it's already
widely used, but we should start using the new triple threaded target.

LLVM checks only if the OS field *starts* with "wasi", so "wasip1" is
still considered a valid `isOSWASI()` target.

See: https://github.com/WebAssembly/wasi-libc/pull/478
2024-03-29 15:35:14 +00:00
Yuta Saito
ee0839aca4 build: Add -threads variant of Wasm stdlib build
This patch adds a `-threads` variant of the Wasm stdlib build, which
has completely different ABI and target triple. Now we build
non-threaded and threaded variants when `--build-wasm-stdlib` is
enabled.
2024-03-29 15:35:14 +00:00
Kuba Mracek
6798948c5b [embedded] Start building and including lld even in Darwin toolchains 2024-03-27 10:29:19 -07:00
Yuta Saito
52e8fbc115 Merge pull request #72345 from kateinoigakukun/katei/has-feature-swiftcall
[embedded] Use `__has_feature(swiftcc)` to detect Swift calling convention
2024-03-27 19:39:25 +09:00
Eric Miotto
0edd96e311 Merge pull request #72486 from edymtt/emiotto/add-flag-to-pass-arguments-to-dsymutil
build-script: add flag to pass arguments to dsymutil
2024-03-25 07:28:35 -07:00
Eric Miotto
efdd4954d3 build-script: add flag to pass arguments to dsymutil
This is currently needed to disable DWARF verification in
some Apple internal configurations.

Addresses rdar://125092216
2024-03-22 08:04:31 -07:00
Mike Ash
0491192337 [Runtime] Remove ExternalGenericMetadataBuilder. 2024-03-21 17:56:17 -04:00
Yuta Saito
f95fd21e1d [test] Add a test for class allocation on Embedded Wasm 2024-03-20 23:07:29 +00:00
Doug Gregor
922e3daaea Remove build infrastructure for globally enabling noncopyable types
Now that the compilation model of noncopyable types is enabled everywhere,
and one can enable the feature for specific modules, we no longer need a
separate build-script/CMake option to enable it globally. Remove it all.
2024-03-19 13:35:31 -07:00
Rokhini Prabhu
bae6450bf9 Merge pull request #72283 from apple/rokhinip/121121793-stdlib-minimal
Enable task-to-thread model by default for mixin_stdlib_minimal
2024-03-13 01:40:04 -07:00
Rokhini Prabhu
99069a3c4e Enable task-to-thread model by default for stdlib_freestanding_minimal
Radar-Id: rdar://problem/121121793
2024-03-12 19:38:19 -07:00
Yuta Saito
cf619e2a7e Merge pull request #71977 from kateinoigakukun/pr-5ff3fb0d5bd5d000aa636f748af814d1607455e3 2024-03-09 13:40:59 +09:00
Yuta Saito
82b1d9c803 build: Rename prefer_just_built_toolchain -> prefer_native_toolchain 2024-03-08 16:24:10 +00:00
Meghana Gupta
f3a85b118f Add build-script option and lit config for nonescapable_types
With this build-script has a flag --enable-experimental-nonescpable-types=1
to enable this feature in stdlib.

Also we can now add // REQUIRES: nonescapable_types to tests which run only when
the compiler is built with this feature turned on.
2024-03-06 21:57:03 -08:00
Yuta Saito
5a66841608 build: Respect native-*-tools-path when building Wasm stdlib
This change allows the Wasm stdlib to be built using the prebuilt Swift
toolchain instead of just built from source.
2024-02-29 17:47:37 +00:00
Ian Anderson
5acd961347 Merge pull request #71474 from ian-twilightcoder/builtin-float-overlay
[overlay] Make an overlay for the clang _Builtin_float module
2024-02-22 12:25:54 -08:00
Kuba Mracek
8e357df938 [embedded] Fix Python lint issues in llvm.py 2024-02-20 15:20:56 -08:00
Kuba Mracek
38bcffa6ff [embedded] When copying clang builtins from host toolchain, include macho_embedded libraries 2024-02-19 14:36:19 -08:00
Ian Anderson
1ce3935eb7 [overlay] Make an overlay for the clang _Builtin_float module
Clang's builtin float.h is no longer included in OS/SDK modules, and so it needs its own overlay.

rdar://122351557
2024-02-16 12:31:47 -08:00
Yuta Saito
8e0a79dc9e test: Skip some exhaustive tests for now due to WasmKit performance
Those tests check so many input variations and take too long (hours) to
run. We can re-enable them once WasmKit is well optimized.
2024-02-07 07:32:50 +00:00
Yuta Saito
581ee4ebcc build: Run executable tests with WasmKit when available
This patch allows running executable tests with WasmKit. If WasmKit is
not built, fall back to running only non-executable tests. Also add
stdlib and Concurrency executable tests to run.
2024-02-07 07:32:50 +00:00