Commit Graph

52 Commits

Author SHA1 Message Date
Alex Hoppen
ef8e4ac0f3 [AST] Remove gyb_syntax_support
We are no longer using these Python files to generate anything in SwiftSyntax. We can just remove them and instead commit the generated `.def` files.
2023-08-01 17:20:14 -07:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
Erik Eckstein
fa2ac84d29 cmake: correctly set NDEBUG for imported headers in SwiftCompilerSources
So that it's consistent with C++ sources

rdar://110363377
2023-06-13 10:26:12 +02:00
Max Desiatov
1769c88fd6 [NFC] SwiftCompilerSources/CMakeLists.txt: fix comment typo (#66235)
`paltforms` -> `platforms`
2023-05-31 21:03:09 +01:00
swift-ci
19b4935fd6 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-17 09:14:24 -08:00
Daniel Rodríguez Troitiño
89fec217fb Fix calls to add_custom_target_command (#63740)
`add_custom_target_command` has a note in its documentation that ask for
all the `COMMAND` arguments to immediately follow the first argument, or
the function will misbehave.

In the two cases below, the `COMMAND` arguments were after the `OUTPUT`
multivalue, and ended by mistake inside the `OUTPUT` parameter. This
kinda works because CMake will interpolate those back, but causes
problems for dependency resolution, marking many targets as dirty. When
one of those targets is dependent by the compiler, this can create
a huge cascade rebuild.

Fix the two cases I found where `add_custom_target_command` was used
incorrectly. This removes cascade rebuilds in my working directory, and
hope it applies to everybody.
2023-02-17 09:09:58 -08:00
Rintaro Ishizaki
d458c8b74a Merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
	include/swift/Sema/ConstraintSystem.h
	include/swift/Syntax/AbsoluteRawSyntax.h
	include/swift/Syntax/Syntax.h
	include/swift/Syntax/SyntaxData.h
	lib/DependencyScan/ModuleDependencyCacheSerialization.cpp
	lib/Syntax/SyntaxFactory.cpp.gyb
	lib/Syntax/SyntaxNodes.cpp.gyb
	tools/SourceKit/lib/SwiftLang/SwiftEditor.cpp
	tools/swift-syntax-test/swift-syntax-test.cpp
2022-11-18 09:37:38 -08:00
Rintaro Ishizaki
2f50d03d77 Remove swiftCompilerModules_SwiftSyntax library
This was used by _InternalSwiftSyntaxParser which was removed some time
ago.
2022-11-17 10:11:26 -08:00
Erik Eckstein
4595185150 cmake: llvm now requires C++17 2022-11-04 20:44:18 +01:00
Alex Hoppen
d6bcfd915a [CMake] Fix issues when running build-tooling-libs
There were three different issues going on here, all of these were triggered by https://github.com/apple/swift/pull/61618 which stared including `AST/AnyFunctionRef.h` from the ASTBridging modulemap

- We did not find the clang include dirs because the unified build that build-tooling-libs is using does not import ClangConfig, setting `CLANG_INCLUDE_DIRS` in `swift_common_unified_build_config` fixed this problem.
- Some of the headers in `swift-ast-generated-headers` import generated headers from clang that might not have been created yet. Making `swift-ast-generated-headers` depend on the clang generated headers fixes this problem. This just lowers the dependency because `swiftAST` depends on `swift-ast-generated-headers`
- If a Swift compiler from Xcode is used, the SwiftShims don’t live next to the compiler but in the SDK. Adding the SDKs lib to the include paths fixes this problem
2022-10-22 12:35:17 +02:00
Egor Zhdan
1cb85e59f4 [SwiftCompilerSources] Add SwiftShims to the include paths
This allows Swift to import C++ headers from `include/swift` that include SwiftShims headers.

Previously that would result in a build error.
2022-09-15 11:36:29 +01:00
Robert Widmann
8cd8c4dd7d Add Missing Dependency Between Bootstrapping Headers and AST Header Generation 2022-09-14 10:02:23 -07:00
Egor Zhdan
e515db9c48 [cxx-interop][SwiftCompilerSources] Include Clang headers
This will allow using Swift headers that include Clang headers from SwiftCompilerSources.

For example, some headers in `swift/Basic` include headers from `clang/Basic`. Currently adding those Swift headers to the modulemap causes a build error.
2022-09-06 14:37:12 +01:00
Eric Miotto
b6878ce752 Link all compatibility libraries when cross compiling and bootstrapping (#60728)
Refactor the logic so to have a single target to reference the
compatibility libraries for the host, and use that when needed.

The main driver for this change is supporting the cross-compilation of
x86-64 on Apple Silicon.

Supports rdar://90307965
2022-08-31 02:18:19 -07:00
Saleem Abdulrasool
7c80c323b3 build: remove sed usage in build system
`sed` is not available on all platforms, we cannot depend on that to
rewrite the module map.  As a temporary stop gap, write the file
statically and generate it at build time.  Eventually, this could be
replaced with a tool or CMake based text processing to generate the
content.  This repairs part of the build for Windows with bootstrapping.
2022-08-12 08:53:42 -07:00
Evan Wilde
7a4bcffb2f Revert "Merge pull request #60453 from etcwilde/ewilde/add-missing-bootstrap-compat-dependencies"
This reverts commit 2ea1c81f34, reversing
changes made to 329d5846bc.
2022-08-09 07:15:59 -07:00
Evan Wilde
bb2fe7e4ec Add missing compat libraries to bootstrapping
The bootstrapping stages were missing dependencies on the Concurrency
and Swift 5.6 backdeployment compatibility libraries resulting in
failing builds.
2022-08-08 17:08:40 -07:00
Alex Hoppen
c096c7e975 [CMake] Use CMAKE_CURRENT_SOURCE_DIR as base for includes in SwiftCompilerSources
When using a unified LLVM + Swift build (using `LLVM_EXTERNAL_PROJECTS=swift`),
`CMAKE_SOURCE_DIR` is `llvm-project/llvm`, and appending `include/swift` to that directory doesn’t result in the directory that contains Swift’s header files.

Instead, look up the header files relative to `CMAKE_CURRENT_SOURCE_DIR`.
2022-08-02 22:08:11 +02:00
Erik Eckstein
e796fc8680 cmake: add a hack to get correct dependencies from C++ header files -> Swift compiler sources 2022-07-29 10:55:13 +02:00
Alex Hoppen
259c1b7148 [CMake] Use CMAKE_CURRENT_BINARY_DIR as base for generated C header for SwiftCompilerSources
When using a unified LLVM + Swift build (using `LLVM_EXTERNAL_PROJECTS=swift`), swift is installed into `build_dir/tools/swift`. Thus, we also need to find the generated headers inside the `tools/swift/include` directory and not at the top-level `build_dir/include` directory.
2022-07-18 14:24:38 +02:00
Egor Zhdan
71706d8bd2 Merge pull request #59102 from apple/egorzhdan/libswift-no-backport
[SwiftCompilerSources][build] Fix build with `SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT=NO`
2022-07-05 11:47:14 +01:00
Egor Zhdan
b8e2f2eacc Merge pull request #58699 from apple/egorzhdan/libswift-sourceloc
[cxx-interop][SwiftCompilerSources] Use `swift::SourceLoc` instead of `BridgedSourceLoc`
2022-06-22 10:54:59 +01:00
Zoe Carver
59a9e282cd Merge pull request #59510 from zoecarver/remove-enable-interop-pt-2 2022-06-16 21:40:21 -07:00
zoecarver
57f721a2f1 [cxx-interop] Remove "enable-cxx-interop" flag again. 2022-06-16 18:02:24 -07:00
Richard Wei
3396ede366 Merge pull request #42611 from rxwei/string-processing-default
Enable string processing by default.
2022-06-13 11:16:05 -07:00
Richard Wei
94e8f5393e Enable string processing by default.
Make frontend flag `-enable-experimental-string-processing` default to true.
2022-06-12 20:25:16 -07:00
Egor Zhdan
5768aebeee [cxx-interop][SwiftCompilerSources] Add LLVM headers to the include paths
This allows the Swift compiler to find headers like `llvm/Support/Compiler.h` that are used by Swift headers.
2022-06-11 00:13:39 +01:00
Egor Zhdan
aeec2eb2b4 Merge pull request #59316 from apple/egorzhdan/hosttools-require-recent-swift
[SwiftCompilerSources] Require very recent Swift compiler in `HOSTTOOLS` mode
2022-06-10 20:45:41 +01:00
Rintaro Ishizaki
e1412a0978 Merge pull request #59209 from rintaro/syntaxparser-libswift
[SwiftCompilerModules] Link lib_InternalSwiftSyntaxParser to libswift
2022-06-08 15:36:21 -07:00
Egor Zhdan
a8ae273a52 [SwiftCompilerSources] Require very recent Swift compiler in HOSTTOOLS mode
To use new C++ interop features in SwiftCompilerSources, we need a very recent Swift compiler when building with host tools.

This does not affect non-HOSTTOOLS builds.
2022-06-08 17:08:00 +01:00
Rintaro Ishizaki
9f4ce612a2 [SwiftCompilerModules] Link lib_InternalSwiftSyntaxParser to libswift
To use _RegexParser from SwiftSyntax.

* Create 'libswiftCompilerModules_SwiftSyntax.a' which is a subset of
  'libswiftCompilerModules.a'
* Link 'lib_InternalSwiftSyntaxParser' to
  'libswiftCompilerModules_SwiftSyntax.a'
* Factor out swift runtime linking logic in CMake so that dynamic
  libraries can link to Swift runtime, in addition to executables
* Link 'lib_InternalSwiftSyntaxParser' to swift runtime
2022-06-02 12:23:03 -07:00
Egor Zhdan
2b3980b3e2 [SwiftCompilerSources][build] Require recent Swift compiler in HOSTTOOLS mode
Some code in SwiftCompilerSources, especially the parts that use C++ interop, triggers bugs in older versions of the Swift compiler. To make sure that `HOSTTOOLS` builds don't produce obscure compiler errors or crashes, let's require a relatively new Swift compiler for `HOSTTOOLS` build.
2022-05-31 13:35:58 +01:00
Egor Zhdan
b07a0abba0 [SwiftCompilerSources][build] Fix build with SWIFT_STDLIB_SUPPORT_BACK_DEPLOYMENT=NO
This allows building SwiftCompilerSources with stdlib compatibility disabled.

Fixes errors like this:
```
[699/716] Building swift module Basic
FAILED: bootstrapping1/SwiftCompilerSources/Basic.o /Users/egorzh/Builds.noindex/swift/swift-release/bootstrapping1/SwiftCompilerSources/Basic.o
cd /Volumes/Projects/swift/swift/SwiftCompilerSources && /Users/egorzh/Builds.noindex/swift/swift-release/bootstrapping0/bin/swiftc -c -o /Users/egorzh/Builds.noindex/swift/swift-release/bootstrapping1/SwiftCompilerSources/Basic.o -sdk /Applications/Xcodes/XcodeSummit.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk -target x86_64-apple-macosx10.9 -module-name Basic -emit-module -emit-module-path /Users/egorzh/Builds.noindex/swift/swift-release/bootstrapping1/SwiftCompilerSources/Basic.swiftmodule -parse-as-library /Volumes/Projects/swift/swift/SwiftCompilerSources/Sources/Basic/SourceLoc.swift /Volumes/Projects/swift/swift/SwiftCompilerSources/Sources/Basic/Utils.swift -wmo -Xfrontend -validate-tbd-against-ir=none -Xfrontend -enable-cxx-interop -Xcc -UIBOutlet -Xcc -UIBAction -Xcc -UIBInspectable -O -cross-module-optimization -Xcc -I -Xcc /Volumes/Projects/swift/swift/include -Xcc -I -Xcc /Users/egorzh/Builds.noindex/swift/swift-release/include -I /Users/egorzh/Builds.noindex/swift/swift-release/bootstrapping1/SwiftCompilerSources
<unknown>:0: error: IR generation failure: Cannot read legacy layout file at '/Users/egorzh/Builds.noindex/swift/swift-release/bootstrapping0/lib/swift/macosx/layouts-x86_64.yaml'
ninja: build stopped: subcommand failed.
```
2022-05-26 14:52:54 +01:00
John Holdsworth
5381466580 Small refinements? 2022-05-19 16:41:46 +02:00
John Holdsworth
277699bd55 Make force_lib.c --xcode specific. 2022-05-19 07:54:11 +02:00
John Holdsworth
3dc815b0a7 Potential fix for --xcode build on M1. 2022-05-18 13:05:16 +02:00
Rintaro Ishizaki
a9ac0130c0 [SwiftCompilerSources] Make Package.swift static
`Package.swift` in the build directory and symlinking Sources directory
wasn't great for source control and break points. Since C modules doesn't
need the generated headers at this point, make `Package.swift` static
again with a symlink to the string processing source directory.
2022-05-09 10:00:00 -07:00
Rintaro Ishizaki
dad5ae286e Merge pull request #58667 from rintaro/swiftcompiler-package-directory
[SwiftCompilerModules] Configured Package.swift use its own directory
2022-05-05 09:39:32 -07:00
Egor Zhdan
d4ac213bc8 [cxx-interop][SwiftCompilerSources] Fix build error with Xcode 12 2022-05-05 12:55:04 +01:00
Rintaro Ishizaki
537bd07487 [SwiftCompilerModules] Configured Package.swift use its own directory
Previously, it used ${CMAKE_CURRENT_BINARY_DIR} as the package
directory. However, since that directory contains all build artifacts so
opening it in Xcode shows those unnecessary files.

Intead of using ${CMAKE_CURRENT_BINARY_DIR}, create its own directory in
the root build directory.
2022-05-04 11:55:22 -07:00
Egor Zhdan
67a28c78d5 [cxx-interop][SwiftCompilerSources] Enable libstdc++ on platforms that use it
Since libstdc++ doesn't come with a Clang modulemap, Swift provides its own modulemap for libstdc++. This change makes the modulemap available while building SwiftCompilerSources.
2022-05-03 19:48:14 +01:00
Josh Soref
1b0aa6d7f1 Spelling swiftcompilersources (#42617)
* spelling: diagnose

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: diagnostic

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intentionally

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: optimization

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: target

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unbalanced

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-25 09:01:23 -07:00
Rintaro Ishizaki
d292a95296 [SwiftCompiler/Regex] Use bridged DiagnosticEngine for error reporting
This fixes:
 * An issue where the diagnostic messages were leaked
 * Diagnose at correct position inside the regex literal

To do this:
 * Introduce 'Parse' SwiftCompiler module that is a bridging layer
   between '_CompilerRegexParser' and C++ libParse
 * Move libswiftParseRegexLiteral and libswiftLexRegexLiteral to 'Parse'

Also this change makes 'SwiftCompilerSources/Package.swift' be configured
by CMake so it can actually be built with 'swift-build'.

rdar://92187284
2022-04-22 22:53:46 -07:00
Erik Eckstein
9906666801 Fix the 'hosttools' bootstrapping build mode
After the rename of the `enable-cxx-interop` option to `enable-experimental-cxx-interop` it was no longer possible to build with installed tools.
This change re-introduces the `enable-cxx-interop` option for backward compatibility
2022-04-09 10:56:06 +02:00
zoecarver
839839f924 [cxx-interop] Rename enable-cxx-interop -> enable-experimental-cxx-interop.
Also removes the driver flag, this will now also always be guarded on `-Xfrontend`.
2022-04-07 19:15:25 -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
Erik Eckstein
0d9b364e05 cmake: Fix a dependency problem when compiling swift modules
There was only an ordering dependency between modules but not a file dependency.
This caused missing re-compiles of depending modules in incremental builds.
2022-01-19 17:56:45 +01:00
Casper Jeukendrup
b3ea191817 Support bootstrapping with Xcode
Xcode does not compile libraries that contain only object files; it just skips them completely, not even mentioning them in the logs. Therefore, it fails to create the static library that would contain all SwiftCompilerSources object files. As a workaround, we add a dummy script phase to the target, to force that it gets compiled.
2022-01-14 02:57:04 +01:00
Erik Eckstein
feaeca2039 cmake: fix a cmake error with the Xcode generator
rdar://86285942
2021-12-22 11:31:52 +01:00
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