Commit Graph

1633 Commits

Author SHA1 Message Date
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
Arnold Schwaighofer
43c24be5cd Merge remote-tracking branch 'upstream/master' into master-next 2020-01-08 06:41:34 -08:00
Xi Ge
7a1ac6b5a4 cmake: add SDK library search path for overlays unavailable in the source
When force linking auto-linked libraries, an overlay will fail to link if the dependence
libraries are missing from the source. This change provides linker flags
to search overlay libraries from the SDK.
2020-01-06 21:17:02 -08:00
swift_jenkins
bb3811a25a Merge remote-tracking branch 'origin/master' into master-next 2020-01-03 16:59:05 -08:00
Saleem Abdulrasool
5f428f594a build: use the new CMark export targets
CMark upstream now provides an exports target entry that we can use.
2020-01-03 14:40:58 -08:00
swift_jenkins
615101cbb5 Merge remote-tracking branch 'origin/master' into master-next 2020-01-02 16:39:11 -08:00
Saleem Abdulrasool
dbc3b433ad build: synchronise with LLDB's version of FindLibEdit
The current FOUND_VAR for FindLibEdit is libedit_FOUND but wasn't set by
find_package_handle_standard_args. However this isn't valid for the
package name.

  The argument for FOUND_VAR is "libedit_FOUND", but only
  "LibEdit_FOUND" and "LIBEDIT_FOUND" are valid names.

This fixes all the variables set by FindLibEdit to match the desired
naming scheme.

Thanks to Jonas for fixing the variable names!
2020-01-02 14:16:58 -08:00
swift_jenkins
81c0ed297a Merge remote-tracking branch 'origin/master' into master-next 2020-01-02 10:19:08 -08:00
Saleem Abdulrasool
1b850a2afd build: improve libedit handling for builds
Use the FindLibEdit.cmake module from LLDB to properly control where
the libedit libraries are searched for and linked from as well as where
the headers come from. This uses the standard mechanisms which allows
users to control where libedit is pulled from (which is important for
cross-compilation).

This second version is more aggressive about pruning the libedit
handling.  The Ubuntu 14.04 version of libedit does not have
`histedit.h`, and the intent is to rely on that to determine if we have
unicode support or not.
2019-12-29 16:32:49 -08:00
Joe Groff
fb34044408 Merge remote-tracking branch 'origin/master' into master-next 2019-12-10 12:46:41 -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
Eric Miotto
a0e7edde67 Merge pull request #28127 from edymtt/search-in-sdkroot
Build: search libraries in Apple SDKs (if needed)
2019-11-21 14:55:16 -08:00
Eric Miotto
88a046c959 Incorporate review feedback from Micheal 2019-11-20 14:27:24 -08:00
swift_jenkins
92d21b9976 Merge remote-tracking branch 'origin/master' into master-next 2019-11-19 08:00:33 -08:00
Eric Miotto
4990bc4c1e [build] amend search path for Cmake modules
Since we are not using symlinks anymore, we need to point to the correct
directory with LLVM cmake modules.

Fixes rdar://problem/57294763
2019-11-18 13:34:41 -08:00
Eric Miotto
4827ed7d85 Add explanation about the change 2019-11-15 15:41:14 -08:00
Eric Miotto
61a8e72091 Build: search libraries in Apple SDKs (if needed)
Addresses rdar://problem/56204969
2019-11-07 07:46:40 -08:00
swift-ci
0266d21f4e Merge remote-tracking branch 'origin/master' into master-next 2019-11-04 13:29:38 -08:00
Saleem Abdulrasool
b861bcc87b build: check the compiler against the correct variable
We were checking the compiler ID against the name of the compiler
binary.  This happened to pass incorrectly on Windows, which hid the
bug.
2019-11-04 10:52:18 -08:00
swift-ci
5323db1cfc Merge remote-tracking branch 'origin/master' into master-next 2019-10-31 13:49:56 -07:00
Saleem Abdulrasool
7a2a0e77dc build: add a dependency on clang
This enables injecting a dependency on clang for the target libraries if
the host compiler is not clang.
2019-10-30 16:50:04 -07:00
Xi Ge
64c0680686 Merge remote-tracking branch 'apple/master' into master-next 2019-10-28 10:19:36 -07:00
Rintaro Ishizaki
60341baf62 [SyntaxParse] Refactor generic requirement syntax structure
Re-apply a part of 0569cbfb28 after
reverting ASTGen changes. This is still an improvement.
2019-10-21 15:16:56 -07:00
Saleem Abdulrasool
33ad3befd8 build: avoid generator expression usage for compiler swap
When using the monorepo, it seems that even if Swift is built
standalone, we would see the target as imported and attempt to use the
generator expression, which would not resolve.
2019-10-20 10:41:37 -07:00
Saleem Abdulrasool
d2302fd774 build: allow unified builds on Windows
We cannot query the location of the clang target when clang is built in
a unified build.  Use a generator expression instead.
2019-10-18 13:40:38 -07:00
Harlan Haskins
2db9402a1b [SkipFunctionBodies] Build everything but the stdlib with function body skipping
This un-revers #27588, which was causing failures on debug builds
because it was only disabling the NonInlinableFunctionSkippingChecker
for the *optimized* OnoneSupport module, but not the unoptimized one.
2019-10-16 19:04:23 -07:00
Rintaro Ishizaki
f8209f2865 Merge pull request #27675 from rintaro/revert-syntaxparse
[SyntaxParse] Revert syntax parsing changes from the master branch
2019-10-15 18:33:36 +02:00
swift-ci
e8dc3adab9 Merge remote-tracking branch 'origin/master' into master-next 2019-10-14 14:49:51 -07:00
Dan Zheng
2bd55f6755 [Autodiff upstream] Add build-script flag for differentiable programming. (#27595)
Add `--enable-experimental-differentiable-programming` build-script flag.

The build-script flag enables/disables standard library additions
related to differentiable programming. This will allow official Swift
releases to disable these additions.

The build-script flag is on by default to ensure testing of
differentiable programming standard library additions. An additional
driver flag must be enabled to use differentiable programming features:
https://github.com/apple/swift/pull/27446
2019-10-14 14:34:48 -07:00
Rintaro Ishizaki
8768832f24 Revert "Merge pull request #27281 from rintaro/reapply-syntaxparse-genericparam"
This reverts commit 5d3e8d6c83, reversing
changes made to 27e881d97e.
2019-10-14 12:46:31 -07:00
Rintaro Ishizaki
bf5aa0a5a1 Revert "Merge pull request #27325 from rintaro/syntaxparse-cctype"
This reverts commit 439b9111b7, reversing
changes made to 4e476ff243.
2019-10-14 12:20:57 -07:00
swift-ci
eb4261ac64 Merge remote-tracking branch 'origin/master' into master-next 2019-10-11 16:10:06 -07:00
Harlan Haskins
5acc4175fd Revert "[SkipFunctionBodies] Build everything but the stdlib with function body skipping" 2019-10-11 15:45:00 -07:00
swift-ci
84f192ddce Merge remote-tracking branch 'origin/master' into master-next 2019-10-10 13:50:08 -07:00
Xi Ge
c9f1900d3b Merge pull request #27464 from nkcsgexi/deserialize-source-info
SerializeLoc: serialize basic decl source location information to .swiftsourceinfo file
2019-10-10 13:46:04 -07:00
swift-ci
111a4b00db Merge remote-tracking branch 'origin/master' into master-next 2019-10-10 11:50:29 -07:00
Xi Ge
dec878360f Driver: rename Name.swiftmodule/Private directory to Name.swiftmodule/Project
This directory should be excluded during installation since the content is only
used for local development. swiftsourceinfo file is currently emitted to this directory.
2019-10-09 15:29:52 -07:00
Harlan Haskins
8cb2449ca3 Update SwiftSource.cmake
CMake...
2019-10-09 11:07:53 -07:00
Harlan Haskins
5301fa0d3e Build everything but the stdlib with function body skipping 2019-10-09 10:14:44 -07:00
swift-ci
c479f15210 Merge remote-tracking branch 'origin/master' into master-next 2019-10-08 09:09:07 -07:00
Alex Langford
c07d02ef74 [CMake] Correctly export SWIFT_LIBRARY_DIRS 2019-10-07 18:57:32 -07:00
swift-ci
cce352f60e Merge remote-tracking branch 'origin/master' into master-next 2019-09-26 14:10:31 -07:00
Xi Ge
7ba1595baf cmake: avoid adding source info driver flag to swift_module_flags
rdar://55748348
2019-09-26 13:10:21 -07:00
swift-ci
76e7b1d2eb Merge remote-tracking branch 'origin/master' into master-next 2019-09-24 20:50:21 -07:00
Xi Ge
adb0e6e19f Merge pull request #27277 from nkcsgexi/add-source-info-to-driver
Frontend: set up output file .swiftsourceinfo
2019-09-24 20:34:47 -07:00
Xi Ge
ec9cf33af0 Driver: expose -emit-module-source-info-path as a driver option 2019-09-24 13:52:17 -07:00
Xi Ge
4cd46d9ed0 cmake: exclude Private dir from installation 2019-09-24 13:52:17 -07:00
Xi Ge
3103b5cec1 Frontend: set up output file .swiftsourceinfo
This patch will focus on teaching driver and frontend to emit this file.
The actual content and de-serialization parts will come later.

More details: https://forums.swift.org/t/proposal-emitting-source-information-file-during-compilation/28794
2019-09-24 13:52:17 -07:00
swift-ci
45461160d6 Merge remote-tracking branch 'origin/master' into master-next 2019-09-24 11:49:46 -07:00
Rintaro Ishizaki
1a9b6d0dbf [SyntaxParse] Introduce CodeCompletionTypeSyntax
To represent a type with code completion.

  type? '.'? <code-completion-token>

This is "parser only" node which is not exposed to SwiftSyntax.
Using this, defer to set the parsed type to code-completion callbacks.
2019-09-24 10:21:38 -07:00