Commit Graph

98 Commits

Author SHA1 Message Date
Saleem Abdulrasool
5f428f594a build: use the new CMark export targets
CMark upstream now provides an exports target entry that we can use.
2020-01-03 14:40:58 -08:00
Vlad Gorlov
62dd6bda10 Android build on macOS Cross-Compile host: Fixes wrong Ninja rules generation. (#25576)
* Fixes wrong Ninja rules generation for Android build on macOS Cross-Compile host.

* PR review fixes.
2019-06-21 17:04:51 -07:00
Saleem Abdulrasool
a6c0e9438b build: allow the user to specify the llvm tools
This is needed for cross-compiling the toolchain to Windows ARM64 on
Windows x64 using Visual Studio which does not permit the NATIVE
sub-build to work properly.
2019-06-19 16:47:18 -07:00
Saleem Abdulrasool
816dfe23ac build: don't always load clang/cmark
clang/cmark are only needed for the tools, not for the runtime/SDK
overlay.  Do not attempt to configure clang and CMark in the case we do
not build the tools.  This is needed to enable the standalone standard
library only builds.
2019-05-01 22:18:29 -07:00
Saleem Abdulrasool
22859376c6 build: do not search for native LLVM when not building tools
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.
2019-04-09 12:38:57 -07:00
Saleem Abdulrasool
01f6a2ad6d build: correct the variable name for cross-compiling
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.
2019-03-18 08:55:31 -07:00
Saleem Abdulrasool
ac5687b81e build: remove some unused variables 2019-02-27 11:14:10 -08:00
Saleem Abdulrasool
350cf67788 utils: attempt to replace custom variables
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.
2019-02-22 18:47:26 -08:00
Slava Pestov
1d8928425a Revert "utils: attempt to replace custom variables" 2019-02-22 19:21:13 -05:00
Saleem Abdulrasool
817597c7f9 utils: attempt to replace custom variables
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.
2019-02-14 20:19:08 -08:00
Saleem Abdulrasool
adbb7d7cbd build: simplify condition and IWYU CMake edition
Include a missing CMake module in a couple of locations that we were
using the function.  Simplify a condition to use `MATCHES` rather than
two `STREQUAL`.
2019-02-14 17:35:18 -08:00
Saleem Abdulrasool
509060c78a build: convert paths to CMake paths before use
This converts the path separators to the CMake way.  This is primarily
important for Windows where the path separator is \ rather than /.  This
conversion allows the specification of the path in the proper windows
path style.
2018-12-30 12:27:16 -08:00
Saleem Abdulrasool
16a4af0e5b build: assume a parallel tree layout for unified builds
Attempt to repair the build for the unified swift build.  This allows us
to build a single unified toolchain with swift support.  In this layout
assume that cmark and clang are peers of LLVM rather than located in
`tools`.  Doing so allows a uniform layout of the tree and a simpler
build approach.
2018-11-29 12:26:02 -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
d9dde28bf1 build: improve the builds with Visual Studio
Visual Studio's compiler does not accept `-Werror=switch`.  Use the equivalent
`-we4062` option instead.  Avoid using the `--` separate that clang uses to
identify that the options that follow are files and not options on the Visual
Studio compiler to reduce the unnecessary spew when building on Windows.
2018-09-12 12:06:48 -07:00
Shoaib Meenai
4a0274acff [CMake] Use NO_CMAKE_FIND_ROOT_PATH for LLVM and clang
When cross-compiling or specifying a custom sysroot and desiring a
hermetic build, many CMake toolchain files will have a custom
CMAKE_FIND_ROOT_PATH and set the CMAKE_FIND_ROOT_PATH_MODE_* variables
to ONLY, meaning packages will only be searched for in the rerooted
directories. We don't want this rerooting to happen when searching for
the LLVM and clang packages though, since we're specifying our search
paths explicitly and excluding search paths from the system, and we
don't want those explicit search paths to be rerooted.

It's standard to set CMAKE_FIND_ROOT_PATH_MODE_PROGRAM to NEVER instead
of ONLY, since you usually want programs to be found for the build
system and not the host system, so the change for the llvm-config search
is not technically required. It doesn't hurt for consistency though, and
I can envision some scenarios in which it might come in handy.
2018-07-12 12:04:04 -07:00
Saleem Abdulrasool
9e7f0e1475 build: filter -z,nodelete on Windows
LLVM recently added a new ELF-only linker flag that gets exported.
Filter this from  the linker flags too.
2018-05-24 09:25:10 -07:00
swift-ci
577b2722f7 Merge pull request #13140 from troughton/windows-cross-compile-fixes 2018-04-18 10:56:06 -07:00
Jordan Rose
20ae19ef22 [CMake] Improve Xcode project generation with folders (#15738)
- Re-enable the use of folders with the USE_FOLDER setting. This got
  lost a while ago when we stopped including LLVM's top-level
  CMakeLists.txt.

- Put a bunch of new targets into folders.

Should not affect the built product and definitely shouldn't affect
anyone not building with Xcode (or MSVC, I guess).
2018-04-04 18:22:59 -07:00
Thomas Roughton
7c2230bc56 Fix cross-compilation for the Windows stdlib
Disable SwiftPrivate, remove -Wl,-z,defs, and use the VFS overlay for compiling the runtime.
2018-02-01 22:08:18 +13: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
Saleem Abdulrasool
d48686ff0d build: effectively revert 986beb7522
This change broke the Windows builds for all the variants.  `-z defs` cannot be
used on all targets, particularly in environments where the stdlib is being
compiled for a foreign host.  This needs to be handled more carefully as I
mentioned on the PR itself.  In the mean time, revert it to get Windows building
again.
2017-12-01 13:34:30 -08:00
David Zarzycki
986beb7522 [CMake] Localize a build hack
The '-Wl,-z,defs' flag is useful, so let's disable it only where needed.
2017-11-13 07:40:54 -05:00
Mishal Shah
df070b858f Update swift master to build with Xcode 9 beta 6, macOS 10.13, iOS 11, tvOS 11, and watchOS 4 SDKs. 2017-08-22 11:52:50 -07:00
swift-ci
d189132667 Merge remote-tracking branch 'origin/master' into master-next 2017-08-01 09:28:54 -07:00
David Zarzycki
dc1d0943b2 [CMake] Infer -Werror=switch via asserts being enabled (#11098)
LLVM-style projects like Swift make heavy use of switch statements and
therefore -Werror=switch is very useful during feature development. That
being said, if asserts are disabled, then you're probably not actively
hacking on the project and -Werror (or warnings in general) aren't
helpful.
2017-08-01 09:23:25 -07:00
Chris Bieneman
9c35042ae6 Merge remote-tracking branch 'origin/master' into master-next 2017-07-28 09:51:36 -07:00
Chris Bieneman
93717c663c Rename SWIFT_TABLEGEN to LLVM_TABLEGEN
Swift doesn't produce its own tablegen and by faking out the LLVM CMake infrastructure into thinking it does all of LLVM's build cross compilation support breaks.
2017-07-25 14:14:56 -07:00
Bob Wilson
52d14e3f0d Set SWIFT_TABLEGEN_TARGET as required by LLVM r305142.
With the change in LLVM r305142, CMake will fail if SWIFT_TABLEGEN_TARGET
is not set. When cross-compiling, it could be set differently than
SWIFT_TABLEGEN_EXE but it does not look like Swift supports that yet. For
now, just set it to the same value as SWIFT_TABLEGEN_EXE.
2017-06-12 10:53:06 -07:00
Hugh Bellamy
9907502ede Add /permissive- flags with VS2017 2017-03-16 22:02:01 +07:00
Greg Parker
25653ac891 [build] Disallow calls to objc_msgSend() with no function pointer cast. 2017-03-14 13:35:39 -07:00
Hugh Bellamy
38d9cb5d33 [CMake] remove dead version specific checks 2017-02-17 14:35:56 +07:00
Hugh Bellamy
2b1c5efe4b [CMake] remove redundant USES_TERMINAL checks
The minimum version of CMake is 3.4.3
2017-02-17 14:33:42 +07:00
Hugh Bellamy
901b73e89c Merge pull request #7450 from hughbe/cleanup-compiler-flags
Fix potentially appending "/wd4068" on mac builds
2017-02-17 00:20:35 +07:00
Hugh Bellamy
46ccacd7fa Fix potentially appending "/wd4068" on mac builds 2017-02-14 09:20:50 +07:00
Hugh Bellamy
15a0a2c337 Fix Windows linker errors trying to statically link to cmark 2017-02-13 18:05:47 +07:00
Chris Bieneman
04c06945ec Fix the Xcode build broken in PR7344
In Xcode builds the library dir variable contains the build configuration in the path, but the exports file doesn't. If we construct the export file path from the build directory instead of the library directory it should all work.
2017-02-09 16:47:47 -08: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
Hugh Bellamy
f446dd0297 Ignore unknown pragma warnings with MSVC 2017-01-18 10:33:28 +00:00
Chris Bieneman
f89461bf22 [CMake] NFC. Updates based on post-merge feedback
* Ensure LLVM_CMAKE_DIR is always set so it can be used
* Use LLVM_CMAKE_DIR instead of searching the module paths
* Label parameters of cmake_parse_arguments in comments
2016-09-28 22:21:03 -07:00
practicalswift
7e89679404 [gardening] Fix recently introduced typos. 2016-07-24 22:32:40 +02:00
Saleem Abdulrasool
5e170ebcb5 build: support cross-compiling to windows 2016-07-13 21:37:04 -07:00
Michael Gottesman
b42b7f43d8 [cmake] Combine apply_xcode_substitutions and escape_llvm_path_for_xcode into a better escape_path_for_xcode that can be reused across cmake. 2016-07-08 09:51:18 -07:00
Michael Gottesman
455d3a1960 [cmake] Move the cmake xcode configuration code from SwiftSharedCMakeConfig.cmake => SwiftXcodeSupport.cmake. 2016-07-08 09:51:18 -07:00
Michael Gottesman
d004abc088 [cmake] Instead of figuring out the exact location of all of the various libraries when translating Xcode targets, just use the path already provided in LLVMConfig.cmake for the configuration that we compiled LLVM specifically for.
If we compile LLVM for <CONFIG> in build-script with Xcode as our generator,
LLVMExports.cmake will have specific IMPORTED_*_<CONFIG> variables set for all
of our targets. These variables are what we really want to splat across all
Swift Xcode build configurations.

This patch rips out the old code that determined the actual location and instead
just grabs the IMPORTED_*_<CONFIG> variables and splats it accordingly.
2016-07-08 09:06:06 -07:00
Michael Gottesman
95b659583e [cmake] Also provide absolute paths for shared libraries/executables in addition to static libraries.
Eliminates a warning when building lldb.

It looks like lldb is still able to find the right library. But doing it this
way is guaranteed to be correct (eliminating future bugs is good).
2016-07-06 17:28:38 -07:00
Michael Gottesman
be09b2f873 [cmake] Remove direct computation of dependencies on LLVM libraries and exact paths to those libraries.
Now that we have the full dependency information from LLVM/Clang, this is no
longer necessary. We will just do the *right* thing.

Additionally, since we were passing these libraries as absolute paths, cmake was
always passing through all of the given libraries even if CMake had already
added them to the link line in its non-absolute form. It is not clear to me how
if all linkers would be smart about this.

Regardless, now we just translate components to libraries and continue on our
merry way. In the future, we can even remove the llvm-build code period by just
specifying LLVM dependencies directly via LINK_LIBRARIES instead of having to do
anything with COMPONENT_DEPENDS.

But that is for a future commit.
2016-07-01 17:35:41 -07:00
Michael Gottesman
c2645d07c6 [cmake] Expand $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) from all LLVM/Clang imported target locations.
Normally when building in Xcode, Xcode will assume that LLVM/Clang use the same
configuration as Swift and will try to pull in the sources from that
configuration's build directory.

This is incorrect when we are compiling a Release LLVM with a Debug Swift. This
commit uses our escaping functionality from 0a48857 and the new imported targets
to fix this issue.

rdar://27062396
2016-07-01 14:02:01 -07:00
Michael Gottesman
0a4885732e [cmake] Expand $(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) in LLVM CMake paths.
In order to support swapping build types without reconfiguring, Swift's CMake
generated Xcode project has one directory for each cmake build type. This
behavior is implemented by placing in variables for Xcode to expand at build
time. This causes issues with our build, namely that our cmake scripts like to
"poke" around the LLVM build directory at configure time. Since the xcode
variables from the commit title are not expanded, failures occur since the
unexpanded paths do not exist.

This patch fixes this problem by expanding out those variables at configure time
from specific LLVM paths. This is essentially tieing LLVM to the specific
build-script build mode used. This is reasonable since we do not support
building in Xcode for configurations that were not selected at build-script
time.

rdar://27062396
2016-07-01 13:47:38 -07:00
Michael Gottesman
523312ed63 Use find_package instead of include.
rdar://27062396
2016-07-01 13:40:21 -07:00