Commit Graph

1635 Commits

Author SHA1 Message Date
Saleem Abdulrasool
8bb91443a9 build: dereference variable for some versions of CMake
CMake quoting is odd and in some versions this would compare the wrong
strings.
2019-06-17 15:07:04 -07:00
Arnold Schwaighofer
5d329464d6 Use thread private key to avoid weak linkage
We use one bit of the third reserved swift private tls key.

Also move the functionality into a separate static archive that is
always linked dependent on deployment target.
2019-06-17 15:03:45 -07:00
Daniel Rodríguez Troitiño
0a27c88163 [android] LINKER_LANGUAGE needs to be applied to executables too.
A previous change did the same change, but only for libraries. The
executables also need to be build to be linked as C to avoid clang++
automatic linking of C++.
2019-06-17 13:47:08 -07:00
Saleem Abdulrasool
5ef3df7c55 build: link to ICU by full path on Android
Use the variable that holds the path to the ICU libraries to link
against ICU rather than hardcoding the names.  This restores control to
the ICU linking to the way that traditional CMake `find_package` based
linking works.
2019-06-14 18:45:12 -07:00
Saleem Abdulrasool
c1c5ee9fa3 build: use LINKER_LANGUAGE to control linking on Android
Rather than using `-nolibstd++` which is not supported by the android toolchain,
use CMake's `LINKER_LANGAUGE` property on the targets.  Since we explicitly link
against the C++ runtime anyways, this avoids the problem of having to remove the
C++ runtime from the link.
2019-06-14 10:36:13 -07:00
Saleem Abdulrasool
d2e85fa285 Merge pull request #25459 from compnerd/what-is-an-executable
build: spell parameter `-fuse-ld=` properly for Windows
2019-06-14 08:04:25 -07:00
Saleem Abdulrasool
bee99a3f4b build: spell parameter -fuse-ld= properly for Windows
We need to pass `-fuse-ld=` `gold.exe` on Windows when targeting
Android.  Given that we do not have a host toolchain for Linux on
Windows currently, do this unconditionally.  This is required for
cross-compiling from Windows to android.
2019-06-13 22:30:42 -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
Saleem Abdulrasool
ad913239ee Merge pull request #25161 from drodriguez/android-backtraces
[android] Basic support for backtraces.
2019-06-10 13:44:51 -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
Saleem Abdulrasool
fcb0ee59ae build: remove ALL_POSIX_PLATFORMS which is no longer used
Cleanup some CMake logic that we no longer need as the entire code base
now builds on all the targets.
2019-06-05 13:58:14 -07:00
Daniel Rodríguez Troitiño
a7025522a4 [android] Basic support for backtraces.
Android doesn't support the GNU backtrace call, but unwind.h is there to
help. The code is a little bit more complicated than a simple backtrace
call, but it is just a callback and the context struct.

Sadly, it seems that -funwind-tables is needed in every piece of code
that the backtrace needs to traverse, which means that at least the
runtime and the stubs need -funwind-tables. However, the flag has been
enabled for all targets (only on Android), just in case some other code
ends up being in the stack. This might only be necessary for ARM
targets, but currently we only build ARM targets in Android. The Swift
parts of the stack seems to have unwind information and can be unwind.

Another problem at the moment is the symbols from the executable are
normally missing. To get symbol names two things need to happen: the
symbol has to be public (so it is an exported symbol, and not just a
local symbol that dladdr seems to not provide the name), and the linker
has to be invoked with -export-dynamic. Without those two pieces, the
addresses are returned (and match the binary just fine), but no names
are printed.
2019-06-05 13:12:04 -07:00
Daniel Rodríguez Troitiño
9498b14af7 Merge pull request #25098 from vgorloff/macos-to-android-crosscompile
Android Intel 32/64 bit (i.e. Android Simulator) support.
2019-06-04 14:10:55 -07:00
Joe Groff
4ed8de10f9 Revert "Revert "Use autolinking to pull in compatibility libraries."" 2019-06-03 20:10:51 -07:00
Joe Groff
a7cc3a38cc Revert "Use autolinking to pull in compatibility libraries." 2019-06-03 14:18:39 -07:00
Ross Bayer
d9409957e0 [Build System: CMake] Check that targets exist before adding them to the global exports. 2019-06-01 17:48:51 -07:00
Joe Groff
dd91bc2180 Install compatibility archive alongside shared libraries.
Although it's a static archive, its use is only relevant to dynamically linked builds of the
standard library. (If you're statically linking a Swift runtime into your process, you don't
need to worry about compatibility with older runtimes.)
2019-05-31 13:11:20 -07:00
Joe Groff
dffd1b27a1 Use autolinking to pull in compatibility libraries.
Many build systems that support Swift don't use swiftc to drive the linker. To make things
easier for these build systems, also use autolinking to pull in the needed compatibility
libraries. This is less ideal than letting the driver add it at link time, since individual
compile jobs don't know whether they're building an executable or not. Introduce a
`-disable-autolink-runtime-compatibility` flag, which build systems that do drive the linker
with swiftc can pass to avoid autolinking.

rdar://problem/50057445
2019-05-31 13:11:14 -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
03dbada12f [Build System: CMake] Convert SWIFT_DARWIN_SUPPORTED_ARCHS and SWIFT_DARWIN_MODULE_ARCHS into semicolon-separated lists rather than space-separated. 2019-05-29 14:39:08 -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
1bc306653c [Build System: CMake] Fix the arch-specific target exporting in add_swift_target_library to export targets for all the defined archs rather than _just_ the last one processed in the foreach loop above. 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
Saleem Abdulrasool
fdf0fa2775 build: improve debug builds on Windows
Ensure that we build all the target libraries with the correct build
configuration.  This is needed on Windows where the different MSVC
runtime libraries are ABI incompatible.
2019-05-18 20:04:09 -07:00
Saleem Abdulrasool
4d5470f905 build: remove unnecessary property sets (NFC)
These properties are extraneous.  They are never queried, and the
`set(...CACHE)` which precedes them will ensure that the value is
cached.  This should be functionally equivalent.
2019-05-17 14:33:19 -07:00
Saleem Abdulrasool
7514adf66a Driver: introduce new -libc option for Windows
On Windows, there are multiple variants of the C runtime that must be
explicitly specified and consistently used from the runtime to the
application.  The new `-libc` option allows us to control the linking
phase by correctly embedding the requested library to be linked.  It is
made into a required parameter on Windows and will add in the
appropriate flags for the imported C headers as well.  This ensures that
the C library is not incorrectly linked.
2019-05-16 21:01:47 -07:00
Ross Bayer
d84e2aa115 [Build System: CMake] Add missing SWIFT_STDLIB_LIBRARY_TYPES to the StandaloneOverlay.cmake module. 2019-05-13 16:26:00 -07:00
Ross Bayer
23a868e9f2 Merge pull request #24382 from Rostepher/usr-lib-install-name-dir
[Build System: CMake] Update the default install_name_dir to /usr/lib/swift for the standard library and overlays.
2019-05-13 15:05:22 -07:00
Ross Bayer
2966af316b [Build System: CMake] Add CMake module paths before importing in StandaloneOverlay.cmake. 2019-05-10 16:39:30 -07:00
Ross Bayer
5c06d77490 [Build System: CMake] Cleanup the StandaloneOveraly CMake module.
Preconditions have been moved to the top of the file. All the variables set have been grouped by kind and a few converted to cache variables for better control when building. This should cut down on merge-conflicts as well."
2019-05-10 15:09:11 -07:00
Saleem Abdulrasool
cd0c1e7150 build: correct flags for Windows build
Adjust the preprocessor macros to get correct DLL Storage for imported
functions.  This should help identify cases of incorrect linkage to
msvcrt/ucrt.
2019-05-09 17:16:51 -07:00
Michael Gottesman
4d4d6f6779 Merge pull request #24508 from compnerd/matchy-matchy
build: rename `LLVM_COMPONENT_DEPENDS`
2019-05-06 11:45:36 -07:00
Saleem Abdulrasool
218b37e1bb build: rename LLVM_COMPONENT_DEPENDS
This is not a target dependency but a target link.  Name the parameter
to be less misleading.  This also makes the name identical to the LLVM
parameter.
2019-05-04 19:58:28 -07:00
Saleem Abdulrasool
f9b304e14b build: obsolete INTERFACE_LINK_LIBRARIES
This was deprecated a while ago, remove support for it.  This is no
longer used in the Swift build.  Remove the dead code.
2019-05-04 18:13:38 -07:00
Saleem Abdulrasool
816dfe23ac build: don't always load clang/cmark
clang/cmark are only needed for the tools, not for the runtime/SDK
overlay.  Do not attempt to configure clang and CMark in the case we do
not build the tools.  This is needed to enable the standalone standard
library only builds.
2019-05-01 22:18:29 -07:00
Saleem Abdulrasool
2e7c328077 Merge pull request #24168 from xiaobai/sink_component_arg
[CMake] Modify swift_install_in_component to support cmake install components
2019-04-30 21:06:32 -07:00
Ross Bayer
316a3b2b9e Merge pull request #24352 from Rostepher/standalone-stdlib-build-type
[Build System: CMake] Convert the SWIFT_STDLIB_BUILD_TYPE variable into a CMake cache variable in cmake/modules/StandaloneOverlay.cmake
2019-04-29 18:30:32 -07:00
Jordan Rose
d20a7ca64e [CMake] Switch to building the overlays in Swift 5 mode (#24350)
Now that that's stabilized, we don't have to keep them in Swift 4 mode
any longer. (Arguably we don't need the CMake variable at all, but it
may be useful again in the future.)

rdar://problem/49040980
2019-04-29 17:55:20 -07:00
Ross Bayer
dfb2d31e74 Rename the LIBRARY_INSTALL_NAME_DIR argument in add_swift_target_library to DARWIN_INSTALL_NAME_DIR which better explains that this argument only controls the install_name_dir for Darwin platforms. 2019-04-29 16:46:09 -07:00
Ross Bayer
bec25a1dad Added a new argument to add_swift_target_library to control the install_name_dir. 2019-04-29 16:46:09 -07:00
Ross Bayer
4cddfccbc1 [Build System: CMake] Convert the SWIFT_STDLIB_BUILD_TYPE variable into a CMake cache variable in cmake/modules/StandaloneOverlay.cmake 2019-04-27 22:44:01 -07:00
Alex Langford
3d9a28925b [CMake] Modify swift_install_in_component to support cmake install components
CMake supports the notion of installation components. Right now we have some
custom code for supporting swift components. I think that for installation
purposes, it would be nice to use the CMake component system.

This should be a non-functional change. We should still only be generating
install rules for targets and files in components we want to install, and we
still use the install ninja target to install everything.
2019-04-19 14:06:11 -07:00
Dave Lee
374c2c82ce [cmake] Fix typo in SWIFT_INCLUDE_DIRS definition 2019-04-17 13:52:49 -07:00
Michael Gottesman
39846a31e8 [cmake] Remove stdlib-experimental from the default install components.
These are mostly private stdlib APIs. It doesn't really make sense to install
private stdlib APIs by default.
2019-04-10 08:33:56 -07:00
swift-ci
7f73f47cb4 Merge pull request #23909 from compnerd/cmake-in-cmake-is-something-something 2019-04-09 16:19:58 -07:00
Saleem Abdulrasool
22859376c6 build: do not search for native LLVM when not building tools
The standard library does not depend on the LLVM libraries at runtime.  Do not
perform the search for the LLVM configuration when the tools are not being
built.  This is needed to permit cross-compiling the standard library standalone
for android on a Linux host without building LLVM and Clang for android.
2019-04-09 12:38:57 -07:00
Saleem Abdulrasool
d3ce6a6da5 build: fix a mixup with the cmake variables
This adjusts the windows build for cross-compiling to use the correct
variable.  Import libraries will be generated and tracked properly if
the CMAKE_SYSTEM_NAME is set to Windows.  It does not matter what the
build system is.
2019-04-09 12:12:27 -07:00
Michael Gottesman
91dbbc3088 Merge pull request #23204 from compnerd/silence-in-the-library
Remove custom handling in add_swift_host_library
2019-04-08 10:49:42 -07:00
Saleem Abdulrasool
a5705d6825 build: add a workaround for reflection test on Windows
Copy the runtime component into the swift runtime directory.  Normally
the runtime directory is not the same as the library directory on
Windows.  This copies the runtime component into the build tree into the
runtime directory to permit the tests to find the standard library.
2019-04-07 14:41:30 -07:00