Commit Graph

506 Commits

Author SHA1 Message Date
Saleem Abdulrasool
fdf0fa2775 build: improve debug builds on Windows
Ensure that we build all the target libraries with the correct build
configuration.  This is needed on Windows where the different MSVC
runtime libraries are ABI incompatible.
2019-05-18 20:04:09 -07:00
Saleem Abdulrasool
7514adf66a Driver: introduce new -libc option for Windows
On Windows, there are multiple variants of the C runtime that must be
explicitly specified and consistently used from the runtime to the
application.  The new `-libc` option allows us to control the linking
phase by correctly embedding the requested library to be linked.  It is
made into a required parameter on Windows and will add in the
appropriate flags for the imported C headers as well.  This ensures that
the C library is not incorrectly linked.
2019-05-16 21:01:47 -07:00
Ross Bayer
23a868e9f2 Merge pull request #24382 from Rostepher/usr-lib-install-name-dir
[Build System: CMake] Update the default install_name_dir to /usr/lib/swift for the standard library and overlays.
2019-05-13 15:05:22 -07:00
Saleem Abdulrasool
cd0c1e7150 build: correct flags for Windows build
Adjust the preprocessor macros to get correct DLL Storage for imported
functions.  This should help identify cases of incorrect linkage to
msvcrt/ucrt.
2019-05-09 17:16:51 -07:00
Michael Gottesman
4d4d6f6779 Merge pull request #24508 from compnerd/matchy-matchy
build: rename `LLVM_COMPONENT_DEPENDS`
2019-05-06 11:45:36 -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
Saleem Abdulrasool
f9b304e14b build: obsolete INTERFACE_LINK_LIBRARIES
This was deprecated a while ago, remove support for it.  This is no
longer used in the Swift build.  Remove the dead code.
2019-05-04 18:13:38 -07:00
Ross Bayer
dfb2d31e74 Rename the LIBRARY_INSTALL_NAME_DIR argument in add_swift_target_library to DARWIN_INSTALL_NAME_DIR which better explains that this argument only controls the install_name_dir for Darwin platforms. 2019-04-29 16:46:09 -07:00
Ross Bayer
bec25a1dad Added a new argument to add_swift_target_library to control the install_name_dir. 2019-04-29 16:46:09 -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
Saleem Abdulrasool
d3ce6a6da5 build: fix a mixup with the cmake variables
This adjusts the windows build for cross-compiling to use the correct
variable.  Import libraries will be generated and tracked properly if
the CMAKE_SYSTEM_NAME is set to Windows.  It does not matter what the
build system is.
2019-04-09 12:12:27 -07:00
Michael Gottesman
91dbbc3088 Merge pull request #23204 from compnerd/silence-in-the-library
Remove custom handling in add_swift_host_library
2019-04-08 10:49:42 -07:00
Saleem Abdulrasool
a5705d6825 build: add a workaround for reflection test on Windows
Copy the runtime component into the swift runtime directory.  Normally
the runtime directory is not the same as the library directory on
Windows.  This copies the runtime component into the build tree into the
runtime directory to permit the tests to find the standard library.
2019-04-07 14:41:30 -07:00
Saleem Abdulrasool
7e79874e0c build: inline the ICU handling into the CFLAGS handling
Rather than have the ICU handling be pushed down into the library handling, this
will move it into the CFLAGS calulation which was being augmented previously.
It is a cleanup that makes it easier to reason about the flags handling.
2019-04-05 16:05:15 -07:00
Saleem Abdulrasool
7e32c43653 build: append to the computed c_compile_flags
Adjust the `c_compile_flags` variable to ensure that the flags are ordered
correctly.  This is of import for the android build which may end up using
invalid header search path ordering otherwise.  This ensures that the path
for the ICU includes comes after the C++ headers which is necessary in new
C++ releases which shadow math.h
2019-04-05 15:52:51 -07:00
Saleem Abdulrasool
871c9a9418 build: sink the ICU flag handling lower (NFC)
Move the ICU flag handling to the same area as `_c_compile_variant_flags` which
computes the C compile flags.  This allows us to ensure that we order the flags
correctly when they are merged into the `c_compile_flags`.
2019-04-05 15:52:51 -07:00
Alex Langford
4cf2af591d [CMake] Make sure ICU libdir is correctly added to library_search_directories
The CMake variables ${sdk} and ${arch} are only set if
_add_variant_link_flags is invoked from add_swift_target_library calling
_add_swift_library_single. If you get to _add_swift_library_single from
add_swift_host_library, those variables will not be set and subsequent
linking will not find ICU libraries. This was an issue when building
swift host libraries on Android.
2019-04-02 12:11:14 -07:00
Ross Bayer
3acef63892 [Build System: CMake] Add back the missing install_name_dir for the standard library. 2019-04-01 11:19:27 -07:00
Ross Bayer
b0a533aa9a [Build System: CMake] Cleanup the install_name_dir special-casing for XCTest in add_swift_target_library. 2019-03-29 17:27:04 -07:00
Mike Ash
26d44d5214 Properly configure the target library name used by magic-symbols-for-install-name.c. 2019-03-22 11:41:00 -04:00
Michael Gottesman
384882d5f3 Merge pull request #23201 from compnerd/patience-is-not-always-a-virtue
build: introduce and switch to GYB_SOURCES
2019-03-20 13:27:32 -07:00
Saleem Abdulrasool
4b9e9d3164 build: excise the concept of fat libraries
This was used for the swift-reflection-test tool.  Instead of using fat
binaries, use the target binary itself.  This simplifies the build logic
as well as paves the road to sub-builds for each target rather than a
monolithic build as we have today.

Originally, the swift-reflection-test was a host tool that linked
against the target libraries since it was testing the target layout.
Now that the tool has been split into a host and target component
(5ea5bb06a3) and we have target and host
libraries that we can link against appropriately, we do not need to link
against the FAT binary.  Since there was exactly one use of this
functionality, switching that from fat linking to regular linking allows
us to remove this functionality entirely.  Switch to regular linking and
remove the option.
2019-03-12 22:30:20 -07:00
Saleem Abdulrasool
8ed5c1a4bc build: introduce and switch to GYB_SOURCES
This avoids us having to pattern match every source file which should
help speed up the CMake generation.  A secondary optimization is
possible with CMake 3.14 which has the ability to remove the last
extension component without having to resort to regular expressions.  It
also helps easily identify the GYB'ed sources.
2019-03-11 13:48:54 -07:00
Saleem Abdulrasool
533a26a5eb build: remove outdated documentation (NFC) 2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
f9df4cad97 build: remove DEPENDS from add_swift_host_library
Use the appropriate CMake mechanisms for building the libraries.
2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
c1c75a4b2d build: drop LINK_FLAGS from add_swift_host_library
This is not currently being used.  Unfortunately, setting linker options
is difficult until CMake 3.13 which introduced target_link_options.
Prior to that, you needed to do:

set_property(TARGET <TARGET> APPEND_STRING LINK_FLAGS <NEW FLAGS>)

If needed, we could write a helper to provide the target_link_options
interface on earlier CMake versions.
2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
31a5ae7f56 build: remove LINK_INTERFACE_LIBRARIES from add_swift_host_library
Use the appropriate CMake mechanism for building the libraries.
2019-03-10 17:01:27 -07:00
Saleem Abdulrasool
b0005e9f87 build: remove C_COMPILE_FLAGS from add_swift_host_library
Use the appropriate CMake mechanism for controlling flags for building
the code.
2019-03-10 15:38:55 -07:00
Saleem Abdulrasool
ee5ab9e98a build: prevent accidental addition of LINK_LIBRARIES
Protect against LINK_LIBRARIES, directing the developer to
target_link_libraries.  This has no impact on the build currently.
2019-03-09 20:44:41 -08:00
Doug Gregor
c94da3b4da [CMake] Set -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING=1 for runtime/overlays
Whenever we're building C++ code as part of the Swift runtime or overlays,
disable the ABI-breaking checks. We are only using header content from
LLVM's ADT library.

Fixes rdar://problem/48618250.
2019-03-06 17:21:17 -08:00
Vedant Kumar
bafb963d7b Enable linker dead stripping on Darwin (#22839)
* Enable linker dead stripping on Darwin

See r://48283130. This shaves 6MB+ off of swift and SourceKitService,
26.8MB off of swift-llvm-opt, 29.4MB off sil-passpipeline-dumper, etc.

* Disable dead stripping in Debug builds

It can hide linker errors caused by dependency cycles.
2019-02-25 10:52:48 -08:00
Saleem Abdulrasool
22fde69e6c cmake: make swiftRemoteMirror export interfaces on Windows
Unfortunately, `swift-reflection-test` links against the *TARGET*
library `swiftRemoteMirror`.  The linked library is built as a target
library, which means that we use the custom library target construction
which suffixes the target with a variant spelling.  Because the number
of variants is really high, we pass along the explicit EXPORTS macro
manually.  However, we also build the library as a static library for
the *HOST*.  This means that we need the sources to be aware of whether
they are built statically or dyanmically.  This is accomplished by means
of the `_WINDLL` macro.  The target library is shared and is built using
the custom wrapper for the library construction, which will create all
the variants and then use `_compute_variant_c_flags` which does not get
told what type of library is being built, so it assumes static and does
not append `_WINDLL`.  This results in the shared library not exposing
any interfaces on Windows.  When this happens, link will helpfully elide
the import library.  The result of that is that the
swift-reflection-test binary will fail to link due to no import library
for the RemoteMirror.  Explicitly add the -D_WINDLL if appropriate
manually after we have computed the C flags.  *siiiiiiigh*
2019-02-23 20:03:47 -08:00
Saleem Abdulrasool
8062230cff CMake: use _WINDLL rather than _USRDLL
`_USRDLL` is used to indicate that you are building a MFC DLL while
`_WINDLL` is specified for **ALL** DLL builds.  Use the correct macro.
2019-02-22 10:49:25 -08:00
Jordan Rose
43feb9cbe1 On Apple platforms, use swiftmodule directories for the stdlib (#21797)
This changes the Swift resource directory from looking like

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          x86_64/
            Swift.swiftmodule
            Swift.swiftdoc
            Darwin.swiftmodule
            Darwin.swiftdoc

to

    lib/
      swift/
        macosx/
          libswiftCore.dylib
          libswiftDarwin.dylib
          Swift.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc
          Darwin.swiftmodule/
            x86_64.swiftmodule
            x86_64.swiftdoc

matching the layout we use for multi-architecture swiftmodules
everywhere else (particularly frameworks).

There's no change in this commit to how Linux swiftmodules are
packaged. There's been past interest in going the /opposite/ direction
for Linux, since there's not standard support for fat
(multi-architecture) .so libraries. Moving the .so search path /down/
to an architecture-specific directory on Linux would allow the same
resource directory to be used for both host-compiling and
cross-compiling.

rdar://problem/43545560
2019-02-19 14:47:21 -08:00
Ross Bayer
083350af77 Revert "[CMake] Remove LINK_LIBRARIES option from _add_swift_executable_single" 2019-02-12 14:42:22 -08:00
Ross Bayer
fc58ad4207 Merge pull request #22128 from xiaobai/remove_link_libs_option
[CMake] Remove LINK_LIBRARIES option from _add_swift_executable_single
2019-02-11 12:22:26 -08:00
Saleem Abdulrasool
f441f089cc build: fix mismatch of MSVCRT in release mode
When building RelWithDebInfo, we would accidentally link against the debug
MSVCRT library rather than the release mode one resulting in memory corruptions.
2019-02-08 15:08:56 -08:00
Saleem Abdulrasool
85f45dfe30 SwiftRemoteMirror: add a host build for the tools
This adds an explicit version of the SwiftRemoteMirror library for use
in the tools that comprise the toolchain.  This is a separate build from
the target specific builds of the library even though we may be building
the runtime for the (same) host.
2019-01-28 18:00:58 -08:00
Michael Gottesman
cc68e6a0d5 Remove some remaining dead code from the +0 argument convention bring up.
I already removed the option from SILOptions, so all of this stuff is dead.
2019-01-27 13:18:06 -08:00
Alex Langford
6c63f4d3f5 [CMake] Remove LINK_LIBRARIES option from _add_swift_executable_single
This option has been unused since commit
dd85d79105. We now use
target_link_libraries instead of this option.
2019-01-25 14:25:58 -08:00
Ben Langmuir
753eb53f1c Merge pull request #21721 from benlangmuir/optionalize
[cmake] Make install of stdlib target libraries OPTIONAL
2019-01-22 16:19:06 -08:00
Ben Langmuir
cba2670479 [cmake] Update OPTIONAL install products to be Darwin-only
Per review feedback.
2019-01-22 12:05:55 -08:00
Ben Langmuir
d08a2a058a [cmake] Make install of stdlib target libraries OPTIONAL
This fixes using --install-swift on macOS when not building all of the
variant stdlibs (e.g. iphonesimulator, etc.).

When we build swift on macOS, by default we build only the macOS stdlib.
The other stdlib variants are still configured and there are targets to
build them if you e.g. run `ninja swift-stdlib-iphonesimulator-x86_64`
manually.  However, we do not separate the _install_ actions.  This
meant that you couldn't install without building all the configured
stdlib variants.
2019-01-22 11:13:29 -08:00
Saleem Abdulrasool
d4598ec15a Merge pull request #22002 from compnerd/nx
build: inline single use `add_swift_executable`
2019-01-19 13:22:40 -08:00
Saleem Abdulrasool
7402221425 build: cleanup unneeded flags for Windows
This flag is now handled by the driver, so remove it from the special
handling in the build system.
2019-01-19 10:06:06 -08:00
Saleem Abdulrasool
a0ec0c0dfb build: inline single use add_swift_executable
Inline the single use of this function and remove the extra parameter
handling around it, letting `_add_swift_executable_single` do the heavy
lifting.
2019-01-19 09:38:40 -08:00
Doug Gregor
00485afc68 Always set the compatibility_version of linked dylibs on Darwin.
Use 1.0.0 when there is no more-specific SWIFT_COMPILER_VERSION.
2019-01-15 14:35:21 -08:00
Michael Gottesman
cb41b77dca Fix --force-optimized-typechecker
I believe this was broken due to recent refactoring of cmake.
2019-01-14 14:27:51 -08:00
Jordan Rose
aea1ef8175 Move API notes out of the arch-specific subdirectories in lib/swift/ (#21690)
They're all the same anyway, and no longer even need to be compiled,
just copied in as text.

And drastically simplify how we "generate" them. Instead of attaching
their build jobs to the appropriate overlays, if present, "just" have
one job to copy them all and attach it to the Darwin overlay. That's
what we do for the overlay shim headers, and it's good enough.
(Eventually we want to get out of the business of shipping them
altogether.)

This does have the same flaw as the shim headers: if you /just/ change
API notes, the corresponding overlay does not get rebuilt. You have to
touch that too. But in practice that'll happen most of the time
anyway.

Part of rdar://problem/43545560
2019-01-09 14:06:21 -08:00
Saleem Abdulrasool
6dac8dd092 build: cleanup swiftCore link definition
Colocate the target specific library specification.  Inline the single
site use of the place holder ICU_UC and ICU_I18N libraries rather than
trying to create special library processing code for that.
2019-01-08 08:31:35 -08:00