Commit Graph

256 Commits

Author SHA1 Message Date
Egor Zhdan
f8b5143573 [build] Respect DEPLOYMENT_VERSION_{IOS|TVOS|WATCHOS} for Swift sources
See https://github.com/apple/swift/pull/69512

rdar://117699474
2023-11-06 16:20:24 +00:00
Mike Ash
6606850232 [Runtime] Add option to remove override point for retain/release.
Add a `SWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE` CMake option. When set to true, swift_retain/release and the other functions in InstrumentsSupport.h can be overridden by setting the appropriate global function pointer, as is already the case. When set to false, those function pointers are removed and the functions always go into the default implementation.

Set `SWIFT_STDLIB_OVERRIDABLE_RETAIN_RELEASE` to false when building the minimal stdlib, and set it to true otherwise by default.

rdar://115987924
2023-10-31 15:26:01 -04:00
Egor Zhdan
e192ee24d1 [build] Respect DEPLOYMENT_VERSION_OSX for Swift-only targets
The CMake flag `DEPLOYMENT_VERSION_OSX` is currently only passed to the C compiler. This change makes sure it is also passed to the Swift compiler, e.g. when building Swift-only targets like Cxx or CxxStdlib.

rdar://117699474
2023-10-30 19:22:02 +00:00
swift-ci
36242019b3 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-12 03:55:00 -07:00
Alastair Houghton
801b970012 [Build] Fix dependency problems when bootstrapping.
If we're bootstrapping *and* skip-early-swiftsyntax is enabled, the
build can fail while trying to build target executables because we
haven't built a copy of libswiftCore yet but *the compiler* refers
to it.

This is "fixed" in other places by setting LD_LIBRARY_PATH, but we
don't want or need to do that here; we just want to delay building
these executables until after libswiftCore is available.

rdar://116485713
2023-10-10 11:22:21 +01:00
swift-ci
e6eb30a186 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-06 00:41:18 -07:00
Alastair Houghton
7b7f77eeaa [Linux] Enable frame pointers when building Swift libraries.
Turn on frame pointers for the Swift runtime libraries.  This makes
backtraces that go through the runtimes more reliable without having
to parse DWARF data.

rdar://116112040
2023-10-05 16:11:20 +01:00
swift-ci
bc6aa1f8d5 Merge remote-tracking branch 'origin/main' into rebranch 2023-10-02 09:14:11 -07:00
Alastair Houghton
9d5ce542bc [Linux] Make sure we link with swiftrt on ELF/COFF platforms.
This was causing `swift-backtrace` to crash when linked with the static
version of the runtime, because the runtime then couldn't locate any of
the necessary metadata.

rdar://115278959
2023-09-29 16:18:53 +01:00
Alastair Houghton
2efd1beabe [Linux] Provide a statically linked swift-backtrace binary.
This adds a new binary, `swift-backtrace-static`, to the build.  The runtime
will not by default use this binary as the backtracer, but if you want to
statically link your own binaries against the standard library you can copy
`swift-backtrace-static` rather than `swift-backtrace` alongside your binary,
naming it `swift-backtrace`, and the runtime should find and use it, which
will mean you don't need to have `libswiftCore.so` et al installed.

rdar://115278959
2023-09-28 18:18:39 +01:00
swift-ci
555c15594b Merge remote-tracking branch 'origin/main' into rebranch 2023-09-20 00:55:11 -07:00
Matt Jacobson
fc7d590a15 build: on FreeBSD, set the rpath of built stdlib dylibs to $ORIGIN (#62334) 2023-09-20 08:41:25 +01:00
swift-ci
7d8091fe2e Merge remote-tracking branch 'origin/main' into rebranch 2023-09-18 12:14:41 -07:00
Kuba Mracek
ae2e903574 [embedded] Build an initial embedded Swift standard library
This isn't a "complete" port of the standard library for embedded Swift, but
something that should serve as a starting point for further iterations on the
stdlib.

- General CMake logic for building a library as ".swiftmodule only" (ONLY_SWIFTMODULE).
- CMake logic in stdlib/public/core/CMakeLists.txt to start building the embedded stdlib for a handful of hardcoded target triples.
- Lots of annotations throughout the standard library to make types, functions, protocols unavailable in embedded Swift (@_unavailableInEmbedded).
- Mainly this is about stdlib functionality that relies on existentials, type erasure, metatypes, reflection, string interpolations.
- We rely on function body removal of unavailable functions to eliminate the actual problematic SIL code (existentials).
- Many .swift files are not included in the compilation of embedded stdlib at all, to simplify the scope of the annotations.
- EmbeddedStubs.swift is used to stub out (as unavailable and fatalError'd) the missing functionality.
2023-09-16 12:38:46 -07:00
Ben Barham
a78daa68b8 [rebranch] Make sure to include remote inspection headers first
These headers need to be ahead of all the LLVM headers, which are added
before the flags are. Add a new parameter to pass through headers to add
as a prefix.

Resolves rdar://113647684.
2023-08-09 16:01:14 -07:00
Saleem Abdulrasool
aa5436d130 Merge pull request #67743 from compnerd/hacks-r-us
Enable CxxStdlib on Windows
2023-08-05 15:03:00 -07:00
Alastair Houghton
208fce1237 Merge pull request #67711 from al45tair/eng/PR-113337854
[Linux] Set rpath in add_swift_executable.
2023-08-05 12:21:58 +01:00
Saleem Abdulrasool
ef037a418b stdlib: adjust the name for static libraries on Windows
Windows names static libraries with a `lib` prefix and a `lib` suffix.
This differentiates them from the import libraries which have no prefix
and a `lib` suffix.  This adjustment enables the parallel installation
of import libraries and static library variants for a given module.
This is required to support static and dynamic library co-existence in
Swift.
2023-08-04 21:19:35 -07:00
Saleem Abdulrasool
3aec82da29 Platform: make stdint module implicit on Windows
This makes the `stdint` module implicit which repairs the ability to
build some components.  In order to accomplish this, we need to
potentially break the fragile Swift build system.  Due to the incorrect
handling of compilers we need some workarounds to support
cross-compilation.  This removes the injected system header paths when
building on Windows to ensure that the clang resource headers are not
following the system headers which breaks the modules as the clang
resources are dependent on the system headers when running in hosted
mode.
2023-08-04 15:37:59 -07:00
Alastair Houghton
c8bdc25508 [Linux] Set rpath in add_swift_executable.
Because the rpath isn't set, the dynamic linker can't find the Swift
libraries when we try to run `swift-backtrace` on Linux (when we
actually install everything).

rdar://113337854
2023-08-03 16:49:43 +01:00
Alastair Houghton
6430cede12 Merge pull request #67505 from al45tair/eng/PR-112662487-part2
[Linux][Backtracing] Fix CMake scripts to install correctly.
2023-07-25 15:31:36 +01:00
Alastair Houghton
7873f52074 [Linux][Backtracing] Fix CMake scripts to install correctly.
The script erroneously used `UNIVERSAL_LIBRARY_NAME` instead of
`UNIVERSAL_NAME`.

rdar://112662487
2023-07-25 12:13:07 +01:00
Evan Wilde
669285fd17 Merge pull request #65534 from stephank/fix/cmake-3.25
build: fix accidental cmake expansions
2023-07-24 09:44:14 -07:00
Alex Lorenz
3748b0ff1c Merge pull request #65129 from hyp/eng/no-evo-cxx
[interop] Prohibit use of C++ APIs in public interfaces that opt-in i…
2023-07-19 08:10:23 -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
Max Desiatov
0d1eca191c stdlib/cmake: add missing macro definitions required for WASI (#67139)
We need `-D_WASI_EMULATED_SIGNAL` passed when building for WASI to fully support it.
2023-07-06 15:51:29 +01:00
Alastair Houghton
e5ece81cc9 [Freestanding] Remove uses of stat() and dlsym().
We shouldn't be using stat() or dlsym() in the freestanding
runtime.

rdar://111214571
rdar://106555012
2023-06-23 17:05:59 +01:00
Arnold Schwaighofer
5d5dbd98a4 Merge pull request #66077 from aschwaighofer/wip_enable_opaque_pointers
Enable usage of LLVM's opaque pointer
2023-06-15 11:47:24 -07:00
Arnold Schwaighofer
654f21f1d1 Enable opaque pointers 2023-06-14 10:48:13 -07:00
Mike Ash
110f428780 [Runtime] Add tracing for section scans.
Section scans (for metadata, protocols, etc.) can be costly. This change adds tracing calls to those scans so we can more easily see how much time is spent in these scans and where they're initiated.

This adds an os_signpost implementation controlled by SWIFT_STDLIB_TRACING, and a default empty implementation for when that's disabled.

rdar://110266743
2023-06-14 12:07:44 -04:00
Yuta Saito
792196feeb [wasm][stdlib] Add -D_WASI_EMULATED_PROCESS_CLOCKS to CFLAGS
Stubs.cpp includes <sys/resource.h> which requires the emulation in
wasi-libc
2023-06-10 10:25:19 +00:00
Alex Lorenz
045fcf3ff5 [interop] Prohibit use of C++ APIs in public interfaces that opt-in into library evolution
The CxxStdlib overlay now has to be built without library evolution enabled.
2023-04-13 10:48:09 -07:00
Egor Zhdan
14f32312bf [cxx-interop] Do not add a dependency on clang to CxxStdlib
Cxx & CxxStdlib modules are Swift-only, they do not require invoking clang directly.

When building with `SWIFT_INCLUDE_TOOLS=NO`, Clang is not available as a CMake target (see `swift_common_standalone_build_config`).

rdar://107780733
2023-04-11 16:45:39 +01:00
Arnold Schwaighofer
49332f8b81 Fix the minimal/lto configuration
We need to disable opaque pointers when we compiler the runtime the
linker complains:

```
  ld: Opaque pointers are only supported in -opaque-pointers mode
```

Alternatively, we could pass the opaque-pointers flag to the linker but
then it would complain about the swiftc generated files which still use
typed pointers.
Until swiftc is fixed, disable opaque pointers for .cpp runtime files.

rdar://106515243
2023-03-09 13:27:34 -08:00
Egor Zhdan
947eefbdda Merge pull request #64187 from Azoy/no-more-sp
[CMake] Always disable string processing import
2023-03-08 09:37:43 +00:00
Alejandro Alonso
8417886b0a Always disable string processing import 2023-03-07 15:00:28 -08:00
Kuba (Brecka) Mracek
8d7c11536c Avoid using separate '-D' + '...' flags in CFLAGS in CMake (#63706) 2023-03-07 14:33:15 -08:00
Alastair Houghton
1258d45152 [Backtracing] Build work.
Additional shimming required for some builds, as well as a few other build
related tweaks.

rdar://106234311
2023-03-04 15:46:30 +00:00
Alastair Houghton
9c3ea84acf [Backtracing] Disable implicit imports for executable builds.
Implicit imports were off for library builds already, but we need them off
for executable builds too, otherwise we have problems with _StringProcessing.
2023-03-04 08:00:09 +00:00
Alastair Houghton
3ec2e6723d [Backtracing] Really only build for OS X.
Added some extra code to AddSwiftStdlib.cmake so executable targets can
specify target SDKs the same way libraries currently can.

Updated the Backtracing targets to specify just OS X for now.
2023-03-04 08:00:09 +00:00
Alastair Houghton
eb38d80655 [Backtracing] Fix Windows build.
While I was doing this, it turns out Saleem was fixing things to avoid
having to patch the Windows include directories, which is awesome but
necessitates an extra change to the backtracing stuff to make the build
not fail on Windows.

rdar://105409147
2023-03-04 08:00:09 +00:00
Alastair Houghton
44783e72c6 [Frontend] Add support for implicit import of _Backtracing
Once the API has gone through Swift Evolution, we will want to implicitly
import the _Backtracing module.  Add code to do that, but set it to off
by default for now.

rdar://105394140
2023-03-04 08:00:06 +00:00
Alastair Houghton
aaa9d6c84d Fix accidental duplication of library names.
In AddSwiftStdlib.cmake, we're adding library names twice for target
executables, once with the path and once without.  This appears to break
things on Windows when building the SDKs.

rdar://106104132
2023-03-01 21:42:21 +00:00
Saleem Abdulrasool
2626f23bf5 Merge pull request #63880 from compnerd/development-vfs
stdlib: remove VS injection for Swift development
2023-03-01 09:09:55 -08:00
Alastair Houghton
60ededb0bf [Backtracing] Accumulate lipo inputs per-sdk.
`THIN_INPUT_TARGETS` needed to be reset per-sdk, not just once.

rdar://105390807
2023-03-01 07:49:56 +00:00
Alastair Houghton
2015c8a91e [Backtracing] Fix a bug in the CMake script that resulted in clashing targets.
I missed off an `${sdk}` in the target name for the lipo'd output :-(

rdar://105390807
2023-02-28 22:18:14 +00:00
Alastair Houghton
69ef2e7be1 [Backtracing] Add support for building target executables into libexec.
We're going to add a program, `swift-backtrace`, that gets built alongside the
stdlib and the runtime, and that needs to be installed in libexec/swift
alongside the libraries in lib/swift.

It wants to be built with the stdlib/runtime because there's an internal
interface between `swift-backtrace` and the runtime, so the program needs to
stay in lock-step with the runtime library.

rdar://105390807

(This reverts commit f042ca043680972e33c856bd69f6ecbcdd91f47a.)
2023-02-28 22:16:21 +00:00
Arnold Schwaighofer
f042ca0436 Revert "[Backtracing] Add support for building target executables into libexec." 2023-02-28 10:02:30 -08:00
Saleem Abdulrasool
4075d706a2 stdlib: remove the dependency on the injected modules
Inject the necessary module maps and apinotes via the VFS.  This cleans
up the developer build in preparation for a secondary change to remove
this need for deployed scenarios as well.  Injecting the content via the
VFS will enable us restore the ability to work with a pristine
installation of Visual Studio, dropping the custom action for the Swift
installer, and open the pathway to per-user installation of Swift.

Thanks to @bnbarham for the help and discussion in resolving the test
issues.
2023-02-28 09:40:51 -08:00
Alastair Houghton
f68c4b40f3 Add support for building target executables into libexec.
We're going to add a program, `swift-backtrace`, that gets built alongside
the stdlib and the runtime, and that needs to be installed in libexec/swift
alongside the libraries in lib/swift.

It wants to be built with the stdlib/runtime because there's an internal
interface between `swift-backtrace` and the runtime, so the program needs
to stay in lock-step with the runtime library.

rdar://105390807
2023-02-13 20:04:37 +00:00