Commit Graph

119 Commits

Author SHA1 Message Date
Max Desiatov
762079665e Add support for WebAssembly/WASI in CMake files 2020-05-10 11:32:04 +01:00
Doug Gregor
b27b4d4bb6 [CMake] Use proper module triples for the names of standard library modules.
The standard library (and other Swift modules built by our CMake build system)
has been building module files with an architecture only (e.g., x86_64.swiftmodule)
rather than a proper module triple (x86_86-apple-macosx10.15,
x86_64-apple-ios13.0-simulator, etc.), unlike every other build
system. There are hacks in the compiler and other tools to cope with
this unnecessary build difference. Fix the module file names so we'll
be able to remove the hacks later.

Fixes rdar://problem/49071536.
2020-04-20 21:16:14 -07:00
Robert Widmann
22b0526917 Merge pull request #30082 from 3405691582/OpenBSD_Port_Build
Build system recognizes OpenBSD.
2020-04-12 09:30:17 -07:00
Doug Gregor
5bbc43c4d2 [CMake] Add -simulator to simulator target triples.
The build systems that drive Swift compilation have been using the
"simulator" environment as part of the increasingly inaccurately
named "target triple" to specify simulator targets for several
years... except our own hand-rolled build system. Identify
simulator targets and append "-simulator" to their target
triples.
2020-04-06 16:52:56 -07:00
3405691582
f8d0174b85 Build system recognizes OpenBSD.
Commit for CMake and build scripts to recognize OpenBSD. To keep this
commit relatively short, this just deals with the rather simple and
uncontroversial changes to the build system.

Note that OpenBSD calls "x86_64" as "amd64", Since the Swift stdlib will
be put in a subdirectory named after ARCH, to ensure the standard
library is properly found later, we use the native architecture name for
OpenBSD in the build system rather than trying to deal with the
difference the other way around.
2020-04-03 13:34:17 -04:00
Doug Gregor
144ec416e6 [CMake] Stop requiring ${SDK}/System/Library/Frameworks/module.modulemap
Remove anachronistic check for a "blanket" module map in
/System/Library/Frameworks from Darwin SDK configuration. We already
extract other information from the SDK that we actually need, so check
for that directly instead.

Fixes rdar://problem/60084609.
2020-03-06 09:34:45 -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
Butta
14cc620016 [android] A few tweaks for native compilation and to get more tests working
Now that CMAKE_HOST_SYSTEM_NAME and CMAKE_SYSTEM_NAME are set by default to
Android in the Termux app, make the needed tweaks. Some tests were adapted
to work natively on Android too, adds sys/cdefs.h to the Bionic modulemap,
and includes the start of native Android platform support in the build-script.
2019-12-07 01:01:59 +05:30
Butta
796d6ade9a [android] Add support for natively building on Android
Check if building on Android through the ANDROID_DATA environment variable, then set
SWIFT_ANDROID_NATIVE_SYSROOT to the default layout for the Termux app, and key all the
include, lib, and other SDK paths off of that. The system libc and a few other libraries
are linked against from /system/lib[64]. Finally, check if lit is running natively on
Android and don't use adb if so.
2019-07-30 00:38:36 +05:30
Saleem Abdulrasool
d11f9abeef build: convert parameter to cached value
This converts the local variable to a cached variable which the user can
specify.  By making this a cached variable, it is easier to control and
ensure that a default value is provided.
2019-06-28 20:00:17 -07:00
Saleem Abdulrasool
ee5e11ae0d build: allow configuration of the system header location
Rather than hardcoding the paths to /usr/include, allow the user to set
the path to their libc headers.  This is particularly important for
environments which may not use the traditional layout (e.g. exherbo) or
for builds which wish to build against an out-of-tree, non-system
installed libc for a Unix target which does not match the host system
(i.e. foreign cross-compilation).
2019-06-27 19:13:52 -07:00
Saleem Abdulrasool
fe86fa8cb4 build: fix the Windows SDK printing 2019-06-27 19:13:52 -07:00
Saleem Abdulrasool
74e7ea3a94 build: reorder SDK configuration messages (NFC)
This just reorders the printed order of the messages to be grouped
better.  This will be further augmented in the next set of changes which
improve the cross-compilation setup that we have currently to allow for
foreign environments better.
2019-06-27 18:48:21 -07:00
Saleem Abdulrasool
c2772f10f4 build: permit cross-compiling android from Windows
The host value is used as part of the path to the tools.  The NDK only
has Darwin, Linux, and Windows prebuilts.  Enumerate the hosts fully and
record an error message otherwise.
2019-06-13 20:20:21 -07:00
Ross Bayer
8db65b35a4 Merge pull request #25122 from Rostepher/darwin-supported-archs
[Build System: CMake] Darwin Supported Archs and Modules.
2019-06-10 12:03:04 -07:00
Ross Bayer
029c25a137 [Build System: CMake] Ensure the SDK supported architectures and module architectures lists are mutually exclusive. 2019-05-29 15:28:53 -07:00
Ross Bayer
4ec60332f9 [Build System: CMake] Add new SWIFT_DARWIN_MODULE_ARCHS CMake cache variable which allows users to specify architectures they wish to configure and build _just_ the .swiftmodule content, even if they are not 'supported' via SWIFT_DARWIN_SUPPORTED_ARCHS. 2019-05-29 13:34:05 -07:00
Ross Bayer
f90cdf563d [Build System: CMake] Add new SWIFT_DARWIN_SUPPORTED_ARCHS CMake cache variable to allow users to specify a subset of architectures they wish to build. 2019-05-29 13:34:05 -07:00
Vlad Gorloff
096f7f38c0 Android Intel 32/64 bit (i.e. Android Simulator) support. 2019-05-28 23:26:13 +02:00
Maya Rashish
bc236c9a37 Fix typo regarding supported FreeBSD architectures 2019-01-21 17:25:34 +02:00
Nathan Lanza
c442763219 Cache VCVARS variables for incremental building on Windows
The initial configure & generate of a build on Windows should have
the necessary VCVARS set in the environment. After that, we should be
incrementally building with those same vars to avoid conflicts between
Windows SDKs.

Cache these vars so that the same Windows SDKs are consistently used
in future incremental builds.
2018-12-14 15:06:28 -08:00
Saleem Abdulrasool
a5d360ba7a build: do not create WinSDK symlinks when unneeded
When building on case insensitive filesystems, there is no need to
create the library symlink forest as the paths will be resolved properly
due to the insensitivity.  This avoids a bit of work and spew on
Windows.
2018-11-05 16:16:08 -08:00
Saleem Abdulrasool
f0beaf2c6f Merge pull request #19861 from compnerd/symlinks
build: workaround incorrectly cased import libraries in WinSDK
2018-10-13 09:10:57 -07:00
Saleem Abdulrasool
dae761fbd5 build: workaround incorrectly cased import libraries in WinSDK
The Windows SDK proides kernel32.Lib which on case sensitive file systems will
fail (due to the capital L in the extension).  Workaround that by creating
symbolic links to handle this.  This mirrors the technique used in LLVM.
2018-10-12 14:44:34 -07:00
Daniel Rodríguez Troitiño
8fb8b39e9f Remove unused variables from Android configuration 2018-10-09 17:15:47 -07:00
Saleem Abdulrasool
b76af893ec build: fix the variable name
The parameter name was not changed, resulting in the string conversion
not working properly for the Windows builds.
2018-10-08 15:53:13 -07:00
Saleem Abdulrasool
8c0fa0e13a build: prevent printing for unused variables for SDK
Reduce some of the SDK configuration printing for non-Darwin
configurations.  This simplifies the output and SDK configuration.  The
parameter reduction simplifies the setup for cross-compilation.
2018-10-08 09:52:29 -07:00
Saleem Abdulrasool
392082fec6 build: remove unneeded variables for non-Darwin SDKs
This alters the SDK configuration to remove the variables that don't
impact the target configuration.  Simply don't define them.
2018-10-08 09:52:29 -07:00
Saleem Abdulrasool
4880b94dfd build: remove sdk parameters which can be computed
The prefix and platform names are case adjusted values of the name of
the SDK.  Compute the value rather than pass them down.  The
simplifications will yield an easier cross-compilation implementation.
2018-10-08 09:52:29 -07:00
Saleem Abdulrasool
5054a22d0b build: hard code the triple into the SDK configuration
Rather than computing the triple first and passing it down to the SDK
configuration, hard code the triple into the SDK's configuration.  This
is a value which is static and will allow us to configure
cross-compilation of the standard library for Linux.  Although most
other targets do not support the same variety of architectures, this
enables those to be cross-compiled as well.
2018-10-08 09:52:29 -07:00
Saleem Abdulrasool
f02cd8f6f1 build: remove unnecessary parameter to configure_sdk_unix
Remove the duplicated platform name parameter to the unix SDK
configuration..  This value is implicit currently and can be computed.
This needs to be computed to permit parallel co-installations of
architectures for targets which do not support fat binaries (i.e.
non-MachO targets).
2018-10-08 09:52:29 -07:00
Saleem Abdulrasool
f0885be6a0 build: allow specifying the Linux SDK path
The SDK is a sysroot.  Permit the user to specify the location of the
SDK when building Linux.  This is in preparation to cross-compile the
Linux standard library.

While we are exposing more control knobs to the user, we can start
simplifying `configure_sdk_unix`.
2018-10-08 09:52:29 -07:00
Saleem Abdulrasool
583ceaede5 build: support android aarch64
This adds the needed support to enable building the standard library for android
aarch64 assuming that the appropriate parameters are passed to CMake.
2018-09-24 09:55:10 -07:00
Saleem Abdulrasool
0494ab651e build: hardcode the android triple in the SDK configuration
The SDK configuration can identify the triple for the android targets.  This is
similar to the Windows behaviour.  Doing so will now enable multi-architecture
builds!
2018-09-24 09:54:54 -07:00
Saleem Abdulrasool
30a4853177 build: remove SWIFT_ANDROID_SDK_PATH
The path to the SDK can be computed from the NDK.  Do so to reduce the
parameters needed to pass to CMake.  More importantly, this will allow building
with multiple architectures simultaneously.
2018-09-24 09:54:45 -07:00
Saleem Abdulrasool
777bd91a15 build: rename a variable to be more descriptive (NFC)
This variable is the build host, not a suffix.  Name it appropriately.  NFC.
2018-09-24 09:54:38 -07:00
Saleem Abdulrasool
5e04c26896 build: inline android specific configuration
The android specific configuration here is the same as the non-android in the
sense that it is setting up the triples for the target.  Simply inline it as it
makes it more obvious what it is doing.  This is preparatory work for adding
support for multiple architectures for Android.
2018-09-24 09:54:26 -07:00
Nathan Lanza
7429856034 Change various search and linker paths to account for changes in NDK16
ndk14 introduced "unified headers" which merged the headers for all
different API versions into one directory which effectively split the
"SWIFT_SDK_ANDROID_ARCH_${ARCH}_PATH" into two different directories.

Add include and library specific paths to various compilation and link
invocations across the Swift project to account for this change. Remove
some broken sysroot/sdk specific settings.
2018-05-02 14:18:11 -07:00
Saleem Abdulrasool
61d979348f build: report the ICU path used for the target
Report the ICU I18N and UC include paths and the library path.  This
makes it obvious when the variable is not defined and more importantly
makes it easier to see what the paths are being used particularly when
cross-compiling for multiple architectures.
2018-04-25 21:23:51 -07:00
Thomas Roughton
823bb0a530 Check for CMAKE_BUILD_TYPE_DEBUG instead of RELEASE
… since MinSizeRel and RelWithDebugInfo are also configurations.
2018-04-18 19:13:47 +12:00
Nathan Lanza
c3fe715c28 Change the arch argument for configure_sdk_unix to architectures (#15756)
General purpose cross compilation from host x to targets a,b,c will
require the ability to have multiple architectures passed to
`configure_sdk_unix`. Simply change the function to accept multiple
archs.
2018-04-09 19:43:19 -07:00
Saleem Abdulrasool
19aeb69cfb build: indicate VC++ CRT type for Windows builds
Indicate whether the debug or release CRT is in use when building for
Windows.
2018-04-06 13:09:41 -07:00
Nathan Lanza
e06c52584f Change various uses of SWIFT_SDK_${SDK}_PATH to its architecture specific vairant
Cross-compilation for multiple architectures & sdks require various
variables to be split to specify the arch/adk variant being focused on.
This change modifies various uses of the `SWIFT_SDK_${SDK}_PATH` to
`SWIFT_SDK_${SDK}_ARCH_${ARCH}`
2018-03-30 17:50:59 +00:00
Nathan Lanza
dd3cbf0b64 Add architecture specific path variables to SwiftConfigureSDK
New variables are introduced to track the path for the architecture
specific subdirectories

This work is mostly attributed to Zach Bowling
2018-03-20 16:20:43 -07:00
Bob Wilson
15ac679694 master-next: fix PR13574 for Linux
Set the deployment target to an empty string for non-Darwin platforms
so that it is safe to append to the target triple without guarding it
with a check for Darwin.
2017-12-21 08:33:18 -08:00
Bob Wilson
b7981aa6ea master-next: Set the deployment version correctly in -target options.
This change leaves in place the use of -m*-version-min options, but
fixes the -target options to match. We can eventually remove the use of
the -m*-version-min options after everyone has moved to build with
versions of Clang that correctly handle the deployment version in the
-target option.
2017-12-20 23:15:44 -08:00
Saleem Abdulrasool
2f9f585b57 build: special case Windows ARM target
Windows ARM NT (the modern, non-Windows CE environment) is a pure thumb2
environment.  The frontend does not canonicalise the target like in
clang.  Ensure that we map the triple by hand to the desired target
triple.
2017-10-15 12:10:58 -07:00
Saleem Abdulrasool
27d051a6c3 build: improve the Windows build infrastructure
Rather than use the `INCLUDE` and `LIB` environment variables to build
the Windows code, use the `UniversalCRTSdkDir`, `UCRTVersion`, and
`VCToolsInstallDir` variables.  Using these we can compute the right set
of include directories and library search paths for the various
architectures.  This will enable us to build multiple variants of the
Windows stdlib at the same time.

Additionally, rather than relying on the magic environment variables to
be processed by the driver, pass them explicitly to the driver through
the build system.  This also is needed to allow parallel builds of
various architecture variants of the stdlib on Windows.
2017-09-23 16:08:42 -07:00
Gonzalo Larralde
443e7614e4 Fixes on linker executable variables per target.
* `prefix` should be `sdk` in runtime cmake list file
* typo on variable existence checking
2017-03-07 10:00:58 -03:00
Saleem Abdulrasool
125e882c8c build: permit overriding the linker
When cross-compiling for android ARM, it is possible that the system
linker does not support the target.  However, in order to cross-compile
the target runtime, we need to adjust the linker to the target linker.
If one is not specified, fall back to the current behaviour of using the
system linker.
2017-02-26 11:25:07 -08:00