Commit Graph

316 Commits

Author SHA1 Message Date
Saleem Abdulrasool
9c85fbc8da AST,DependencyScan,IRGen,Serialization,Tooling: track library style (#78777)
Track if the dependency is static or dynamic. This is in preparation for
helping rename the static library to differentiate it from import
libraries.
2025-02-06 13:22:56 -08:00
Tim Kientzle
cf4701ce5d [Gardening] Include Runtime/Config.h directly
This file was relying on Runtime/Config.h for SWIFT_CC() but
didn't include it directly.

I found this when some local experiments went awry in confusing
ways.
2025-01-15 15:36:56 -08:00
swift-ci
2bf8a521eb Merge remote-tracking branch 'origin/main' into rebranch 2024-08-07 09:53:42 -07:00
Ben Langmuir
1f00ffe42c Revert "[immediate] Load Foundation early enough for bridging" 2024-08-06 16:10:42 -07:00
swift-ci
ef054444fd Merge remote-tracking branch 'origin/main' into rebranch 2024-08-02 01:03:44 -07:00
Ben Langmuir
8a824d70a0 [immediate] Load Foundation early enough for bridging
Foundation needs to be loaded early in the process for Swift's runtime
to properly initialize bridging support; otherwise it may cause issues
like unrecognized selectors. When scripting, load Foundation early in
performFrontend before any swift code runs.

rdar://129528115
2024-08-01 15:02:13 -07:00
Ben Langmuir
37ced22047 [immediate] Leak SwiftJIT to avoid unmapping metadata memory
It's not safe to unmap memory that has been registered with the
swift/objc runtimes. For now, avoid this by leaking the JIT object. In
the future we should be able to detach the JIT from the allocated
memory, or be more fine-grained about which memory needs to be preserved
and which can be freed.

rdar://128432487
2024-07-29 16:22:24 -07:00
Xi Ge
736ccef626 Merge remote-tracking branch 'apple/main' into rebranch 2024-06-20 15:16:55 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Ben Barham
0f52071c22 Fix up various references to renamed/moved enums
A bunch of enums were moved to enum classes and slightly renamed. Fix up
their references.
2024-04-08 08:58:58 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Slava Pestov
06b1aee360 Evaluator: Cache circular evaluation to avoid redundant diagnostics
Previously, if a request R evaluated itself N times, we would emit N
"circular reference" diagnostics. These add no value, so instead let's
cache the user-provided default value on the first circular evaluation.

This changes things slightly so that instead of returning an
llvm::Expected<Request::OutputType>, various evaluator methods take
a callback which can produce the default value.

The existing evaluateOrDefault() interface is unchanged, and a new
evaluateOrFatal() entry point replaces
llvm::cantFail(ctx.evaluator(...)).

Direct callers of the evaluator's operator() were updated to pass in
the callback. The benefit of the callback over evaluateOrDefault() is
that if the default value is expensive to constuct, like a dummy
generic signature, we will only construct it in the case where a
cycle actually happened, otherwise we just delete the callback.

(cherry picked from commit b8fcf1c709efa6cd28e1217bd0efe876f7c0d2b7)
2024-02-09 16:02:24 -08:00
Ellie Shin
72a7760027 Support package SIL linkage.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.

Resolves rdar://121409846
2024-02-06 01:23:14 -08:00
Lang Hames
06384be243 For scripts, use DYLD_FRAMEWORK/LIBRARY_PATH to find frameworks / runtimes.
Add DYLD_FRAMEWORK_PATH=/System/Library/Frameworks to the environment when
constructing swift-frontend invocations for the interpreter so that dlopen can
find autolinked frameworks. This is intended to fix
https://github.com/apple/swift/issues/68785.

As a follow-up: don't expand runtime paths to find the path to the runtime in
libImmediate, but instead hard-code "/usr/lib/swift/libswiftCore.dylib" and
allow any overrides to be found via DYLD_LIBRARY_PATH (this ensures that dyld
treats whichever libswiftCore.dylib is found as override for the one in the
shared cache, which doesn't happen if dlopen is passed a non-standard path).
2024-01-18 21:41:48 -08:00
Zak Kent
2abca625d7 Merge branch 'main' into update-immediate 2023-08-18 16:07:14 -07:00
Zak Kent
6aafeec181 [Immediate] [SILGen] Implement on-demand compilation of globals 2023-08-17 11:03:11 -07:00
Zak Kent
e276c79939 [SIL] [Immediate] Promote linkage of SILFunctions defining requested symbols
Promotes the linkage of `SILFunction`s defining requested symbols,
ensuring they are emitted during IRGen.
2023-08-17 10:11:29 -07:00
Zak Kent
f82fa91de9 [Immediate] Promote linkage of lazily discovered internal symbols 2023-08-17 09:56:40 -07:00
Zak Kent
a6eb4b44c7 [TBD] Refactored SymbolSourceMap to be a typedef 2023-08-17 09:55:49 -07:00
Zak Kent
c0a16d06ed [Immediate] Drop back to RuntimeDyld on Linux 2023-08-14 13:28:23 -07:00
Zak Kent
4616e03f61 [Immediate] Only add renamer plugin on macOS 2023-08-14 13:28:23 -07:00
Zak Kent
514fc1e55f [Immediate] Explicitly move error when returning 2023-08-14 13:28:23 -07:00
Zak Kent
03b539d06e [TBD] [Immediate] Revert implementation of SymbolSourceMap 2023-08-14 13:28:23 -07:00
Zak Kent
5181270a87 [Immediate] Remove unused functions in SwiftJIT 2023-08-14 13:28:22 -07:00
Zak Kent
0b618fe9bf [Immediate] Replace uses of SILMaterializationUnit with EagerSwiftMaterializationUnit 2023-08-14 13:28:22 -07:00
Zak Kent
473a18d2ce [Immediate] Implement EagerSwiftMaterializationUnit 2023-08-14 13:28:22 -07:00
Zak Kent
6abc5c5d39 [Immediate] Re-introduce lazy reexports 2023-08-14 13:28:22 -07:00
Zak Kent
48c36c956d [Immediate] Move SwiftMaterializationUnit to public library 2023-08-14 13:28:22 -07:00
Zak Kent
148cd6acc4 [Immediate] [Sema] Implemented Lazy Type Checking
Implements lazy type checking in Swift Immediate mode,
allowing functions to be type-checked as they are
executed.
2023-08-14 13:28:22 -07:00
Zak Kent
17fedabb5e [Immediate] Implemented SwiftMaterializationUnit
Implemented SwiftMaterializationUnit, supporting
lazy compilation of individual Swift functions.
2023-08-14 13:28:22 -07:00
Zak Kent
94530c7584 [NFC] [Immediate] Lazily materialize global values 2023-08-14 13:28:22 -07:00
Evan Wilde
e51988ecdf Rebranch: Removing extra null
allocateCString includes the null end character, so we ended up with
two, in the symbol name. This made them not match, causing failures
while attempting to run the JIT'd program.

Remove one from the symbol name length to account for the null
character.
2023-08-07 23:29:31 -07:00
Evan Wilde
36f1e68cdd [Next][JIT] Fix JIT API in Immediate
Fixing some of the JITing API differences between `next` and
`stable/20221013`.
2023-07-17 18:18:10 -07:00
Evan Wilde
26a974e772 [NFC] Headers headers headers!
Including headers that were being transitively included from LLVM
before. Also pointing them at the new locations for some of them.
2023-07-17 10:55:55 -07:00
Zak Kent
c2c41f8afd [Immediate] Only lazily compile on Darwin
Fallback to eager compilation on Linux
and Windows due to issues with older
versions of JITLink on those platforms.
2023-07-13 10:30:38 -07:00
Zak Kent
e96f1d8d59 [Immediate] Implement whole-module lazy compilation
Establishes the framework for implementing function
at-a-time lazy compilation by adding lazy re-exports.
2023-07-11 15:35:51 -07:00
Zak Kent
a12a6f13ad [Immediate] Refactor Immediate Mode to use Materialization Unit
Refactor Immediate Mode to use the Materialization Unit API,
materializing the entire `SILModule` corresponding to the script
when the `main` symbol is looked up.
2023-07-07 12:23:37 -07:00
Ben Langmuir
e759007256 [Immediate] Workaround for loading merged frameworks in immediate mode
Some frameworks that previously had a separate swift overlay have been
merged in macOS 14. This is causing symbols to not resolve if using the
new SDK but running on an older OS in immediate mode. Ideally we would
handle this automatically in JITLink as is done by the system linker,
but in the meantime add a workaround to load the correct libraries
manually.

rdar://110371405
2023-06-09 16:37:57 -07:00
Steven Wu
09b8af86fb Virtualize swift compiler outputs (#63206)
Using a virutal output backend to capture all the outputs from
swift-frontend invocation. This allows redirecting and/or mirroring
compiler outputs to multiple location using different OutputBackend.

As an example usage for the virtual outputs, teach swift compiler to
check its output determinism by running the compiler invocation
twice and compare the hash of all its outputs.

Virtual output will be used to enable caching in the future.
2023-04-05 23:34:37 +08:00
Erik Eckstein
67a98e9a37 JIT: getAddress -> getValue 2022-11-04 20:44:19 +01:00
Dario Rexin
317a6ab2d4 [Immediate]: Workaround for loading Foundation in immediate mode (#59730)
* [Immediate]: Workaround for loading Foundation in immediate mode

rdar://94645534

* Update Immediate.cpp

* Update Immediate.cpp
2022-06-28 10:03:02 -07:00
swift-ci
da1ab99326 Merge remote-tracking branch 'origin/main' into rebranch 2021-12-22 05:56:01 -08:00
Erik Eckstein
3540c01125 rename initializeLibSwift -> InitializeSwiftModules
and some updates in comments.
2021-12-22 11:31:52 +01:00
swift-ci
41ef4e8c9d Merge remote-tracking branch 'origin/main' into rebranch 2021-12-20 09:15:08 -08:00
Alex Hoppen
fe7878ecce [Serialization] Improve module loading performance
When looking for a Swift module on disk, we were scanning all module search paths if they contain the module we are searching for. In a setup where each module is contained in its own framework search path, this scaled quadratically with the number of modules being imported. E.g. a setup with 100 modules being imported form 100 module search paths could cause on the order of 10,000 checks of `FileSystem::exists`. While these checks are fairly fast (~10µs), they add up to ~100ms.

To improve this, perform a first scan of all module search paths and list the files they contain. From this, create a lookup map that maps filenames to the search paths they can be found in. E.g. for
```
searchPath1/
  Module1.framework

searchPath2/
  Module1.framework
  Module2.swiftmodule
```
we create the following lookup table
```
Module1.framework -> [searchPath1, searchPath2]
Module2.swiftmodule -> [searchPath2]
```
2021-12-14 12:44:13 +01:00
Ben Barham
5343c72d10 [rebranch] Fix missing includes 2021-11-13 17:04:29 +10:00
Evan Wilde
a5f11c4851 Fix the main->next merge conflicts
This cleans up all of the merge conflicts from main into next after the
rebranch merge.
2021-10-15 15:57:55 -07: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
Arnold Schwaighofer
f958804cdc OrcRPCTargetProcessControl.h -> OrcRPCExecutorProcessControl.h 2021-08-05 12:15:23 -07:00
Evan Wilde
26af94ec2b Fix ExecutionEngine include
LLVM Commit 662c55442f17c changed the name of the header file, causing
some breakage.
2021-07-02 16:45:47 -07:00