Commit Graph

456 Commits

Author SHA1 Message Date
Evan Wilde
9d3a975170 Merge pull request #85229 from etcwilde/ewilde/nudge-glibc-modulemap
Modularize signal.h on FreeBSD
2025-11-03 07:25:49 -08:00
Evan Wilde
ff92f9e5d3 Modularize signal.h on FreeBSD
This nudges the Glibc modulemap just enough to get SwiftPM and later
targets building. Without it, Swift tries to import the signal hander
APIs through CDispatch instead of Glibc. CDispatch shouldn't be directly
imported, so recommending that is nonsensical.

This is not a full solution for all headers, but meant to perturb the
module machinery sufficiently that it pulls signal.h into glibc
correctly.

Works around:
```
Swift-Project/swiftpm/Sources/Basics/Cancellator.swift:79:24:
error: property '__sigaction_u' is not available due to missing import of defining module 'CDispatch' [#MemberImportVisibility]
```
2025-10-30 16:35:07 -07:00
Saleem Abdulrasool
04ab94d4cf Platform: correct posix_file_actions_init on Android
Adjust the API annotations to get this imported into Swift properly. The
outer pointer may be `nullptr`, but the inner pointer may not.
2025-10-30 13:49:25 -07:00
Saleem Abdulrasool
39fd9c1c6d Platform: correct posix_spawn API nullability
The `posix_spawn` API is not annotated appropriately for nullability.
Adjust the signature to allow proper usage with older NDKs.
2025-10-30 13:49:13 -07:00
Egor Zhdan
a58b623d9e [WinSDK] Modularize <winapifamily.h>
This prevents other Clang modules from hijacking this header, causing modularization errors. For example, several WinRT headers `#include <winapifamily.h>`.
2025-10-03 19:26:15 +01:00
3405691582
9683569f25 OpenBSD 7.8 will require OpaquePointer for FILE. (#84478)
OpenBSD 7.8 snapshots hide the type information for FILE. Therefore, the
types for the standard stdio streams should (regrettably) be
OpaquePointer, due to the well-discussed issue of losing type
information for forward-declared C types.

We explicitly drop to void * in the LibcOverlayShims for backwards
compatibility, since OpenBSD 7.8 is not yet released.
2025-09-27 18:16:58 +05:30
Jonathan Grynspan
4dd71a437e Rename the new _GUID clang module to _GUIDDef. (#84466)
This PR changes the name of the clang module introduced in #83914 from
`_GUID` to `_GUIDDef`. This change is necessary because the Windows SDK
declares a type named `_GUID` and Swift gets confused when a module and
a type have the same name.

This confusion is the motivation for
[SE-0491](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0491-module-selectors.md),
but we can't just wait for a fix because the new module is a
source-breaking change and clients won't be able to adopt the proposed
syntax for some time.
2025-09-23 18:53:23 -07:00
Egor Zhdan
28f9db7bfa [WinSDK] Modularize <guiddef.h>
This fixes modularization errors that arise when importing a C++ header that contains `#include <guiddef.h>`, which might hijack this header from the WinSDK module where it belongs.
2025-08-28 22:21:55 +01:00
Saleem Abdulrasool
eafc8140da Windows: annotate unsafe constructs in the overlay
Mark a number of overlay calls as `unsafe` to account for the new memory
safety work.
2025-08-26 18:03:56 -07:00
Max Desiatov
900c7c9d7b Platform/CMake: use arch instead of arch_subdir
This fixes wasi-libc.modulemap not found after installation
2025-08-19 11:25:14 +01:00
Max Desiatov
e227e50704 Platform/CMake: remove unused message func, mod var 2025-08-18 20:42:45 +01:00
Max Desiatov
4299bca9d6 Platform/CMake: add embedded-stdlib-${mod} dependency 2025-08-18 20:28:59 +01:00
Max Desiatov
6582ad92bc Embedded Wasm: enable import WASILibc
WASILibc wasn't built for the embedded stdlib in `stdlib/public/Platform/CMakeLists.txt`. New `copy_wasilibc_modulemap_embedded_resource` and `embedded-stdlib-platform-${triple}` targets are added, the latter for `wasm32-unknown-wasip1` only for now. Also added a `wasilibc_functions.swift` test to verify the result.

Resolves https://github.com/swiftlang/swift/issues/83513

rdar://157467412
2025-08-18 18:41:10 +01:00
Jonathan Grynspan
3195c28b8d Add WinSDK.GDIPlus Clang module. (#83425) 2025-07-31 07:08:51 -07:00
Egor Zhdan
a818de1588 [cxx-interop] Modularize xsmf_control on Windows
This adds `xsmf_control.h` into the STL modulemap on Windows.

Fixes the following compiler error emitted by Clang when trying to use `std::variant` from Swift with C++ interop:
```
...\MSVC\14.42.34433\include\variant:923:25: error: missing '#include <xsmf_control.h>'; '_Non_trivial_move_assign' must be defined before it is used
```
2025-07-29 14:30:34 +01:00
Luke Howard
451f309935 build with 64-bit time_t on 32-bit platforms (#82595)
It is good practice to build with 64-bit `time_t`/timeval on 32-bit
platforms to avoid the Y2038 issue. This is the default when building on
Yocto for armv7, for example. Unfortunately `suseconds_t` is not an
alias to a type of the correct width (unlike time_t).

Question: on release/6.1, tv_usec is assumed to be `Int32`, but on main
it is `Int`, but appears to be the same commit hash?

#### git blame main stdlib/public/Platform/Platform.swift

```
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 350) @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 351) extension timeval {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 352)   @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 353)   public init(_ duration: Duration) {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 354)     let comps = duration.components
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 355)   // Linux platforms define timeval as Int/Int
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 356)   self.init(tv_sec: Int(comps.seconds),
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 357)               tv_usec: Int(comps.attoseconds / 1_000_000_000_000))
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 358)   }
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 359) }
```

#### git blame release/6.1 stdlib/public/Platform/Platform.swift

```
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 455) @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 456) extension timeval {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 457)   @available(SwiftStdlib 5.7, *)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 458)   public init(_ duration: Duration) {
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 459)     let comps = duration.components
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 460) #if os(Linux)
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 461)   // Linux platforms define timeval as Int/Int
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 462)   self.init(tv_sec: Int(comps.seconds),
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 463)               tv_usec: Int(comps.attoseconds / 1_000_000_000_000))
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 464) #else
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 465)     // Darwin platforms define timeval as Int/Int32
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 466)     self.init(tv_sec: Int(comps.seconds),
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 467)               tv_usec: Int32(comps.attoseconds / 1_000_000_000_000))
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 468) #endif
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 469)   }
e675b310f8 (Philippe Hausler    2022-02-17 09:32:46 -0800 470) }
```
2025-06-30 18:19:32 -07:00
Saleem Abdulrasool
2ee8787712 Merge pull request #82343 from compnerd/ntapi
Platform: expose NTAPI
2025-06-18 23:09:01 -07:00
Saleem Abdulrasool
e049493d77 Platform: expose NTAPI
The NTAPIs are sometimes required to access some system information. At
the very least, the types defined here are useful to expose.
2025-06-18 09:51:52 -07:00
(null)
bc870eff36 removed duplicated 2025-06-17 16:07:39 -04:00
(null)
cf041b126e address pltaform orders and other nits 2025-06-17 15:37:49 -04:00
(null)
d6811260a9 Merge commit '665515c781999a81094bbe4f8302a7cb1a6a6b39' into mchiu/freebsd 2025-06-17 15:12:23 -04:00
Fabrice de Gans
4596a04f6a modulemap: Add missing dependency on vcruntime
`stdlib.h` includes `limits.h`, which is defined in the `vcruntime`
module.
2025-06-09 15:20:58 -07:00
Fabrice de Gans
e94cc8626c Platform: Windows SDK 26100.3916 module map update
A minor update to the Windows SDK broke our module maps. This fixes the
issue by re-separating a few modules. For backward-compatibility and
proper export of symbols, the split headers are also included in the
main `ucrt` module.
2025-06-03 11:59:34 -07:00
Fabrice de Gans
72dad03924 Simplify ucrt.modulemap 2025-06-02 15:24:43 -07:00
Fabrice de Gans
6f9876a565 Platform: Update module maps for the static SDK
Building with the Windows static SDK uncovered issues in the Windows
module maps. Some of the headers were missing and others had incorrect
layering. This updates the module maps to build with the static Windows
SDK.
2025-06-02 15:24:17 -07:00
michael-yuji
8738e722bd Merge branch 'main' into mchiu/freebsd 2025-05-28 14:44:11 -07:00
Ian Anderson
15345ef2d5 [CMake][Darwin] Remove support for building the SDK overlays on Apple platforms
The SDK overlays have been provided in the Apple SDKs for many years, and the interface and implementation has diverged in more recent years such that trying to build the Swift version no longer works. Remove all of the dead code.

rdar://151889154
2025-05-23 23:38:08 -07:00
michael-yuji
9a948a9c3b Merge branch 'main' into mchiu/freebsd 2025-05-21 16:29:16 -07:00
Kuba Mracek
6d71f45101 [embedded] Stop using -D__APPLE__ and -D__MACH__ 2025-03-31 15:07:11 -07:00
Fabrice de Gans
d5ea19405d Put float and stddef back inside the ucrt module
These were split out in #79751. However, this split is not needed for
these. Furthermore, modulemaps have bugs when it comes to re-exporting
some modules, resulting in missing exports.
2025-03-21 10:01:01 -07:00
Fabrice de Gans
7a965cee00 Restore legacy_stdio_definitions in ucrt.modulemap
This was removed in #79751 but is required in some cases.
2025-03-19 16:51:38 -07:00
Fabrice de Gans
5e3bd9f90b Merge pull request #79751 from Steelskin/fabrice/update-ucrt-modulemap
Update ucrt.modulemap for Windows SDK 10.0.26100
2025-03-18 09:04:24 -07:00
Michael Chiu
26dd5c3787 FreeBSD cxx stdlib and tests fixes 2025-03-14 02:15:15 -04:00
Michael Chiu
0c47c45303 Adding FreeBSD support
This commit adds required conditional compilation blocks to enable bulding on
FreeBSD (tested on x86_64 FreeBSD 14.1-RELEASE-p6). Also implements FreeBSD
synchronization shims using `_umtx_op(2)`
2025-03-14 02:15:15 -04:00
Saleem Abdulrasool
1dffb688d6 WinSDK: add DDE, OLE, LZ32 submodules
Further modularise the Windows SDK. This adds 3 new submodules to get
better coverage of the Windows SDK.
2025-03-03 13:44:51 -08:00
Saleem Abdulrasool
c4f5831507 Platform: add APINotes for bionic.spawn
Add some APINotes for `bionic.spawn` to correct the nullability
annotations. This allows building Foundation with NDK r26b.
2025-02-27 21:09:23 -08:00
Saleem Abdulrasool
79d2af759b ClangImporter: support modularizing __msvc_string_view.hpp
This header was introduced in a recent STL release. Modularise the
header properly, adding a shim for compatibility with older releases.

Partially based on a change from @egorzhdan.
2025-02-10 12:48:35 -08:00
Finagolfin
22833fbc54 [android] Update to LTS NDK 27c
Add a new bits/ header to the Android overlay, include runtime libraries that are
auto-extracted and listed many times to the list of libraries to be de-duplicated,
enable a C++ interop test that's working again, and update the doc with new
libraries that need to be available to run a simple executable.
2024-11-14 00:11:53 +05:30
Artem Chikin
60538d5918 Revert "Attempt to reduce the number of embedded stdlib targets being built simultaneously."
This reverts commit dfa1bdb1ce.
2024-11-11 14:42:59 -08:00
Artem Chikin
dfa1bdb1ce Attempt to reduce the number of embedded stdlib targets being built simultaneously.
We are seeing strange crashes during embedded stdlib build stage on Ubuntu 24.04. These crashes only seem to occur when we dispatch many stdlib emit-module tasks at the same time. While we root-cause it, this change attempts to slow down the process to only two Embedded StdLib tasks at-a-time.

Workaround for rdar://137674862
2024-11-08 13:55:14 -08:00
furby™
c68b0d8320 Fix typos in VCRuntime modulemap.
* https://github.com/swiftlang/swift/issues/77351

Signed-off-by: furby™ <devs@wabi.foundation>
2024-11-01 19:16:00 -06:00
Egor Zhdan
168413ef61 Merge pull request #76823 from swiftlang/egorzhdan/msvc-bit-module
[cxx-interop] Modularize __msvc_bit_utils on Windows
2024-10-07 12:10:55 +01:00
Egor Zhdan
16e7cbeafa [cxx-interop] Modularize __msvc_bit_utils on Windows
`__msvc_bit_utils.hpp` was added in a recent version of MSVC, and it is causing build errors for SwiftCompilerSources:
```
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\numeric:598:12: error: function '_Select_countr_zero_impl<unsigned long long, (lambda at C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.39.33519\include\numeric:598:55)>' with deduced return type cannot be used before it is defined
    return _Select_countr_zero_impl<_Common_unsigned>([=](auto _Countr_zero_impl) {
```

This change references the `__msvc_bit_utils.hpp` header from the modulemap. Since we still need to support older versions of Visual Studio that do not provide `__msvc_bit_utils.hpp`, this also teaches ClangImporter to inject an empty header file named `__msvc_bit_utils.hpp` into the system include directory, unless it already exists.

rdar://137066642
2024-10-04 13:15:20 +01:00
Egor Zhdan
5b9186e445 [Glibc] Remove WASI gyb logic from the modulemap
This is a minor cleanup of the generated Glibc modulemap.

WASI no longer uses the Glibc modulemap since 902d75e6.
2024-10-04 01:00:24 +01:00
Egor Zhdan
0c106006db [Glibc] Remove Android gyb logic from the modulemap
This is a minor cleanup of the generated Glibc modulemap.

Android no longer uses the Glibc modulemap since 57b89d53.
2024-10-03 19:37:11 +01:00
Dmitrii Galimzianov
a8b71ea97f Add -print-diagnostic-groups flag
This change adds the `-print-diagnostic-groups` flag as described by SE-0443.
2024-09-11 13:34:42 +02:00
Yuta Saito
ba63b9f628 Merge pull request #75821 from kateinoigakukun/pr-680047d2b871e809cf13f27c8a4a5abc2f5c31d2
[wasm] Annotate errno as SwiftPrivate by apinotes
2024-08-17 14:35:42 +09:00
Yuta Saito
be08ebb12a [wasm] Annotate errno as SwiftPrivate by apinotes
This patch adds an apinotes file for SwiftWASILibc clang module to mark
`errno` macro hidden from Swift code. This resolves ambiguity between
the C macro definition and the Swift wrapper in WASILibc overlay module.

This change installs the apinotes file to the resource directories for
both lib/swift/apinotes and lib/swift_static/apinotes.
2024-08-16 10:57:24 +00:00
Alex Lorenz
d35af38ce4 Merge pull request #75721 from hyp/eng/75691
[windows] split out complex module from ucrt module, to allow new swi…
2024-08-12 08:30:47 -07:00
Yuta Saito
90799cfdf7 Revert "[wasm] Fix ambiguous errno error when importing WASILibc module"
This reverts commit 164ec0adaa.
2024-08-10 13:29:48 +00:00