Commit Graph

713 Commits

Author SHA1 Message Date
Ian Anderson
94e860e795 [ClangImporter] Swift needs to pass -Xclang -fbuiltin-headers-in-system-modules for its module maps that group cstd headers
Swift has some module maps it overlays on Linux and Windows that groups all of the C standard library headers into a single module. This doesn’t allow clang and C++ headers to layer properly with the OS/SDK modules. clang will set -fbuiltin-headers-in-system-modules as necessary for Apple SDKs, but Swift will need to pass that flag itself when required by its module maps.
2023-12-08 22:33:12 -08:00
Steven Wu
034c15ce54 [Caching] Add new CacheReplay APIs to libSwiftScan
Add new APIs libSwiftScan that can be used for cache query and cache
replay. This enables swift-driver or build system to query the cache and
replay the compilation results without invocation swift-frontend for
better scheduling.
2023-11-03 15:59:56 -07:00
Rintaro Ishizaki
66b8946eb4 [swift-parse-test] Add -skip-bodies option
This is no-op for SwiftParser. Also add a sanity check test file.
2023-10-30 13:18:04 -07:00
Yuta Saito
5f684ec75f [wasm][test] Add objc_codegen feature to exclude enable-objc-interop tests
Clang does not accept `-x objective-c` with WebAssembly target and it
crashes with "Objective-C support is unimplemented for object file
format" for now. `-enable-objc-interop` can work without the objc
runtime support (which is indicated by `objc_interop` feature), so this
adds a new `objc_codegen` feature to require Objective-C support only
at compile-time.
2023-10-11 00:51:17 +00:00
Yuta Saito
072d4cc8fa [wasm][test] WASI platform does not support injecting dynamic library
WASI does not provide any interface to inject dynamic library at
runtime and all stdlib are now always statically linked, so don't
need to inject dynamically.
2023-10-03 06:20:01 +00:00
Alastair Houghton
62c4999249 Merge pull request #68669 from al45tair/eng/PR-115774613
[Linux] Force the inclusion of the backtracing code when static linking.
2023-09-26 22:16:06 +01:00
Alastair Houghton
598bce2404 [Linux] Force the inclusion of the backtracing code when static linking.
When we're statically linking the standard library, we need to force
the inclusion of the backtracing code in the runtime, otherwise we don't
get on-crash backtraces.

Also, add a test to make sure that this works.

rdar://115774613
2023-09-21 15:03:51 +01:00
Alex Hoppen
a5a17aa955 [tests] Add a %batch-code-completion lit substitution
I could never remember the command to run batch code completion tests. Add a lit substitution for it.
2023-09-18 13:57:49 -07:00
Finagolfin
de41f83833 [test] Add new libdispatch -vfsoverlay flag for linux, as in apple/swift-corelibs-libdispatch#785
This allows the tests that use libdispatch to find its modulemap, plus add the
libdispatch compilation flags to one test that was missing them and fix one
async test on linux.
2023-09-08 09:48:05 -07:00
Saleem Abdulrasool
99453fc2e8 test: introduce a new %swift-plugin-dir macro
Use this to define the macro location rather than the "host" dir (which
is actually for the build and not the host).  Furthermore, on Windows,
the build dir is /usr/lib/swift as the host content is in the SDK.

This prepares the tests for Windows.
2023-09-04 13:04:18 -07:00
Saleem Abdulrasool
d0bf84a89a Update lit.cfg 2023-09-04 10:32:59 -07:00
Saleem Abdulrasool
c549028f88 test: sink -no-toolchain-stdlib-rpath into lit
This is a platform specific option and should be handled by lit patterns
rather than encoded into the tests.
2023-09-04 09:07:27 -07: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
Tristan Labelle
136642c167 Use llvm's abs_path_preserve_drive (#68038) 2023-08-22 09:10:29 -07:00
Hiroshi Yamauchi
d975ab3698 Fix some swift tests due to the substitute drive paths on Windows.
After
05d613ea93
17 tests started to fail on Windows when when the SOURCE_DIR is on a
substitute drive due to the path expansion difference.

This fixes 7 of these tests.
2023-08-18 17:57:47 -07:00
Saleem Abdulrasool
39a47a0733 Merge pull request #65968 from finagolfin/droid
[android][test] Fix a handful of tests and disable one CxxToSwiftToCxx bridging test
2023-08-17 08:47:29 -07:00
Cyndy Ishida
a533c63d78 Update references of tapi-diff to readtapi in tests (#67877) 2023-08-12 08:18:06 -07:00
Finagolfin
30ba49e7fa [android][test] Fix a handful of tests and disable one CxxToSwiftToCxx bridging test
Also, make the analogous change to apple/swift-driver#1372, which gets the
sanitizer tests working on Android again, and remove the lld_lto feature in the
tests, which is now unused.
2023-08-12 16:36:35 +05:30
Allan Shortlidge
7bb2d82f19 NFC: Update lit.cfg to specify -parse-as-library for module interface tests.
Tests that use the `%target-swift-emit-module-interface` lit substitution are
designed to test the behavior of the compiler when emitting module interfaces
for resilient libraries. It therefore makes sense to pass `-parse-as-library`
by default for these frontend invocations.

Fixes a few tests that were accidentally depending on parsing source files as
top level code.
2023-08-09 14:24:11 -07:00
Alastair Houghton
4962d1209d [Test][Backtracing] Pass SWIFT_BACKTRACE through lit if it's set.
If someone explicitly sets `SWIFT_BACKTRACE` and runs `lit`, we should
probably pass it through to the tests.

rdar://113550381
2023-08-08 11:36:59 +01:00
Kavon Farvardin
b5e0f95a18 eliminate pipes in favor of shlex
This solves deprecation warnings in build-script:

```
DeprecationWarning: 'pipes' is deprecated and slated for removal in Python 3.13
```

This change assumes that the minimum version
of Python3 is 3.3, which has `shlex.quote`.

Since our build bots currently use 3.6 as their
Python version, we can't yet use `shlex.join`
to further simplify some of the code using
quote.
2023-07-25 15:24:54 -07:00
Max Desiatov
8d41e4eddb test: Add missing target-specific lit properties for WASI (#67472)
Lack of these properties prevents the WASI test suite from running successfully.
2023-07-22 22:48:13 +01:00
Max Desiatov
67e5f1ef38 Merge pull request #67473 from apple/maxd/wasm-run-tests
tests: configure Wasm runtime selection in `lit.cfg`

Currently `wasmer` is hardcoded as a Wasm runtime for running tests. We should make this configurable to be able to select an arbitrary runtime.
2023-07-22 21:02:52 +01:00
Max Desiatov
0457451c7b test/lit.cfg: force static linking for WASI as dynamic is unsupported (#67467)
wasm32-unknown-wasi target doesn't support dynamic linking.
2023-07-22 19:28:10 +01:00
Max Desiatov
b53646a75a test/lit.cfg: fix path to wasm-run.py script 2023-07-22 15:32:29 +01:00
Max Desiatov
9e75e8e6a1 tests: configure Wasm runtime selection in lit.cfg 2023-07-22 15:30:16 +01:00
Daniel Rodríguez Troitiño
70376a15f0 [ScanDependencies] Fix JSON generation under certain circunstances. (#67246)
The code of `ScanDependencies.cpp` was creating invalid JSON since #66031
because in the case of having `extraPcmArgs` and `swiftOverlayDependencies`,
but not `bridgingHeader`, a comma will not be added at the end of
`extraPcmArgs`, creating an invalid JSON file. Additionally that same PR
added a trailing comma at the end of the `swiftOverlayDependencies`, which
valid JSON does not allow, but that bug was removed in #66366.

Both problems are, however, present in the 5.9 branch, because #66936
included #66031, but not #66366.

Besides fixing the problem in `ScanDependencies.cpp` I modified every test
that uses `--scan-dependencies` to pass the produced JSON through
Python's `json.tool` in order to validate proper JSON is produced. In
most cases I was able to pipe the output of the tool into `FileCheck`,
but in some cases the validation is done by itself because the checks
depend on the exact format generated by `--scan-dependencies`. In
a couple of tests I added a call to `FileCheck` that seemed to be
missing.

Without these changes, two tests seems to be generating invalid JSON in
my machine:

- `ScanDependencies/local_cache_consistency.swift` (which outputs `Expecting ',' delimiter: line 525 column 11 (char 22799)`)
- `ScanDependencies/placholder_overlay_deps.swift`
2023-07-12 14:19:20 -07:00
Cyndy Ishida
4f0e866061 [TBDGen] Ensure symbols listed include maccatalyst when library is built (#67160)
zippered.

This also introduces a dependency on new testing tool
llvm-tapi-diff. This allows for a structural difference check on tbd
files.

resolves: rdar://107368040
2023-07-07 08:40:07 -07:00
Max Desiatov
85396f24cb lit.cfg: simplify driver arguments when testing for WASI (#67137)
We can pass a single `-sdk` argument instead of passing identical values to both `-Xcc --sysroot` and `-Xclang-linker --sysroot`
2023-07-06 10:17:44 +01:00
Steven Wu
bed01ade89 [CAS][DependencyScanning] Don't keep a shared state of common file deps
Unlike `swift-frontend -scan-dependencies` option, when dependency
scanner is used as a library by swift driver, the SwiftScanningService
is shared for multiple driver invocations. It can't keep states (like
common file dependencies) that can change from one invocation to
another.

Instead, the clang/SDK file dependencies are computed from each driver
invocations to avoid out-of-date information when scanning service is
reused.

The test case for a shared Service will be added to swift-driver repo
since there is no tool to test it within swift compiler.
2023-06-27 09:50:26 -07:00
Steven Wu
2b7d38dc16 [CAS] Improve swift cas options
Using the same CASOption from clang to communicate CAS configurations so
it is easier to exchange CAS configuration between them.
2023-06-26 10:34:26 -07:00
Arnold Schwaighofer
8f7e433c71 Fix LTO test to use just use libLTO.dylib
This is necessary until the Xcode toolchain's libLTO.dylib supports opaque pointers
2023-06-14 10:49:50 -07:00
Arnold Schwaighofer
5d1378d355 Add a %use_no_opaque_pointers subsitution for tests
This substitution can be used to run tests under the -no-opaque-pointers
option.
2023-06-14 10:48:13 -07:00
Alastair Houghton
2f0e42ba8d [Backtracing] Use stderr by default unless interactive.
This means we don't need to specify `output-to` in CI.

rdar://110371557
2023-06-07 13:54:36 +01:00
Hamish Knight
27cd942fab Merge pull request #66254 from ktoso/remove-lit-leaks 2023-06-01 10:18:43 +01:00
Konrad `ktoso` Malawski
401e9304f4 Revert "[lit] introduce target-run-simple-leaks-swift to run with leaks"
This reverts commit 44aff27d7f.
2023-05-31 22:36:27 +02:00
Konrad `ktoso` Malawski
e55a7314c8 Revert "fix lit config on windows"
This reverts commit e3d4b55448.
2023-05-31 22:36:04 +02:00
Yuta Saito
21d57e887a [lit] Repair tests for stdlib-only build
`config.host_triple` can be None when no host tools are built
2023-05-31 18:47:54 +00: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
Daniel Rodríguez Troitiño
8f0382c109 [test] Replace swift_obj_root for alternates that work in LLVM unified builds (#66167)
In LLVM unified builds `%swift_obj_root` points to `<LLVM build dir>/tools/swift`,
and folders like `bin`, `lib` and `share` are not under `swift_obj_root`, which
makes some tests fail.

For the cases in which `%swift_obj_root/lib` was used, replace it by
using `%swift-lib-dir` instead. Replicate `%swift-lib-dir` to create
`%swift-bin-dir` and `%swift-share-dir`, and use those instead of
`%swift_obj_root/bin` and `%swift_obj_root/share`.

This alternates work both in Swift build-script builds and also in LLVM
unified builds.
2023-05-26 08:39:31 -07:00
swift-ci
9698128a36 Merge pull request #65613 from ktoso/wip-discarding-error-task-leak
[DiscardingTG] Undo pointer auth workaround; fix memory leaks
2023-05-25 19:06:48 -07:00
Konrad `ktoso` Malawski
e3d4b55448 fix lit config on windows 2023-05-25 19:42:00 +02:00
Tristan Labelle
21725b40c5 Support NUMBER_OF_PROCESSORS not being defined 2023-05-24 14:36:42 -04:00
Konrad `ktoso` Malawski
44aff27d7f [lit] introduce target-run-simple-leaks-swift to run with leaks
[lit] cleanup lit leaks target
2023-05-24 17:19:31 +02:00
Max Desiatov
0fc365960c Merge pull request #65795 from apple/maxd/fix-missing-cmake-value
CMake: fix missing `SWIFT_CONCURRENCY_GLOBAL_EXECUTOR` value

`SWIFT_CONCURRENCY_GLOBAL_EXECUTOR` is defined in `stdlib/cmake/modules/StdlibOptions.cmake`, which is not included during the first pass of evaluation of the root `CMakeLists.txt`. It is available on subsequent evaluations after the value is stored in CMake cache. This led to subtle bugs, where `usr/lib/swift_static/linux/static-stdlib-args.lnk` didn't contain certain flags on clean toolchain builds, but did contain them in incremental builds.

Not having these autolinking flags in toolchain builds leads to errors when statically linking executables on Linux.

Additionally, since are trivial tests previously didn't link Dispatch statically, the didn't expose a bug where `%import-static-libdispatch` substitution had a missing value. To fix that I had to update `lit.cfg` and clean up some of the related path computations to infer a correct substitution value.

Resolves some of the errors reported in https://github.com/apple/swift/issues/65097.
2023-05-17 20:52:05 +01:00
Konrad `ktoso` Malawski
da6f08a24e [Concurrency] Adopt stable keyword consuming instead of __owned
add test for warnings emitted when missing consuming attribute

use -emit-sil in mock SDK tests for better coverage
2023-05-11 15:18:54 +02:00
Max Desiatov
2db62cade8 Fix -DSWIFT_PATH_TO_LIBDISPATCH_STATIC_BUILD value 2023-05-10 14:05:25 +01:00
Eric Miotto
2c91c5482b Allow simulator tests on Apple Silicon (#65700)
Some of the conditions in lit.cfg assume a simulator always targets
Intel, but this is not true after the introduction of Apple Silicon.

Rely instead on run_environment.

Addresses rdar://108751951, rdar://108788348
2023-05-08 07:52:15 -07:00
Eric Miotto
a9501e08e6 test: simulators on Apple Silicon conform to the stable ABI
Addresses rdar://108788348
2023-05-05 11:56:54 -07:00
Daniel Rodríguez Troitiño
cfb76cc780 [test] Allow customizing swift-ide-test invocations during tests. (#65684)
In some Linux setups, one might need to provide extra arguments to setup
the environment for invocations done during the tests. The Swift
frontend and driver already had a mechanism to provide those arguments
in the shape of `SWIFT_FRONTEND_TEST_OPTIONS` and
`SWIFT_DRIVER_TEST_OPTIONS`. `swift-ide-test` was sadly missing the same
feature, which meant that many tests might fail or tests against the
incorrect environment.

The changes implement the `SWIFT_IDE_TEST_TEST_OPTIONS` mechanism to
cover that gap.
2023-05-05 09:35:45 -07:00