Commit Graph

506 Commits

Author SHA1 Message Date
Slava Pestov
23b2a4ace8 Merge pull request #6462 from hughbe/libraries-windows
Fix linking libraries on Windows
2017-01-10 22:31:36 -08:00
Michael Gottesman
c9a6532e08 [cmake] Add support for generating targets for a -Onone sib stdlib and a -O sib stdlib, but do not build them by default.
This is useful for engineers who do not want to reconfigure to look at a
-Onone/-O sib stdlib.
2017-01-09 16:39:23 -08:00
Hugh Bellamy
cceba6c09b Fix library_IMPLIB-NOTFOUND errors building Swift on Windows 2017-01-09 14:47:05 +00:00
Slava Pestov
16b20cadd8 Merge pull request #6466 from hughbe/empty-sdk-windows
Don't pass empty "/" SDK path to the swift compiler when compiling the stdlib
2017-01-09 01:45:52 -08:00
Slava Pestov
cc867af8e1 Merge pull request #6498 from hughbe/windows-dependencies
Fix Windows dependency library names
2017-01-09 01:02:30 -08:00
swift-ci
982b711dd4 Merge pull request #6488 from gonzalolarralde/link-paths-issue 2017-01-07 11:40:42 -08:00
swift-ci
e265cc684a Merge pull request #6499 from hughbe/lib-prefix-stdlib 2017-01-03 17:09:17 -08:00
Hugh Bellamy
464fee9110 Remove lib prefix from Windows stdlib libraries 2016-12-27 14:12:53 +00:00
Hugh Bellamy
d90b3afeb0 Fix Windows dependency library names 2016-12-27 14:08:23 +00:00
Gonzalo Larralde
e85e9e1029 Fix swift_target_link_search_directories issue appending just the last directory.
STLD_FLAGS wasn't being appended, but replaced.
2016-12-26 18:11:55 -03:00
Gonzalo Larralde
b057252400 Use linking directories from _add_variant_link_flags in _add_swift_executable_single.
Linking directories from `_add_variant_link_flags` of were overwritten
in `_add_swift_executable_single` by not using the
`LIBRARY_SEARCH_DIRECTORIES` parameter.
2016-12-26 18:11:39 -03:00
Gonzalo Larralde
b3477823f6 Improved naming for _add_variant_link_flags's parameter for library search directories.
`LIBRARY_SEARCH_DIRECTORIES` is actually being used as
`RESULT_VAR_NAME` to affect the value on the parent scope. In this
context `LIBRARY_SEARCH_DIRECTORIES_VAR_NAME` sounds like a better name.
2016-12-26 18:11:06 -03:00
Jordan Rose
fdd02f61d3 [CMake] Stop linking CoreFoundation into swiftc and libobjc into everything.
We link the stdlib against Foundation and that's quite sufficient for the REPL
and script mode to work.
2016-12-22 08:50:13 -08:00
Hugh Bellamy
c94e2a121d Don't pass empty "/" SDK path to the swift compiler when compiling the stdlib 2016-12-22 11:12:41 +00:00
Saleem Abdulrasool
5ec82c73a3 Merge pull request #6354 from compnerd/link-search-path
build: introduce and use `swift_target_link_search_directories`
2016-12-20 10:28:05 -08:00
Saleem Abdulrasool
92a09a0ebe build: ensure that Windows is built without PIC
PIC on windows does not make sense.  All code is position independent.
Currently clang and LLVM do the wrong thing and generate ELF style PIC
code on Windows when `-fPIC` is used.  Add `-fno-pic` to disable that
when cross-compiling to Windows.
2016-12-19 20:44:08 -08:00
Saleem Abdulrasool
f3ffd76c62 Merge pull request #6353 from compnerd/library-names
fix cross-compiled library names
2016-12-19 13:29:12 -08:00
Saleem Abdulrasool
b79b743bac Merge pull request #6350 from compnerd/windows-stdlib-improvements
Windows stdlib improvements
2016-12-18 13:31:56 -08:00
Saleem Abdulrasool
54d5188120 build: collapse a few set_property calls into set_target_properties
Just use a single call to set both properties.  NFC.
2016-12-17 21:11:32 -08:00
Saleem Abdulrasool
6ecef42a45 build: fix invalid variable usage
When the code was refactored, the old variable name `libkind` was left
in a couple of spots.  Update them to `kind`.  Remove unnecessary
quoting which would have exposed this bug.
2016-12-17 21:11:31 -08:00
Saleem Abdulrasool
6ab6d3f532 build: introduce and use swift_target_link_search_directories
Introduce a swift_target_link_search_directories which allows you to
append a search path to the linker.  This interface also allows a tweak
to make the library search directory addition more portable across
compilers (e.g. cl vs clang).
2016-12-17 21:09:58 -08:00
Michael Gottesman
7f06ef40dc [cmake] Instead of using EMIT_SIB to generate sib output, just generate targets
for sib/sibgen files for libraries without building them by default.

This will let engineers just cd into the build directory and type:

ninja swift-stdlib-sib
ninja swift-stdlib-sibgen

To generate sib and sibgen files respectively.

There are still some dependency issues in between the sib targets, so to get
this to work well, I would suggest doing a full build and then using these
targets.
2016-12-17 18:38:32 -08:00
Saleem Abdulrasool
980eb7a250 build: specify the Windows family when building for Windows
`_pipe` is only available in the Desktop App family.  Indicate to msvcrt
that we wish to use the desktop app family windows APIs.
2016-12-17 16:36:04 -08:00
Saleem Abdulrasool
90b329b6aa Merge pull request #6219 from compnerd/icu-include-flags
build: treat ICU includes as system headers
2016-12-12 13:45:06 -08:00
Saleem Abdulrasool
fbb60f8a4b build: treat ICU includes as system headers
These headers should be treated as system headers as we do not control them.

Use target_include_directories so that we can use the `SYSTEM` option to
indicate that they are system headers.  It also simplifies the invocation by not
directly modifying the underlying property.
2016-12-11 22:11:23 -08:00
Saleem Abdulrasool
24644ceef3 build: ignore non-standard C warnings on Windows
Silence a warning from Microsoft's ucrt due to use of the POSIX name (strdup).
2016-12-11 21:34:48 -08:00
Jordan Rose
26d8a9f649 [CMake] Don't pass -embed-bitcode to module generation commands. (#6109)
These are the commands Pete added in 5834df3, doing slightly more work
by compiling Swift sources twice in order to start building downstream
libraries sooner.

Really, we should diagnose when -embed-bitcode is passed here, instead
of generating nonsense commands and then falling over. I filed
https://bugs.swift.org/browse/SR-3352 for that.

rdar://problem/29537164
2016-12-06 16:42:48 -08:00
Simon Evans
1daa3ee1f8 [SR-648] Add option to create statically linked binaries
- Add ImageInspectionStatic.cpp to lookup protocol conformance
  and metadata sections in static binaries

- For Linux, build libswiftImageInspectionShared.a and
  libswiftImageInspectionStatic.a for linking with libswiftCore.a.
  This allows static binaries to be built without linking to
  libdl. libswiftImageInspectionShared (ImageInspectionELF.cpp) is
  automatically compiled into libswiftCore.so

- Adds -static-executable option to swiftc to use along with
  -emit-executable that uses linker arguments in
  static-executable-args.lnk. This also requires a libicu
  to be compiled using the --libicu which has configure options
  that dont require libdl for accessing ICU datafiles

- Static binaries only work on Linux at this time
2016-11-29 13:36:19 +00:00
Doug Coleman
dcb9b39ff5 Merge pull request #5821 from rintaro/cmake-depends-handle_swift_sources
[CMake] Add DEPENDS to dependencies for compiling sources.
2016-11-17 16:47:40 -08: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
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
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +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
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
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
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