Commit Graph

864 Commits

Author SHA1 Message Date
Yuta Saito
94b40d1bde Merge pull request #81799 from kateinoigakukun/yt/unify-wasmllvmruntime-build-dir
[wasm] Unify WasmLLVMRuntimeLibs and WasmThreadsLLVMRuntimeLibs build directories
2025-05-28 23:31:37 +09:00
Yuta Saito
1592c9e2b3 [wasm] Unify WasmLLVMRuntimeLibs and WasmThreadsLLVMRuntimeLibs build directories
Having separate build product does not make sense and just adds
complexity to manage build directory names.
2025-05-28 04:14:23 +00:00
Evan Wilde
a313a63bba Merge pull request #81662 from etcwilde/ewilde/aarch64-freebsd
Fix the ARM architecture on FreeBSD
2025-05-22 20:21:17 -07:00
Evan Wilde
fd2ba8b95d Fix the ARM architecture on FreeBSD
The 64-bit ARM architecture spelling on FreeBSD is aarch64, not arm64.
This results in a build failure about a missing
`freebsd/arm64/swiftrt.o` while building the runtimes.
2025-05-20 21:38:41 -07:00
Evan Wilde
5f2b0022d1 Build Swift-Testing with WMO
This tells build-script to build Swift-testing with WMO.
This results in a faster build products, but is also necessary for
configurations using the legacy swift driver, which would emit an
invalid swift interface in non-WMO builds.

Fixes: rdar://151357567
2025-05-19 13:24:23 -07:00
Eric Miotto
a5261ae492 Merge pull request #81386 from edymtt/edymtt/do-not-crosscompile-llvm-under-linux
Reenable build of compiler-rt with LLVM_ENABLE_RUNTIMES in Linux bots...
2025-05-14 06:47:30 -07:00
Eric Miotto
fcc03898c7 Reenable build of compiler-rt with LLVM_ENABLE_RUNTIMES in Linux bots...
...we disabled in #81354

This requires a couple of supporting changes

* under Linux, do not cross compile LLVM when building for the host
 architecture -- that will ensure that the compiler-rt build will use
the just built compiler and not the system one (which may not be
new enough for this purpose);
* provide sanitizer flags depending on the linker the just built compiler
 will use -- this detection is brittle, so print a message advising the
user how to override this.

Addresses rdar://150849329
2025-05-13 08:34:11 -07:00
Max Desiatov
eac419b8ca Merge pull request #81178 from swiftlang/maxd/install-wasmkit
This enables `swift run` and `swift test` to use WasmKit when cross-compiling to Wasm with Swift SDKs that have toolsets pointing to WasmKit.

rdar://150382758
2025-05-12 02:27:49 +01:00
Max Desiatov
06bee27b9e Set rpath correctly for installed wasmkit binary 2025-05-11 17:36:28 +01:00
Evan Wilde
6ad5c40caa Merge pull request #81364 from etcwilde/ewilde/extend-swift-cmake-options
[Build-Script]: Extend Swift cmake options
2025-05-09 09:07:48 -07:00
finagolfin
e76b97e2b7 [build-script] Add an option to build the Foundation tests in another mode (#78390)
Use it in the linux CI presets to set them to Debug mode and speed up
the linux CI, plus add a new preset which keeps building them in Release
mode.

I was looking at a passing linux CI run and saw the log timings at the
end: it takes [longer to build and test the swift-foundation repos than
to compile all 7k+ mostly C++ files in
LLVM](https://ci.swift.org/job/swift-PR-Linux/18996/console)!
```
--- Build Script Analyzer ---
Build Script Log: /home/build-user/build/.build_script_log
Build Percentage 	 Build Duration (sec) 	 Build Phase
================ 	 ==================== 	 ===========
9.2%              	 1132.94               	 Running tests for foundationtests
9.1%              	 1120.57               	 linux-x86_64-swift-build
9.0%              	 1104.2                	 Building llvm
7.2%              	 878.84                	 Running tests for swiftfoundationtests
6.5%              	 796.81                	 Running tests for swiftpm
5.6%              	 684.7                 	 Building swiftpm
5.5%              	 667.92                	 linux-x86_64-swift-test
4.9%              	 597.64
```
Looking at the log, building swift-foundation in release mode takes a
long time, so let's see if changing it to debug mode helps. Some
background - the Foundation repos are built twice on the linux CI: once
by CMake, which is the version installed in the toolchain, then a second
time by SwiftPM purely for testing.

This pull only affects that second SwiftPM build for testing, which is
not shipped in the final toolchain but thrown away.
2025-05-09 21:07:01 +05:30
Max Desiatov
7db6c5ddaa Build CMake on macOS if one is not preinstalled (#81161)
We build CMake on all platforms (except Darwin for an unknown reason) if CMake is not preinstalled. Since CMake 4.0 regresses certain build configurations, there's currently no way to build on Darwin without installing an older CMake version 3.x manually. This can be simplified if we build a pinned version of CMake consistently on all platforms.
2025-05-09 15:59:05 +01:00
Yuta Saito
3dc24b83bd Merge pull request #81387 from kateinoigakukun/yt/remove-wasilibc-workaround 2025-05-09 19:03:57 +08:00
Yuta Saito
e32566154b [wasm] Remove workaround for wasi-libc's check-symbols target
Our LLVM has been already updated to 19, so we no longer need to
workaround the `__FPCLASS_XXX` macro issue in wasi-libc's
check-symbols target.
2025-05-08 23:31:35 +00:00
Max Desiatov
cb038fa0da Build WasmKit with the freshly-built SwiftPM 2025-05-08 16:11:55 +01:00
Max Desiatov
07d611ec5a Merge branch 'main' of https://github.com/swiftlang/swift into maxd/install-wasmkit 2025-05-08 13:03:41 +01:00
Evan Wilde
004a738c70 [Build-Script]: Extend Swift cmake options
The existing swift-cmake-options flag overwrites all flags computed by
build-script. Sometimes it is useful to be able to append additional
CMake flags without overwriting the existing flags.
This patch adds `--extra-swift-cmake-options` that adds the specified
flags to the Swift CMake configuration instead of overwriting them.

This also adds a similar `--extra-llvm-cmake-options`, which adds the
new flags to the end, allowing one to replace and overwrite CMake flags
that build-script computed.
Due to the parameter passing mechanisms in build-script-impl, while this
behavior would be useful for Swift, it is not immediately apparent how
one would best implement this at this time.
2025-05-07 14:49:45 -07:00
Eric Miotto
ad3616f5fa LLVM build product: build LLVMTestingSupport by default
This supports scenarios when tests are run separately from
`build-script` using e.g. `run-test`

Addresses rdar://150774282
2025-05-06 10:11:19 -07:00
Eric Miotto
1bf6ac8118 compiler-rt: use the current host architecture for the runtime targets
This will ensure all the test executables generated by `check-*` targets
can run on the current machine.

Addresses rdar://150469492
2025-05-01 15:48:12 -07:00
Max Desiatov
9ba86e7b28 Rename wasmkit-cli to wasmkit when installing 2025-05-01 10:10:55 +01:00
Max Desiatov
7bb6282c60 Copy WasmKit to install_destdir
This enables `swift run` and `swift test` to use WasmKit when cross-compiling to Wasm with Swift SDKs that have toolsets pointing to WasmKit.
2025-04-29 22:07:02 +01:00
Kuba Mracek
c5aa98a449 [embedded] Make the CMake setup for Embedded Concurrency distnguish ARCH and SUBDIR for builds products 2025-04-26 07:03:19 -07:00
Eric Miotto
7b001765bd Merge pull request #80174 from edymtt/edymtt/use-runtimes-build-quater
build-script: Permit to build compiler-rt with `LLVM_ENABLE_RUNTIMES`
2025-04-22 06:48:17 -07:00
Eric Miotto
0c8171f53c build-script: Permit to build compiler-rt with LLVM_ENABLE_RUNTIMES
LLVM-21 plans to remove the legacy method for building compiler-rt
in the same invocation as LLVM using `LLVM_ENABLED_PROJECTS` and
`LLVM_BUILD_EXTERNAL_COMPILER_RT`.

Support the new way of building compiler-rt with a new build-script
opt-in flag `--llvm-build-compiler-rt-with-use-runtimes` --
this will allow a staged introduction, and will ensure we can revert
back to the old behaviour temporarily in case of unforeseen regression.

Since this flag is meant to be short lived, in an attempt to keep the
logic simple we are gating on it only the
CMake cache entries that strictly control the compilation mode, all the
other entries used for configuring are added in both modes.

Take this chance to remove some stale code from `build-script-impl`, and
move some code in the generic CMake product to the LLVM one.

Addresses rdar://147505298
2025-03-31 13:53:08 -07:00
Max Desiatov
eb1a2960b6 Enable _Concurrency for Embedded Swift with WASI (#79292)
WASI with Embedded Swift provides WASI-libc and libc++ headers necessary to build the `_Concurrency` module for Wasm. We now add `wasm32-unknown-wasip1-wasm` triple to `EMBEDDED_STDLIB_TARGET_TRIPLES` when `SWIFT_WASI_SYSROOT_PATH` is set, which builds the necessary stdlib slice.

---------

Co-authored-by: Yuta Saito <kateinoigakukun@gmail.com>
2025-03-26 21:14:05 +00:00
Evan Wilde
321c8208f5 [build-script] Create time log dir
If the directory where the build time log is supposed to go doesn't
exist, create it. The append file mode will create files, but won't
create directories. When we start building ninja, we haven't necessary
created the build directory yet, so this results in an error about the
missing directory when writing the build time log.
2025-03-24 08:33:35 -07:00
Evan Wilde
bbd412b0dc Revert "[build-script] Remove ninja build time tracking"
This reverts commit fb4799f5d1.
2025-03-24 08:30:29 -07:00
Evan Wilde
fb4799f5d1 [build-script] Remove ninja build time tracking
Logging the build time is failing because the build log time file
doesn't always exist by the time Ninja is getting brought up.
2025-03-24 08:09:11 -07:00
Mishal Shah
deb1d9696d Merge pull request #80199 from etcwilde/ewilde/remove-ninja-host
[build-script] Remove ninja host
2025-03-21 09:43:50 -07:00
Evan Wilde
bafbfa2d46 [build-script] Remove ninja host
The ninja builder took a host argument that was unused by the function.
The ninja build failed to pass this argument, resulting in
an execution failure. Removing the argument.
2025-03-21 08:55:19 -07:00
Evan Wilde
9402a1689b Automatically choose a built ninja
Instead of using `--build-ninja` to decide to build ninja, build it
automatically if a sufficiently new enough version is not available.
Also record the build time taken to build the local Ninja so that we can
see how much time we would save by stashing a pre-built Ninja in CI.
2025-03-19 07:35:32 -07:00
Evan Wilde
d2d5925695 Disable building Ninja tests
Ninja builds its tests by default.
We don't run the Ninja test suite, we aren't doing development on Ninja,
and we are using a release tag that has been verified to work. There
isn't much point in building the tests if we're not going to use them.
Disabling building the Ninja tests. If it is desirable to build them,
one can set `BUILD_TESTING` to `YES` and re-run their build.
2025-03-18 09:32:40 -07:00
Evan Wilde
bac5232d18 Merge pull request #80034 from etcwilde/ewilde/ninja-build-fix
[build-script] Build Ninja with CMake
2025-03-16 23:15:35 -07:00
Evan Wilde
e46e3220b5 [build-script] Build Ninja with CMake
This patch switches the Ninja build from using the configure.py script
to building with the just-built CMake.
The configure.py in Ninja 1.11.1 still uses Python 2.7, importing the
`pipes` module. The pipes module was deprecated in Python 3.11 and
removed in 3.13, so folks using newer versions of Python are running
into issues with this.

The CMake build doesn't have this issue and is also perfectly valid, so
we can switch to that.
2025-03-15 08:53:38 -07:00
Evan Wilde
f7655ae393 Merge pull request #79973 from etcwilde/ewilde/build-script-cmake
[build-script] CMake bootstrapping updates
2025-03-14 18:48:15 -07:00
Evan Wilde
90bf96c104 [build-script] Don't rebuild CMake
This patch updates the CMake-building mechanism to avoid
re-bootstrapping CMake if we already bootstrapped one that is new
enough.

I've made it so that all paths through the function return the path to a
CMake so we can use the result of the function as the cmake path without
having to check.

The function will choose one of the following ways of getting CMake in
order of preference:
 - One we already built
 - The system CMake
 - Bootstrapping one from scratch

It prefers one we built over checking the system CMake because, if we
have already built a CMake previously, it's a good indication that
there either was no system CMake installed, or it wasn't new enough. We
shouldn't waste time checking it again if a previous run detected that
it wasn't good enough.

The system CMake is preferable to building one from scratch if we don't
need to though, so we determine if the system CMake is sufficient.

Finally, if one that we built either doesn't exist, or isn't new enough,
and the system either doesn't have a CMake, or a new enough CMake, build
one. It is built into the location that we are checking for caching, so
the next time we run build-script, it should hit the first case and
choose the already-built CMake instead of building it again.
2025-03-14 13:33:14 -07:00
Evan Wilde
71b7725d44 [build-script] Log CMake Bootstrap build time
Include the CMake bootstrap time in the build-script build times.
We're including everything else. Would be good to determine how much
time we can save by caching a new enough pre-built CMake in the builder
images.

Importing the log_time_in_scope exposes a cyclic dependency cycle
between the `swift_build_support` and `build_swift` python modules in
such a way that the tests fail due to re-importing parts of build_swift:

```
ImportError: Failed to import test module: tests.build_swift.test_migration
Traceback (most recent call last):
  File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
    module = self._get_module_from_name(name)
  File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
    __import__(name)
  File "/home/build-user/swift/utils/build_swift/tests/build_swift/test_migration.py", line 14, in <module>
    from build_swift import migration
  File "/home/build-user/swift/utils/build_swift/build_swift/migration.py", line 18, in <module>
    from swift_build_support.swift_build_support.targets import \
  File "/home/build-user/swift/utils/swift_build_support/swift_build_support/targets.py", line 15, in <module>
    from . import cmake
  File "/home/build-user/swift/utils/swift_build_support/swift_build_support/cmake.py", line 26, in <module>
    from swift_build_support.swift_build_support.utils import log_time_in_scope
  File "/home/build-user/swift/utils/swift_build_support/swift_build_support/utils.py", line 20, in <module>
    from build_swift.build_swift.constants import SWIFT_BUILD_ROOT
ModuleNotFoundError: No module named 'build_swift.build_swift'
```

I've put the import of log_time_in_scope into the function definition
to ensure that build_swift has been fully loaded by the time we need
log_time_in_scope, ensuring that there is order between the two pieces.

Python caches the imported module, so if we accidentally re-import the
log_time_in_scope, nothing actually changes.

This re-orders the instantiation of the BuildScriptInvocation object so
that it comes before the creation of the CMake path. This ensures that
BuildScriptInvocation() does not delete the build log after logging the
CMake bootstrap time. This is fine because the toolchain and arguments
are reference types, so updating the CMake path in both of those will be
reflected in the copy taken in the BuildScriptInvocation() object.
2025-03-14 13:33:12 -07:00
Michael Gottesman
243cfe0719 Merge pull request #79804 from gottesmm/pr-f26aec536f9d333150b49e0faf50a70a9a26ac53
Add a flag to enable-new-runtime-build that enables the new runtime build
2025-03-07 16:03:49 -08:00
Alex Hoppen
67f312cc2f Merge pull request #79834 from ahoppen/remove-syntax-lint
[build-script] Remove option to lint swift-syntax
2025-03-07 06:42:29 -08:00
Alex Hoppen
a4b8878787 Merge pull request #79827 from ahoppen/remove-swiftsyntax-verify-documentation
Remove the documentation verification step
2025-03-07 06:42:07 -08:00
Alex Hoppen
8ad0ca8c17 Remove the documentation verification step
This step is now performed by GitHub Actions.
2025-03-06 18:40:55 -08:00
Alex Hoppen
7256a92775 [build-script] Remove option to lint swift-syntax
This is being verified by GitHub Actions now as of https://github.com/swiftlang/swift-syntax/pull/2998.
2025-03-06 18:38:47 -08:00
Michael Gottesman
7418b42215 Add a flag to enable-new-runtime-build that enables the new runtime build.
What is nice about this is that by not using extra-cmake-args, we can avoid
passing this into LLVM as well when attempting to reproduce failures on the bots
(thus avoiding having to rebuild LLVM as well).
2025-03-05 14:10:26 -08:00
Michael Gottesman
f68e23aaf1 Merge pull request #79329 from gottesmm/pr-295dfc37ee8e5bf71b1249c2717a30c37de1aee2
[build-script] Add an option to force the linker used.
2025-02-14 21:09:09 -08:00
Bassam (Sam) Khouri
ac52024827 Merge pull request #79330 from bkhouri/t/main/support-swifttesting-in-swiftpm-for-toolchain-build
Add verbosity when building swiftpm
2025-02-14 12:39:09 -05:00
Sam Khouri
6e42092751 Add verbosity when building swiftpm 2025-02-12 15:37:03 -05:00
Michael Gottesman
3e2a6f6665 [build-script] Add an option to force the linker used.
I have been doing this using extra-cmake-args/etc... just feels better to have
an actual option to do this.

Just did this quickly while waiting for my Linux build to finish that uses
extra-cmake-args to set the linker.
2025-02-12 11:49:01 -08:00
Hamish Knight
d260bd8ddb [build-script] Remove Xcode generation support
This was quite brittle and has now been superseded
by swift-xcodegen. Remove the CMake/build-script
logic for it, leaving the option behind to inform
users to switch to using xcodegen instead.
2025-02-12 12:19:21 +00:00
Sam Khouri
1f3e232de7 swiftpm: Test only running host platform architecture
When adding a Swift Testing test to Swift PM repository, the `test`
portion of t he OSX package pipeline was building against x86_64 and
arm64.

Ensure Swift PM testing only runs against the host platform
architecture.
2025-02-07 10:35:29 -05:00
Eric Miotto
8f9829dce8 build-script-impl: propagate --verbose-build to nested CMake builds
The main goal of this change is to ensure that the new build of the
stdlib matches the same level of verbosity of the compiler build that
spawn it.

For now I'm not matching this behaviour to the regular CMake build
products (which would be needed if want to target external projects
configured in LLVM).

Addresses rdar://144256800
2025-02-05 14:58:46 -08:00