Commit Graph

1818 Commits

Author SHA1 Message Date
Max Desiatov e37274c5c8 lib/Basic: Emscripten triple support in swift-frontend (#88732)
- **Explanation**:  Adding support for `swift-frontend -print-target-info -target wasm32-unknown-emscripten`, which is required before this triple is supported in `swiftc`.
- **Scope**: Limited to Emscripten Wasm support.
- **Issues**: rdar://175887675
- **Risk**: Very low due to limited scope.
- **Testing**: Added a new case to the lit test suite.
2026-04-30 10:23:59 +01:00
3405691582 732de1f28e Fix module names on OpenBSD for amd64/x86_64.
In #88224 we moved to unversioned triples. However in using the existing
getUnversionedTriple implementation, we lost the call to
getMajorArchitectureName and just used getArchName on the triple.

On OpenBSD, the spelling is amd64. We make a number of transpositions to
use the LLVM spelling x86_64 in a number of places, but the target
triple by default uses amd64. This means that instead of having a
mismatch between versioned and unversioned triple, we have a mismatch
between architecture spellings.

Here, we call getMajorArchitectureName on OpenBSD to use the LLVM
architecture spellings in getUnversionedTriple for the platform. This is
only a problem for amd64/x86_64; there is no problem on aarch64,
which is why this wasn't spotted earlier.
2026-04-09 07:38:02 -04:00
3405691582 9ca2816557 Use unversioned triples on OpenBSD.
Prior to this change, we used versioned triples on this platform.
However, swift-build and the planned future migrations effectively
constrain the platform to abandon this module naming scheme.

Ideally, we would look for a swiftmodule named after the versioned
triple, then fall back to the unversioned triple, or vice versa.
However, this is not straightforward to do, and/or would induce a larger
change. It transpired that it was more straightforward to just convert,
despite reservations and modules generated on earlier versions requiring
recompilation in the future. Because the install base for the platform
is likely few, tackle the work to implement the fallback later and just
get this quickly done first, especially so we can hopefully make the cut
to have this incorporated in 6.3.
2026-03-31 16:58:41 -04:00
Doug Gregor 7be87567fd Merge pull request #88185 from DougGregor/stdin-input-file-as-swift
Consistently classify "-" as a Swift input file
2026-03-30 14:22:42 -07:00
Doug Gregor 6e2eaee27a Consistently classify "-" as a Swift input file
Fixes rdar://171657301
2026-03-30 09:37:35 -07:00
Alexis Laferrière 1af6d6d28e Merge pull request #87353 from xymus/polyglot-ast-gen
ClangImporter: Services to parse Objective-C code and generate a `@objc @implementation` stub
2026-03-27 12:18:56 -07:00
Alexis Laferrière 43654566ae Frontend: Intro emit-polyglot-ast action 2026-03-25 11:36:15 -07:00
Ben Langmuir 768fb73f8b Merge pull request #87862 from benlangmuir/casoptions-adaptation
[cas] Adapt to clang::CASOptions change to remove internal cache of instances
2026-03-19 09:42:20 -07:00
Allan Shortlidge a303829e6e Basic: Add support for #if os(anyAppleOS).
As a complement to `@available(anyAppleOS ...)`, evaluate `#if os(anyAppleOS)`
to true when targeting Apple's operating systems.

Resolves rdar://172747814.
2026-03-17 09:06:50 -07:00
Steven Wu f620d37dda Reapply: [Caching][NFC] Using llvm::cas::CASConfiguration
This no longer causes a regression in number of CAS instances.

Prefer llvm::cas::CASConfiguration where it used to clang::CASOption.

(cherry picked from commit 4f059033bb)
2026-03-13 15:41:36 -07:00
Jonas Devlieghere 33185e5ce6 Merge pull request #87265 from adrian-prantl/170181060
Improve compatibility between swift::version::Version and llvm::Versi…
2026-02-18 09:49:58 -08:00
Adrian Prantl 5a8d603ada Improve compatibility between swift::version::Version and llvm::VersionTuple
llvm::VersionTuple now also supports 5-component versions; this patch removes
the limitation of stripping the last component when converting from a
swift::version::Version to an llvm::VersionTuple. This fixes a bug in LLDB's
Swift version compatibility warning.

rdar://170181060
2026-02-16 11:41:17 -08:00
Saleem Abdulrasool 10efdbd240 Merge pull request #86797 from sundresh/sundresh/windows_trace_events_stats
Ensure trace CSVs include entry and exit for all events on Windows, with microsecond-level timing
2026-02-10 14:25:12 -08:00
Anthony Latsis 2627c91576 Basic: Replace Version::getValidEffectiveVersions with LanguageMode::allSupportedModes 2026-02-10 16:07:00 +00:00
Anthony Latsis abf1ca69b4 Basic: Switch upcoming features to LanguageMode 2026-02-10 16:06:58 +00:00
Anthony Latsis 1900bb70d7 Basic: Introduce a safe, structured representation for language modes 2026-02-10 16:06:51 +00:00
Sameer Sundresh d1a403030a Use ElapsedTime 2026-02-06 18:29:05 -07:00
Ian Anderson 69fa949c01 [Triple] Support the new target triple "os" for firmware
Add support for the new Firmware llvm::Triple::OSType, and make a swift::DarwinPlatformKind to go with it.

rdar://165361368
2026-02-03 13:02:44 -08:00
Sameer Sundresh 0dac0c6baa Updated formatting 2026-02-03 12:37:22 -07:00
Sameer Sundresh 9758795050 Add WallClockMicroseconds, which provides microsecond level precision wall clock measurements.
This complements the existing Time and Live columns which (a) measure process CPU time, not wall clock time and (b) only offer 25 microsecond level precision or worse on Windows.
2026-01-29 15:18:25 -07:00
Sameer Sundresh 0d90561ecf Ensure all events have rows in trace CSV on Windows 2026-01-29 15:12:27 -07:00
Artem Chikin 0a4d352844 De-register temporary buffer 'SourceFile's created during availability attribute argument parsing
Otherwise these source file objects linger in the source manager but they refer to a fully-temporary 'ASTContext' which does not exist after parsing is complete, which means they cannot be used in any way and attempting to do so would lead to a crash.
2025-12-12 10:14:21 -08:00
Egor Zhdan a6b30c4dd0 Merge pull request #85869 from egorzhdan/egorzhdan/remove-interop-compat-version
[cxx-interop] Remove compatibility versions
2025-12-09 15:45:00 +00:00
Egor Zhdan 69be33d3ba [cxx-interop] Remove compatibility versions
This removes the C++ interop compat version mechanism. It was added in mid-2023 and was never used. It complicates the testing story, and makes it harder to reason about the compiler's behavior. It also isn't compatible with explicit module builds.

The flag `-cxx-interoperability-mode` is preserved, so projects that use the flag will continue to build normally.

rdar://165919353
2025-12-05 18:01:09 +00:00
Anthony Latsis 153dd02cd8 Merge pull request #85833 from swiftlang/jepa-main
[NFC] "SwiftVersion" → "LanguageMode" in `DiagnosticEngine::warnUntilSwiftVersion`, etc.
2025-12-05 09:34:30 +00:00
Anthony Latsis 88220a33c3 [NFC] "SwiftVersion" → "LanguageMode" in DiagnosticEngine::warnUntilSwiftVersion, etc. 2025-12-04 15:11:07 +00:00
Anthony Latsis 8572b7e38c Address llvm::StringSwitch deprecations in advance
There's a whole bunch of these, e.g.
- https://github.com/llvm/llvm-project/pull/163405
- https://github.com/llvm/llvm-project/pull/164276
- https://github.com/llvm/llvm-project/pull/165119
- https://github.com/llvm/llvm-project/pull/166016
- https://github.com/llvm/llvm-project/pull/166066
2025-12-02 17:13:17 +00:00
Steven Wu 8e68fab034 Revert "[Caching][NFC] Using llvm::cas::CASConfiguration"
This reverts commit 4f059033bb. The change
is actually not NFC since previously, there is a cache in the
CompilerInvocation that prevents the same CAS from the same CASOptions
from being initialized multiple times, which was relied upon when
running inside sub invocation. When switching to a non-caching simple
CASOption types, it causes every single sub instance will create its own
CAS, and it can consume too many file descriptors and causing errors
during dependency scanning.

rdar://164903080
2025-11-17 12:21:53 -08:00
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