Commit Graph

79 Commits

Author SHA1 Message Date
Hiroshi Yamauchi
71d8118af9 Fix the clang dependency of sourcekit libraries.
Because swift_swap_compiler_if_needed updates the compiler ID to
Clang, we need to account for it when deciding to add a dependency on
clang. Otherwise, the sourcekit build could fail due to the clang
executable not having been built there yet.
2023-09-27 14:15:12 -07:00
Stéphan Kochen
7b460ce495 build: fix accidental cmake expansions
As of CMake 3.25, there are now global variables `LINUX=1`, `ANDROID=1`,
etc. These conflict with expressions that used these names as unquoted
strings in positions where CMake accepts 'variable|string', for example:

- `if(sdk STREQUAL LINUX)` would fail, because `LINUX` is now defined and
  expands to 1, where it would previously coerce to a string.

- `if(${sdk} STREQUAL "LINUX")` would fail if `sdk=LINUX`, because the
  left-hand side expands twice.

In this patch, I looked for a number of patterns to fix up, sometimes a
little defensively:

- Quoted right-hand side of `STREQUAL` where I was confident it was
  intended to be a string literal.

- Removed manual variable expansion on left-hand side of `STREQUAL`,
  `MATCHES` and `IN_LIST` where I was confident it was unintended.

Fixes #65028.
2023-07-17 21:50:50 +02:00
Connor Wakamo
c0b5925a41 [CMake] Removed an overwrite of the SOURCEKIT_DEPLOYMENT_TARGET setting.
This setting is set early in SourceKit's CMake logic to match Swift's CMake settings.
However, it was then reset back to the empty string. The CMake logic would then see that it was unset and use the host OS as the deployment target.

Thankfully, the compiled binaries have been correct without this change, but sourcekitd.framework's Info.plist when building for iOS was incorrect.
By removing the reset, the correct value propagates to the right places.

This is for <rdar://problem/85511244> and addresses <rdar://problem/68656762>.
2021-11-17 14:58:04 -08:00
Dario Rexin
51bdfa1919 [Concurrency] Build C-only libdispatch as part of Swift build (#35837)
* [Concurrency] Build C-only libdispatch as part of Swift build
2021-02-09 14:24:52 -08: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
Ben Langmuir
d7b813b9ef [sourcekit] Identify xpc service by toolchain instead of sdk
rdar://72310494
2020-12-14 13:31:35 -08:00
Saleem Abdulrasool
d0f6681463 SourceKit: use add_compile_options (NFCI)
Use `add_compile_options` to add new compiler options rather than
modifying `CMAKE_C_FLAGS` and `CMAKE_CXX_FLAGS` which are meant to be
controlled entirely by the user.
2019-06-18 19:30:01 -07:00
Saleem Abdulrasool
9b8310c3f9 build: extract compiler swap into a helper
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.
2019-03-27 15:04:49 -07:00
Saleem Abdulrasool
79b05aaf97 SourceKit: fix silly copy paste error in CMake
Correct the variable setting to setup the compiler as desired.
2019-03-26 17:00:33 -07:00
Saleem Abdulrasool
12e75eeedd SourceKit: fallback to just built clang-cl
SourceKit uses libdispatch for concurrency.  Unfortunately, libdispatch
requires clang due to extensions.  Switch to `clang-cl` or `clang` as
appropriate when building with a non-clang based host compiler.

In particular, the dependency on blocks (and certain attributes) makes
porting libdispatch to cl infeasible.
2019-03-25 09:22:48 -07: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
Nathan Hawes
15dd6f920a [sourcekit] Fix for Ubuntu 16.04 Swift ASAN bot failures
Don't mix and match between the just-built clang and the host clang when
ASAN is enabled.

rdar://problem/45273748
2018-11-07 17:29:13 -08:00
Ben Langmuir
98ceebe6e8 Add dependency on the libdispatch-install step
Libraries in sourcekitd depending on the external libdispatch project
appear to only depend on the *build* step, but really need the install
to happen as well since we are linking to the installed location.
2018-10-16 15:56:00 -07:00
Saleem Abdulrasool
c20a7550d4 build: correct case for compiler id
The STREQUAL would fail as the C in Clang for the compiler ID is capital.
Correct the case.
2018-10-15 16:20:59 -07:00
Saleem Abdulrasool
ed3cb02475 build: use the host compiler if possible (#19888)
Attempt to use the host compiler when building libdispatch for SourceKit.  This
is needed for cross-compiling scenarios (e.g. building the Windows toolchain on
Linux).  However, unfortunately, the Ubuntu 14.04 build bots are using an
ancient compiler, so we cannot use that for building libdispatch.  Add a
fallback to the just built clang.  Ensure that the fallback only activates when
compiling on the same host as the target.
2018-10-15 15:13:45 -07:00
Ross Bayer
c1f17f00c2 Changed the external project build for libdispatch in tools/SourceKit to use the just-build clang and clang++ rather than the system versions (rdar://45148295). (#19845) 2018-10-12 14:53:04 -07:00
Saleem Abdulrasool
0295a83237 SourceKit: re-package libdispatch, BlocksRuntime
The SourceKit component requires libdispatch and BlocksRuntime to run.
We build the libraries as part of the build and use it via imported
targets.  Ensure that the dependencies get installed for use at runtime.
2018-10-09 13:23: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
6ab8389ecf Merge pull request #19674 from compnerd/shared-blocks-are-back
SourceKit: use shared BlocksRuntime
2018-10-04 15:31:57 -07:00
Saleem Abdulrasool
a140c41ce0 build: be a bit more resilient
In the case that a system update temporarily breaks the command, the output may
be empty, and this can cause CMake to fail in a weird manner.  Quote the
variable to be more resilient to the transient failure.
2018-10-03 18:24:17 -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
swift-ci
9034066396 Merge pull request #19642 from compnerd/inproc-or-xpc 2018-10-01 12:29:28 -07:00
Saleem Abdulrasool
daabc237fa SourceKit: libdispatch swift requires swift stdlib
When building libdispatch for SourceKit, only enable the swift overlay
components if the swift standard library is being built.  This allows building
just the compiler and SourceKit.
2018-10-01 10:02:17 -07:00
Saleem Abdulrasool
f1997236fe SourceKit: hoist decision for building InProc
The decision to whether build InProc or as an XPC service is needed for the
test tools as well.  Rather than recompute it for the tests as well, hoist it to
the top level for the SourceKit project.  This repairs the build of the
SourceKit tests on non-Darwin hosts.
2018-10-01 09:58:53 -07:00
Saleem Abdulrasool
df208b370c build: honour the libdispatch build type
When configuring libdispatch as part of the swift build on Linux with SourceKit
enabled, we would default to a release build.  However, that results in known
leaks being reported with LSAN when building with a debug standard library.
Pass along the `LIBDISPATCH_BUILD_TYPE` into the CMake build and map that to the
CMAKE_BUILD_TYPE for the project.
2018-08-22 11:16:03 -07:00
Ted Kremenek
fb6b24f1c1 Revert "build: extract libdispatch build for swift" 2018-08-13 10:06:45 -07:00
Saleem Abdulrasool
f140734584 build: extract libdispatch build for swift
Extract the ExternalProject handling for libdispatch needed to build
SourceKit on Linux into a separate CMake list.  This will allow us to
pull in a dependency on Foundation as well to allow building SwiftSyntax
on Linux which requires Foundation.  Foundation has a dependency on
libdispatch requiring that the external project handling is centralised.
2018-08-08 13:41:49 -07:00
Xi Ge
7542f991c1 Re-apply "SourceKit: make SwiftLang build in linux. (#18455)" (#18506) 2018-08-06 11:37:09 -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
Xi Ge
69bbf2ba71 sourcekitd: using gyb to generate UIDs instead of a def file. NFC (#14549)
Inspired by the infrastructure of SwiftSyntax, a gyb file can facilitate
cross-language sharing.
2018-02-12 22:48:54 -08:00
Xi Ge
2e03eac75c [WIP] Re-apply "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" (#14506)
After removing white space changes and attempting to configure dependencies
correctly.
2018-02-11 09:38:53 -08:00
Doug Gregor
774bee2294 Revert "Re-apply "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" (#14465)"
This reverts commit f8c77e17ce.
2018-02-08 22:58:45 -08:00
Xi Ge
f8c77e17ce Re-apply "SwiftSyntax: Teach SwiftSyntax to use SourceKitd to serialize syntax trees. (#14424)" (#14465) 2018-02-08 15:11:31 -08:00
swift-ci
5e13094e8f Merge pull request #12400 from compnerd/dispatch-make-program 2017-10-12 13:13:26 -07:00
Saleem Abdulrasool
429a368ef3 build: pass along CMAKE_BUILD_PROGRAM to sub-build
Pass along our `CMAKE_BUILD_PROGRAM` to the libdispatch build which is
done as part of the build for SourceKit.
2017-10-12 08:28:32 -07:00
Saleem Abdulrasool
e6a0655a9c build: add a dependency on SwiftShims for libdispatch
During a parallel build, this was noticed:
  <unknown>:0: error: missing required module 'SwiftShims'

Ensure that we have a dependency on the SwiftShims target for
libdispatch.
2017-10-10 15:05:25 -07:00
Saleem Abdulrasool
a192e67ae9 build: force rebuild of libdispatch always
This pays a small penalty in build times by invoking an extra call to
ninja.  However, unless there is a change in libdispatch, no actions
will be taken other than ensuring that it is up-to-date.  Should ensure
that the buildbots switching between builds DTRT.
2017-10-07 11:06:59 -07:00
Saleem Abdulrasool
e69c44352b Update CMakeLists.txt 2017-10-03 22:01:19 -07:00
Saleem Abdulrasool
9fff09d817 build: improve SourceKit handling of libdispatch
Avoid overwriting the `swiftCore` target in the SourceKit build.
Instead, link to the explicit variant of the swiftCore.  This tracks the
dependency better and enables multiple parallel cross-compilations of
the stdlib.

Implicitly link against swiftCore when linking against libdispatch.
Remove the extraneous link against the Blocks runtime on Linux.  The
`add_sourcekit_executable` call already handles this.  Ensure that we
enable the swift SDK overlay for libdispatch by sending it the path to
the swift compiler.
2017-10-02 21:40:29 -07:00
Michael Gottesman
a05c4dda07 [cmake] Move the 'routines' of SourceKit's cmake into a cmake module.
This is a NFC change that makes it easier to read SourceKit's main
CMakeLists.txt file since you only see "actions" rather than also this huge list
of helper routines.
2017-09-20 20:33:16 -07:00
Saleem Abdulrasool
8d3c30e2fa build: switch libdispatch build to cmake
Use the cmake based build system for building libdispatch now that it is
able to build Linux, android, and even possible to cross-compile to
Windows.
2017-09-17 17:01:28 -07:00
Harlan
4ff07077bc Rename DEPENDS to LINK_LIBS throughout SourceKit (#11228)
Currently, SourceKit's CMake functions all use DEPENDS to specify
libraries the targets will link with. This is confusing as it doesn't
behave the same way that add_swift behaves, and implies that
dependencies are created when there aren't.
2017-08-01 21:25:19 -07:00
Harlan
4b83c16c07 Make SourceKitSwiftLang depend on swift-syntax-generated-headers (#11226) 2017-07-27 13:24:55 -07:00
Chris Bieneman
3003bf6f9e Don't override CMAKE_* variables if CMAKE_CROSSCOMPILING is set
This patch allows Swift to build correctly when using CMake's cross compiling facilities instead of hacking around them.
2017-07-25 13:49:02 -07:00
Norio Nomura
a93bddf019 Set rpath to libsourcekitdInProc.so on Linux 2017-04-29 06:28:35 +09:00
Alex Blewitt
1673b5e8fd Build SourceKit on Linux if dispatch is present
SourceKit can be built on Linux if dispatch is available
so enable this so it happens by default.

Issue: SR-1676
2017-02-10 22:03:13 +00:00
Chris Bieneman
44b6f32f0e Clean up handling of CMark library dependency.
This change depends on:

https://github.com/apple/swift-cmark/pull/4
2017-02-08 14:32:50 -08:00
Alex Blewitt
3e9f66c6ca Enable sourcekitd to be built by default on Linux
The Linux build has a dependency on the libdispatch library,
which is needed by the various native libraries for sourcekitd.

On macOS, the dependency for libdispatch is satisfied directly through
the base OS, but on Linux no such dependency exists.

Modify this so that if the SourceKit library is built, and the
libdispatch library is already present, then we shell out to make
the libdispatch binary project when the SourceKit is built.

Issue: SR-1676
2017-01-17 19:21:52 +00:00
Alex Blewitt
25fc295e4a Revert "Merge pull request #6807 from alblue/SR-1676"
This reverts commit c85cbe5c78, reversing
changes made to 5d293ab9d2.
2017-01-17 09:47:07 +00:00
Alex Blewitt
f7836ae0c8 Enable sourcekitd to be built by default on Linux
The Linux build has a dependency on the libdispatch library,
which is needed by the various native libraries for sourcekitd.

On macOS, the dependency for libdispatch is satisfied directly through
the base OS, but on Linux no such dependency exists.

Modify this so that if the SourceKit library is built, and the
libdispatch library is already present, then we shell out to make
the libdispatch binary project when the SourceKit is built.

Issue: SR-1676
2017-01-14 10:38:45 +00:00