Commit Graph

303 Commits

Author SHA1 Message Date
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 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
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
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
Jordan Rose
aaebfc11c0 [CMake] Derive module names from target names rather than source file names. (#4494)
This will remove the restriction that overlays always need to have a source
file matching the name of the framework, at the "cost" of standardizing the
"swiftFoo" convention for libraries with a module named "Foo". (Until
someone exposes the MODULE_NAME setting at the add_swift_library level.)

If this passes all tests, a follow-up commit will adjust the names of
some of the source files in stdlib/.

rdar://problem/17535693
2016-08-26 09:08:26 -07:00
Michael Gottesman
b3819c6783 [cmake] Rename COMPONENT_DEPENDS to LLVM_COMPONENT_DEPENDS (#4311)
Now that I am going to be adding an IN_SWIFT_COMPONENT argument, I need to do
this to distinguish the concepts of an LLVM_COMPONENT and a SWIFT_COMPONENT.
2016-08-16 12:13:34 -04:00
Dmitri Gribenko
1d6b08ba97 stdlib: share the Unicode dataset across different test files 2016-08-07 23:29:24 -07:00
Luke Larson
4c421c5fd9 Ad-hoc sign stdlib dylibs
rdar://problem/27432896
2016-07-28 16:13:23 -07:00
Saleem Abdulrasool
5e170ebcb5 build: support cross-compiling to windows 2016-07-13 21:37:04 -07:00
swift-ci
7ae2ea26cc Merge pull request #3434 from gottesmm/create_add_swift_subdirectory 2016-07-10 00:30:12 -07:00
Michael Gottesman
23987b26f3 [cmake] Add the option SWIFT_BUILD_RUNTIME_WITH_HOST_LIBLTO.
Currently when we build with bitcode, we use the liblto that we just built,
despite the fact that we just compiled the runtime with the host clang. Really,
we should be consistent.

In the short term to unblock LTO (which wants to use the host liblto), provide
an option to use the host liblto but leave it off so that the normal behavior is
preserved.
2016-07-09 23:46:32 -07:00
Michael Gottesman
224d76391c [cmake] Follow LLVM/Clang's example and use add_llvm_subdirectory and invoke add_llvm_subdirectory when adding tools/libs. This allows us to selectively disable the building of tools by setting the variable SWIFT_{TOOL,LIB}_XXX_BUILD=OFF.
This is done by introducing the macros: add_swift_{lib,tool}_subdirectory.
2016-07-09 21:24:20 -07:00
Michael Gottesman
29ddcd8fb7 Merge pull request #3413 from gottesmm/cmake-refactor-xcode-support
Cmake refactor xcode support
2016-07-09 20:59:33 -07:00
Dmitri Gribenko
1302449935 Merge pull request #3411 from compnerd/target-sdk-aliases-and-exclusions
Target sdk aliases and exclusions
2016-07-08 14:10:16 -07:00
Brian Gesiak
c7b21e32f2 Merge pull request #3390 from modocache/3316-add-module-depends-android
[CMake] Expand SWIFT_MODULE_DEPENDS_* to Android
2016-07-08 15:10:34 -04:00
Michael Gottesman
b42b7f43d8 [cmake] Combine apply_xcode_substitutions and escape_llvm_path_for_xcode into a better escape_path_for_xcode that can be reused across cmake. 2016-07-08 09:51:18 -07:00
Michael Gottesman
0e95abd35c [cmake] Move SwiftApplyXcodeSubstitutions.cmake => SwiftXcodeSupport.cmake.
As an additional fix, this moves the include of SwiftXcodeSupport to the one
place where its functionality is used, AddSwift.cmake. Keeping the include in
./CMakeLists.txt makes it seem like the functionality is needed there (when it
is not).

In a subsequent commit, I am going to refactor the xcode support I have been
adding to SwiftSharedCMakeConfig into this file and have SwiftSharedCMakeConfig
import it.
2016-07-08 09:51:18 -07:00
Saleem Abdulrasool
b4960195c1 build: support aliases for TARGET_SDKS
Introduce two new aliasees `ALL_POSIX_PLATFORMS` and `ALL_APPLE_PLATFORMS`.  The
latter expands to iOS, tvOS, watchOS, macOS and if relevant, the simulators.
The former expands to the same list as `ALL_APPLE_PLATFORMS` as well as Linux
and FreeBSD.
2016-07-08 09:38:02 -07:00
Brian Gesiak
3d566a358b [CMake] Expand SWIFT_MODULE_DEPENDS_LINUX to Android
2633a0f3 expanded SWIFT_MODULE_DEPENDS_* to treat Linux and FreeBSD
separately. Android needs the same treatment as Linux, so expand the
Linux check to include Android as well. These changes fix an Android
build error, in which Glibc was not linked to private stdlib libraries
that relied upon it.
2016-07-08 08:00:11 -07:00
practicalswift
9a8bbe0014 [gardening] Fix recently introduced typos. 2016-07-07 13:14:25 +02:00
Saleem Abdulrasool
34dce93062 Merge pull request #3316 from compnerd/multiple-platforms
stdlib: build multiple platform libraries simultaneously
2016-07-06 21:25:47 -07:00
Saleem Abdulrasool
3d174c372a stdlib: be more DLL friendly on Windows
When the standard library is built dynamically on COFF targets, the public
interfaces must be decorated in order to generate a proper DLL which can be
confused by the dependent libraries.  When the exported interface is used, it
must be indirectly addressed.  This can be done manually in code or the MS
extension of `__declspec(dllimport)` may be used to indicate to the compiler
that this symbol be addressed indirectly.  This permits building more pieces of
the standard library dynamically on Windows.
2016-07-06 17:51:31 -07:00
Saleem Abdulrasool
2633a0f312 build: expand SWIFT_MODULE_DEPENDS_<TARGET>
Expand the macros to have Linux and FreeBSD specific module depends.  This
enables us to build more libraries unconditionally.
2016-07-05 17:32:38 -07:00
Saleem Abdulrasool
7be43242d1 build: prefer SWIFT_SDK_*_OBJECT_FORMAT
Fix another instance of a SDK target check in favour of the object format check.
2016-07-03 11:36:21 -07:00
Saleem Abdulrasool
970c059d30 build: simplify check using the SDK OBJECT_FORMAT
_OBJECT_FORMAT was added recentlyish for all the SDKs.  Use that property rather
than enumerating all the ELFish targets.  This ensures that the code path is
correct if another ELFish target is ported to.
2016-07-03 10:01:43 -07:00
Harlan
1625d97976 Switch to llvm-profdata's pooled profdata merge (#3281) 2016-07-01 16:45:21 -07:00
Dmitri Gribenko
ad559f9812 Merge pull request #3205 from compnerd/foreign-icus
build: support having more than one ICU in use
2016-06-28 23:23:01 -07:00
Michael Gottesman
1d28c0ac4d [cmake] Refactor two list processing utility functions from AddSwift.cmake => SwiftList.cmake. 2016-06-28 14:19:18 -07:00
Dmitri Gribenko
37b7d3d9ee Merge pull request #3209 from compnerd/dead-code-elimination
build: clean up dead code
2016-06-27 23:13:35 -07:00
Saleem Abdulrasool
1baeed7c26 build: allow experimental selection of lld
Add an option which the user can specify to switch to the lld linker.  Although
this linker is still nascent, it is interesting to permit linking with this.  It
is also an alternative to the BFD linker for COFF targets.  It will allow for a
cross-compilation story for Windows on non-Windows targets.
2016-06-25 12:39:17 -07:00
Saleem Abdulrasool
956503a975 build: clean up dead code
This is not used currently and is unlikely to be needed in the future as well.
Remove the dead code.
2016-06-25 12:37:44 -07:00
Saleem Abdulrasool
4d2593fb95 build: support having more than one ICU in use
This allows us to cross-compile the standard library to foreign targets on a
single host.  The ICU dependencies can be specified on the command line on a
per-target basis.  If one is not specified, we fall back to the default search
path and use that for the other targets.

Special thanks to Dimitri Gribenko for the various hints in getting this wired
up.
2016-06-25 12:35:12 -07:00
Brian Gesiak
f12a1323ce [SR-1738] Allow *only* static libraries to be built
This splits the `--build-swift-stdlib` and `--build-swift-sdk-overlay`
arguments into `dynamic` and `static` variants, which makes the
following build command possible:

```
utils/build-script -- \
  --build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 \
  --build-swift-static-stdlib=1 --build-swift-static-sdk-overlay=0
```

This command produces *only* static libraries for the stdlib, and no
SDK overlay libraries at all. Many other finely-grained build options
are now possible.
2016-06-24 09:18:24 -07:00
Brian Gesiak
8d4bc744c5 [CMake] Android NDK r12 appends ".x" to libgcc dir
The Android NDK r12 release appends a ".x" to the libgcc directory;
it is now:

```
android-ndk-r12/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x
```

Update the linker path for the Android build to accomodate this change.
2016-06-22 14:39:28 -07:00
Saleem Abdulrasool
d771054c7b build: use the new object format property
Simplify the ELF checks based on review comments from Dimitri Gribenko.
2016-06-22 09:37:56 -07:00
Saleem Abdulrasool
526127be41 build: only use gold on ELF targets
gold only supports ELF.  This adds two new helper functions
(is_windows_based_sdk and is_elfish_sdk) to ensure that we dont try to use gold
on non-ELF targets.  This comes up when trying to setup cross-compilation for
the standard library for Windows.

The ELF check is implemented as the negation of Darwin (which uses MachO) and
Windows (which uses COFF).  The reason for this is that there are additional
targets which also use ELF.  Rather than enumerating the larger set, enumerate
the smaller set (windows) and use the negation.
2016-06-20 20:54:20 -07:00
Saleem Abdulrasool
6cb73cfdf5 cmake: avoid some duplications by using a helper
Create a helper function to determine if we are targeting a Darwin SDK or not.
The repetition is error-prone and verbose.  Simplify by adding a checking
function.  NFC.
2016-06-20 07:09:21 -07:00
swift-ci
7575e66971 Merge pull request #3068 from compnerd/single-is-crossed 2016-06-20 01:29:29 -07:00
Saleem Abdulrasool
b3ba45758d build: make swift_lib_add_single more amenable to cross-compilation
Use the SWIFTLIB_SINGLE_SDK variable rather than the CMAKE_BUILD_SYSTEM variable
to determine the target type.  This allows us to use the logic for adding
libraries for foreign OSes on a build host.  This is needed to pave the road to
cross-crompiling the standard library for different targets.
2016-06-19 22:21:51 -07:00
Saleem Abdulrasool
985651feca build: use -isystem on non-Darwin targets
The use of `-isysroot` is a Darwin specific behaviour.  It is used to switch to
a platform SDK, however, other targets use the `--sysroot` flag.  Windows uses a
custom mechanism which is a set of system header paths.
2016-06-18 17:47:44 -07:00
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
swift-ci
3de52f4d17 Merge pull request #2985 from gottesmm/thinko_fix_update_unittests_to_use_compute_lto_flag 2016-06-10 15:17:47 -07:00
swift-ci
3826628d81 Merge pull request #2984 from gottesmm/cmake_rename_host_library_to_force_build_for_host_sdk 2016-06-10 14:51:29 -07:00
Michael Gottesman
ee08987896 [lto][cmake] While chopping up patches, I lost an update to AddSwiftUnittests to use _compute_lto_flag.
rdar://24717107
2016-06-10 14:31:42 -07:00
Michael Gottesman
034441a782 [cmake] Rename the variable HOST_LIBRARY => FORCE_BUILD_FOR_HOST_SDK in add_swift_library.
HOST_LIBRARY is supposed to mean "no matter what the defaults say, also build
this library for the host". FORCE_BUILD_FOR_HOST_SDK is a less confusing name.
2016-06-10 14:02:55 -07:00
Michael Gottesman
95d926abb0 [lto] Only build host libraries using LTO.
At some point in the future, we may consider using LTO on the runtime/standard
library, but right now is not that time. We are just trying to use LTO to
improve the compile time performance of the compiler itself.

rdar://24717107
2016-06-10 13:33:54 -07:00
Michael Gottesman
db2126c139 [lto][cmake] Do not access SWIFT_TOOLS_ENABLE_LTO directly in _add_variant_{c_compile,variant_link}_flags. Pass it in as an arg instead.
This will allow control on the outside of these calls on whether or not LTO is
enabled. This is necessary for turning off LTO on target libraries.

rdar://24717107
2016-06-10 13:27:42 -07:00