Commit Graph

127 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
55bd906906 [Frontend] Add -print-supported-features option
This is a replacement for `-emit-supported-features` that prints
all of the upcoming/experimental features supported by the compiler
with some additional meta information in JSON format to stdout.
2025-04-16 16:34:47 -07:00
Anthony Latsis
0210872916 [NFC] Basic: Extract feature API definitions into their own file 2025-02-27 20:45:07 +00:00
Saleem Abdulrasool
a04c75a43a Basic: query the target pointer width from clang
Use the `clang::TargetInfo` to query the target pointer size for the
given triple. This is meant to enable us to properly determine
`CMAKE_SIZEOF_VOID_P`.
2025-02-10 09:20:02 -08:00
Alex Hoppen
40b91aa97a Share logic to load dynamic libraries between SourceKit plugins and macro plugins 2025-01-03 16:23:16 +01:00
Tim Kientzle
5b49a04ddc New assertions support
This adds three new assertion macros:
* `ASSERT` - always compiled in, always checked
* `CONDITIONAL_ASSERT` - always compiled in, checked whenever the `-compiler-assertions` flag is provided
* `DEBUG_ASSERT` - only compiled into debug builds, always checked when compiled in  (functionally the same as Standard C `assert`)

The new `-compiler-assertions` flag is recognized by both `swift-frontend` and
`swiftc`.

The goal is to eventually replace every use of `assert` in the compiler with one of the above:
* Most assertions will use `ASSERT` (most assertions should always be present and checked, even in release builds)
* Expensive assertions can use `CONDITIONAL_ASSERT` to be suppressed by default
* A few very expensive and/or brittle assertions can use `DEBUG_ASSERT` to be compiled out of release builds

This should:
* Improve quality by catching errors earlier,
* Accelerate compiler triage and debugging by providing more accurate crash dumps by default, and
* Allow compiler engineers and end users alike to add `-compiler-assertions` to get more accurate failure diagnostics with any compiler
2024-05-16 11:38:00 -07:00
Nate Chandler
600164257a [NFC] Moved SmallBitVector dumping to Basic.
Moved out of MemoryLocations.h and merged the implementations of <<,
keeping the version from MemoryLocations with its brackets and commas
available via a flag but defaulting the implementation previously in the
header.
2024-02-19 11:41:38 -08:00
Steven Wu
3986937e03 [Caching][NFC] Restructure CASOption in swift. NFC
Clean up how CASOptions are kept and passed inside swift to make the
code more readable. Also avoid a copy of CAS configuration in
ClangImporter.
2024-02-11 14:08:09 -08:00
Hamish Knight
6afde8a6d2 Remove CBasicBridging and CASTBridging
Merge with BasicBridging and ASTBridging
respectively. The changes here should be pretty
uncontroversial, I tried to keep it to just moving
code about.
2023-10-30 23:49:56 +00:00
Evan Wilde
41d59b215a Update Triple.h location
Triple moved from ADT to TargetParser. Updating includes to reflect
that.
2023-07-17 10:53:42 -07:00
Xi Ge
ba31c97d4f Basics: add a stub for centralized configurations for block list 2023-04-05 11:52:41 -07:00
Saleem Abdulrasool
08608390f0 cmake: extract version string and add PrintVersion.cmake
Add a helper to allow us to programatically extract the Swift version
string during the build. This is particularly useful for injection into
the packaging stages.

Co-authored-by: Evan Wilde <etceterawilde@gmail.com>
2023-03-27 11:53:36 -07:00
Rintaro Ishizaki
0e31393024 [Macros] Add executable plugin support
Executable compiler plugins are programs invoked by the host compiler
and communicate with the host with IPC via standard IO (stdin/stdout.)
Each message is serialized in JSON, prefixed with a header which is a
64bit little-endian integer indicating the size of the message.

* Basic/ExecuteWithPipe: External program invocation. Lik
  llvm::sys::ExecuteNoWait() but establishing pipes to the child's
  stdin/stdout
* Basic/Sandbox: Sandboxed execution helper. Create command line
  arguments to be executed in sandbox environment (similar to SwiftPM's
  pluging sandbox)
* AST/PluginRepository: ASTContext independent plugin manager
* ASTGen/PluginHost: Communication with the plugin. Messages are
  serialized by ASTGen/LLVMJSON

rdar://101508815
2023-02-22 10:22:14 -08:00
Rintaro Ishizaki
66aba1bc67 [ASTGen] Add Encoder/Decoder implementation backed by llvm::json::Value
Preparation for a future use.
2023-02-15 11:55:16 -08:00
Robert Widmann
a71b970b01 Revert "Add link between swiftBasic and swiftAST"
This reverts commit 901081359b.
2022-09-09 00:21:57 -07:00
Evan Wilde
901081359b Add link between swiftBasic and swiftAST
swiftBasic uses `InFlightDiagnostic::flush`, which is defined in
swiftAST. The build graph did not contain that link edge, so it failed
to link on Windows. No idea how it's working on macOS.
2022-09-08 10:06:57 -07:00
Rintaro Ishizaki
7486cd1c21 [SwiftCompiler] Move common bridging facilities to 'Basic'
A preparation for AST/DiagnosticEngine bridging
2022-02-20 22:06:39 -08:00
Artem Chikin
40a1b321f5 Add libSwiftScan entry-point to query target info.
This provides the library with functionality to answer `-print-target-info` queries in place of calls to `swift-frontend`.
2021-11-12 11:01:45 -08:00
Ben Barham
c54c9c7079 [Gardening] Extract basic source info structs from RawComment.h 2021-04-14 10:05:27 +10:00
Robert Widmann
73ac8d3531 Replace llvm::MD5 with StableHasher 2021-01-21 17:19:38 -08:00
Slava Pestov
5585cac9dd AST: Remove AnyValue type eraser now that it's no longer needed
I'm keeping AnyValue.h around, since it has some useful overloads of
hash_value() and simple_display() that don't have a good home at this
time.
2021-01-08 23:17:12 -05:00
Artem Chikin
b827875c5e Sink the parseable-output library into Basic from Driver 2020-12-11 16:01:03 -08:00
Robert Widmann
8e5d64fa55 Add a Fingerprint Currency Type
A fingerprint is a stable hash of a particular piece of compiler data. This formalizes the stable notion of identity that the dependency trackers use for type body fingerprints in iterable decl contexts and the file-level interface hash
2020-11-18 12:20:14 -08:00
Marcel Hlopko
3e6199b0a9 Add a switch to not include git commit hash in the built artifacts (#32998)
This PR adds a SWIFT_APPEND_VC_REV Cmake option (in symmetry with LLVM's LLVM_APPEND_VC_REV).

When enabled, lib/Basic/SwiftRevision.inc header contains git commit hash and repository information, e.g.

#define SWIFT_REVISION "ed4cef9b839d4a87618758d8b8705ab66b61917f"
#define SWIFT_REPOSITORY "https://github.com/scentini/swift.git"

This is useful for keeping track of the VCS state that produced a binary. But for local development builds, this information is often ignored and since this file is invalidated by every git commit or git checkout command and it leads to long rebuilds, it's useful to have a switch to disable this behavior. When SWIFT_APPEND_VC_REV is disabled, lib/Basic/SwiftRevision.inc contains:

#undef SWIFT_REVISION
#undef SWIFT_REPOSITORY
2020-07-22 19:40:42 +02:00
Robert Widmann
638977454b Remove SharedTimer Infrastructure
Teach the UnifiedStatsReporter to directly construct
llvm::NamedRegionTimer for itself.
2020-07-16 17:35:50 -07:00
David Zarzycki
aefeab859e [Basic] Revise version printing
Now that we use the LLVM mono-repo, we don't need to worry about clang's
version number. Also, git has the ability to estimate the safe number of
digits a hash can be truncated to and now git estimates that large
projects like LLVM and Linux "require" 12 digits for safe commit hash
abbreviation. Let's stay a little ahead of the curve and statically
truncate to 15.
2020-06-16 05:37:30 -04:00
Saleem Abdulrasool
e6f2e6257f build: de-GYB_SOURCES the host tools
Use a newly introduced `swift_gyb_target_sources` to gyb and use the
generated sources when building.  Let CMake figure out when to run the
command, let it invoke the command properly, and indicate that the
sources being added to the target are generated.
2020-04-19 10:24:40 -07:00
Robert Widmann
1f2346d381 [NFC] Drastically Reduce The Scope of the Global Context
Delete all of the formalism and infrastructure around maintaining our own copy of the global context. The final frontier is the Builtins, which need to lookup intrinsics in a given scratch context and convert them into the appropriate Swift annotations and types. As these utilities have wormed their way through the compiler, I have decided to leave this alone for now.
2020-04-17 14:02:45 -07:00
Tony Allevato
5284cb6f99 Add dependencies where targets depend on inclusions from unspecified targets.
A follow-up PR adds a flag to control an inline namespace that allows
symbols in libDemangling to be distinguished between the runtime and
the compiler. These dependencies ensure that the flag is plumbed
through for inclusions of Demangling headers that aren't already
covered by existing `target_link_libraries`.
2020-03-31 09:19:41 -07:00
Saleem Abdulrasool
ab5c682683 Revert "Revert "build: simplify version tracking logic""
This reverts commit be37141b0f.  Add a
small fix in the dereferencing.
2020-01-31 16:20:11 -08:00
Mishal Shah
be37141b0f Revert "build: simplify version tracking logic" 2020-01-29 23:56:09 -08:00
Saleem Abdulrasool
b5c02ee9e8 build: simplify version tracking logic 2020-01-07 08:58:15 -08:00
Kita, Maksim
c70bd2b2c9 SR-11889: Located added dump methods 2019-12-20 17:19:00 +03:00
Karoy Lorentey
d8aa67bb90 Merge branch 'master' into master-next
# Conflicts:
#	utils/build-script-impl
2019-05-29 13:09:01 -07:00
Argyrios Kyrtzidis
df721bd67f [CMake] Fix linker issue when doing a parser-lib only build 2019-05-29 11:28:25 -07:00
swift-ci
67cf8799ed Merge remote-tracking branch 'origin/master' into master-next 2019-05-06 11:49:16 -07:00
Saleem Abdulrasool
218b37e1bb build: rename LLVM_COMPONENT_DEPENDS
This is not a target dependency but a target link.  Name the parameter
to be less misleading.  This also makes the name identical to the LLVM
parameter.
2019-05-04 19:58:28 -07:00
swift-ci
efdafdce91 Merge remote-tracking branch 'origin/master' into master-next 2019-04-16 14:29:43 -07:00
Alex Langford
d8d93fd622 [CMake] Fix UUID include dir logic 2019-04-15 14:40:15 -07:00
swift-ci
06a1281bb8 Merge remote-tracking branch 'origin/master' into master-next 2019-04-08 11:09:56 -07:00
Michael Gottesman
91dbbc3088 Merge pull request #23204 from compnerd/silence-in-the-library
Remove custom handling in add_swift_host_library
2019-04-08 10:49:42 -07:00
swift-ci
d45e63b98e Merge remote-tracking branch 'origin/master' into master-next 2019-03-20 13:30:07 -07:00
Saleem Abdulrasool
8ed5c1a4bc build: introduce and switch to GYB_SOURCES
This avoids us having to pattern match every source file which should
help speed up the CMake generation.  A secondary optimization is
possible with CMake 3.14 which has the ability to remove the last
extension component without having to resort to regular expressions.  It
also helps easily identify the GYB'ed sources.
2019-03-11 13:48:54 -07:00
Saleem Abdulrasool
b0005e9f87 build: remove C_COMPILE_FLAGS from add_swift_host_library
Use the appropriate CMake mechanism for controlling flags for building
the code.
2019-03-10 15:38:55 -07:00
swift-ci
37da95021f Merge remote-tracking branch 'origin/master' into master-next 2019-02-24 10:29:22 -08:00
Argyrios Kyrtzidis
04992a58d1 [CMake] Provide a way to build the minimum things necessary for the syntax parser library
These changes allow to optionally perform a very fast build that is targeted to only produce the syntax parser library.
Part of addressing rdar://48153331
2019-02-23 11:31:31 -08:00
swift-ci
a61b1f049b Merge remote-tracking branch 'origin/master' into master-next 2019-02-23 11:09:25 -08:00
Saleem Abdulrasool
9934532e07 cmake: switch host libraries to use target_link_libraries
This is a follow up to the discussion on #22740 to switch the host
libraries to use the `target_link_libraries` rather than the
`LINK_LIBRARIES` special handling.  This allows the dependency to be
properly tracked by CMake and allows us to use the more modern syntax.
2019-02-22 15:28:07 -08:00
Saleem Abdulrasool
5daeb562d7 Basic: adjust for SVN r353268
The versioning script has changed for the preparation for the monorepo
adjustment and to generalise it further.  Update our usage.
2019-02-06 15:26:07 -08:00
Michael Gottesman
a761d7c0ba Revert "Revert "Revert "[Build System: CMake] make add_swift_library a wrapper to add_llvm_library"""
This reverts commit 121f5b64be.

Sorry to revert this again. This commit makes some pretty big changes. After
messing with the merge-conflict created by this internally, I did not feel
comfortable landing this now. I talked with Saleem and he agreed with me that
this was the right thing to do.
2018-11-06 13:24:00 -08:00