Commit Graph

1731 Commits

Author SHA1 Message Date
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
Brian Gesiak
328de9e280 [SR-1738] add_swift_library takes SHARED/STATIC arg
As a first step to allowing the build script to build *only*
static library versions of the stdlib, change `add_swift_library`
such that callers must pass in `SHARED`, `STATIC`, or `OBJECT_LIBRARY`.

Ideally, only these flags would be used to determine whether to
build shared, static, or object libraries, but that is not currently
the case -- `add_swift_library` also checks whether the library
`IS_STDLIB` before performing certain additional actions. This will be
cleaned up in a future commit.
2016-06-16 13:15:58 -04:00
swift-ci
3de52f4d17 Merge pull request #2985 from gottesmm/thinko_fix_update_unittests_to_use_compute_lto_flag 2016-06-10 15:17:47 -07:00
swift-ci
3826628d81 Merge pull request #2984 from gottesmm/cmake_rename_host_library_to_force_build_for_host_sdk 2016-06-10 14:51:29 -07:00
Michael Gottesman
ee08987896 [lto][cmake] While chopping up patches, I lost an update to AddSwiftUnittests to use _compute_lto_flag.
rdar://24717107
2016-06-10 14:31:42 -07:00
swift-ci
166ac9ffe4 Merge pull request #2945 from gottesmm/only-build-host-libraries-with-lto 2016-06-10 14:09:14 -07:00
Michael Gottesman
034441a782 [cmake] Rename the variable HOST_LIBRARY => FORCE_BUILD_FOR_HOST_SDK in add_swift_library.
HOST_LIBRARY is supposed to mean "no matter what the defaults say, also build
this library for the host". FORCE_BUILD_FOR_HOST_SDK is a less confusing name.
2016-06-10 14:02:55 -07:00
Michael Gottesman
95d926abb0 [lto] Only build host libraries using LTO.
At some point in the future, we may consider using LTO on the runtime/standard
library, but right now is not that time. We are just trying to use LTO to
improve the compile time performance of the compiler itself.

rdar://24717107
2016-06-10 13:33:54 -07:00
Michael Gottesman
db2126c139 [lto][cmake] Do not access SWIFT_TOOLS_ENABLE_LTO directly in _add_variant_{c_compile,variant_link}_flags. Pass it in as an arg instead.
This will allow control on the outside of these calls on whether or not LTO is
enabled. This is necessary for turning off LTO on target libraries.

rdar://24717107
2016-06-10 13:27:42 -07:00
swift-ci
c8bbd63a7c Merge pull request #2980 from rintaro/gyb-validation-test 2016-06-10 10:21:14 -07:00
Rintaro Ishizaki
46a6df2f67 [CMake] Remove --test option from normal gyb invocation in CMake 2016-06-10 18:56:17 +09:00
Michael Gottesman
bd9d59578b [lto] Do not pass in the LLVM_ENABLE_LTO flag to Swift's cmake invocation.
*NOTE* We are still passing this variable into LLVM. Just not into Swift anymore.

I originally passed in the variable -DLLVM_ENABLE_LTO=YES to Swift's cmake to
ensure that the Swift unittests were compiled with lto. That was the wrong
fix.

The reason why is that if -DLLVM_ENABLE_LTO is set to YES then HandleLLVMOptions
in llvm will append -flto to both CMAKE_C_FLAGS and CMAKE_CXX_FLAGS implying
that -flto can not be disabled selectively. This ability to disable flto
selectively is something that we need in order to lto host libraries, but not
lto target libraries.

Thus in this commit, we no longer pass in -DLLVM_ENABLE_LTO=YES to swift's cmake
invocation. Instead we apply the lto flag to the unittest target ourselves in
add_swift_unittest.

rdar://24717107
2016-06-10 01:48:36 -07:00