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.
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.
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
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
The two invocations here both had a single parameter passed to it.
Replace it with `add_dependencies` which already actually supports
multiple dependencies specified. Sink the custom wrapper into the
usage location in `AddSwiftStdlib.cmake`.
The host tools do not use ICU, only the standard library does. Remove
the special handling in the host tool path for ICU. This simplifies the
flag computation and allows the ICU handling to be sunk entirely into
the target specific paths.
Convert the out parameters for `_add_host_variant_c_compile_flags` to
use the target as an in-parameter. Doing so allows us to set the
properties on the target directly rather than providing them as out
parameters which then get set subsequently.
Convert the out parameters for `_add_host_variant_link_flags` to use the
target as an in-parameter. Doing so allows us to set the properties on
the target directly rather than providing them as out parameters which
then get set subsequently.
Perform some constant folding, constant value propagation, dead argument
elimination over the flag computation methods. This reduces the
unnecessary parameters and more clearly and succinctly describes what is
happening.
Apply constant value propagation to the host flag variant operations.
This reduces the parameters needed for the invocations and enables
further cleaning in the hopes that we can apply these per-target using
CMake instead.
Merge the single use `_add_swift_host_executable_single` into the
singular site. The host tools are built in a single variant. This
avoids the custom logic for adding multiple variants. Folding this
away will allow further simplifications in order to move towards a
standard CMake build.
Remove some unused parameters for this function. This simplification
will make it easier to merge `_add_swift_host_executable_single` into
`add_swift_host_executable`.
After noticing that also in CMake 3.16 the LINKER: prefix is not
expanded correctly when used in `target_link_options`, prefer to set the
linker parameters in a more verbose way and leave a comment behind on
when this behavior was observed in case we want to change the
implementation later.
Follow up to #29636.
Addresses rdar://problem/59732421