Commit Graph

667 Commits

Author SHA1 Message Date
Alejandro Alonso
5fe6a7e247 Add caseFolded to scalar properties 2022-04-10 13:03:13 -07:00
stevapple
b913a9f189 Improve memcmp extern logic 2022-04-07 09:24:10 +08:00
Alejandro Alonso
79bf63505b Add Unicode script data to scalar properties 2022-04-06 13:37:04 -07:00
Saleem Abdulrasool
d7a5e2bef2 Merge pull request #42143 from compnerd/malign
runtime: allow over-aligned types in the runtime
2022-04-06 07:58:43 -07:00
Saleem Abdulrasool
b694ce4634 runtime: allow over-aligned types in the runtime
Not all targets have a 16-byte type alignment guarantee.  For the types
which are not naturally aligned, provide a type specific `operator new`
overload to ensure that we are properly aligning the type on allocation
as we run the risk of under-aligned allocations otherwise.

This should no longer be needed with C++17 and newer which do a two
phase `operator new` lookup preferring
`operator new(std::size, std::align_val_t)` if needed.  The base type
would be fully pre-processed away.  The empty base class optimization
should help ensure that we do not pay any extra size costs for the
alignment fixes.

As we are a C++14 codebase, we must locally implement some of the
standard type_traits utilities, namely `void_t`.  We take the minimal
definition here, assuming that the compiler is up-to-date with C++14 DR
reports which fixed an issue in SFINAE.  We use the SFINAE for detecting
the presence of the `operator new` overload to guide the over-alignment,
which is inherited through the new `swift::overaligned_type<>`  base
type.

Annotate the known classes which request explicit alignment which is
non-pointer alignment.  This list was identified by
`git grep ' alignas(.*) '`.
2022-04-04 18:26:20 -07:00
Yuta Saito
6fd3ae7812 [Wasm] Specify the least valid pointer for wasm32
WebAssembly doesn't reserve low addresses but without "extra inhabitants" of
the pointer representation, runtime performance and memory footprint are
worse. So assume that compiler driver uses wasm-ld and --global-base=1024 to
reserve low 1KB.
2022-04-03 07:00:32 +00:00
Yuta Saito
ed7ab2a5a3 [Wasm][KeyPath] Resolve absolute function pointer as identity
Emit and resolve idValue of KeyPath as an absolute pointer if relative
function pointer is turned-off on Wasm target.
The existing ABI can't distinguish an idValue between function pointer
or data pointer in use-site at compile-time and also at runtime. So this
patch adds a new id resolution scheme `ResolvedAbsolute` to distinguish
them at runtime properly.
2022-04-02 16:25:23 +00:00
Butta
7b2256f97b [android] Move the string and other tags in pointers to the second byte because Android enabled memory tagging
Starting with Android 11, AArch64 placed a tag in the top byte of pointers to
allocations, which has been slowly rolling out to more devices and collides
with Swift's tags. Moving these tags to the second byte works around this
problem.
2022-04-02 08:50:54 +05:30
冀卓疌
b6e39817d7 [gardening] typo "teh" → "the" 2022-03-31 23:25:20 +08:00
Konrad `ktoso` Malawski
4f8c0152c3 update some missing places with _ 2022-03-16 08:35:37 +09:00
YR Chen
b359d4af89 Fix type of memcmp on Windows 2022-03-13 16:32:05 +08:00
Saleem Abdulrasool
0bc375d97c Revert "visualc: clean up the module definition"
This reverts commit c194d1cf24.
2022-03-07 18:25:25 -08:00
Robert Widmann
7cd3541c62 Merge pull request #41656 from MillerTechnologyPeru/feature/ppc32
[stdlib] Added PowerPC 32-bit support
2022-03-07 15:08:26 -08:00
Saleem Abdulrasool
c194d1cf24 visualc: clean up the module definition
Clean up the submodules in visualc to not export all imported modules.
The one special case is `vcruntime` which re-exports `SAL` due to a
dependency in the headers.  The import of `visualc` however will
re-export all submodules to keep the current behaviour.  This is
required to get the ARM64 SDK building on newer MSVC toolsets.
2022-03-07 10:59:00 -08:00
Jonathan Grynspan
845182252c Add exported symbol on non-Apple platforms to enumerate MetadataSection structures at runtime. 2022-03-04 23:44:10 -05:00
Alsey Coleman Miller
0ab3eec987 Added PowerPC 32-bit support 2022-03-03 22:21:33 -05:00
Robert Widmann
beda891274 Merge pull request #40557 from 3405691582/UnifiedModulemap 2022-02-21 22:45:55 -08:00
Tim Kientzle
4d91b45988 [RemoteMirror] Get spare bit info from reflection records (#40906)
This adds a new reflection record type carrying spare bit information for multi-payload enums.

The compiler includes this for any type that might need it in order to accurately reflect the contents of the enum. The RemoteMirror library will use this if present to determine how to project the contents of the enum. If not present (for example, in older binaries), the RemoteMirror library falls back on an internal calculation of the spare bitmask.

A few notes:
 * The internal calculation is not perfect.  In particular, it does not support MPEs that contain other enums (e.g., optionals).  It should accurately refuse to project any MPE that it does not correctly support.
 * The new reflection field is designed to be expandable; this might someday avoid the need for a new section.

Resolves rdar://61158214
2022-02-21 17:06:14 -08:00
3405691582
600d500ed6 [stdlib] Use the single-header Glibc modulemap.
This migrates OpenBSD to use the single-header Glibc modulemap proposed
and implemented in #32404, and necessitates introducing some missing
headers for building Foundation added in #38341.

Additionally, incorporate nullability annotations in SwiftShims per
2022-02-11 13:04:12 -05:00
Robert Widmann
f5bc40be10 Merge pull request #35707 from buttaface/droid
[android] Switch to new single-header modulemap for Bionic too
2022-02-10 15:50:19 -08:00
Daniel Rodríguez Troitiño
c6c88ce714 [cmake] Allow overriding Clang resource symlink target (#41301)
When building with a prebuilt Clang, the changes introduced in #40707
supposed that the toolchain was in its final path.

When building in stages (first the toolchain, then the standard
library), the toolchain might not be in the final path, and the created
symlink will point to a machine-local path that does not make sense.

The changes introduced should not modify the existing behaviour
introduced by #40707, but should allow customizing the final
installation target using the CMake cached variable for those setups
that need the flexibility.
2022-02-09 14:37:40 -08:00
Karoy Lorentey
b20f0158b2 Merge pull request #41274 from lorentey/remove-Dispatch-shims
[shims] Remove the _SwiftDispatchOverlayShims module
2022-02-09 14:36:49 -08:00
Kuba (Brecka) Mracek
6fe3ccc47d Drop read/write/close LibcShims and use the platform APIs directly from the SwiftPrivate module (#40211) 2022-02-08 15:32:49 -08:00
Karoy Lorentey
4e90871b4c [shims] Remove the _SwiftDispatchOverlayShims module
This module used to be a private implementation detail of the Distpatch overlay on Apple platforms, and swift-corelibs-libdispatch elsewhere.

Darwin hasn't been using this module for a couple years now, and swift-corelibs-dispatch stopped using it with https://github.com/apple/swift-corelibs-libdispatch/pull/592. We are now free to remove it from the Swift toolchain -- which is good, as it contains declarations that are specific to Dispatch, and the compiler/stdlib is not the right place to maintain them.
2022-02-08 11:38:45 -08:00
Karoy Lorentey
6d20137711 [shims] Remove the _SwiftXCTestOverlayShims module
This used to be a private implementation detail of the XCTest overlay.

This module has been unused since the Xcode 12.5 release, but we temporarily kept it in the toolchain in case a downloadable toolchain gets used with an older Xcode. (The module used to be imported by the XCTest overlay interface, so its removal would have made it tricky to import XCTest in that scenario.)

Including the 13.3 beta, there have now been seven Xcode releases since the last one that imported this module, and the compiler/stdlib repository no longer supports building with Xcode 12.4 or below. It seems reasonable to stop installing this module on the toolchain now.

rdar://80552912
2022-02-07 17:16:03 -08:00
ShenYj
c0658c7adc The one here seems to be the end of '__swift__' 2022-01-28 12:39:32 +08:00
Evan Wilde
3de0bbb476 Merge pull request #40707 from buttaface/symlink-clang
[build] Link the Swift resource directory against the headers from a prebuilt clang, if building with one
2022-01-12 18:10:53 -08:00
Alejandro Alonso
6ca7366cd8 Merge pull request #40746 from Azoy/indic-grapheme-clusters
[stdlib] Implement the Indic grapheme breaking rules
2022-01-11 12:50:02 -08:00
Alejandro Alonso
4a451829f8 Implement the Indic grapheme breaking rules 2022-01-05 16:18:54 -08:00
Jonathan Grynspan
099fdc2e41 Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.) 2022-01-01 11:39:25 -05:00
Butta
8fd1d64a4e [build] Link the Swift resource directory against the headers from a prebuilt clang, if building with one 2021-12-26 16:59:21 +05:30
Erik Eckstein
3d33f11e6c cmake/build-script: rename the libswift option to "bootstrapping"
In cmake, rename LIBSWIFT_BUILD_MODE to BOOTSTRAPPING_MODE.
Also, rename the lit feature "libswift" to "swift_in_compiler".
2021-12-22 11:31:52 +01:00
Arnold Schwaighofer
cf3951394a Revert "Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.)" 2021-12-21 07:15:08 -08:00
Jonathan Grynspan
7fe5ea7398 Fix an issue on COFF/ELF targets where the runtime would register each loaded image twice (at least early on.) 2021-12-20 15:15:02 -05:00
Pavel Yaskevich
3f4c06eb1b [Distributed] Runtime: Add skeleton support for accessible function sections 2021-12-17 10:52:56 -08:00
Butta
5eb29d99dd [android] Switch to new single-header modulemap for Bionic too 2021-12-13 23:23:45 +05:30
Alejandro Alonso
8a5f728daf Merge pull request #40340 from Azoy/drop-icu
[stdlib] Drop ICU
2021-12-07 01:44:38 -08:00
David Smith
fc3e718771 Initial support for compile-time generation of vprintf format strings, behind the SWIFT_STDLIB_STATIC_PRINT flag 2021-12-02 16:58:36 -08:00
Alejandro Alonso
21ee3a5e0f Drop ICU
update freestanding deps
2021-11-30 13:53:08 -08:00
Alejandro Alonso
ac6c08f157 [stdlib] Make the rest of the scalar properties native (#40233)
* Factor out the scalar bit array index mechanism

* Implement native numeric scalar properties

* Implement native scalar name aliases

* Implement native scalar mappings

* Implement native scalar names

* Implement native scalar age

* Implement native scalar general category

* Address Michael's and others comments

fix special mappings

fix bug
2021-11-30 12:40:32 -08:00
Erik Eckstein
61db072617 cmake: fix libswift build dependencies
Unfortunately using the convenient "bootstrapping0-all", etc. custom targets does not work.
For some reason it does not cause a dependent file (like libswift's SIL.o) being rebuilt when a depenency (like swift-frontend from the previous bootstrapping stage) changes.
Instead we have to list al library- and executable-targets explicitly.
2021-11-23 18:33:43 +01:00
Alejandro Alonso
3b402f0179 [stdlib] Implement native Unicode.Scalar binary properties (#39597)
* Generate Unicode data for Scalar Binary Properties

* Use native scalar binary property lookup

* Add _BinaryProperties to Scalar Properties

narrow access control

* Upgrade the notice to a warning in UnicodeScalarProperties
2021-11-15 15:20:46 -08:00
Saleem Abdulrasool
d001831041 Shims: strongly link swift_isStackAllocationSafe on !Darwin
Windows objects to the multiple different aliases for
`swift_isStackAllocationSafe`.  Use strong linkage on all non-ABI stable
targets.  This should repair the Windows build and matches the
conditional emission in the stdlib.

Thanks to @lorentey for the discussion around how to handle this and the
pointer to where this was getting introduced!
2021-11-05 18:39:05 -07:00
Erik Eckstein
09552abc44 libswift: improve the bootstrapping-with-hostlibs build mode
Don't build the swiftCore module files in the bootstrapping phases. Instead use the module files in the SDK.
This reduces the build time overhead from 3min -> 30seconds.
2021-11-05 18:32:25 +01:00
Karoy Lorentey
6313748c5d Merge pull request #39405 from Bo98/copy_shim_headers-all
[build] Add copy_shim_headers to all target
2021-11-01 17:29:43 -07:00
Alejandro Alonso
5a0bbb9f89 [stdlib] Implement native grapheme breaking for String (#37864)
* Implement GraphemeWalker that does native grapheme breaking

* Bridged strings use native grapheme breaking for forward strides

* Implement bidirectional native grapheme breaking for native and foreign strings

* Remove ICU's grapheme breaking support

* Use UnicodeScalarView to implement GraphemeWalker

use an Iterator approach

remove Iterator conformance

* Incorporate Michael's feedback

more comments addressed

fix crlf bug

* Try bringing back some old fast paths

* Parameterize nextBoundary and previousBoundary

Parameterize nextBoundary and previousBoundary

* Implement Michael's suggestions
2021-11-01 16:52:28 -07:00
Jonathan Grynspan
f1bf7badba [SE-0322] Temporary uninitialized buffers
Adds two new IRGen-level builtins (one for allocating, the other for deallocating), a stdlib shim function for enhanced stack-promotion heuristics, and the proposed public stdlib functions.
2021-10-25 11:20:10 -04:00
Kuba (Brecka) Mracek
7538949859 Split out CommandLine enum into a separate static library, allow removing it from stdlib (#39591)
This is for the 'freestanding' build to stop assuming the platform has argc/argv.

- Introduce a new sub-library, libswiftCommandLineSupport.a
- Move stubs/CommandLine.cpp into this library
- Conditionally embed it into libswiftCore
- Conditionally embed it into libswiftPrivateLibcExtras if not in libswiftCore to support testing
- Add SWIFT_STDLIB_HAS_COMMANDLINE CMake (and build-script) flag
2021-10-13 07:02:43 -07:00
Kuba (Brecka) Mracek
c2c1bfb053 Add SWIFT_STDLIB_HAS_ENVIRON to remove usage of getenv/environ from stdlib (#39599) 2021-10-12 07:16:36 -07:00
Alex Hoppen
6e07ee8f90 Fix a couple of build warning
Fixes a couple of compiler warnings that occur frequently when building the compiler:
- Copy the nullability annotation definitions from `Visibility.h` to `BridgedSwiftObject.h` and wrap all code that contains nullability annotations in `SWIFT_BEGIN_NULLABILITY_ANNOTATIONS` and `SWIFT_END_NULLABILITY_ANNOTATIONS` (supressing the warning `type nullability specifier '_Nullable' is a Clang extension [-Wnullability-extension]`)
- Suppress warnings about using `$` (mangling prefix) as an identifier using pragmas (supressing the warning `'$' in identifier [-Wdollar-in-identifier-extension]`)
- Change the macro condition of `SWIFT_NODISCARD` from `__cplusplus >= 201402l` (which checked for >= C++14) to `__cplusplus > 201402l`. This appears to have been a copy-paste error from `LLVM_NODISCARD` (supressing the warning `use of the 'nodiscard' attribute is a C++17 extension [-Wc++17-extensions]`)
2021-10-08 10:11:33 +02:00