Commit Graph

1633 Commits

Author SHA1 Message Date
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
a0480e5f79 Merge pull request #3299 from gottesmm/fix_xcode_builds
Fix xcode builds
2016-07-01 17:11:41 -07:00
Harlan
1625d97976 Switch to llvm-profdata's pooled profdata merge (#3281) 2016-07-01 16:45:21 -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
Dmitri Gribenko
ad559f9812 Merge pull request #3205 from compnerd/foreign-icus
build: support having more than one ICU in use
2016-06-28 23:23:01 -07:00
Michael Gottesman
1d28c0ac4d [cmake] Refactor two list processing utility functions from AddSwift.cmake => SwiftList.cmake. 2016-06-28 14:19:18 -07:00
John McCall
bd3bc93787 Fix unified builds. 2016-06-28 10:04:54 -07:00
Dmitri Gribenko
37b7d3d9ee Merge pull request #3209 from compnerd/dead-code-elimination
build: clean up dead code
2016-06-27 23:13:35 -07:00
swift-ci
24a5b121ee Merge pull request #3210 from compnerd/experimental-linkers 2016-06-27 23:08:16 -07:00
Saleem Abdulrasool
1baeed7c26 build: allow experimental selection of lld
Add an option which the user can specify to switch to the lld linker.  Although
this linker is still nascent, it is interesting to permit linking with this.  It
is also an alternative to the BFD linker for COFF targets.  It will allow for a
cross-compilation story for Windows on non-Windows targets.
2016-06-25 12:39:17 -07:00
Saleem Abdulrasool
956503a975 build: clean up dead code
This is not used currently and is unlikely to be needed in the future as well.
Remove the dead code.
2016-06-25 12:37:44 -07:00
Saleem Abdulrasool
ff2a0aeedf build: more stringent gold checks
This is the only site which allowed you to accidentally accept gold for targets
which are not ELFish.  For the time being, we can only add unit tests for the
host variant, so use the `SWIFT_HOST_VARIANT_SDK` to determine the target file
format.  This will make supporting cross-compiling to non-ELFish targets
simpler.
2016-06-25 12:36:17 -07:00
Saleem Abdulrasool
4d2593fb95 build: support having more than one ICU in use
This allows us to cross-compile the standard library to foreign targets on a
single host.  The ICU dependencies can be specified on the command line on a
per-target basis.  If one is not specified, we fall back to the default search
path and use that for the other targets.

Special thanks to Dimitri Gribenko for the various hints in getting this wired
up.
2016-06-25 12:35:12 -07:00
Michael Gottesman
1abe85ab41 [cmake] Turns out ClangTargets.cmake can also be in $CLANG_BUILD/lib/cmake/clang.
LLVM's cmake path has this extra path (for LLVM) as well. I should have followed
its example. = /.

rdar://26154980
2016-06-25 01:28:52 -07:00
Michael Gottesman
6c261ce993 [cmake] Include ClangTargets.cmake so that any clang libraries we include get the correct LLVM/Clang dependency ordering.
This means that one can just use LINK_LIBRARIES to get the correct dependency
information without needing to know anything further.

rdar://26154980
2016-06-24 23:00:54 -07:00
Michael Gottesman
f6c2532552 [cmake] Remove standalone clang config code for building clang separate from llvm/swift.
We do not support this now. When we do, code can be added back.

rdar://26154980
2016-06-24 19:14:35 -07:00
Michael Gottesman
7f5116336a [cmake] Remove manual setting of include_directories for LLVM include dirs.
LLVM already provides these directories via the LLVMConfig.cmake variable
LLVM_INCLUDE_DIRS, which we are already using to import those directories.

Thus this work is and even worse gives the illusion that we are not delegating
the computation of LLVM's include paths to LLVM (which is really what we are
doing and should be doing).

rdar://26154980
2016-06-24 19:14:35 -07:00
Michael Gottesman
3168df8c11 [cmake] Do not set CMAKE_INCLUDE_CURRENT_DIR.
Setting this value is equivalent to setting:

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})

in all subdirectories. Since these are all macros, this means that we are adding to the configuration
path the root swift directory. There is no reason to do this and will result in
confusion/bugs in the future.

rdar://26154980
2016-06-24 19:14:34 -07:00
Michael Gottesman
242fa0cd50 [cmake] Refactor out llvm related config from swift_common_standalone_build_config to swift_common_standalone_build_config_llvm.
*NOTE* The diff looks bigger than it actually is. This is just a pure
refactoring.

rdar://26154980
2016-06-24 18:32:34 -07:00
Michael Gottesman
5236f2d384 [cmake] Refactor out clang related config from swift_common_standalone_build_config to swift_common_standalone_build_config_clang.
rdar://26154980
2016-06-24 18:25:20 -07:00
Michael Gottesman
db964d35fc [cmake] Refactor out cmark related config from swift_common_standalone_build_config to swift_common_standalone_build_config_cmark.
This is apart of a series of patches that separates configuration of
llvm/clang/cmark in swift_common_standalone_build_config. Right now each project
has configuration occurring in a mixed up way. By refactoring it becomes much
easier to read the code.

rdar://26154980
2016-06-24 18:14:34 -07:00
Michael Gottesman
bd43806047 Merge pull request #3200 from gottesmm/use_swift_tablegen_instead_of_llvm_tablegen
Use swift tablegen instead of llvm tablegen
2016-06-24 18:09:46 -07:00
Michael Gottesman
25ac3a2df5 [cmake] Remove duplicate unncessary work.
Even before my changes, we had been setting this value twice. = /.

rdar://26154980
2016-06-24 17:51:24 -07:00
Michael Gottesman
5d984de9ec [cmake] Instead of setting LLVM_TABLEGEN_EXE, use our own SWIFT_TABLEGEN_EXE variable.
This eliminates us setting an LLVM_ prefixed variable in a situation where there is
a viable alternative.

We want to eliminate as many of these as possible since they can cause conflicts
with variables set in LLVMConfig.cmake.

I also added some convenience tablegen functions in AddSwiftTableGen.cmake and
changed all tblgen users to use that instead.

rdar://26154980
2016-06-24 17:18:45 -07:00
Michael Gottesman
41e375a8d2 [cmake] Instead of trying to find an absolute path to LLVMConfig.cmake, just add all of the LLVM cmake paths to the CMAKE_MODULE_PATH and just use include(LLVMConfig).
rdar://26154980
2016-06-24 15:22:10 -07:00
Michael Gottesman
d8be0e027b [cmake] When not cross compiling, instead of searching for llvm-tblgen, just use the real native cmake target.
This fixes part of the Xcode build by allowing us to avoid having to use cmake
variables with an unexpanded CMAKE_CFG_INTDIR.

Since those variables are not expanded, they point to a non-existant path like:

.../$(CONFIGURATION)$(...)/lib

So finding tablegen fails. In the cross compile case, we still try to find the
native tablegen.

rdar://26154980
2016-06-24 15:15:43 -07:00
Brian Gesiak
f12a1323ce [SR-1738] Allow *only* static libraries to be built
This splits the `--build-swift-stdlib` and `--build-swift-sdk-overlay`
arguments into `dynamic` and `static` variants, which makes the
following build command possible:

```
utils/build-script -- \
  --build-swift-dynamic-stdlib=0 --build-swift-dynamic-sdk-overlay=0 \
  --build-swift-static-stdlib=1 --build-swift-static-sdk-overlay=0
```

This command produces *only* static libraries for the stdlib, and no
SDK overlay libraries at all. Many other finely-grained build options
are now possible.
2016-06-24 09:18:24 -07:00
Michael Gottesman
266ead97b9 [cmake] Remove support for invoking llvm-config.
I already removed the one invocation of llvm-config. This code is just dead.

rdar://26154980
2016-06-23 22:19:59 -07:00
Michael Gottesman
be112f18d1 [cmake] Use LLVM_TOOLS_BINARY_DIR from LLVMConfig.cmake and remove any invocation of llvm-config.
There are a couple of things going on in this patch. Lets consider first the
crosscompiling case.

In the cross compiling case, we were already setting LLVM_TOOLS_BINARY_DIR to
the binary dir of the just compiled LLVM (not the native LLVM/clang). This is
exactly what using LLVMConfig.cmake from that just compiled LLVM will set
LLVM_TOOLS_BINARY_DIR.

In the non-cross compiling case, we originally grabbed LLVM_TOOLS_BINARY_DIR
from llvm-config and then used that value to set the NATIVE llvm/clang paths.

rdar://26154980
2016-06-23 18:51:09 -07:00
Michael Gottesman
87fc9ca420 [cmake] Get the default value for LLVM_ENABLE_ASSERTIONS from LLVMConfig.cmake.
rdar://26154980
2016-06-23 18:47:33 -07:00
Michael Gottesman
ea3914d75e [cmake] Remove dead link directory.
This was added some time ago in case we want to build clang separate from llvm
just like we do swift. We do not actually support that though.

Currently, this just results in the main llvm binary directory being added for a
second time to the link path (i.e. this work iw asted). Thus just remove the
line but leave in a *NOTE* to deliver the message that this is where the clang
link path in such a case would need to go.
2016-06-23 17:47:48 -07:00
swift-ci
b2240d0ef0 Merge pull request #3158 from gottesmm/cmake_fix_bug_and_remove_dead_store 2016-06-23 00:33:10 -07:00
Michael Gottesman
8c3bc0a211 [cmake] Remove dead variable.
This variable was added in 2015 to set a value that was needed given upstream
changes. In Feb 2016, we started importing LLVMConfig.cmake. LLVMConfig.cmake
provides this value for us. Thus we can remove the dead variable.

rdar://26154980
2016-06-22 23:36:31 -07:00
Michael Gottesman
ef87fe7ba3 [cmake] Remove dead set (i.e. LLVM_MAIN_INCLUDE_DIR already equals LLVM_MAIN_SRC_DIR/include).
rdar://26154980
2016-06-22 23:16:33 -07:00
Michael Gottesman
8389dae8fb [cmake] Remove line of code that is setting LLVM_BINARY_DIR to CMAKE_BINARY_DIR (i.e., SWIFT_BINARY_DIR).
This bug was in tree before I began to make my changes. I uncovered the bug when
I was thinking about whether or not this line of code was dead and thus looked
at how it was used.

rdar://26154980
2016-06-22 23:16:33 -07:00
Michael Gottesman
e24e1f7dee [cmake] Use LLVMConfig.cmake instead of llvm-config to set some variables.
Previously in order to support cross-compiling, we were setting these variables
in build-script. Now that we are using LLVMConfig.cmake, passing in these values
are no longer necessary. As an added benefit, Swift when not cross compiling,
does not need to set these variables anyways.

rdar://26154980
2016-06-22 19:58:20 -07:00
Michael Gottesman
c87aabb79b [cmake] Use already defined ${product}_PATH_TO_LLVM_{SOURCE,BUILD} values instead of re-setting it later ot the same value.
Before this patch, we would always set ${product}_PATH_TO_LLVM_{SOURCE,BUILD} to
a value taken from llvm-config. But, turns out we had generated llvm-config
using these values. Thus llvm-config is just giving us back values we already
have.

This commit changes these variables to be precondition variables and doesn't
cause them to be reset.

rdar://26154980
2016-06-22 19:58:19 -07:00
Michael Gottesman
e12fff76fd [cmake] Add a SwiftUtils.cmake file to contain little helper routines such as precondition. 2016-06-22 19:57:49 -07:00
Brian Gesiak
8d4bc744c5 [CMake] Android NDK r12 appends ".x" to libgcc dir
The Android NDK r12 release appends a ".x" to the libgcc directory;
it is now:

```
android-ndk-r12/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9.x
```

Update the linker path for the Android build to accomodate this change.
2016-06-22 14:39:28 -07:00
Saleem Abdulrasool
d771054c7b build: use the new object format property
Simplify the ELF checks based on review comments from Dimitri Gribenko.
2016-06-22 09:37:56 -07:00
Saleem Abdulrasool
b1978d5144 build: track object format with SDK 2016-06-22 09:37:56 -07:00
Brian Gesiak
089425bd9f Merge pull request #2549 from compnerd/include-directories
build: include more directories
2016-06-21 12:20:22 -04:00
Saleem Abdulrasool
526127be41 build: only use gold on ELF targets
gold only supports ELF.  This adds two new helper functions
(is_windows_based_sdk and is_elfish_sdk) to ensure that we dont try to use gold
on non-ELF targets.  This comes up when trying to setup cross-compilation for
the standard library for Windows.

The ELF check is implemented as the negation of Darwin (which uses MachO) and
Windows (which uses COFF).  The reason for this is that there are additional
targets which also use ELF.  Rather than enumerating the larger set, enumerate
the smaller set (windows) and use the negation.
2016-06-20 20:54:20 -07:00
Saleem Abdulrasool
6cb73cfdf5 cmake: avoid some duplications by using a helper
Create a helper function to determine if we are targeting a Darwin SDK or not.
The repetition is error-prone and verbose.  Simplify by adding a checking
function.  NFC.
2016-06-20 07:09:21 -07:00
swift-ci
7575e66971 Merge pull request #3068 from compnerd/single-is-crossed 2016-06-20 01:29:29 -07:00
Saleem Abdulrasool
b3ba45758d build: make swift_lib_add_single more amenable to cross-compilation
Use the SWIFTLIB_SINGLE_SDK variable rather than the CMAKE_BUILD_SYSTEM variable
to determine the target type.  This allows us to use the logic for adding
libraries for foreign OSes on a build host.  This is needed to pave the road to
cross-crompiling the standard library for different targets.
2016-06-19 22:21:51 -07:00
Saleem Abdulrasool
985651feca build: use -isystem on non-Darwin targets
The use of `-isysroot` is a Darwin specific behaviour.  It is used to switch to
a platform SDK, however, other targets use the `--sysroot` flag.  Windows uses a
custom mechanism which is a set of system header paths.
2016-06-18 17:47:44 -07:00
Saleem Abdulrasool
b604369fb2 build: include more directories
llvm/Support/Compiler.h recently grew a dependency on llvm-config.h.  This
pointed out that we were not including the path to the generated header
directory in the build output.  Ensure that we have the corresponding -I.
2016-06-18 17:41:45 -07:00