Commit Graph

1633 Commits

Author SHA1 Message Date
K Staring
6a121fb6e3 Merge branch 'master' of https://github.com/apple/swift 2016-11-17 21:13:04 +01:00
Rintaro Ishizaki
87bf209664 [CMake] Add DEPENDS to dependencies for compiling sources. 2016-11-17 02:03:44 +09:00
Doug Coleman
692bc1c031 cmake: Allow requiring minimum versions using sdk-os-version triples on
Darwin.

Example:
--darwin-sdk-deployment-targets=fookit-ios-8.0;barkit-tvos-9.2
2016-11-15 16:43:37 -08:00
Peter Cooper
43add7cfa1 Fix <rdar://problem/29053173> by checking for module_name before generating module command.
We need to actually have a module name and outputs or else the add_custom_command will try to
generate multiple commands all with the name NOTFOUND.

Note, this bug was introduced in 5834df33f9 via PR #5472.
2016-11-01 15:29:40 -07:00
cooperp
5834df33f9 Merge pull request #5472 from cooperp/cmake-swiftmodule
Change stdlib swiftc's to depend on .swiftmodule's instead of .o's
2016-11-01 12:12:21 -07:00
Peter Cooper
53ecbf2486 Change stdlib build to depend on .swiftmodule's instead of .o's for swiftc deps.
Currently SwiftOnoneSupport.o waits on Swift.o to finish compiling before we start
compiling SwiftOnoneSupport.o.  We don't need the .o for compilation but instead just
need Swift.swiftmodule which we were generating anyway.

This change causes .o and { .swiftmodule, .swiftdoc } to be built independently of each
other.  Downstream compiles only wait on the module while downstream links wait on the .o.

Given that .apinotes are sometimes used by swiftc invocations, this also separates out
apinotes in to its own step which these other commands can both depend on.

The result of this is a 30% improvement in building the stdlib with -R and 20% with -d.
Specifically, -R drops from 3m to 2m and -d drops from 12m to just under 10m.
2016-10-31 14:25:14 -07:00
K Staring
536c1ac6ce Merge branch 'master' of https://github.com/apple/swift 2016-10-31 07:10:16 +01:00
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +02:00
K Staring
134bd2e962 don't hard-force ld.gold as per @jrose-apple 's suggestion 2016-10-25 22:07:49 +02:00
Brian Gesiak
61868b5aec [CMake] Updates for Android NDK r13
Fixes the Android build, and makes some adjustments for Android NDK r13.

* Fix FindICU.cmake to properly set the `SWIFT_${sdk}_ICU_UC` and
  `SWIFT_${sdk}_ICU_I18N` values. These were not properly set because
  "uc" and "i18n" were lowercase.
* Adapt `add_swift_library` to parse `ICU_UC` and `ICU_I18N` for
  private link libraries and use the proper `SWIFT_${sdk}_ICU_*` values.
* NDK r13 removes a subdirectory from the llvm-libc++ includes path.
  Adapt to this change, and add a FIXME to address this issue before it
  may break again.
* Update the documentation to point to a new libicu download for NDK 13.
2016-10-24 15:17:20 -07:00
K Staring
97d3fbaffb change some variables to make it more clear - when comparing with swift/master - what exactly changed. In short: the first loop used ${MODULE} in uppercase when setting the INCLUDE paths, while the second loop used ${MODULE} in lowercase to retrieve the INCLUDE paths. This can't have worked. Also, there was a discrepancy for the first and second loop where *_INCLUDE_DIR vs *_INCLUDE_DIRS was used. Again, this cannot have worked (just try in the currenct swift/master code, surround the code with some message(STATUS ...) lines) 2016-10-24 08:23:22 +02:00
K Staring
f3b612a835 Merge branch 'master' of https://github.com/apple/swift 2016-10-21 22:37:25 +02:00
K Staring
22c0b4a9c8 fix ICU include paths. Please check this commit and verify that the previous solution simply coudn't have worked *at all*. The usage of slightly differently named variables (e.g. *LIB vs *LIBS) and lower-case module in the include for loop while a TOUPPER variable should have been used, caused the INCLUDE variables to never be filled. Apart from that, a find_package() was missing in the stubs CMakeFiles.txt . 2016-10-21 22:25:19 +02:00
K Staring
419c832cb3 default ld.gold on FreeBSD for as long as the ld linker problem exists on {linux,freebsd} 2016-10-21 22:21:31 +02:00
Michael Gottesman
bfc9f60614 Revert "[cmake] Add the option SWIFT_BUILD_RUNTIME_WITH_HOST_LIBLTO."
This reverts commit 23987b26f3.

I originally thought that I was going to need this for LTO work. Now it is just
dead code.

Even if we were to enable this though it wouldn't fix the underlying issue since
swiftc would still emit bitcode that may be incompatible with the host compiler.

So reverting this makes the most sense.
2016-10-18 13:41:54 -07:00
Brian Gesiak
be5a34e2fd [Android] Enable building static stdlib on macOS
The Swift runtime can be built for Android on Linux host machines using
the instructions in `docs/Android.md`. This commit allows a static build
of the runtime to be compiled on macOS host machines as well.

This work is inspired by @compnerd's work in enabling Windows builds
from macOS hosts. It assumes host tools are already built for macOS. It
also does not support building SDK overlays yet. I intend to support these in a
future commit.

For now, the Android runtime may be built by using the following bash
script, which simply calls CMake:

```sh

set -e
set -x

HOME_DIR="/Users/bgesiak"

APPLE_DIR="${HOME_DIR}/GitHub/apple"
BUILD_DIR="${APPLE_DIR}/build/Ninja-Release"
CMARK_SRC_DIR="${APPLE_DIR}/cmark"
CMARK_BUILD_DIR="${BUILD_DIR}/cmark-macosx-x86_64"
LLVM_SRC_DIR="${APPLE_DIR}/llvm"
LLVM_BUILD_DIR="${BUILD_DIR}/llvm-macosx-x86_64"
SWIFT_BUILD_DIR="${BUILD_DIR}/swift-macosx-x86_64"

ANDROID_NDK_DIR="${HOME_DIR}/android-ndk-r12b"
LIBICU_SRC_DIR="${APPLE_DIR}/libiconv-libicu-android"
LIBICU_BUILD_DIR="${LIBICU_SRC_DIR}/armeabi-v7a"

SWIFT_ANDROID_BUILD_DIR="${APPLE_DIR}/build/SwiftAndroid"

mkdir -p "${SWIFT_ANDROID_BUILD_DIR}"

cmake \
  -G "Ninja" \
  \
  -DCMAKE_C_COMPILER:PATH="${LLVM_BUILD_DIR}/bin/clang" \
  -DCMAKE_CXX_COMPILER:PATH="${LLVM_BUILD_DIR}/bin/clang++" \
  \
  -DSWIFT_PATH_TO_CMARK_SOURCE:PATH="${CMARK_SRC_DIR}" \
  -DSWIFT_PATH_TO_CMARK_BUILD:PATH="${CMARK_BUILD_DIR}" \
  -DSWIFT_CMARK_LIBRARY_DIR:PATH="${CMARK_BUILD_DIR}/src" \
  -DSWIFT_PATH_TO_LLVM_SOURCE:PATH="${LLVM_SRC_DIR}" \
  -DSWIFT_PATH_TO_LLVM_BUILD:PATH="${LLVM_BUILD_DIR}" \
  -DSWIFT_PATH_TO_CLANG_SOURCE:PATH="${LLVM_SRC_DIR}/tools/clang" \
  -DSWIFT_PATH_TO_CLANG_BUILD:PATH="${LLVM_BUILD_DIR}" \
  -DSWIFT_NATIVE_LLVM_TOOLS_PATH:STRING="${LLVM_BUILD_DIR}/bin" \
  -DSWIFT_NATIVE_SWIFT_TOOLS_PATH:STRING="${SWIFT_BUILD_DIR}/bin" \
  \
  -DSWIFT_ANALYZE_CODE_COVERAGE:STRING=FALSE \
  -DSWIFT_SERIALIZE_STDLIB_UNITTEST:BOOL=FALSE \
  -DSWIFT_STDLIB_SIL_DEBUGGING:BOOL=FALSE \
  -DSWIFT_CHECK_INCREMENTAL_COMPILATION:BOOL=FALSE \
  -DSWIFT_STDLIB_ENABLE_RESILIENCE:BOOL=FALSE \
  -DSWIFT_STDLIB_SIL_SERIALIZE_ALL:BOOL=TRUE \
  -DSWIFT_BUILD_PERF_TESTSUITE:BOOL=FALSE \
  -DSWIFT_BUILD_EXAMPLES:BOOL=FALSE \
  -DSWIFT_INCLUDE_TESTS:BOOL=FALSE \
  -DSWIFT_EMBED_BITCODE_SECTION:BOOL=FALSE \
  -DSWIFT_TOOLS_ENABLE_LTO:STRING= \
  -DSWIFT_AST_VERIFIER:BOOL=TRUE \
  -DSWIFT_SIL_VERIFY_ALL:BOOL=FALSE \
  -DSWIFT_RUNTIME_ENABLE_LEAK_CHECKER:BOOL=FALSE \
  \
  -DCMAKE_BUILD_TYPE:STRING=Release \
  -DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE \
  -DSWIFT_STDLIB_BUILD_TYPE:STRING=Release \
  -DSWIFT_STDLIB_ASSERTIONS:BOOL=TRUE \
  -DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER:BOOL=TRUE \
  -DSWIFT_HOST_VARIANT=macosx \
  -DSWIFT_HOST_VARIANT_SDK=OSX \
  -DSWIFT_HOST_VARIANT_ARCH=x86_64 \
  -DSWIFT_BUILD_TOOLS:BOOL=FALSE \
  -DSWIFT_INCLUDE_TOOLS:BOOL=FALSE \
  -DSWIFT_BUILD_REMOTE_MIRROR:BOOL=FALSE \
  -DSWIFT_BUILD_DYNAMIC_STDLIB:BOOL=FALSE \
  -DSWIFT_BUILD_STATIC_STDLIB:BOOL=TRUE \
  -DSWIFT_BUILD_DYNAMIC_SDK_OVERLAY:BOOL=FALSE \
  -DSWIFT_BUILD_STATIC_SDK_OVERLAY:BOOL=FALSE \
  -DSWIFT_EXEC:STRING="${SWIFT_BUILD_DIR}/bin/swiftc" \
  \
  -DSWIFT_ENABLE_GOLD_LINKER:BOOL=TRUE \
  -DSWIFT_SDKS:STRING=ANDROID \
  -DSWIFT_ANDROID_NDK_PATH:STRING="${ANDROID_NDK_DIR}" \
  -DSWIFT_ANDROID_NDK_GCC_VERSION:STRING=4.9 \
  -DSWIFT_ANDROID_SDK_PATH:STRING="${ANDROID_NDK_DIR}/platforms/android-21/arch-arm" \
  -DSWIFT_ANDROID_ICU_UC:STRING="${LIBICU_BUILD_DIR}" \
  -DSWIFT_ANDROID_ICU_UC_INCLUDE:STRING="${LIBICU_BUILD_DIR}/icu/source/common" \
  -DSWIFT_ANDROID_ICU_I18N:STRING="${LIBICU_BUILD_DIR}" \
  -DSWIFT_ANDROID_ICU_I18N_INCLUDE:STRING="${LIBICU_BUILD_DIR}/icu/source/i18n" \
  \
  "${APPLE_DIR}/swift"

cmake --build "${APPLE_DIR}/swift" -- -j8 swift-stdlib-android-armv7
```
2016-10-14 15:31:03 -07:00
Michael Gottesman
b16d4fa505 [semantic-arc] Add build-script option --enable-sil-ownership to turn on the SIL ownership model.
rdar://28685236
2016-10-11 11:29:12 -07:00
Brian Gesiak
d9fe1d0840 Merge pull request #5175 from modocache/cmake-reflection-test-macos-host-android
[stdlib] Only add Apple reflection test targets
2016-10-08 14:47:54 -04:00
Chris Bieneman
40e14e33c4 [CMake] Fix the Xcode generator
In PR 5182 I broke the Xcode generator in cases where the output path had ${CMAKE_CFG_INTDIR} in it. This broke because $(CONFIGURATION) is invalid in the name of a target.

Since all targets will have the same value for CMAKE_BINARY_DIR and CMAKE_CFG_INTDIR we can remove those from the target names and still have unique values.

This has the impact of shortening the generated target names so that the filename components are unlikely to hit OS limits using IDE generators where CMake generates Makefiles or scripts for custom commands. It also retains the debug ability that PR 5182 was attempting to add.
2016-10-07 19:32:37 -07:00
Chris B
370697f9d9 Merge pull request #5182 from llvm-beanz/dont-use-hashes
[CMake] Don't use hashes in target names
2016-10-07 16:36:46 -07:00
Chris Bieneman
85d44735fd [CMake] Don't use hashes in target names
This code was added in the mega-commit 6670bb7 with the commit message "Rewrite the CMake build system", so I'm a little bit light on context here. The comment in the code was:

# Construct a unique name for the custom target.
# Use a hash so that the file name does not push the OS limits for filename
# length.

This seems bunk to me. Since the string being hashed is a filename it seems to me that we don't need a hash to stay under the OS filename size limits. Additionally since output files must be unique using the filename as the unique target name seems like a good idea to me. The only issue here is that custom target names can't contain '/'s. To workaround that we replace the '/' character with '-'.

This patch has the added benefit of having the full filename encoded into the target names, so if you need to debug the build dependency graph you can much more easily walk back from the generated build files to the place in CMake where it was generated.
2016-10-07 13:39:19 -07:00
Chris Bieneman
2dae4322f5 [CMake] Fix codesign dependency (take 2)
This approach side steps the whole dependency issue between the lipo target and the codesign target by just combining them (if needed). This is accomplished by moving the codesign code into `_add_swift_lipo_target` and having it conditional on passing `CODESIGN` as an option.

This patch also updates `_add_swift_lipo_target` to use named arguments instead of positional ones, and provides a little bit of cleanup. There is more opportunity for larger refactoring and cleanup here by not generating a lipo target at all on non-darwin platforms.
2016-10-07 13:09:46 -07:00
Brian Gesiak
c42d0d29b6 [stdlib] Only add Apple reflection test targets
When building on a macOS host, and when `SWIFT_INCLUDE_TESTS` is specified,
the `swiftSwiftReflectionTest` target is added to all platforms.
However, this target has a dependency upon Foundation, which is not
available on non-Apple platforms.

Use `add_swift_library`'s `TARGET_SDKS` parameter and other gating
logic to ensure the target is only added for platforms that actually
have Darwin available.
2016-10-07 15:41:31 -04:00
Brian Gesiak
db1a921605 Merge pull request #5159 from modocache/cmake-set-target-prefix-android
[CMake] Explicitly set Android lib prefix/suffix
2016-10-07 13:23:46 -04:00
Doug Coleman
bf38b865bc Merge pull request #5166 from erg/revert-cmake-codesign
Revert "[CMake] Fix dependency on codesign steps"
2016-10-06 16:41:45 -07:00
Brian Gesiak
1c90753e7b Merge pull request #5160 from modocache/cmake-plist-info-apple-platforms
[CMake] Check target, not host, for Info.plist
2016-10-06 18:26:12 -04:00
Doug Coleman
7d95b6630d Revert "[CMake] Fix dependency on codesign steps"
This reverts commit 10506e00c0.

There are dylibs in lib/swift/macosx/x86_64/ and lib/swift/macosx/, and
with this patch the dylibs in the latter path don't get updated when the
code changes and are stale.

I'm not sure exactly how to correct this patch so let's just try again
when it updates both sets of dylibs.

rdar://28660201
2016-10-06 15:16:59 -07:00
Brian Gesiak
5ef02f69b0 [CMake] Check target, not host, for Info.plist
The CMake variable `APPLE` is set to true when building on a macOS
host, which means that logic to include linker flags for application
extensions, etc., will be enabled on a macOS host. That is, they will
be enabled even when cross-compiling the standard library to a
non-Apple platform, such as Android.

Instead of using `APPLE` to check the host OS, check whether the target
is an Apple platform.
2016-10-06 16:33:01 -04:00
Brian Gesiak
99cad87ea0 [CMake] Explicitly set Android lib prefix/suffix
When compiling the Swift standard library for Android on Linux, the
target prefixes and suffixes for static and shared libraries happen to
be the same for both platforms. When using a macOS host to compile,
however, the suffixes are different, causing build errors.

Explicitly set the prefixes and suffixes to prevent errors when
building on macOS.
2016-10-06 16:23:51 -04:00
Brian Gesiak
47bd025feb [cmake] Use is_darwin_sdk over CMAKE_SYSTEM_NAME
Checking CMAKE_SYSTEM_NAME to append Darwin-specific flags happens to
work when cross-compiling from one Darwinian system to another -- like
using a macOS host to build the standard library for iOS. It doesn't
work, however, when cross-compiling from macOS to Android, for example.

Instead of checking the host system name, check whether the SDK target
is Darwinian.
2016-10-05 11:04:59 -04:00
Brian Gesiak
f653d52fc1 Merge pull request #5101 from modocache/cmake-add-lipo-target-sdk
[cmake] Only add lipo targets for Darwin
2016-10-04 13:39:59 -04:00
swift-ci
95bd36f327 Merge pull request #5068 from modocache/add-swift-cmake-refactor-suffix-prefix 2016-10-03 20:13:48 -07:00
Brian Gesiak
60edee9155 [cmake] Only add lipo targets for Darwin
Swift's CMake build system creates "fat" binaries for Swift libraries,
so long as the host machine used to compile the libraries is a macOS
machine. However, when a non-Darwin target, such as Android, is being
compiled on a macOS host, this doesn't work. Instead, only add lipo
targets if the *target* is Darwin.
2016-10-03 14:23:15 -04:00
swift-ci
6568b2081c Merge pull request #5067 from modocache/add-swift-lipo-target-use-precondition 2016-09-29 14:17:54 -07:00
Brian Gesiak
126aed5abb [CMake] Add library target prefix/suffix in func
Add a function to set library target prefixes and suffixes. When new
targets require setting these prefixes/suffixes, contributors will be
able to modify this one function. NFC.
2016-09-29 16:22:04 -04:00
Brian Gesiak
68c99665b7 [CMake] Use precondition in _add_swift_lipo_target
Use the `precondition` CMake function added in e12fff76fd, rather than
custom logic, to check if arguments to `_add_swift_lipo_target` are not
set.
2016-09-29 15:59:01 -04:00
Brian Gesiak
7fbf5014f0 Merge pull request #4999 from modocache/cmake-in-list
[cmake] Enable IN_LIST compare policy
2016-09-29 15:45:01 -04:00
Chris Bieneman
f89461bf22 [CMake] NFC. Updates based on post-merge feedback
* Ensure LLVM_CMAKE_DIR is always set so it can be used
* Use LLVM_CMAKE_DIR instead of searching the module paths
* Label parameters of cmake_parse_arguments in comments
2016-09-28 22:21:03 -07:00
Brian Gesiak
3123b47602 [cmake] Enable IN_LIST compare policy
Enable CMake policy CMP0057, which allows `if()` statements to use the `IN_LIST`
operator. In addition, simplify several `if()` statements that used the
`list(FIND ...)` operation instead.
2016-09-28 22:35:05 -04:00
Chris B
3f0adbd6fd Merge pull request #5034 from llvm-beanz/fix-swiftshims-dependency
[CMake] Fix bad dependency in symlink_clang_headers
2016-09-28 13:34:06 -07:00
Chris Bieneman
10506e00c0 [CMake] Fix dependency on codesign steps
CMake's ninja generator doesn't apply POST_BUILD steps to phony targets, instead in creates standalone CUSTOM_COMMAND actions for them. The generated CUSTOM_COMMANDS then end up running always because they don't have properly specified dependencies.

This patch changes the code sign step on the lipo commands from being POST_BUILD commands to being standalone commands with properly specified inputs and outputs. It works by appending "-unsigned" to the name of the lipo target and the lipo output on Darwin build and replacing the lipo target with a target that wraps the code sign command.

With this patch re-running ninja on an already built build directory no longer results in re-codesigning all the stdlib dylibs.
2016-09-27 16:17:09 -07:00
Chris Bieneman
58ca217e8d [CMake] Fix bad dependency in symlink_clang_headers
The problem here is a bit complicated. The symlink_clang_headers target creates two symlinks to clang's headers, one under the build directory at lib/swift/clang, and the other under a temporary path.

The one under the temporary path is a bad symlink, and it is only created during the build so that it can be installed. It isn't actually used by the build. Ninja treats the bad symlink as a non-existing file, and since the build rule that creates it has the restat property on it this results in the commands to symlink the clang headers directory running over and over and over again during the build.

This patch prevents that by not generating the bad symlink during the build. Instead we generate it at install time using the LLVMInstallSymlink script that is vended as part of LLVM's distribution.
2016-09-27 15:29:29 -07:00
Michael Gottesman
82cc5cab3d Merge pull request #5005 from gottesmm/specify_lto_object_path_on_macos
Specify lto object path on macos
2016-09-25 02:44:20 -07:00
Michael Gottesman
e338c45964 [lto][cmake] When building with lto on macOS, specify to the linker the path where it should put the generated LTO object file.
This is important so that the object file references in the debug info are
preserved for possible use by dsymutil.

rdar://28062659
2016-09-24 22:38:33 -07:00
Chris Bieneman
239df580bb [CMake] Updates based on post-merge feedback on PR4966
This update addresses feedback from gottesmm.
2016-09-23 18:04:12 -07:00
Chris Bieneman
fde50dcc81 [CMake] Swift target libraries should depend on clang in non-standalone builds
When building non-standalone and using the in-tree clang all TARGET_LIBRARIES should depend on clang. This ensures clang is built before the build tries to use it.
2016-09-23 10:59:08 -07:00
Michael Gottesman
f1ae1f176c Revert "Define swift include build components but dont wire them up" 2016-08-28 15:49:33 -07:00
Michael Gottesman
7e2568dcf0 [cmake-components] Introduce a new API add_swift_host_tool for creating/initializing swift tool targets.
The main action here is to sink the creation of the installation rule for all of
the swift host tools into this API. In a latter commit, I will use this API to
create include and build rules for add_swift_host_tool.
2016-08-28 14:12:14 -07:00
Michael Gottesman
de3a7d78d1 [cmake][swift-components] Introduce SWIFT_{INCLUDE,BUILD}_COMPONENTS
We also validate that each one of the given components sets are actually sets
and in addition are disjoint from each other.

In order to make sure that this is a NFC change, add all components to all 3
variables. This ensures that we preserve normal behavior of generating cmake
targets for all components and building all components by default even when
nothing is passed in to be installed.
2016-08-28 13:32:51 -07:00
Michael Gottesman
a40e4194ec [cmake] Merge swift_configure_install_components into swift_configure_components. 2016-08-28 12:43:33 -07:00