Commit Graph

525 Commits

Author SHA1 Message Date
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
Dave Lee
7168d18e14 s/true/false/ 2020-09-14 18:43:42 -07:00
Dave Lee
157505196a [build-script] Disable pkg-config for Darwin hosts 2020-09-14 08:14:26 -07:00
Mishal Shah
bf7c03b1f6 Support cross compile Xcode toolchain for Apple Silicon
Support cross compile Xcode toolchain for Apple Silicon

* Add CMake flag DCMAKE_OSX_ARCHITECTURES to LLVM

* Add CMake flag DCMAKE_OSX_ARCHITECTURES to cmark

* Add CMake flag DCMAKE_OSX_ARCHITECTURES to lldb

* Add CMake flag DCMAKE_OSX_ARCHITECTURES to llbuild

* Add llbuild CMake options array to provide DCMAKE_OSX_ARCHITECTURES

* [Build System] Use one install package for cross compile hosts

* Remove Lipo before non-build-script-impl products

* Add support to only lipo without running installable package tests

* [Build System] Support cross compile install prefix for SwiftPM product in Swift Build Support

* Use cross compile toolchain path for indexstoredb and swift-driver

* Use cross compile toolchain path for swiftpm, swiftsyntax, swiftformat, and skstresstester

* Add cross compile toolchain support to Benchmarks, and fix the python lint issue in skstresstester.py

* [SwiftPM] Add support for cross-compile-hosts flag to build swiftpm using bootstrap script
2020-09-02 10:14:51 -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
Mishal Shah
3e1c2c45ba Merge pull request #33297 from apple/shahmishal/source-compat-preset-arm64
[Preset] Source compat suite cross compile for macOS arm64
2020-08-14 14:05:14 -07:00
Mishal Shah
e54127b152 Clean up the whitespace in build-script 2020-08-13 21:55:44 -07:00
Mishal Shah
c123f4206f [Build System] Move host lipo step after install step 2020-08-12 22:05:29 -07:00
swift-ci
2a5af15d39 Merge pull request #33154 from buttaface/flags 2020-08-11 15:03:48 -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
Butta
587973fd8b [build] Remove unemployed 'skip-{build,test}-*' flags from build-script-impl
These flags have done nothing for awhile, as 26 of 31 have already been moved to
build-script. Only the flags related to haiku, maccatalyst, and external-benchmarks
are unrecognized by either build script after this removal.
2020-07-28 12:32:44 +05:30
Saleem Abdulrasool
9f0e0a6e2e build: remove PythonKit integration 2020-07-23 13:38:54 -07:00
Butta
c969814a11 [build] Fix --skip-build-llvm so that its minimal targets, like tblgen, are still built 2020-07-18 03:45:17 +05:30
Mishal Shah
6c89aa0526 [Build System] Support host target prefix in symbols package 2020-07-08 14:12:51 -07:00
Yuta Saito
2612e9f3e8 [WASM] Resolve build failure by fixing cross compile issue on build-script
The added lines by Apple Silicon patch really depend on the build
machine platform and it forces that we can build stdlib only for
darwin targets. So I changed to allow non-darwin targets and filter only
unsupported darwin targets. This patch shuold be sent to upstream.
2020-07-06 17:08:01 +01:00
Mishal Shah
83c57f3e58 [Apple Silicon] [Build] Filter out any architectures that are unsupported by the SDKs 2020-07-02 19:05:45 -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
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
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
Doug Gregor
7e19cf35a5 [build-script] Appease Python linter 2020-06-17 12:11:04 -07:00
Doug Gregor
fb42e07a0a [build-script] Isolate CMake from the system
When building on Darwin, we're supposed to build against the SDK,
not the host system. Isolate the build further from the system.
2020-06-17 09:54:15 -07:00
Michael Gottesman
a7b3e37471 [build-script] Print out inferred products/build order when --verbose-build is enabled. 2020-06-11 22:23:17 -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
Michael Gottesman
37fefa7508 [build-script] Explicitly separate build-script-impl products and non-build-script-impl-products when building the list of products to build.
This was already being done in a really hacky way namely, we computed the
build-script-impl list by filtering a single product list. But if one looked at
the actual product classes that we have, all of the build-script-impl products
are already a prefix of the entire original list?! So just repersent it as a
prefix/suffix pair.

I also put in an assert to verify we do not break this invariant in the future.
2020-06-06 01:19:42 -07: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
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
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
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
4450ce365a [Build System: build-script] Remove the diagnostics module from swift_build_support. 2020-02-02 14:30:51 -08:00
Ross Bayer
39d28fcf4a Merge pull request #29500 from atrick/fix-skip-build
Fix the build-script --skip-build option.
2020-01-28 17:12:11 -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
Ross Bayer
c10b904bdc [Build System: build-script] Move the static methods from the BuildScriptInvocation class to the top level of build-script. 2020-01-27 15:09:07 -08:00
Ross Bayer
23b936c9af [Build System: build-script] Re-organize build-script into more logical sections. 2020-01-27 12:35:50 -08:00
Ross Bayer
ca4fc19a50 [Build System: build-script] Remove the tar module from swift_build_support.
The single function it provided to archive a source diretory has been moved to build-script which was the only caller.
2020-01-26 23:32:34 -08:00
Ross Bayer
3bc3f795a3 [Build System: build-script] Remove the debug module from swift_build_support.
The single function it provided to print the xcodebuild version and SDK versions has been moved to build-script which was the only caller.
2020-01-26 14:31:06 -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
Devin Coughlin
e9df206b9d Merge pull request #29017 from devincoughlin/maccatalyst
Build system and availability support for macCatalyst
2020-01-21 22:52:48 -08:00
swift-ci
c40b298368 Merge pull request #29337 from brentdax/dump-fire 2020-01-21 22:50:21 -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
Brent Royal-Gordon
cf8b045f0e Fix build-script --dump-config
The Version object used __slots__ instead of __dict__, so it was not serializable. Update JSONDumper to stringify objects if vars() won’t work.

This change does not update any tests because build-script does not currently have a way to write full-script integration tests.
2020-01-21 14:00:41 -08:00