Commit Graph

52 Commits

Author SHA1 Message Date
Doug Gregor
4da85ea091 Clean up build logic for ASTGen library.
Only introduce it and its dependency when the new Swift parser is being
built, and rely more on existing logic to make sure we get the right
build/link flags.
2022-10-07 10:19:05 -07:00
Doug Gregor
962e330e9a [CMake with Swift] Add toolchain lib path for stage != 0 bootstrapping builds.
Fixes a linker failure where we cannot find the compatibility libraries.
2022-09-27 14:40:21 -07:00
Alex Hoppen
53901f5a22 [Build] Ensure that we link in SwiftSyntax and Swift for SourceKit
This applies the changes from c50b142a14 to AddSwiftSourceKit.cmake.
2022-09-26 17:19:26 +02:00
Josh Soref
436484c8c8 Gardening: Fix spelling mistakes in */SourceKit
* about
* and
* answering
* because
* before
* cancellation
* clear
* comment
* complete
* corresponding
* cursor
* custom
* dependencies
* doesn't
* expression
* extension
* immediately
* implementation
* implicit
* innovation
* intentionally
* occasionally
* oldest
* parameter
* property
* response
* reuseastcontext
* snapshot
* sourcekit_swift_runtime_link_flags
* synchronously
* target
* that
* unlabeled
* usefulness
* work

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-09-21 02:03:25 -04:00
Doug Gregor
b247c6d9f3 Enable build of Swift Swift parser even when bootstrapping is OFF.
The Swift Swift parser doesn't require any bootstrapping, so allow it to
be built even when bootstrapping is off.
2022-09-07 17:52:21 -07:00
Eric Miotto
b6878ce752 Link all compatibility libraries when cross compiling and bootstrapping (#60728)
Refactor the logic so to have a single target to reference the
compatibility libraries for the host, and use that when needed.

The main driver for this change is supporting the cross-compilation of
x86-64 on Apple Silicon.

Supports rdar://90307965
2022-08-31 02:18:19 -07:00
Rintaro Ishizaki
88e1905746 [SourceKit] Link SwiftCompilerModules to SourceKit
This is required for SourceKit to parse Regex literals

rdar://90236990
2022-03-30 09:14:57 -07:00
Saleem Abdulrasool
b6d2c5bc9a Revert "build: add a workaround for CMake[>=3.22] and SourceKit"
This reverts commit 1e5df70d89.

This does not actually impact the build, so revert it to reduce the
complexity in the build.
2021-12-22 10:15:26 -08:00
Saleem Abdulrasool
1e5df70d89 build: add a workaround for CMake[>=3.22] and SourceKit
The switch between compilers causes problems due to new flags being used
for building.  This adds a workaround to avoid the search path
re-ordering which breaks the build with a newer CMake.
2021-12-03 16:26:38 -08:00
Argyrios Kyrtzidis
fcad3802ea [AddSwiftSourceKit.cmake] Add dependency to the module map file due to the custom pre-build command 2021-09-12 16:53:58 -07:00
Ben Langmuir
d7b813b9ef [sourcekit] Identify xpc service by toolchain instead of sdk
rdar://72310494
2020-12-14 13:31:35 -08:00
Ben Langmuir
d4a52b8cb7 [sourcekit] Avoid duplicating implementation of InProc and XPC service when possible
When installing both InProc and XPC versions of sourcekitd, dynamically
link the XPC service to the InProc version. This lets us install both
frameworks without wasting the disk space from having another copy of
the swift frontend statically linked.
2020-11-10 14:31:40 -08: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
Dario Rexin
6290d8c28d Merge pull request #31125 from compnerd/opt-flags
optimize flag computation
2020-05-01 10:16:34 -07:00
Ben Langmuir
e96f98b466 [sourcekitd] Use add_llvm_symbol_exports instead of our old copy
Reduces duplication with llvm and, more importantly, gives us Linux
support via a linker script. This will let us link libsourcekitdInProc
in binaries that have their own copy of llvm symbols on Linux, and let
sourcekit-lsp stop using dlopen with `RTLD_DEEPBIND`, which fixes
running with asan among other things.
2020-04-24 13:41:53 -07:00
Saleem Abdulrasool
123c2b06dc build: convert output variables to target
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.
2020-04-19 10:24:40 -07:00
Saleem Abdulrasool
9873280853 build: convert output variables to target
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.
2020-04-19 10:24:38 -07:00
Saleem Abdulrasool
6de2863468 build: CVP some of the flags handling
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.
2020-04-19 10:23:21 -07:00
Saleem Abdulrasool
87cbb3132d build: duplicate and rename the _add_variant_* functions
This allows us to start splitting up the swift and C/C++ specific paths.
2020-04-11 13:24:31 -07:00
Saleem Abdulrasool
a1c971907b build: repair the Windows build
This should repair the Windows build after #29451.  The quoting
behaviour was incorrect and was constructing an invalid compiler
invocation.  Solve the issue by using `target_include_directories`
instead.  However, since this needs the target, hoist the flag
computation to the local sites.  This replicates more logic because of
the custom build trying to replicate the CMake build logic in CMake.
2020-01-27 22:35:28 -08:00
Saleem Abdulrasool
d8b3b626fe build: use modern target property handling
Use specific operations for setting the compile flags, link flags,
linked libraries, and library search paths.  This allows us to use CMake
more effectively, simplifies the logic, and will ensure that flags are
not duplicated.
2020-01-25 16:08:51 -08:00
Saleem Abdulrasool
d3f72155d8 Merge pull request #29399 from compnerd/sk-rpath
build: move the RPATH handling to the executables
2020-01-24 08:19:27 -08:00
Saleem Abdulrasool
bc21d4ff46 build: move the RPATH handling to the executables
This moves the handling of the RPATH and the exported symbol to the
binary themselves.  The exported symbol is needed due to the use of the
exported symbol list.  This makes the small difference that `_main` is
always exported on Darwin which is not strictly needed in ASAN as ASAN
provides the entry point.

The RPATH is only setup on installation which is sufficient for testing
purposes as CMake ensures that the libraries are fully linked and will
be loaded properly when run from the build tree.
2020-01-23 13:38:22 -08:00
Saleem Abdulrasool
1f961414a5 build: remove support for EXCLUDE_FROM_ALL (NFC)
This parameter is unused.  Simply remove the option from the
`add_swift_sourcekit_executable`.
2020-01-23 12:44:28 -08:00
Michael Gottesman
8d712af965 [cmake] Add support for exporting frameworks/libraries into cmake export files.
I think this was just an oversight. The new cmake 3.16 seems to choke if we do
not add SourceKit to the exports file since there are dependencies upon it in
other swift libraries.
2019-12-18 10:44:55 -08:00
Butta
14cc620016 [android] A few tweaks for native compilation and to get more tests working
Now that CMAKE_HOST_SYSTEM_NAME and CMAKE_SYSTEM_NAME are set by default to
Android in the Termux app, make the needed tweaks. Some tests were adapted
to work natively on Android too, adds sys/cdefs.h to the Bionic modulemap,
and includes the start of native Android platform support in the build-script.
2019-12-07 01:01:59 +05:30
Saleem Abdulrasool
717c4d3ebf SourceKit: remove LINK_LIBS (NFC)
This removes the custom `LINK_LIBS` in favour of
`target_link_libraries`.  This simplifies the custom functions that we
have for adding libraries, makes it easier to query the information from
ninja and will allow us to slowly remove more of the custom logic for
building the products.
2019-11-14 13:41:01 -08:00
Saleem Abdulrasool
2dbb7fae96 build: add a dependency on the just built clang (NFC)
When building in a unified build and building the host tools with a
non-clang compiler, we switch compilers.  In such a case, we need to
actually add an explicit dependency on the new compiler.
2019-10-26 17:17:41 -07:00
Alex Langford
61be4d969f [CMake][NFC] Introduce component targets for proper dependency tracking
This commit introduces a CMake target for each component, adds install targets
for them, and switches build-script-impl to use the target `install-components`
for installation. Each of the targets for each component depends on each
of the individual targets and outputs that are associated with the
corresponding swift-component.

This is equivalent to what already exists, because right now install rules are
only generated for components that we want to install. Therefore, this commit
should be an NFC.

This is a resubmission (with modifications) of an earlier change. I originally
committed this but there were problems with some installation rules.
2019-08-22 10:16:50 -07:00
Ben Langmuir
327c666b8a Revert "[CMake][NFC] Introduce component targets for proper dependency tracking" 2019-08-08 16:35:59 -07:00
Alex Langford
50a0e87c69 [CMake][NFC] Introduce component targets for proper dependency tracking
This commit introduces a CMake target for each component, adds install targets
for them, and switches build-script-impl to use the target `install-components`
for installation. Each of the targets for each component depends on each
of the individual targets and outputs that are associated with the
corresponding swift-component.

This is equivalent to what already exists, because right now install rules are
only generated for components that we want to install. Therefore, this commit
should be an NFC.
2019-08-08 11:50:35 -07:00
Alex Langford
07214e1377 [CMake] Support cmake install components for targets with multiple target files
When installing a target, you could have multiple target files with
different rules for installation. For example, you can specify rules for
`RUNTIME` files, `LIBRARY` files, `ARCHIVE` files, etc. Each of these
can take several options, e.g. `DESTINATION`. When you want to specify
the install component for a target, each of the different target file
rules need to have their own `COMPONENT` field. If not, they end up as
"Unspecified" which means they will not get installed with the
associated swift component.
2019-07-17 13:27:41 -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
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
Alex Langford
799eb632c8 [CMake] Make SourceKit respect link_libraries and library_search_directories
add_sourcekit_default_compiler_flags was invoking
_add_variant_link_flags and getting link flags but not actually using
the link_libraries or library_search_directories. In android builds,
this means that the correct libc++ is not being linked against.
2019-04-02 12:06:44 -07:00
Ben Langmuir
1efade0b47 [cmake] Move install() after set_target_properties() to workaround crash
Calling install() on a framework target before setting the FRAMEWORK
property triggers a [crash](https://gitlab.kitware.com/cmake/cmake/issues/18848). Workaround by changing the call order.
2019-01-28 16:24:09 -08:00
Saleem Abdulrasool
522f97da43 build: simplify the blocks handling
`-fblocks` is a core driver option now, so it can be used with both the GCC
style driver as well as the cl style driver.  Simplify the logic for the
handling of this option.
2018-12-07 08:24:19 -08:00
Argyrios Kyrtzidis
92377cc145 [CMake] Move cross-platform dispatch/blocks support to the tools level, in preparation for the syntax parser library 2018-12-05 22:41:39 -08:00
Jordan Rose
6afe77ae98 [CMake] Clean up (somewhat) the generated Xcode project (#20586)
Still to do: have command-only targets that present sources, for things
like copy_shim_headers.
2018-11-26 11:31:41 -08:00
Michael Gottesman
3f17bb6ddf Carefully split the build's invocation of add_swift_library into host/target variants.
The key thing here is that all of the underlying code is exactly the same. I
purposely did not debride anything. This is to ensure that I am not touching too
much and increasing the probability of weird errors from occurring. Thus the
exact same code should be executed... just the routing changed.
2018-10-27 12:58:51 -07:00
Saleem Abdulrasool
2f8a4dbf4a Merge pull request #19933 from compnerd/micro-opt
SourceKit: micro-optimization of CMake (NFC)
2018-10-19 14:58:20 -07:00
Saleem Abdulrasool
13c83b121e SourceKit: always install headers
Ensure that we install the client header for the InProc sourcekitd. This is
needed to actually make it usable. With this, it is now possible to develop
against SourceKit on Linux and Windows.
2018-10-17 15:01:27 -07:00
Saleem Abdulrasool
8395e355e5 SourceKit: micro-optimization of CMake (NFC)
Set all the target properties in a single shot.  This avoids the multiple string
parsing within CMake.  Although this makes no noticable differnce, it is
slightly more efficient and also colocates all the target properties.
2018-10-17 14:53:24 -07:00
Saleem Abdulrasool
0df7b2f4be SourceKit: enable builds for Windows
SourceKit's build is now ammenable to building for Windows.  Generalize the path
to enable building it for Windows as well as Linux.  The libdispatch build for
the compiler is needed for all non-Darwin targets currently.
2018-10-04 16:44:54 -07:00
Saleem Abdulrasool
3469797df5 SourceKit: use shared BlocksRuntime
Adjust the SourceKit's embedded libdispatch build to use the shared build of
BlocksRuntime now that we can generate that.
2018-10-03 09:27:49 -07:00
Saleem Abdulrasool
6c8c7151ff SourceKit: repair the build when cross-compiling
Not all targets (CMAKE_SYSTEM_NAME) use `lib` and `.a` for the static library
name.  Adjust the name properly for the host that we are building for.  This
repairs the build when performing a cross-compile from Linux to Windows.
2018-10-01 14:54:06 -07:00
Argyrios Kyrtzidis
4179ceb4f9 Add a comment for the AddSwiftSourceKit.cmake change 2018-06-26 10:57:01 -07:00
Argyrios Kyrtzidis
7f6afa0357 [SourceKit/CMake] Make sure the XPC service executable isn't linked with an absolute build directory rpath
rdar://40462455
2018-06-26 10:47:11 -07:00
Argyrios Kyrtzidis
3156180c08 [SourceKit] For the XPC service identifier, also include the platform name
This is useful because the embedded platforms may have the same toolchain version but they contain
different stdlibs. We need to make sure the XPC service name is unique between them, otherwise we may load
and use the incorrect toolchain service.

rdar://39077520
2018-04-10 11:24:55 -07:00
Bob Wilson
390058972a [master-next] Use PRIVATE in target_link_libraries for executables
This is needed to work with LLVM r319840.
2017-12-06 21:55:22 -08:00