Commit Graph

792 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis
a3095e71aa [AddSwift.cmake] Unbreak non-assertions build
Fails to build with "error: macro name must be an identifier" due to trying to pass `-D-DNDEBUG` as compiler argument.
2021-05-21 21:57:48 -07:00
Michael Gottesman
53a7ccafba [cmake] Allow for add_swift_host_libraries to set that they shouldn't use llvm update flags.
This is specifically important for host libraries that include swift
content. llvm_update_compile_flags currently doesn't conditionalize the flags it
adds since it needs to be updated like I updated Swift's cmake in
558c9d4086.

In the short amount of time that I am dealing with upstream to patch those
flags, this patch will unblock eeckstein and let him continue with his libswift
work.
2021-05-21 15:20:30 -07:00
Michael Gottesman
245905d161 [cmake] Allow for host libraries to be object libraries by letting add_swift_host_library take an OBJECT parameter. 2021-05-21 15:20:30 -07:00
Michael Gottesman
0c1d8a6c6f [cmake] Enable cross-module-optimization when compiling swift libraries in release/relwithdebinfo. 2021-05-20 13:57:04 -07:00
Michael Gottesman
bc6dbd4a09 [cmake] Force the linker_language of host executables to be CXX.
In certain cases our executables are going to have a mix of cxx,swift. There are
current issues when linking cxx,swift code with swiftc itself, so this lets us
avoid that problem.
2021-05-20 13:57:04 -07:00
Michael Gottesman
7e439eed09 [cmake] For now when compiling host swift code into a library, put -gnone to prevent the driver from running dsymutil on static libraries.
Work around for this problem until rdar://78271443 (which tracks the underlying
issue) lands so this no longer happens.
2021-05-20 13:57:04 -07:00
Michael Gottesman
95aeaf7b64 Merge pull request #37510 from gottesmm/pr-af6b60d3b83155f33bb1d91e497422748ddcc917
[cmake] Use generator expressions to change conditionalize target_compile_definition that are for c/c++ only be used for c/c++
2021-05-19 19:01:57 -07:00
Michael Gottesman
558c9d4086 [cmake] Use generator expressions to change conditionalize target_compile_definition that are for c/c++ only be used for c/c++
I am in the process now of preparing the tree for the addition of Swift code in
the optimizer as a normal source of source file. The goal is to make it so that
one can just include a random swift library anywhere in the swift project host
build and the cmake will use the swift compiler from the host
toolchain/compile-link the code just as if it was a normal host side thing (1).

In order to do this though, we need to deal with the legacy of our cmake
creating compile flags without constraining the flags to only being used if
cmake is compiling c/c++ code. To fix this, I just inserted generator
expressions into the host side swift build's cmake that uses generator
expressions to perform such conditionalization. The result is that the parts of
a target that are c/c++ will get these flags, but these flags will not propagate
to any Swift files that we add.

(1) With time this implies that we will need to be able to bootstrap the swift
compiler. We are not crossing that bridge now since the only places that we are
going to use this today is in the SILOptimizer optimier passes. These can always
be disabled while cross compiling, meaning that we can make progress here
without having the bootstrapping completely ironed out.
2021-05-19 14:46:36 -07:00
Michael Gottesman
9412f19802 [cmake] Change set_swift_llvm_is_available to set definitions on a specific target.
Otherwise we set it on all targets/languages in a subdirectory (I forgot if it
propagates up). Regardless, this type of viral stuff is something we want to
move away from since it creates a code that is a "forall" piece of code rather
than a piece of code that only effects a single target.

I also conditionalized the actual definitions being added on the compiled file's
language being C,CXX,OBJC,OBJCXX since as we add Swift sources to the host side
of the compiler, we will not want these flags to propagate to Swift sources.
2021-05-19 13:22:02 -07:00
Dario Rexin
1ae371b470 Re-add dependency on libatomic for 32-bit Linux platforms (#36659) 2021-03-31 13:31:58 -07:00
buttaface
e6f5913772 [android] Move to the NDK's unified sysroot (#34491)
Since the NDK removes the platforms/ and sysroot/ directories in the latest NDK
22, switch to the unified sysroot in toolchains/llvm/ and take advantage of a
bunch of simplification that's now possible.
2021-02-07 09:19:18 -08:00
Varun Gandhi
36b589d623 Merge pull request #35538 from mininny/disable-dead-stripping-option
[build-script] Add swift-disable-dead-stripping option for disabling dead stripping
2021-01-31 16:31:48 -08:00
Erik Eckstein
adae4d7dc7 cmake: another fix for include all header files in Xcode projects.
Header files from within the lib directory were missing.
Also: use get_filename_component instead of regex matching.
2021-01-29 20:48:33 +01:00
Erik Eckstein
3c90576db0 cmake: fix Xcode project generation to include all header files.
This was broken by commit cf1f240534.
This commit reverts the 2 lines which broke the inclusion of header files in the generated Xcode project.
2021-01-29 16:29:08 +01:00
Minhyuk Kim
b0426829fe Add swift_disable_dead_stripping option for disabling dead stripping in Swift build 2021-01-22 23:56:02 +09:00
Robert Widmann
b436825948 Trade Usages of -m${platform}-version-min For -target
There's no reason to use -m${platform}-version-min as of clang-11/Xcode 11. Clang is now smart enough to parse -target and provide Apple's ld with the appropriate -platform_version argument string.
2021-01-13 11:00:39 -08:00
John McCall
c346d94655 Fix the build and implementation of the 16-byte atomics for MSVC.
Credit for the cmake fix here goes to Saleem Abdulrasool.

The substantive fix is embarrassing; I didn't pay close attention
to the intrinsic's argument order and just assumed that the first
argument for the replacement value was the low half (the part
you'd find at index 0 if it were an array), but in fact it's the
high half (the part you'd find at index 1).

I also change the code to be much more reinterpret_casty, which
isolates the type-punning mostly "within" the intrinsic, and
which seems to match how other code uses it.
2020-12-04 01:51:29 -05:00
John McCall
ca16548470 Add a swift::atomic<T> which uses a better ABI than MSVC's 128-bit std::atomic. 2020-12-02 18:47:02 -05:00
Michael Gottesman
86b7bac395 Merge pull request #34023 from buttaface/rpath
[linux] remove absolute rpath of /usr/lib/swift/linux added to many shared libraries
2020-10-19 12:02:32 -07:00
Saleem Abdulrasool
563c99bc7c Merge pull request #34160 from buttaface/arm
[android] Add support for building the toolchain for ARMv7
2020-10-04 14:40:44 -07:00
Butta
f7576a7bef [android] Add support for building the toolchain for ARMv7 2020-10-03 18:55:23 +05:30
John McCall
e1004499c4 [NFC] Split ProtocolDispatchStrategy out of MetadataValues.h.
This allows us to avoid rebuilding most of the compiler
whenever we add a new ABI constant.
2020-10-03 02:26:17 -04:00
Butta
69d04aad08 [linux] remove absolute rpath of /usr/lib/swift/linux added to many shared libraries
This was presumably added as a backup, in case the libraries in a toolchain
couldn't be found, but will not work well, so take it out.
2020-09-25 23:07:14 +05:30
Kuba (Brecka) Mracek
d9d929a594 Revert "Start using optimization (-O0/-O2/-O3/-Os) and debug (-g) flags from CMAKE_CXX_FLAGS_${CFLAGS_BUILD_TYPE} (#33388)" (#33924) 2020-09-11 21:06:05 -07:00
Kuba (Brecka) Mracek
28a2826ef4 Start using optimization (-O0/-O2/-O3/-Os) and debug (-g) flags from CMAKE_CXX_FLAGS_${CFLAGS_BUILD_TYPE} (#33388) 2020-08-17 19:26:24 -07:00
Kuba (Brecka) Mracek
f91fe9c0c1 Use SWIFT_SDK_${prefix}_USE_ISYSROOT to select which SDKs should be building with -isysroot (#33469) 2020-08-14 14:33:28 -07:00
Kuba (Brecka) Mracek
ef89b0dc51 Add a 'standalone_minimal' preset to build a minimal, static, OS independent, self-contained binaries of stdlib. (#33286) 2020-08-12 07:28:34 -07:00
Eric Miotto
6fdcfb0ebf [build] remove support for embedding bitcode in host libraries (#32730)
We are more interested in generating bitcode for the standard library.

Addresses rdar://64952135
2020-07-07 13:46:19 -07:00
Eric Miotto
e80b188213 [build] Add LTO flag to link options (#32683)
Following the refactoring in #31612, LTO flag was only added to compile
flags -- we need to pass this only when linking.

Addresses rdar://65037856
2020-07-02 14:44:37 -07:00
Eric Miotto
d285123c0a [build] Pass target to linker for host tools for Apple SDKs (#32618)
As part of this refactor some code touched as part of #31794 to better fit into the work done in #32120 -- in detail

* `_add_host_variant_c_compile_link_flags` is now invoked by both add_swift_host_library and add_swift_host_library
* `_add_host_variant_c_compile_link_flags` now sets the target in linker arguments when building against Apple SDKs

Addresses rdar://64911978
2020-07-01 11:01:14 -07:00
Saleem Abdulrasool
10d15b8bad build: switch gyb to Python3
Change the build system to invoke gyb with python3 instead of python2.
2020-06-19 11:03:31 -07:00
Saleem Abdulrasool
dc1624dee0 build: style updates (NFC)
Adjust the CMakeLists.txt to match the rest of the usage.
2020-06-06 14:00:50 -07:00
Saleem Abdulrasool
f9128bac81 build: use the same pattern for detecting Darwin platforms
The host platform should be using `CMAKE_SYSTEM_NAME STREQUAL Darwin`.
However, we currently drive the host side of the compilation against
custom variables.  This makes the migration simpler by ensuring that the
entire file uses the same pattern.

Since `is_darwin_based_sdk` is now used only in the standard library
build, sink it to the standard library build.
2020-06-04 08:39:59 -07:00
Saleem Abdulrasool
f5a75dcefd build: simplify macOS path (NFC)
It does not make sense to use the `cl` frontend to clang to build for
macOS.  Remove the unnecessary condition and always perform the
operation.
2020-06-01 08:40:03 -07:00
Saleem Abdulrasool
1cc6698ae6 build: remove unnecessary CXX_STANDARD for Windows
The entire project is now at C++14.  Windows had to adopt C++14 earlier
to support processing the Windows SDK headers.  This is no longer
necessary, adopt the global settings instead.
2020-05-30 15:26:02 -07:00
David Zarzycki
3767ece85c [CMake] Simplify two binary variables into one tri-state variable
Also remove some ancient logic to detect and ignore requests to use LLD.
If people want to explicitly use LLD, they probably have a reason and we
shouldn't second guess them.
2020-05-28 06:08:03 -04:00
Saleem Abdulrasool
79bed6c4a7 Merge pull request #31481 from compnerd/not-everything-that-glitters-is-gold
build: default the lld/gold enabling as per reality
2020-05-23 19:42:24 -04:00
Eric Miotto
0c403fe766 [build] Pass target argument to the linker if needed (#31794)
Following #31125 and #31612, `-target` is not added automatically to
linker flags when that's needed (e.g. when building for Apple SDKs) --
mimic the logic used to add it for compiler flags.

Addresses rdar://63138761
2020-05-18 08:14:59 -07:00
Dario Rexin
32a189c281 Merge pull request #31329 from compnerd/host-library-handling
`add_swift_host_library` cleanup
2020-05-12 12:23:38 -07:00
Dario Rexin
a554f088d6 Merge pull request #31612 from compnerd/out-in
build: convert out parameter to target
2020-05-11 21:50:12 -07:00
Saleem Abdulrasool
84a7882419 build: add file dependencies for gyb
Add dependencies on the files for gyb to ensure that updates gyb are
treated as triggers to regenerate the files.  This is suspected to have
caused issues for incremental builds.
2020-05-07 12:33:04 -07:00
Saleem Abdulrasool
f03cd0e9a8 build: convert out parameter to target
Rework `_add_host_variant_c_compile_link_flags` to apply the flags
directly rather than to compute the value and have the caller apply.
2020-05-06 22:03:13 -07:00
Saleem Abdulrasool
d1f798bedb Merge pull request #31548 from compnerd/analytical-methods
build: remove `ANALYZE_CODE_COVERAGE` from `_add_host_variant_c_compi…
2020-05-06 17:18:20 -07:00
Saleem Abdulrasool
58fc3c5920 build: remove explicit link against atomic
This is no longer required after the fix for the over-aligned type for
the atomic type.
2020-05-05 08:50:34 -07:00
Saleem Abdulrasool
d5c2bc20db build: remove ANALYZE_CODE_COVERAGE from _add_host_variant_c_compile_link_flags
This flag does not make sense here as this function is called from
`_add_host_variant_link_flags` and `_add_host_variant_c_compile_flags`.
The latter will add the flags appropriately.  The former is always
invoked *after* `_add_host_variant_c_compile_flags`.  This effectively
was duplicating the flags.
2020-05-04 16:06:29 -07:00
Saleem Abdulrasool
c6cc769a64 build: default the lld/gold enabling as per reality
Rather than defaulting both of these to true, enable gold by default
only on ELFish targets, and enable LLD by default for Windows on
non-Windows hosts.
2020-05-01 13:56:57 -07:00
Saleem Abdulrasool
d6b43e4b6f build: clean up the mac catalyst flag handling in the host
The toolchain does not actually use any catalyst flavor, which resulted
in these paths actually being dead.  Cull them except for the one path
which simply computes the target triple.
2020-05-01 13:19:59 -07:00
Saleem Abdulrasool
cf1f240534 build: cleanup some of the organization in add_swift_host_library
This is just a cleanup of the implementation of
`add_swift_host_library`, reorganizing the flag computation and
application as well as the property setting.
2020-05-01 12:59:44 -07:00
Saleem Abdulrasool
62a4bd67d6 build: inline _add_swift_host_library_single
This function is used at one site and is an internal function.  Host
libraries are always built in a single configuration, just inline it to
avoid unnecessarily reparsing arguments.
2020-05-01 12:59:44 -07:00
Saleem Abdulrasool
e6f2e6257f build: de-GYB_SOURCES the host tools
Use a newly introduced `swift_gyb_target_sources` to gyb and use the
generated sources when building.  Let CMake figure out when to run the
command, let it invoke the command properly, and indicate that the
sources being added to the target are generated.
2020-04-19 10:24:40 -07:00