Commit Graph

426 Commits

Author SHA1 Message Date
Butta
9ed6766856 [build-script] Move --native-{clang,llvm,swift}-tools-path flags into the Python build-script
Also, fix two places where the LLVM path was wrongly employed to set up clang,
and use the Swift path in install_toolchain_path().
2020-10-27 00:24:46 +05:30
Max Desiatov
4b6bc60d23 NFC: fix typo in build_swift/versions.py 2020-10-07 11:13:46 +01:00
Cassie Jones
6d92486c9a [build-script] Add SWIFT_ prefix to USE_SCCACHE env var 2020-09-30 19:37:25 -04:00
Cassie Jones
e01893cb56 [build-script] Add a flag for sccache
This adds a flag to enable sccache in order to simplify the build-script
invocation, particularly for new contributors.
2020-09-30 16:49:34 -04:00
Mishal Shah
40024718ac Update doc and links to support new main branch 2020-09-22 23:53:29 -07:00
Dave Lee
0c79763b33 [build-script] Cleanup source directory layout help 2020-09-14 17:16:13 -07:00
Artem Chikin
fc4ef192ae [build-script] Add a default-enabled "clean" step for swift-driver and swiftpm
Along with options to disable the mandatory clean using: `--skip-clean-swift-driver` and `--skip-clean-swiftpm`.

This will ensure that every invocation of build-script will, by default, clean up all build artifacts of these projects and re-build them from scratch.
This is needed for all builds because today arbitrary changes to the compiler can lead to us being unable to incrementally build components that are themselves written in Swift. This causes now-frequent failures in incremental build bots, and is a scenario that is encountered by developers. (For example see: rdar://65006593)

The proper long-term solution is to enable library evolution for these projects. Until this is done, the only safe thing to do is to always rebuild them.

Resolves rdar://65006593
2020-08-20 11:27:27 -07:00
Michael Gottesman
c8c807f349 Consistently use toggle_true instead of store_true when selected projects.
This allows for child cascading presets to mixin a parent preset and then
selectively turn off these projects. store_true in contrast can not be
overwritten making cascading impossible.
2020-08-18 18:10:19 -07:00
Kuba (Brecka) Mracek
ef89b0dc51 Add a 'standalone_minimal' preset to build a minimal, static, OS independent, self-contained binaries of stdlib. (#33286) 2020-08-12 07:28:34 -07:00
Doug Gregor
e2cdc5e04b Merge pull request #33196 from DougGregor/concurrency-lib
[Concurrency] Stub out an experimental concurrency support library.
2020-07-30 11:51:27 -07:00
tbkka
afb573687c Use assert(mock.called) (#33194)
The `mock.assert_called()` method was added in Python 3.6,
so fails on some of our older CI machines that use Python 3.5.
`assert(mock.called)` is precisely equivalent and works with
older versions of the Python unittest.mock library.
2020-07-30 11:32:58 -07:00
Doug Gregor
45549692d8 [Concurrency] Update expected options for --enable-experimental-concurrency 2020-07-29 22:05:45 -07:00
Doug Gregor
9b0266cf6a [Concurrency] Stub out an experimental concurrency support library.
The experimental concurrency model will require a supporting runtime
and possibly end-user-visible library constructs. Introduce a stub of
such a library, enabled by a new `build-script` option
`--enable-experimental-concurrency`, so we have a place to put this
work.
2020-07-29 16:32:27 -07:00
Saleem Abdulrasool
2bf0ee413f build: remove tensorflow-swift-apis from the master branch
Remove the ability to build this dependency.
2020-07-28 08:27:24 -07:00
Saleem Abdulrasool
9f0e0a6e2e build: remove PythonKit integration 2020-07-23 13:38:54 -07:00
tbkka
868425be8a More Python3 lint fixes (#32967)
* More Python3 lint fixes

Some of the issues addressed include:
* Don't use `l` as a variable name (confusable with `1` or `I`)
* `print` statement does not exist in Py3, use `print` function instead
* Implicit tuple deconstruction in function args is no longer supported,
  use explicit splat `*` at the call site instead
* `xrange` does not exist in Py3, use `range` instead

* Better name per review feedback
2020-07-19 21:44:13 -07:00
Ben Langmuir
c03ea7ad44 Merge pull request #32546 from dylansturg/add_swift_format_product
Add a build product and presets for swift-format.
2020-07-01 14:40:01 -07:00
Dylan Sturgeon
3b168d87fd Changes for review:
- Fix extra space in build-script arg to build swift-format.
- Fix python lint errors in `swiftformat.py`.
- Remove swiftsyntax from swiftformat build preset.
2020-06-26 13:38:54 -07:00
Dylan Sturgeon
e225bfb332 Add a build prodct for swift-format.
This product supports building and testing swift-format, forwarding the commands to a build script inside of swift-format's repo to handle actually invoking Swift PM. There are new command line options to support the swift-format product:

`--swiftformat`: Enables building swift-format.
`--skip-test-swiftformat': Disables running tests for swift-format after building.

Installing is intentionally not implemented because swift-format isn't ready to be installed as part of the Swift toolchain.
2020-06-25 10:35:07 -07:00
Doug Gregor
33af86769c [build-script] Fix swift-driver options and test thereof 2020-06-19 14:56:59 -07:00
Doug Gregor
bf9f0eca1b [build-script] Add support for building, installing, and testing swift-driver
Add build-script command-line options for building, installing, and
testing swift-driver:
* `--swift-driver` will build the Swift driver. If testing is enabled,
  it will be tested as well
* `--install-swift-driver` will install the `swift-driver` and
  `swift-help` executables in the toolchain.
* `--skip-test-swift-driver` will disable testing of the Swift driver
when other tests are being run.

The Swift driver depends on SwiftPM to build; it is recommended that
you use `--infer` to get the appropriate dependencies built.

Note that this option does not yet replace the existing Swift driver
executables (`swiftc`, `swift`) with the new driver, nor does it
install the SwiftDriver library for use elsewhere.
2020-06-19 12:19:47 -07:00
Michael Gottesman
5ec7cb7b68 [build-script] llvm-dsymutil's component is dsymutil. 2020-06-12 14:14:09 -07:00
Michael Gottesman
a313f62522 [build-script] Add option --infer to infer dependencies.
This causes build-script to use the conservative dependency information that I
committed. When one uses this option, it is assumed that one wants to also
install all built products.

Some notes:

1. I included an extra --install-all option so without --infer enabled
   one can enable this sort of install everything that we want to
   build behavior.

2. I added %cmake as a lit variable. I did this so I could specify in
   my build-system unit tests that on Linux they should use the just
   built cmake (if we built cmake due to an old cmake being on the
   system). Otherwise, the build system unit tests took way too
   long. These are meant to be dry-runs, so building this cmake again
   is just wasteful and doesn't make sense.

3. I unified how we handle cmark, llvm, swift with the rest of the
   build products by making them conditional on build_* variables, but
   to preserve current behavior I made it so that they are just
   enabled by default unlike things like
   llbuild/swiftpm/foundation/etc. This was necessary since previously
   we would just pass these flags to build-script-impl and
   build-script didn't know about them. Now I taught build-script
   about them so I can manipulate these skip-build-{cmark,llvm,swift}
   and then just pass them down to build-script-impl if appropriate
   rather than relying on build-script-impl to control if these are
   built.

Once this lands, I think we are at a good enough place with
build-script until we get rid of build-script-impl in terms of high
value QoI that will imnprove productivity. Once build-script-impl is
destroyed, we can start paring back what build-script itself does.
2020-06-09 11:04:43 -07:00
Michael Gottesman
00146f8b1c [build-script] Define default llvm_install_components.
This is just based off of the defaults that we use on the buildbots as of this
commit.

In order to not break the bots as they are, I left the internal representation
as a semicolon list of components. So this should be NFC from the perspective of
the bots since they all explicitly specify llvm-install-components if needed
(and we do not install without install-llvm anymore).
2020-06-08 19:59:21 -07:00
Mike Ash
6c8fa9375e Add swift-inspect default values to expected_options.py. 2020-05-29 16:42:46 -04:00
Ben Cohen
49cbf9788f Rename swiftdt to swift-inspect 2020-05-29 08:31:04 -07:00
Michael Gottesman
404867eee7 [build-script] Convert swiftdt to be a swiftpm project that is built via a build-script product. 2020-05-29 08:31:03 -07:00
Ben Langmuir
5eb14326f0 [build-script] Add sanitizer options to sourcekit-lsp
For now, default to no sanitizers.
2020-04-14 10:33:38 -07:00
Ben Langmuir
1d7ce7efe5 [build-script] Add sanitizer support to indexstore-db product
Support the usual `--enable-*san options`, but also add a
`--test-indexstore-db-santitize-all` that runs the tests once for each
sanitizer. Sanitizing just indexstore-db with a regular toolchain should
be much faster than using sanitized compilers.
2020-04-13 15:39:36 -07:00
Ben Langmuir
7710ba7c43 Bump the default clang version to 10.0.0
To match the current value in llvm-project. This fixes runnign clang
tests under build-script without explicitly setting the version, where
there is a test passing -fclang-abi-compat=9 that was previously
failing.

rdar://60376468
2020-03-19 14:12:09 -07:00
Ted Kremenek
39c34c89ee Bump Swift version to 5.3 2020-03-17 13:54:32 -07:00
Daniel Rodríguez Troitiño
073e44d6e8 Merge pull request #29296 from buttaface/droid
[android] Get build scripts working natively, fix tests and install
2020-02-24 21:05:47 -08:00
Mishal Shah
2f7ff37329 [Build System] Add support to execute non-executable tests 2020-02-21 18:03:16 +05:30
Saleem Abdulrasool
9b332a3a35 build: add an option to optionally build tensorflow-swift-apis
Now that the autodifferentiation support is being upstreamed, add an
option to enable building the TensorFlow swift-apis package optionally.
This enables easier development cycles for the engineers working on it.
2020-02-13 13:21:30 -08:00
Saleem Abdulrasool
8d32ee36fc Merge pull request #29443 from compnerd/unsupported-playground-support
build: migrate playground support to post-build artifact
2020-02-12 11:28:03 -08:00
Ross Bayer
e793fcf052 [Build System: build-script] Moved SWIFT_SOURCE_ROOT, SWIFT_BUILD_ROOT and SWIFT_REPO_NAME along with other project path constants into a new build_swift.constants module. 2020-02-11 12:46:03 -08:00
Michael Gottesman
704b0cc169 Presets add missing preset default for build_swift test. 2020-02-09 16:01:03 -08:00
Saleem Abdulrasool
f4086d8428 build: migrate playground support to post-build artifact
This migrates the playground support out of the build-script-impl and
into the python based build system.  This makes it build more similarly
to the Swift Package Manager and SourceKit-LSP.  More importantly, it
reduces the dependency on build-script-impl.
2020-02-08 14:00:02 -08:00
Butta
3f4109b3a2 [android] Get build scripts working natively, fix tests and install
The build scripts assume Android cross-compilation using the NDK, so avoid
that configuration if building on an Android host. Fix or disable some tests,
and don't install a glibc.modulemap without a native sysroot prefix.
2020-02-05 11:36:33 +05:30
Ross Bayer
52428ff971 [Build System: build-script] Remove the host module from swift_build_support.
The functions used to calculate default LTO link jobs for LLVM and Swift have been moved to the build_swift.defaults module.
2020-02-02 14:01:19 -08:00
Ross Bayer
a7d6cd8126 [Build System: build-script] Adds a new cache_utils module to build_swift which replaces the existing module from swift_build_support. 2020-01-30 23:06:14 -08:00
Andrew Trick
4a123f102e Fix the build-script --skip-build option.
This option configures the build directories without building any
targets. Splitting configuration from build allows for the decoupling
of build products. This decoupling is essential for the enlightened
way of developing Swift where the build-script is never actually used
to build anything, and build products can be independently
configured. When fully supported, this avoids many unnecessary
full/clean rebuilds and enables debugging by mixing-and-matching
configurations and rebuilding only select products after a change.

Sadly, the option has degraded, and a recent commit rendered it fully broken:

  commit 34848e6026
  Author: Alex Langford <apl@fb.com>
  Date:   Wed Jan 22 19:27:44 2020

    [build] Unify logic to skip building projects in build-script-impl

The breaking commit was itself a reasonable cleanup. The underlying
problem was the original --skip-build was implemented using hacks that
conflated configuration with build.

This fix reinstates a reasonable situation:

--skip-build has no effect on configuration, as documented. It merely
  skips building the targets. This is how it must behave to work as
  intended.

--skip-build-{product} and its inverse --build-{product} controls
  which products will be configured. These options are in heavy use
  throughout the scripts, so changing the name (e.g. to --skip-config)
  would be disruptive and of questionable benefit.

None of this changes the fact that any required build logic that
people have dumped into build-script-impl still effectively breaks the
enlightened way of building Swift, particularly when building
toolchain components.
2020-01-28 13:09:08 -08:00
Saleem Abdulrasool
e26b21675d Merge pull request #29366 from compnerd/optional-pythonkit-support
build: add support for optionally building PythonKit
2020-01-25 09:15:44 -08:00
Saleem Abdulrasool
cad0c7ae21 build: add support for optionally building PythonKit
This adds support for building PythonKit as a package as part of the
toolchain build.
2020-01-24 11:17:41 -08:00
Ross Bayer
603a47266e [Build System: build-script] Allow users to enable distcc via the USE_DISTCC environment variable. 2020-01-24 01:59:54 -08:00
Ross Bayer
cc9ff6aed8 [Build System: build-script] Support Swift versions with up to four version components, matching Clang. 2020-01-23 16:39:58 -08:00
Devin Coughlin
9b4a890262 [Utils] Attempt to appease python_lint 2020-01-21 20:27:14 -08:00
Devin Coughlin
89e381ca66 [CMake/Tests] CMake and lit.cfg support for running macCatalyst tests
Add support for testing with macCatalyst to lit.cfg and the test CMake.

This adds lit test features for whether the standard library and runtime was
built with macCatalyst support:

  REQUIRES: maccatalyst_support

The test suite can also be run in two modes: one where the macOS tests
are run as usual (against a zippered standard library, runtime, and overlays)
and another where iOS tests are compiled with the macCatalyst target
triple and executed as macCatalyst processes.

The iOS tests for macCatalyst can be run by passing `--maccatalyst-ios-tests`
to build-script. There are new lit test features to enable a test to specify
whether it supports that environment:

  REQUIRES: OS=maccatalyst
  UNSUPPORTED: OS=macCatalyst
2020-01-21 18:28:17 -08:00
Devin Coughlin
63ce243437 [CMake] Add initial build system support for macCatalyst
This commit adds initial build system support for macCatalyst,
an Apple technology that enables code targeting iOS
to be recompiled so that it can be executed on macOS while still using
iOS APIs. This is the first in a series of commits building out support for
macCatalyst in the compiler, runtime, standard library, and overlays. Swift
for macCatalyst represents the work of multiple people, including
Devin Coughlin, Ross Bayer, and Brent Royal-Gordon.

Under macCatalyst, compiler-provided shared libraries (including overlays)
are built as one of four kinds (or "flavors") of libraries,
each with different install names and Mach-O load commands. This commit
adds the build system infrastructure to produce these different
library flavors.

**macOS-like Libraries**

A "macOS-like" library (such as the GLKit overlay) is a plain-old macOS library
that can only be loaded into regular macOS processes. It has a macOS slice with
a single load command allowing it to be loaded into normal macOS processes.

**iOS-like Libraries**

An "iOS-like" library, such as the UIKit overlay, is a library with a
macOS slice but with a load command that only allows it be loaded into
macCatalyst processes. iOS-like libraries are produced by passing a new
target tuple to the compiler:

  swiftc ... -target x86_64-apple-ios13.0-macabi ...

Here 'ios' (and an iOS version number) is used for OS portion
of the triple, but the 'macabi' environment tells the compiler
that the library is intended for macCatalyst.

**Zippered Libraries**

A "zippered" library can be loaded into either a macCatalyst process or
a standard macOS process. Since macCatalyst does not introduce a new Mach-O
slice, the same code is shared between both processes. Zippered libraries
are usually relatively low level and with an API surface that is similar
between macOS and iOS (for example, both the Foundation overlay and the Swift
Standard Library/Runtime itself are zippered).

Zippered libraries are created by passing both the usual `-target`
flag to the compiler and an additional `-target-variant` flag:

   swiftc ... -target x86_64-apple-macos10.15 \
              -target-variant x86_64-apple-ios13.0-macabi

Just like the -target flag, -target-variant takes a target tuple.
This tells the compiler to compile the library for the -target tuple but
to add an extra load command, allowing the library to be loaded into processes
of the -target-variant flavor as well.

While a single zippered library and slice is shared between macOS and
macCatalyst, zippered libraries require two separate .swiftinterface/.swiftmodule
files, one for macOS and one for macCatalyst. When a macOS or macCatalyst client
imports the library, it will use module file for its flavor to determine what
symbols are present. This enables a zippered library to expose a subset of its
target APIs to its target-variant.

**Unzippered-Twin Libraries**

"Unzippered Twins" are pairs of libraries with the same name but different
contents and install locations, one for use from macOS processes and one for
use from macCatalyst processes. Unzippered twins are usually libraries that
depend on AppKit on macOS and UIKit on iOS (for example, the MapKit overlay)
and so do not share a common implementation between macOS and macCatalyst.

The macCatalyst version of an unzippered twin is installed in a parallel
directory hierarchy rooted at /System/iOSSupport/. So, for example, while macOS
and zippered Swift overlays are installed in /usr/lib/swift/, iOS-like and
the macCatalyst side of unzippered twins are installed in
/System/iOSSupport/usr/lib/swift. When building for macCatalyst, the build system
passes additional search paths so that the macCatalyst version of libraries is
found before macOS versions.

The add_swift_target_library() funciton now take an
optional  MACCATALYST_BUILD_FLAVOR, which enables swift libraries to indicate
which flavor of library they are.
2020-01-21 18:26:13 -08:00
Ross Bayer
5852aea3e8 [Build System: build-script] Updated the presets module to simplify the API and improve testability. 2020-01-20 02:34:45 -08:00