Commit Graph

1790 Commits

Author SHA1 Message Date
Slava Pestov
9ac70ce728 Basic: Use getrusage() to read memory usage
On macOS 26, malloc_zone_statistics() always returns
a malloc_statistics_t with the max_size_in_use field
set to zero. This was an intentional change, so let's
remove calls to this API.

Instead, use the proc_pid_rusage() API and return the
ri_lifetime_max_phys_footprint field of rusage_info_v4.

Finally, remove the llvm::sys::Process::GetMallocUsage()
call on other platforms altogether. It returns the
current value and not the max value, so its misleading.
2025-11-11 20:02:20 -05:00
Guillaume Lessard
4bc3d6a695 Merge pull request #85083 from KushalP/TaskQueueTest-fix-race
TaskQueue(Test): Add destructor to close FDs, preventing resource leak, fix race in TaskSignalHandling test
2025-10-24 09:31:51 -07:00
3405691582
25543a56fc Merge pull request #85025 from 3405691582/nobtcfi_amd64
Supply -z,nobtcfi on x86_64 as well.
2025-10-23 21:23:53 -04:00
Kuba (Brecka) Mracek
66eef684ee Merge pull request #80212 from kubamracek/object-file-format
Add #objectFormat compilation conditional (SE-0492)
2025-10-23 12:58:23 -07:00
Kushal Pisavadia
8f14263fd5 TaskQueue: Add destructor to close FDs, preventing resource leak
The `Task` class was missing a destructor to close pipe file descriptors when
destroyed. This caused file descriptor exhaustion after ~2,187 test runs,
making tests fail with POLLNVAL errors when the system ran out of resources.

This was found with:
```
./unittests/Basic/SwiftBasicTests --gtest_filter="TaskQueueTest.*" --gtest_repeat=1000
```
2025-10-23 12:59:29 +01:00
3405691582
0158137afc Supply -z,nobtcfi on x86_64 as well.
On older x86_64 hardware, this isn't a problem since CET IBT hardware
support may not have been available. However, newer x86_64 hardware
supports the feature, which will lead to BTCFI failures. Therefore ensure
the same BTCFI disabling logic applies on x86_64 as well as aarch64.
2025-10-20 21:23:45 -04:00
Steven Wu
5d480ef063 Merge pull request #84861 from cachemeifyoucan/eng/PR-swift-cas-configuration
[Caching][NFC] Using llvm::cas::CASConfiguration
2025-10-20 09:27:19 -07:00
Mads Odgaard
c92e5b47f3 Merge pull request #84574 from madsodgaard/android-availability 2025-10-20 10:40:37 +09:00
Steven Wu
4f059033bb [Caching][NFC] Using llvm::cas::CASConfiguration
Prefer llvm::cas::CASConfiguration where it used to clang::CASOption.
2025-10-17 16:42:35 -07:00
Kuba Mracek
c3f865be4a Add #objectFormat compilation conditional (SE-0492) 2025-10-16 15:15:27 -07:00
Kushal Pisavadia
43ac8ce1cc Remove unused size statistics tracking from Mangler
Removed:
- unused `SizeStatEntry` struct and `SizeStats` vector
- unused statistics counters
- dead code from `printManglingStats()` that referenced these variables
2025-10-14 15:11:21 +01:00
Mishal Shah
03a599c5be Merge pull request #84606 from swiftlang/rebranch
Merge clang 21.x rebranch into main
2025-10-02 20:17:05 -07:00
Doug Gregor
c4527dc47d Merge pull request #84580 from DougGregor/static-build-configure 2025-09-30 20:47:04 -07:00
Doug Gregor
2a46916536 Reseat CompilerBuildConfiguration on top of StaticBuildConfiguration
Now that we have a per-ASTContext StaticBuildConfiguration, reimplement
(almost) everything in CompilerBuildConfiguration to sit on top of it.
Only canImport requires the full ASTContext, so that gets its own
implementation, as does one other operation that can produce an error.
Aside from more code sharing, this provides additional validation that
the StaticBuildConfiguration we build is complete and accurate.
2025-09-29 18:42:15 -07:00
Doug Gregor
3082b04b75 [Macros] Feed the static build configuration into macro expansions
Thread the static build configuration (formed from language options) in
to the macro plugin handler, which will serialize it for use in the
macro implementation. test this with a simple macro that checks
whether a particular custom configuration (set via `-D`) is enabled or
not.

This required some re-layering, sinking the logic for building a
StaticBuildConfiguration from language options down into a new
swiftBasicSwift library, which sits on top of the C++ swiftBasic and
provides Swift functionality for it. That can be used by the C++
swiftAST to cache the StaticBuildConfiguration on the ASTContext,
making it available for other parts of ASTGen.
2025-09-29 18:42:15 -07:00
Doug Gregor
ae8f9d8234 Add -print-static-build-config to print a static build conformance
Introduce the ability to form a `StaticBuildConfiguration` from
language options. Add a frontend option `-print-static-build-config`
to then print that static build configuration as JSON in a manner that
can be decoded into a `StaticBuildConfiguration`.

Most of the change here is in sinking the bridged ASTContext queries
of language options into a new BridgedLangOptions. The printing of the
static build configuration only has a LangOptions (not an ASTContext),
so this refactoring is required for printing.
2025-09-29 18:42:14 -07:00
swift-ci
e35756ef85 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-23 15:38:03 -07:00
Doug Gregor
0737723c5c Merge pull request #84465 from DougGregor/has-feature-library-evolution
Add an optional language feature for Library Evolution
2025-09-23 15:18:48 -07:00
Doug Gregor
c68ef1cf71 Add an optional language feature for Library Evolution
Replace the one-off compiler flag for Library Evolution with an
optional language feature. This makes the
`hasFeature(LibraryEvolution)` check work in an `#if`, and is
otherwise just cleanup.

Tracked by rdar://161125572.
2025-09-22 17:45:34 -07:00
swift-ci
c13a72800d Merge remote-tracking branch 'origin/main' into rebranch 2025-09-22 12:56:40 -07:00
Owen Voorhees
e6c9dceae9 Update OS versions requiring stdlib OS rpaths 2025-09-21 09:47:18 -07:00
swift-ci
e93ab979eb Merge remote-tracking branch 'origin/main' into rebranch 2025-08-14 05:15:47 -07:00
Allan Shortlidge
eb4b049c20 Basic: Fix -print-supported-features.
The check to only include experimental features that are available in
production was inverted.

Resolves rdar://158273047.
2025-08-13 21:33:11 -07:00
swift-ci
23eb9d68bb Merge remote-tracking branch 'origin/main' into rebranch 2025-08-11 09:35:30 -07:00
Evan Wilde
3fcca83d07 Refactor getMinPlatformVersion
The definitions of how version numbers were extracted from target
triples split between the minimum platform version and for determining
the minimum inlining version.

This resulted in inlinable and transparent functions not being imported
correctly on non-Apple platforms where the version number is retained as
part of the target triple.
Specifically, `_checkExpectedExecutor` was found in the module, but
didn't have the appropriate availability version assigned, resulting in
it failing to import and the compiler silently omitting the check in
SILGen when compiling for FreeBSD.

This patch refactors the implementation of `getMinPlatformVersion` into
a separate function that is used in both places so that they cannot get
out of sync again.

Note: This changes how Windows is handled. getMinPlatformVersion
returned an empty version number for Windows, while the availability
implementation returned the OS version number. This makes both
consistently return the OS version number.
2025-08-08 15:10:04 -07:00
swift-ci
90c32c2aad Merge remote-tracking branch 'origin/main' into rebranch 2025-07-16 00:55:25 -07:00
Anthony Latsis
90f9fce339 Merge pull request #82665 from swiftlang/jepa4
Bridging: Bridge some basic classes like `swift::SourceLoc` directly
2025-07-16 08:27:12 +01:00
Anthony Latsis
5620abbad8 Bridging: Bridge swift::CharSourceRange directly 2025-07-15 21:34:48 +01:00
Anthony Latsis
6eb5d7d857 Bridging: Bridge swift::SourceLoc directly 2025-07-15 21:33:06 +01:00
Anthony Latsis
06a5670c8f Basic: Untie swift::SourceLoc from llvm::SMLoc
Storing a `llvm::SMLoc` is a superfluous indirection, and getting rid of
it enables us to unconditionally import `SourceLoc` into Swift.
2025-07-11 18:48:42 +01:00
swift-ci
f7bc202e92 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-10 21:35:02 -07:00
Allan Shortlidge
0a86d007e8 Basic: Stop enabling NoncopyableGenerics, BorrowingSwitch, and MoveOnlyPartialConsumption.
These features are baseline features and therefore are considered to be
implicitly enabled. They don't need to be explicitly enabled or queried for in
any part of the compiler.
2025-07-10 12:17:46 -07:00
Anthony Latsis
5e22a5ba64 Merge pull request #82243 from AnthonyLatsis/rebranch
[rebranch] Get Swift almost building with stable/20250601
2025-06-17 12:20:37 +01:00
Anthony Latsis
faa7f67960 Merge pull request #82165 from AnthonyLatsis/jepa
{AST,Basic}Bridging: Use  `<swift/bridging>` and try directly bridging one of our enums
2025-06-17 04:52:41 +01:00
Cyndy Ishida
64168edbf5 [Modules] Allow implicit conversions when loading interfaces with invalid os versions (#82228)
Initially, the compiler rejected building dependencies that contained OS
versions in an invalid range. However, this happens to be quite
disruptive, so instead allow it and request that these versions be
implicitly bumped based on what `llvm::Triple::getCanonicalVersionForOS`
computes.

resolves: rdar://153205856
2025-06-16 12:46:32 -07:00
Anthony Latsis
106d5f4461 {AST,Basic}Bridging: Use SWIFT_COMPUTED_PROPERTY 2025-06-16 19:11:32 +01:00
Anthony Latsis
0981b71090 Adjust calls to clang::DiagnosticsEngine ctor (now takes ref vs. ptr)
See https://github.com/llvm/llvm-project/pull/139584
2025-06-13 21:57:36 +01:00
Anthony Latsis
9322c9f992 Adjust calls to clang::TargetInfo::CreateTargetInfo (now takes ref vs. ptr)
See https://github.com/llvm/llvm-project/pull/106271
2025-06-13 21:57:36 +01:00
Anthony Latsis
dcb905bddd Basic: Conservatively handle new llvm::Triple case
Added in https://github.com/llvm/llvm-project/pull/87845
2025-06-13 21:57:36 +01:00
Allan Shortlidge
aca604660f AST/Sema: Make MemberImportVisibility a migratable feature.
The migration to `MemberImportVisibility` can be performed mechanically by
adding missing import declarations, so offer automatic migration for the
feature.

Resolves rdar://151931597.
2025-05-30 15:34:08 -07:00
Allan Shortlidge
522fee4a14 Basic: Fix a bug in LangOptions::hasFeature().
Don't skip checking if a feature is enabled for migration when the feature also
has an associated language version.
2025-05-30 15:34:08 -07:00
Hamish Knight
6d3455f52b Merge pull request #81849 from hamishknight/message-in-an-error
[Basic] Always dump message to stderr in `_abortWithMessage`
2025-05-30 20:53:37 +01:00
Ben Barham
b0d5e0e8f1 Merge pull request #81697 from bnbarham/use-toolchain-version
Add the distribution tag to `-print-target-info`
2025-05-30 09:51:03 -07:00
Hamish Knight
b9b2cb25c2 [Basic] Always dump message to stderr in _abortWithMessage
This allows it to be seen while e.g attached with a debugger.
2025-05-30 16:08:37 +01:00
Ben Barham
3c098782b4 Add the distribution tag to -print-target-info
Ideally this would also update the `--version` output to be overridden
by `SWIFT_TOOLCHAIN_VERSION`, but unfortunately various tools rely on
the current format (eg. swift-build).
2025-05-28 17:29:17 -07:00
Anthony Latsis
e7b2bc0d08 Basic: Adjust condition for include after macro removal in upstream LLVM
`HAVE_SYS_RESOURCE_H` was removed in
https://github.com/llvm/llvm-project/pull/123288, so this header is no
longer included at this particular location on rebranch, which breaks
the Linux build, where it is not transitively included either.

Use the same condition as in the use site
(`getChildrenMaxResidentSetSize`) instead.

Also, don't wrap `HAVE_GETRUSAGE` in `defined()` in case it does get
defined to 0.
2025-05-28 23:02:15 +01:00
Doug Gregor
32267f4971 Finish comment 2025-05-22 12:15:53 +01:00
Doug Gregor
414adb55ca Add optional language features to the supported features output
Optional language features don't have a specific "-enable-*" flag, because
they're rare and don't fit the same upcoming/experimental distinction. Add
a flag_name field to provide the flag name as well.
2025-05-22 11:07:13 +01:00
Doug Gregor
7f2649ff33 Add the set of diagnostic categories to each migratable feature
The name of a migratable feature might differ from the names of the
diagnostic groups containing the diagnostics that are used to drive
migration for that feature. Provide the set of diagnostic categories
that are associated with each migratable feature as part of the
supported features list.
2025-05-22 11:07:13 +01:00
Doug Gregor
abad2fae0f Make the optional feature StrictMemorySafety migratable
This feature is essentially self-migrating, but fit it into the
migration flow by marking it as migratable, adding
`-strict-memory-safety:migrate`, and introducing a test.
2025-05-22 11:07:13 +01:00