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.
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.
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.
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.
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.
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
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`.
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.
This is needed as SwiftSyntaxParser also needs to be built with clang as
it uses blocks unconditionally. However, building with cl provides much
better diagnostics and debugging as well as a significantly faster
build (~15-20% faster) as well as a faster compiler.
I also removed the -verify-sil-ownership flag in favor of a disable flag
-disable-sil-ownership-verifier. I used this on only two tests that still need
work to get them to pass with ownership, but whose problems are well understood,
small corner cases. I am going to fix them in follow on commits. I detail them
below:
1. SILOptimizer/definite_init_inout_super_init.swift. This is a test case where
DI is supposed to error. The only problem is that we crash before we error since
the code emitting by SILGen to trigger this error does not pass ownership
invariants. I have spoken with JoeG about this and he suggested that I fix this
earlier in the compiler. Since we do not run the ownership verifier without
asserts enabled, this should not affect compiler users. Given that it has
triggered DI errors previously I think it is safe to disable ownership here.
2. PrintAsObjC/extensions.swift. In this case, the signature generated by type
lowering for one of the thunks here uses an unsafe +0 return value instead of
doing an autorelease return. The ownership checker rightly flags this leak. This
is going to require either an AST level change or a change to TypeLowering. I
think it is safe to turn this off since it is such a corner case that it was
found by a test that has nothing to do with it.
rdar://43398898
A typo snuck into the cross-compiling path and due to the machine that it was
tested on hvaing `/bin/llvm-tblgen`, the build succeeded. Correct the typo to
ensure that we use the correct tblgen.
I have been meaning to do this change for a minute, but kept on putting it off.
This describes what is actually happening and is a better name for the option.
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.
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.
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.
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.
The previous commit resulted in multiple targets that claimed to be
able to generate the directories in question. Instead, just create the
directories as a pre-build step for the targets that actually need
them. (This does keep the cleanup for the existing directory creation
target, though.)
More https://bugs.swift.org/browse/SR-10029
The way it was set up before worked for Ninja but not for Xcode, due
to me not listing the swiftmodule directories as actual outputs of the
create-directories target. The resulting fix here is actually simpler
and involves fewer processes anyway, so good for us.
https://bugs.swift.org/browse/SR-10029
* Enable linker dead stripping on Darwin
See r://48283130. This shaves 6MB+ off of swift and SourceKitService,
26.8MB off of swift-llvm-opt, 29.4MB off sil-passpipeline-dumper, etc.
* Disable dead stripping in Debug builds
It can hide linker errors caused by dependency cycles.
Unfortunately, `swift-reflection-test` links against the *TARGET*
library `swiftRemoteMirror`. The linked library is built as a target
library, which means that we use the custom library target construction
which suffixes the target with a variant spelling. Because the number
of variants is really high, we pass along the explicit EXPORTS macro
manually. However, we also build the library as a static library for
the *HOST*. This means that we need the sources to be aware of whether
they are built statically or dyanmically. This is accomplished by means
of the `_WINDLL` macro. The target library is shared and is built using
the custom wrapper for the library construction, which will create all
the variants and then use `_compute_variant_c_flags` which does not get
told what type of library is being built, so it assumes static and does
not append `_WINDLL`. This results in the shared library not exposing
any interfaces on Windows. When this happens, link will helpfully elide
the import library. The result of that is that the
swift-reflection-test binary will fail to link due to no import library
for the RemoteMirror. Explicitly add the -D_WINDLL if appropriate
manually after we have computed the C flags. *siiiiiiigh*
CMake defaults to using a special <package>_DIR for finding packages.
Prefer this to import the CMake package for LLVM/Clang/Swift rather than
custom paths.