Commit Graph

22 Commits

Author SHA1 Message Date
Alastair Houghton
82bd345f64 [Build] Tweak Libdispatch.cmake for static linking support.
Don't try to build dynamic libraries if the SDK only supports
static linking.  Also, *do* build static libraries if the SDK
only supports static linking.

rdar://123503191
2024-02-23 15:49:52 +00:00
Saleem Abdulrasool
2bab362663 build: make SWIFT_CLANG_LOCATION take precedence
If this is defined, prefer this compiler over the just built compiler.
2023-10-16 13:41:06 -07:00
Evan Wilde
94c2be87da Merge pull request #68561 from etcwilde/ewilde/add-missing-clang-dep-edge
Add dependency edge between dispatch and clang
2023-09-16 16:59:59 -07:00
Evan Wilde
5ac32e7a3f Add dependency edge between dispatch and clang
The dispatch that's built into concurrency on Linux and Windows is built
with clang, but there's no dependency edge. Usually this isn't noticed
because concurrency and most the things it depends on also depend on
clang directly, but occasionally ninja will choose the dispatch build
before building other dependencies, which then fails because there's no
clang.
2023-09-15 14:37:41 -07:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
Anthony Latsis
d553d0466a Merge pull request #62355 from AnthonyLatsis/sr-no-sr
[NFC] Migrate remnant Jira issue references to GitHub issues
2022-12-04 12:08:25 +03:00
Anthony Latsis
4cb63c8a0f [NFC] Migrate remnant Jira issue references to GitHub issues 2022-12-04 08:20:34 +03:00
Saleem Abdulrasool
6c384e0b78 build: honour SWIFT_CLANG_LOCATION
We would previously use `clang-cl` without the explicit path which could
find an alternative `clang-cl` instance.  This manifested as a failure
to build libdispatch as part of the compiler when cross-compiling x64 to
arm64.
2022-12-02 09:14:56 -08: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
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
Bo Anderson
6be2b40fdd [build] correct libdispatch test flag 2021-10-29 03:42:19 +01: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
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
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
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
Saleem Abdulrasool
2990e8bc07 build: repair the build with VS2019 16.10.0
The newest VS2019 release updates CMake to 3.20, which picks up
`llvm-mt` as a preferred manifest tool.  However, we do not build
`llvm-mt` with libxml2 support currently, which prevents the use of the
just built manifest tool for building libdispatch.  Explicitly opt into
using the MSVC manifest-tool.
2021-05-28 11:20:25 -07:00
Dario Rexin
01298df2f5 Enable import of _Concurrency by default on Linux 2021-04-13 23:14:06 -07:00
Saleem Abdulrasool
9b1eccc003 Merge pull request #35920 from compnerd/target-libdispatch
build: build target libdispatch as necessary
2021-02-11 17:57:16 -08:00
Daniel Rodríguez Troitiño
87a403e53f [Concurrency] Fix Android ARMv7 C libdispatch build (#35905)
For cross-compiling Android one can simply provide
CMAKE_ANDROID_ARCH_ABI and the right CMAKE_SYSTEM_PROCESSOR will be
chosen by CMake. Since the SDK arch names are not the expected ones by the Android NDK,
it is better not to use them. The change should keep sending the
CMAKE_SYSTEM_PROCESSOR for SDKs that are not ANDROID, while skipping it
for the ANDROID SDKs.
2021-02-11 09:17:02 -08:00
Saleem Abdulrasool
3b1f01d60e build: build target libdispatch as necessary
This should not be predicated on the host libdispatch being built, only
if concurrency is being built in multithreaded mode.
2021-02-11 09:10:10 -08:00
Dario Rexin
00117e8750 [Concurrency] Fix Android C libdispatch build (#35881)
* [Concurrency] Fix Android C libdispatch build

We need to pass CMAKE_ANDROID_NDK and CMAKE_ANDROID_ARCH_ABI to the
build.

* Set proper ANDROID_ARCH_ABI

* Add -DCMAKE_ANDROID_API to C libdispatch build

* Fix compiler config for Android
2021-02-10 17:35:14 -08:00
Dario Rexin
51bdfa1919 [Concurrency] Build C-only libdispatch as part of Swift build (#35837)
* [Concurrency] Build C-only libdispatch as part of Swift build
2021-02-09 14:24:52 -08:00