Commit Graph

1731 Commits

Author SHA1 Message Date
Konrad `ktoso` Malawski
e7342eb878 Merge pull request #39365 from kateinoigakukun/katei/fix-coop-executor-part-2
[Concurrency] repair cooperative executor and its tests
2021-09-27 09:47:09 +09:00
Zoe Carver
6300b8b4f8 Merge pull request #39356 from zoecarver/cxx-interop-lib-swift
[cxx-interop][libswift] Use `std::string` instead of `BridgedStringRef` 🚀
2021-09-23 15:06:19 -04:00
zoecarver
f063701f84 [cxx-interop][libswift] Use std::string instead of BridgedStringRef.
The first C-bridge to be removed! 🚀
2021-09-22 16:13:44 -07:00
Yuta Saito
1b56c037a3 [test] fix runtime unittests for single threaded runtime
Some headers switch their inline implementations based on
SWIFT_STDLIB_SINGLE_THREAD_RUNTIME definition.
This fixes linking failure while building runtime unittests
2021-09-19 14:37:29 +00:00
zoecarver
25e5bc22e6 [cxx-interop][libswift][build] Enable C++ interop when building libSwift 2021-09-17 18:00:13 -07:00
Max Desiatov
a723e6d4c2 CMake: disable libdispatch when targeting Wasm/WASI (#39274)
Wasm/WASI doesn't currently support multi-threading, and libdispatch should be disabled when building for this target.

Related to SR-12097.
2021-09-15 18:00:13 +01:00
Max Desiatov
8cd8ca01ad CMake: clean up WASI SDK sysroot paths (#39275)
Paths to WASI SDK sysroot should not assume `/share/wasi-sysroot` directory hierarchy. It's much more flexible to have this part hidden under the more general `SWIFT_WASI_SYSROOT_PATH` variable.
2021-09-13 16:36:10 +01:00
Saleem Abdulrasool
90cb550d73 Merge pull request #39099 from compnerd/windows-i686
caches: add a cache for a i686 build of the runtime on Windows
2021-09-01 09:44:11 -07:00
Saleem Abdulrasool
7aa00e889c build: repair the sub-build for libdispatch on Windows i686
When building on Windows i686 with a toolchain build for Windows x64, we
would try to build libdispatch for i686 as x86_64.  This obviously would
be incorrect.  Explicitly pass the target triple for the sub-builds.  We
can do this unconditionally since we always use `clang-cl` builds.  This
allows us to build the SDK only components for Windows i686 from a 64bit
build.
2021-08-30 13:48:40 -07:00
Saleem Abdulrasool
db6cec96ed caches: add a cache for a i686 build of the runtime on Windows
This adds a cache for a configuration of the standard library for
Windows x86 configurations.  This should help restore the x86 builds of
the SDK for Windows.
2021-08-30 13:13:01 -07:00
Argyrios Kyrtzidis
8224df3bb2 Merge pull request #38913 from akyrtzi/link-with-demangle-along-with-support
[cmake/AddSwift] When `support` is passed for LLVM_LINK_COMPONENTS also implicitly include `demangle`
2021-08-27 14:19:58 -07:00
Doug Gregor
3f749dc13b Add an option to build the concurrency library for back deployment.
Introduce an additional build product to build-script to build
back-deployable concurrency libraries. These libraries would need to
be embedded in apps deployed prior to macOS 12/iOS 15 to support
concurrency.

The built-script option `--back-deploy-concurrency` can be provided to
build these back-deployment libraries. They are built in addition to
the normal concurrency libraries, as a separate product that installs
into `lib/swift-5.5/<platform>` within the toolchain. The macro
`SWIFT_CONCURRENCY_BACK_DEPLOYMENT` is set when building the
concurrency library, so that we can adapt the implementation to older
OS's.
2021-08-26 08:49:43 -07:00
Kuba (Brecka) Mracek
c079c0897b Split SWIFT_DARWIN_PLATFORMS and SWIFT_APPLE_PLATFORMS in CMake. SWIFT_APPLE_PLATFORMS may contain 'FREESTANDING' when building the freestanding SDK and SWIFT_FREESTANDING_FLAVOR is set to 'apple'. (#38997) 2021-08-23 19:16:28 -07:00
Kuba (Brecka) Mracek
750ba09ef4 Introduce SWIFT_FREESTANDING_FLAVOR to select whether the FREESTANDING stdlib should be built/tested using an Apple SDK, or another SDK (e.g. Linux, not implemented yet) (#34450) 2021-08-19 15:56:04 -07:00
Argyrios Kyrtzidis
dea7f9f1c3 [cmake/AddSwift] When support is passed for LLVM_LINK_COMPONENTS also implicitly include demangle
Using `support` llvm component ends up adding `-Xlinker /path/to/lib/libLLVMDemangle.a`
to `LINK_FLAGS` but `libLLVMDemangle.a` is not added as an input to the linking ninja statement.
As a workaround, in order to setup precise inputs for the ninja link statement, include `demangle` component
whenever `support` is mentioned.
2021-08-17 14:54:09 -07:00
Argyrios Kyrtzidis
00d3f7d2d4 [CMake] Add some missing dependencies of the gyb custom command invocations 2021-08-16 15:24:02 -07:00
Argyrios Kyrtzidis
35f0744b1c [CMake] Declare the precise dependencies of the gyb custom command invocations 2021-08-10 13:51:54 -07:00
Saleem Abdulrasool
0a8da95fb4 caches: add LLVM_DEFAULT_TARGET_TRIPLE to Windows-x86_64
Add the default target triple to match the target for the Windows
toolchain.  This avoids the need for an additional parameter, and
it makes sense for the target to be the host by default. Explicit
parameters can change the target when desired.
2021-07-15 09:50:53 -07:00
Xi Ge
d22b348adb cmake: add a workaround to rdar://77839981 2021-07-14 10:02:27 -07:00
Dario Rexin
7ed4ccf538 Merge pull request #37231 from 3405691582/DispatchGoesInLibSubdir
[cmake] Copy Dispatch to the SDK subdir on host.
2021-07-12 09:28:22 -07:00
Alastair Houghton
4b1978cff5 Merge pull request #38023 from al45tair/sr-14813
[SR-14813] [Fuzzers] Fix the mangler and reflection fuzzer build.
2021-06-29 09:38:45 +01:00
Michael Gottesman
c5fe4f0c18 [cmake] Add the SDK directory after the toolchain directory when compiling host swift code.
This ensures that we pick up libraries from the toolchain before picking up
libraries from the SDK we are using. Normally it would not matter the order that
we add these -L files since the contents of the SDK and toolchain are
disjoint. Once we begin performing stage2 swift builds though, we no longer have
this property since we pass in the stage1's installed libraries as the SDK
directory and we have not split the two sets of libraries yet. The end result is
that if we have the -L in the previous order, we will pick up just built
compatibility libraries before we pick up the actual compatibility libraries
from the actual toolchain we are using to compile. This results in compilation
breakage.
2021-06-27 16:40:19 -07:00
Evan Wilde
849ee7ac5e Merge pull request #37958 from etcwilde/ewilde/pass-sanitizer-flags-to-swift
Pass sanitizer flags to swift driver
2021-06-24 06:48:09 -07:00
Alastair Houghton
d74fef90a2 [SR-14813] Add Swift compile options for fuzzing.
We only had the C/C++/ObjC/ObjC++ option.  Add the Swift one too.
2021-06-23 12:52:06 +01:00
Alastair Houghton
a6ec498099 [SR-14813] [Fuzzers] Fix the mangler and reflection fuzzer build.
The mangler fuzzer and reflection fuzzer build was broken, both by a problem in
the CMake scripts and also because of changes that have happened in other parts
of the code.
2021-06-22 11:56:53 +01:00
Evan Wilde
49fad17cb4 Fix spacing in if's
Little fix for the indentation of the if's.
2021-06-17 10:58:30 -07:00
Evan Wilde
b33d2273cc Update cmake/modules/AddSwift.cmake
Use `SEND_ERROR` instead of `FATAL_ERROR`.

Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
2021-06-17 10:39:31 -07:00
Evan Wilde
a884e7faec This should work on Windows
After talking with compnerd, because we're passing this directly to the
swift driver, we shouldn't have to do anything weird with the flags and
it should "just work". I'm frustrated enough with Windows that I'm just
going to go with that and go to bed. If I broke something, I'm sorry. I
tried as far as my sanity would allow.
2021-06-16 21:59:15 -07:00
Evan Wilde
90abf31d6f Pass sanitizer flags to swift on Unix-y systems
This patch fixes the part of the build system where we aren't passing
the sanitizer flags to swift, so the linker isn't linking against the
sanitizer libraries.
2021-06-16 16:42:53 -07:00
Mishal Shah
d914ac25ee Update the macOS arch list to x86_64 and arm64 2021-06-15 23:02:02 -07:00
swift-ci
8687e61bb8 Merge pull request #36971 from rollmind/main 2021-06-13 23:46:29 -07:00
Erik Eckstein
809ce72e05 libswift: build support for the initial libswift
* add the (still empty) libswift package
* add build support for libswift in CMake
* add libswift to swift-frontend and sil-opt

The build can be controlled with the LIBSWIFT_BUILD_MODE cmake variable: by default it’s “DISABLE”, which means that libswift is not built. If it’s “HOSTTOOLS”, libswift is built with a pre-installed toolchain on the host system.
2021-06-09 11:25:15 +02:00
3405691582
c0c93fa0bc [cmake] Copy Dispatch to the SDK subdir on host.
We have two directories for Swift libraries,
* `SWIFT_SDK_<platform>_LIB_SUBDIR`, a.k.a., the SDK subdir,
  a.k.a., `swift-<platform>-<arch>/lib/swift/<platform>`, and
* `SWIFTLIB_SINGLE_SUBDIR`,
  a.k.a., `swift-<platform>-<arch>/lib/swift/<platform>/<arch>`.

Through the Swift build, libraries are emitted to both
`.../lib/swift/<platform>` and `.../lib/swift/<platform>/<arch>`.
However, when building toolchains, only `.../lib/swift/<platform>/` is
populated with libraries.

None of this normally isn't a problem; the Swift libraries do not have
inherent interdependencies. This however changes with Concurrency:
Concurrency has an implicit dependency on libdispatch.

When Swift is built, we have two copies of `libswift_Concurrency.so`:
one in `.../lib/swift/<platform>` and one in
`.../lib/swift/<platform>/<arch>`. Prior to this commit, we
unconditionally copy `libdispatch.so` and `libBlocksRuntime.so` to only
_one_ place -- that is, `.../lib/swift/<platform>/<arch>`.

swiftc emits binaries on ELF systems with an rpath of
`.../lib/swift/<platform>`. These binaries implicitly import
Concurrency, so they link against `libswift_Concurrency.so` (whether
they use Concurrency features or not). The library's `$ORIGIN` is
searched to find `libdispatch.so`.

Now, nothing breaks on Linux because there the loader, when given an
rpath, searches both `.../lib/swift/<platform>` and
`.../lib/swift/<platform>/<arch>` even though the rpath only specifies
one directory..

However, on other platforms, only the given rpath is searched.
`libdispatch.so` does not reside next to `libswift_Concurrency.so`
because it has been copied to  `.../lib/swift/<platform>/<arch>`; not in
the rpath.

There are a few ways to solve this: change the way rpaths are
configured, only emit libraries into one place, copy `libdispatch.so`
only to the path matching the rpath, or copy `libdispatch.so` wherever
`libswift_Concurrency.so` is copied,

Because the toolchain file layout is different to the file layout when
only Swift is built, hacking the rpath is brittle. Presumably, the
reason why we have a `libswift_Concurrency.so` residing in two places is
to support builds where multiple architectures are supported in the one
build directory, so we cannot just copy `libdispatch.so` _only_ to
`.../lib/swift/<platform>`.

Ultimately, We need to ensure that every instance where
`libswift_Concurrency.so` can be used has `libdispatch.so` residing next
to it, which we do here.

Note that this implicit dependency resolution would not happen unless we
added a `-ldispatch` flag to make this all work, but other platforms are
instaed using `$ORIGIN` to get the search to work properly, so we also
do this for OpenBSD in this commit.
2021-06-08 22:20:47 -04:00
Michael Gottesman
98ab14d9ef [cmake] Rather than forcing parts of the build that don't depend on LLVM to define LLVM_COMMON_DEPENDS, just have add_swift_host_library respect the global if it is set. 2021-06-08 14:42:16 -07:00
Michael Gottesman
db370dec73 [cmake] Do not use the just built swift link directory for host side executables.
This is just cruft that remained from the time when swift's host/target used the
same cmake code. Host tools do not statically link against just built artifacts.
2021-06-08 14:42:16 -07:00
David Zarzycki
a410243b8a Merge pull request #37766 from davezarzycki/pr37766
[cmake] Fix fallout from pull request #37741
2021-06-03 17:17:36 -04:00
Saleem Abdulrasool
509e0264d3 Merge pull request #37745 from compnerd/runtimes
Windows: enable the profiling library on Windows
2021-06-03 13:00:55 -07:00
David Zarzycki
987faae14e [cmake] Fix fallout from pull request #37741 2021-06-03 14:37:19 -04:00
Michael Gottesman
8f876cf4ff Merge pull request #37721 from gottesmm/pr-a29fee875eff61d38bd51f7fff8c622eaf3d526e
[cmake] Work around a bug in the swift-driver by passing host side libraries from LLVMSupport to linker jobs via a -Xlinker flag.
2021-06-02 15:35:36 -07:00
Saleem Abdulrasool
b05c1e9ca0 Windows: enable the profiling library on Windows
The official builds include the profiling library, so we should enable
it on the CI to ensure that the path is tested.  This should only add
~1m to the total build time.
2021-06-02 12:51:35 -07:00
Saleem Abdulrasool
a2d56784f3 Merge pull request #37737 from compnerd/organization
Windows CMake Cache organization (NFC)
2021-06-02 12:50:18 -07:00
Michael Gottesman
ef2b9d8631 [cmake] On Darwin, teach add_swift_host_tool how to find swift's SDK/compat libs, fix the rpath of tools, and add tests.
There are three things going on here (note all on Darwin):

1. If one compiles a swift static library and links the static library into a
   cxx executable, the cxx executable will need the -L flags to find the
   appropriate libraries in the SDK/toolchain.

2. I fixed an rpath issue where due to old code I didn't understand/propagated
   forward, we were setting the rpath to be the -L directory in the appropriate
   SDK. After reasoning about this a little bit I realized that this was code
   that was actually intended to be used for target libraries (for which the
   given rpath would be correct). On the host side though on Darwin, we want to
   use the rpath for the standard stabilized stdlib on the system.

3. I added Build System Unittests to ensure that this keeps on working. I also
   added test cases that I should have added before. I just had never thought
   about how to test this and I realized this method would work and would
   prevent regressions while I am waiting for a new swiftc with driver fixes to
   land.
2021-06-01 22:01:39 -07:00
Michael Gottesman
cf4cdf4670 [cmake] Now that we link with cxx and set the right load paths, use appropriate backdeployment target for swiftc.
Before a8ae9525aa, we could not do this since we
would fail to link since we didn't pass to clang the path to the toolchain dir
when the compatibility libraries live.
2021-06-01 19:05:26 -07:00
Michael Gottesman
4a189d8025 [cmake] Work around a bug in the swift-driver by passing host side libraries from LLVMSupport to linker jobs via a -Xlinker flag.
Clang and Swift both support this so we can do this until the actual fix lands
in a host toolchain to unblock ErikE.

The specific problem is the swift driver should just push tbd files through to
the linker, but it treats it as an input file. I am going to be putting a fix
into 5.5. This patch in the mean time filters out the tbd files in cmake. This
is a temporary fix.

I also had to add direct dependencies from swift-refactor and
libSwiftSyntaxParser on LLVMSupport to ensure that the right linker flags get to
them.
2021-06-01 18:43:12 -07:00
Saleem Abdulrasool
3aababb46c Windows: re-organise toolchain cache (NFC)
Make a few more options more explicit and re-group a few options. This
is merely for ease of human processing.
2021-06-01 18:30:09 -07:00
Saleem Abdulrasool
47e7991005 Windows: remove duplicated entry in distribution
This removes the duplicated `llvm-mt` from the toolchain distribution
list.
2021-06-01 18:30:09 -07:00
Michael Gottesman
a8ae9525aa Merge pull request #37696 from gottesmm/pr-ff93c482e7efc01aa8c1d7d9569fb74e41a65fdf
[cmake] When compiling swift libraries that are not pure swift on macOS be sure to set the linker language to cxx.
2021-06-01 16:47:03 -07:00
Karoy Lorentey
f3f8ade3f6 Update cmake/modules/AddSwiftUnittests.cmake
Co-authored-by: Eric Miotto <1094986+edymtt@users.noreply.github.com>
2021-06-01 10:54:32 -07:00
Michael Gottesman
0b8c39bb9f [cmake] When compiling swift libraries that are not pure swift on macOS be sure to set the linker language to cxx.
I already did this for executables. The reason why we must do this is that right
now there are bugs in cmake's swift support that makes it so that one can not
use swiftc to link targets with mixed c/c++/swift content even if the swift
content is indirectly added via linking. To work around this we must also ensure
that all libraries with mixed c/c++/swift objects link using clang. As an
additional side-effect of this, we must pass to the clang linker -L flags that
swiftc would normally provide for the linker. The two cases where I needed to do
this were:

1. -L path for the compatibility libraries. This path points into the toolchain
where these live. This is important since otherwise we will fail to link given
the minimum deployment target that swift (both host/stdlib) target today (10.9).

2. -L path to the SDK. This path points to the SDKs lib/swift/${HOST_PLATFORM}
for swiftCore and friends.

That being said, we still want people to be able to link pure swift libraries
using swiftc, so we introduce an option called PURE_SWIFT to add_host_library
that preserves this and is used to also set
IGNORE_LLVM_UPDATE_COMPILE_FLAGS (which arguably should have been called
PURE_SWIFT).
2021-06-01 10:26:34 -07:00
Karoy Lorentey
f76539f416 [unittest] Add /usr/lib/swift to the rpath of unit test executables
As a postprocessing step for unittest executables, `utils/swift-rpathize.py` unconditionally rewrites the install name of any library linked from /usr/lib/swift to be `@rpath`-relative, in an effort to load the just-built libraries instead of the OS-supplied ones.

This works great for dylibs like libswiftCore.dylib that are built as part of the toolchain, but `/usr/lib/swift` also includes a huge number of overlay dylibs that are no longer part of this repository. These dylibs must ~always be loaded from the OS location.

In order to prevent load-time issues, we need to add /usr/lib/swift to the rpath, so any libraries that we haven’t built will be picked up from there.

We could also do this by extending swift-rpathize.py with an allow (or deny) list, but keeping the list up to date would generate a bunch of maintenance work we could do without.
2021-05-28 21:20:12 -07:00