Commit Graph

1631 Commits

Author SHA1 Message Date
swift-ci
aae06b0943 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-31 22:54:14 -07:00
Saleem Abdulrasool
fe42740f3e build: clean up dependency tracking for portability
`:` is not a valid file system character but is used to namespace the
imported targets.  This is then used to create the stamp file.  Sanitize
the name prior to use as a stamp file name.
2023-08-31 18:08:08 -07:00
Finagolfin
010759da20 [CMake] Tweak path separators in new Swift runpaths 2023-08-31 19:26:32 +05:30
swift-ci
97970caeac Merge remote-tracking branch 'origin/main' into rebranch 2023-08-30 20:55:33 -07:00
Rintaro Ishizaki
8049922861 [CMake] Update host platform check for macro support
"Support Macros in Linux" patches was inconsistent with checking
platforms. Some only checked 'LINUX' but some matches
'LINUX|ANDROID|OPENBSD|FREEBSD'. Although I don't have tested other
platoforms than Linux at all, there's no reason to limit it to Linux.
So use the consistent check to match 'LINUX|ANDROID|OPENBSD|FREEBSD'
2023-08-30 13:52:37 -07:00
swift-ci
484684f0dd Merge remote-tracking branch 'origin/main' into rebranch 2023-08-29 17:55:14 -07:00
Rintaro Ishizaki
f64506976a [CMake] Use RPATH_CHANGE instead RPATH_SET
RPATH_SET is not available until cmake 3.21.0. Use RPATH_CHANGE instead.
2023-08-29 01:12:02 +00:00
Rintaro Ishizaki
dc6877334f [CMake] Stop some exectuable link with swiftCore
swift-compatibility-symbols, swift-def-to-strings-converter,
and swift-serialize-diagnostics don't use any Swift modules. But when
SWIFT_SWIFT_PARSER was enabled, they are linked with swiftCore. But
these binaries can be executed before the runtime is being built.
We need to stop them linking with swiftCore.
2023-08-28 19:10:01 +00:00
Rintaro Ishizaki
757aaa347d [CMake] Set LD_LIBRARY_PATH to builder's runtime when building stdlib
In Linux. Instead of setting temporary "fallback" RUNPATH, Set
LD_LIBRARY_PATH to builder's runtime when building standard library.
So we don't need to strip the temporary RUNPATH when installing.
2023-08-28 01:16:18 +00:00
Rintaro Ishizaki
9017ef51ce [CMake] Update for review comments 2023-08-25 21:58:38 +00:00
Rintaro Ishizaki
2a2787b2d0 Avoid adding redundant temporary RUNPATH to builder's stdlib
Many shared libs and executables are only run after stdlib/runtime are
built. They don't need to link with builders stdlib at all.
2023-08-24 23:10:20 +00:00
Rintaro Ishizaki
9c9010e5b7 [CMake] Support Macros in Linux
For compiling codes required for macro support, we now need swiftc
compiler in the build machine.

Unlike Darwin OSes, where swiftCore runtime is guaranteed to be present
in /usr/lib, Linux doesn't have ABI stability and the stdlib of the
build machine is not at the specific location. So the built compiler
cannot relies on the shared object in the toolchain.
2023-08-24 17:04:15 +00:00
Evan Wilde
d8acc6e2f1 Link or copy in install_symlink
LLVM install_symlink takes a new argument on whether to create a symlink
or copy binaries when run. -- https://reviews.llvm.org/D145443

The variable that controls this in LLVM is `LLVM_USE_SYMLINKS`, which
defaults to `ON` on Unix-y hosts, but otherwise is false so that Windows
works. This is a configurable option, so Windows configs that can
support symlinks can take advantage of symlinks and save some space.
`LLVM_USE_SYMLINKS` is not exported from LLVM though, so we can't see
it to use. Instead, we have `SWIFT_USE_SYMLINKS`.
2023-08-11 10:47:53 -07:00
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
Evan Wilde
669285fd17 Merge pull request #65534 from stephank/fix/cmake-3.25
build: fix accidental cmake expansions
2023-07-24 09:44:14 -07:00
AlexDenisov
a5f2f76716 CMake: expose Swift version through CMakeConfig.cmake (#67152)
Rationale: we are using Swift compiler as a library in a downstream project and having these exposed would streamline version detection for our use case.
Additionally, this PR makes CMake config a bit more uniform with LLVM/Clang configs.
2023-07-22 13:12:15 -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
Alastair Houghton
e5ece81cc9 [Freestanding] Remove uses of stat() and dlsym().
We shouldn't be using stat() or dlsym() in the freestanding
runtime.

rdar://111214571
rdar://106555012
2023-06-23 17:05:59 +01:00
Alastair Houghton
4f4d0147ca Merge pull request #66721 from al45tair/eng/PR-110665213
[Threading][TSan] Fix TSan errors from lazy init on Linux.
2023-06-22 20:03:00 +01:00
Saleem Abdulrasool
53e4e19e71 build: add a workaround for ARM64 Windows
MSVC 17.6p3 introduced new ARM64 intrinsics for atomic
(load-acquire/store-release) operations.  Since clang does not support
this yet, force the fallback path to temporarily unblock the build while
we implement support for the `__stlr[8|16|32|64]` intrinsics in clang.

See: llvm/llvm-project#62103
2023-06-21 22:08:59 -04:00
Alastair Houghton
3f0018df97 [Threading][TSan] Fix linkage issue.
We need to pick up the `_swift_tsan_xxx` symbols from libswiftCore in
most cases, but sometimes we're statically linked and in that case we
want to use a local copy.

rdar://1106655213
2023-06-19 17:24:35 +01:00
Max Desiatov
8499aa044c SwiftConfigureSDK.cmake: support freebsd-arm64 2023-06-15 01:11:47 +01:00
Ben Barham
b0b9705ae0 [CMake] Prevent rebuilds of pure swift libraries and executables
`.swiftmodule` is listed as an output of pure swift libraries, but it
isn't updated if there's been no changes (just like the library and
its object files). Add it to the touch hack as well.

Swift *executables* also list `.swiftmodule` as an output, even though
one isn't generated at all. Add a new POST_BUILD command to touch it
regardless.
2023-06-08 20:43:40 -07:00
Ben Barham
7dcebb249c [CMake] Allow install_name_tool to edit pure swift library load paths 2023-06-06 14:02:22 -07:00
Doug Gregor
a41c36934b [CMake] Fix host library builds and rpaths for testing macros
This enables running macro tests on Linux.
2023-05-28 22:20:25 -07:00
Doug Gregor
c9383ff619 [CMake] Add paths for building Swift code against host toolchain
When building Swift code into the compiler (e.g, the new Swift parser
along with macros support), make sure we always add the appropriate
paths to (1) link against the host Swift toolchain, and (2) find the
host Swift libraries (such as SwiftSyntax) at runtime.

The CMake code for doing this was only running for Darwin builds, so
generalize it to also work on Linux.
2023-05-28 17:01:01 -07:00
Kuba (Brecka) Mracek
683985e824 Add missing armv7 variants into the lists of allowed CPU types for the 'freestanding' stdlib builds (#65633) 2023-05-04 08:36:43 -07:00
Alex Langford
7c52fe21d6 [CMake] Workaround sanitizer flag bug in swift driver
Some versions of the swift driver have a bug where passing `-sanitize=`
does not emit the correct `-fsanitize=` flag for the clang link step.
Although this is being fixed, we must be able to correctly build with older
versions of the swift driver for some period of time. We workaround that
issue by explicitly passing the correct `-fsanitize=` argument
ourselves.

This works around rdar://107733898
2023-04-06 16:58:01 -07:00
Rintaro Ishizaki
d5565c9855 [CMake] Add correct sanitizer options to pure Swift libs/tools
rdar://107056349
2023-03-22 13:05:20 -07:00
Rintaro Ishizaki
93e25d2935 Merge pull request #64376 from rintaro/macros-plugin-server 2023-03-20 07:52:08 -07:00
Rintaro Ishizaki
d28e1c963c [CMake] Fix swift_supports_implicit_module failure
swift_supports_implicit_module invokes /path/to/toolchain/usr/bin/swiftc
directly without using `xcrun`. That fails to set necessary
environmental variables to make swiftc infer the SDK path. Because of
that swift_supports_implicit_module used to fail because the test
compilation fails to load the stdlib. This PR workaround it by passing
`-parse-stdlib` to avoid implicit stdlib loading.
2023-03-16 16:13:50 -07:00
Ben Barham
e137b32c73 Merge pull request #64409 from bnbarham/add-link-path
[CMake] Add lib to swift host libraries link directories
2023-03-16 14:42:20 -07:00
Rintaro Ishizaki
025d8746fe [CMake] Set correct RPATH in add_pure_swift_host_tool
Also, build pure swift library/tool with install RPATH like non Swift
things.
2023-03-16 14:00:45 -07:00
Ben Barham
4186d628e1 [CMake] Add lib to swift host libraries link directories
Our libraries have a `LC_LINKER_OPTION` for eg. `-lswiftLLVMJSON`.
This is resolved (probably just based on the actual libswiftLLVMJSON.a
added to the link command) by ld, but not by lld. Add in a link
directory so that these libraries can be found.
2023-03-15 16:55:01 -07:00
Rintaro Ishizaki
f9fba6ce3e [CMake] Move add_pure_swift_host_library to a file
* Move `add_pure_swift_host_library()` from lib/CMakeLists.txt to
  AddPureSwift.cmake so that code outside `lib` can use it
* Add `add_pure_swift_host_tool()` function to make a pure Swift
  host executable target (for future usages)
* Specify depending `SwiftSyntax` modules explicitly because not all
  Swift libraries uses all SwiftSyntax libraries
2023-03-13 19:28:13 -07:00
Rintaro Ishizaki
9004fd24d4 [ASTGen] Separate JSON serialization module from ASTGen
For future usage from other host libraries written in Swift

For CMake:
 * Explicitly specify LINKER_LANGAGE to CXX in existing components so
   that 'swiftc' is not used when linking with 'swiftASTGen'
 * Add 'EMIT_MODULE' argument to 'add_pure_swift_host_library' to emit
   .swiftmodule usable from other Swift libraries.
2023-03-09 19:15:45 -08:00
Daniel Rodríguez Troitiño
b4090419ea [cmake] Modify libedit target name to match LLVM's FindLibEdit
For unified builds, LLVM with the update to stable/20221013 includes its
own FindLibEdit, which shares many of the same names than Swift's
FindLibEdit, except that they differ in the target name.

Match both LLVM and Swift target names, so unified builds can find
LibEdit::LibEdit correctly and not try to link against libedit
mistakenly.

This should not affect Darwin/Linux builds from upstream Swift, since
they build non-unified in most people setups (including CI).
2023-03-07 17:10:11 -08:00
Alastair Houghton
1258d45152 [Backtracing] Build work.
Additional shimming required for some builds, as well as a few other build
related tweaks.

rdar://106234311
2023-03-04 15:46:30 +00:00
Alastair Houghton
44783e72c6 [Frontend] Add support for implicit import of _Backtracing
Once the API has gone through Swift Evolution, we will want to implicitly
import the _Backtracing module.  Add code to do that, but set it to off
by default for now.

rdar://105394140
2023-03-04 08:00:06 +00:00
Mishal Shah
41a903c425 Fix the bad merge from main to rebranch in cmake/modules/AddSwift.cmake 2023-03-01 22:28:05 -08:00
Arnold Schwaighofer
ed9da31fc6 Revert "Merge pull request #63650 from al45tair/backtracing/add-libexec"
This reverts commit b88f3b6545, reversing
changes made to be4caa5b93.
2023-02-28 10:08:56 -08:00
swift-ci
8c1e33acd8 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-28 06:35:01 -08:00
Alastair Houghton
f68c4b40f3 Add support for building target executables into libexec.
We're going to add a program, `swift-backtrace`, that gets built alongside
the stdlib and the runtime, and that needs to be installed in libexec/swift
alongside the libraries in lib/swift.

It wants to be built with the stdlib/runtime because there's an internal
interface between `swift-backtrace` and the runtime, so the program needs
to stay in lock-step with the runtime library.

rdar://105390807
2023-02-13 20:04:37 +00:00
swift-ci
db6b4d0e60 Merge remote-tracking branch 'origin/main' into rebranch 2023-02-06 21:33:17 -08:00
Eric Miotto
6b2809ab19 [CMake] Assume watchOS and watchSimulator SDKs support 32 bit (#63472)
Update to match SDKSettings.json in watchOS 9.0

Addresses rdar://104967031
2023-02-06 21:29:56 -08:00
swift-ci
53edbec88e Merge remote-tracking branch 'origin/main' into rebranch 2022-12-16 08:55:12 -08:00
Alex Hoppen
1ebe7ef6a2 Copy files from SwiftSyntax’s gyb_syntax_support that are relevant to the compiler to this repo
This allows us to evolve e.g. token kinds and how attributes are modelled independently between SwiftSyntax and the compiler. It also makes it easier to e.g. add an attribute because you don’t need to create PRs for two repositories.
2022-12-15 16:40:28 +01:00
swift-ci
fcdbbfe6d8 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-09 16:23:24 -08:00
Rintaro Ishizaki
d05f45b7f0 [CMake] Don't add unnecessary gyb support .py files
'add_gyb_target' can accept 'DEPENDS'. Utilize it.
2022-12-08 14:49:08 -08:00
swift-ci
84236ec390 Merge remote-tracking branch 'origin/main' into rebranch 2022-12-04 01:13:44 -08:00