Commit Graph

826 Commits

Author SHA1 Message Date
Vlad Gorlov
62dd6bda10 Android build on macOS Cross-Compile host: Fixes wrong Ninja rules generation. (#25576)
* Fixes wrong Ninja rules generation for Android build on macOS Cross-Compile host.

* PR review fixes.
2019-06-21 17:04:51 -07:00
Saleem Abdulrasool
1ab0008d23 Merge pull request #25523 from drodriguez/android-fix-test-build
[android] LINKER_LANGUAGE needs to be applied to executables too.
2019-06-18 12:35:12 -07:00
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
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
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
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
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
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
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
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
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
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
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
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
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
Saleem Abdulrasool
7e79874e0c build: inline the ICU handling into the CFLAGS handling
Rather than have the ICU handling be pushed down into the library handling, this
will move it into the CFLAGS calulation which was being augmented previously.
It is a cleanup that makes it easier to reason about the flags handling.
2019-04-05 16:05:15 -07:00
Saleem Abdulrasool
7e32c43653 build: append to the computed c_compile_flags
Adjust the `c_compile_flags` variable to ensure that the flags are ordered
correctly.  This is of import for the android build which may end up using
invalid header search path ordering otherwise.  This ensures that the path
for the ICU includes comes after the C++ headers which is necessary in new
C++ releases which shadow math.h
2019-04-05 15:52:51 -07:00
Saleem Abdulrasool
871c9a9418 build: sink the ICU flag handling lower (NFC)
Move the ICU flag handling to the same area as `_c_compile_variant_flags` which
computes the C compile flags.  This allows us to ensure that we order the flags
correctly when they are merged into the `c_compile_flags`.
2019-04-05 15:52:51 -07:00
Alex Langford
4cf2af591d [CMake] Make sure ICU libdir is correctly added to library_search_directories
The CMake variables ${sdk} and ${arch} are only set if
_add_variant_link_flags is invoked from add_swift_target_library calling
_add_swift_library_single. If you get to _add_swift_library_single from
add_swift_host_library, those variables will not be set and subsequent
linking will not find ICU libraries. This was an issue when building
swift host libraries on Android.
2019-04-02 12:11:14 -07:00
Ross Bayer
3acef63892 [Build System: CMake] Add back the missing install_name_dir for the standard library. 2019-04-01 11:19:27 -07:00
Ross Bayer
b0a533aa9a [Build System: CMake] Cleanup the install_name_dir special-casing for XCTest in add_swift_target_library. 2019-03-29 17:27:04 -07:00
Mike Ash
26d44d5214 Properly configure the target library name used by magic-symbols-for-install-name.c. 2019-03-22 11:41:00 -04:00
Michael Gottesman
384882d5f3 Merge pull request #23201 from compnerd/patience-is-not-always-a-virtue
build: introduce and switch to GYB_SOURCES
2019-03-20 13:27:32 -07:00
Saleem Abdulrasool
4b9e9d3164 build: excise the concept of fat libraries
This was used for the swift-reflection-test tool.  Instead of using fat
binaries, use the target binary itself.  This simplifies the build logic
as well as paves the road to sub-builds for each target rather than a
monolithic build as we have today.

Originally, the swift-reflection-test was a host tool that linked
against the target libraries since it was testing the target layout.
Now that the tool has been split into a host and target component
(5ea5bb06a3) and we have target and host
libraries that we can link against appropriately, we do not need to link
against the FAT binary.  Since there was exactly one use of this
functionality, switching that from fat linking to regular linking allows
us to remove this functionality entirely.  Switch to regular linking and
remove the option.
2019-03-12 22:30:20 -07:00
Saleem Abdulrasool
8ed5c1a4bc build: introduce and switch to GYB_SOURCES
This avoids us having to pattern match every source file which should
help speed up the CMake generation.  A secondary optimization is
possible with CMake 3.14 which has the ability to remove the last
extension component without having to resort to regular expressions.  It
also helps easily identify the GYB'ed sources.
2019-03-11 13:48:54 -07:00
Saleem Abdulrasool
533a26a5eb build: remove outdated documentation (NFC) 2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
f9df4cad97 build: remove DEPENDS from add_swift_host_library
Use the appropriate CMake mechanisms for building the libraries.
2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
c1c75a4b2d build: drop LINK_FLAGS from add_swift_host_library
This is not currently being used.  Unfortunately, setting linker options
is difficult until CMake 3.13 which introduced target_link_options.
Prior to that, you needed to do:

set_property(TARGET <TARGET> APPEND_STRING LINK_FLAGS <NEW FLAGS>)

If needed, we could write a helper to provide the target_link_options
interface on earlier CMake versions.
2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
31a5ae7f56 build: remove LINK_INTERFACE_LIBRARIES from add_swift_host_library
Use the appropriate CMake mechanism for building the libraries.
2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
b0005e9f87 build: remove C_COMPILE_FLAGS from add_swift_host_library
Use the appropriate CMake mechanism for controlling flags for building
the code.
2019-03-10 15:38:55 -07:00
Saleem Abdulrasool
ee5ab9e98a build: prevent accidental addition of LINK_LIBRARIES
Protect against LINK_LIBRARIES, directing the developer to
target_link_libraries.  This has no impact on the build currently.
2019-03-09 20:44:41 -08:00
Doug Gregor
c94da3b4da [CMake] Set -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 for runtime/overlays
Whenever we're building C++ code as part of the Swift runtime or overlays,
disable the ABI-breaking checks. We are only using header content from
LLVM's ADT library.

Fixes rdar://problem/48618250.
2019-03-06 17:21:17 -08:00