Commit Graph

309 Commits

Author SHA1 Message Date
Saleem Abdulrasool
ca13658270 runtime: avoid the toolchain Swift registrar
Pass `-nostartfiles` to the driver as a staged toolchain would attempt
to link the Swift registrar which may not exist if the SDK is not
integrated. Furthermore, the registrar to be used is locally built and
not the one from the previous build.
2024-12-13 13:55:51 -08:00
Saleem Abdulrasool
215db61ea7 Merge pull request #78145 from compnerd/unescapable-features
Core: add `NonescapeableTypes` feature
2024-12-13 13:54:51 -08:00
Saleem Abdulrasool
540a5c271e Merge pull request #78133 from compnerd/exports
Runtime: control `swiftCore_EXPORTS` based on the build
2024-12-13 13:54:32 -08:00
Evan Wilde
9aba19b8cf [CMake] Add build-system vendor hook for swiftCore
Adding a hook point for vendors to add flags, definitions, etc, to the
swiftCore library build.
2024-12-13 12:26:12 -08:00
Saleem Abdulrasool
fae4ec1437 Runtimes: Threading requires "compiler" headers
Add an additional header search path as the threading library has
intertwined dependencies and requires some headers from the compiler
set.
2024-12-12 21:29:23 -08:00
Saleem Abdulrasool
0e68650065 Core: add missing experimental features
Enable the non-escapeable types and lifetime dependence features when
building swiftCore. While we do not enable all the same features being
used in the current standard library, this allows us to build the
runtime.
2024-12-12 21:08:30 -08:00
Saleem Abdulrasool
59a9ef5bb7 Merge pull request #78134 from etcwilde/ewilde/x-platform-fixes
[CMake] Fix some issues in new runtime build for Linux and Windows builds
2024-12-12 18:11:07 -08:00
Saleem Abdulrasool
7b8c339cb6 Merge pull request #78146 from compnerd/non-modularity
Core: add missing flags for Windows
2024-12-12 17:31:10 -08:00
Saleem Abdulrasool
fc27a28411 Merge pull request #78144 from compnerd/threading-the-needle
Core: specify the threading package that is in use
2024-12-12 17:30:03 -08:00
Saleem Abdulrasool
f5487e41d4 Core: add missing flags for Windows
Windows core modules require the `-fbuiltin-headers-in-system-modules`
flag to be passed to the clang importer. Adjust the build flags for the
platform.
2024-12-12 10:50:25 -08:00
Saleem Abdulrasool
6d678ac01d Core: specify the threading package that is in use
This is required for the non-Darwin targets as `SWIFT_THREADING_DARWIN`
does not enable any additional code. However, that macro is used in
other places that are not yet integrated. This was identified by
building for Windows.
2024-12-12 10:48:43 -08:00
Saleem Abdulrasool
8bf26a795c Runtime: control swiftCore_EXPORTS based on the build
This define is meant to be present only when performing a build of a
dynamic library. The general pattern for this is:

  ```c
  #if defined(LIBRARY_STATIC)
  # define LIBRARY_ABI /**/
  #else
  # if defined(_WIN32)
  #   if defined(LIBRARY_EXPORTS)
  #     define LIBRARY_ABI __declspec(dllexport)
  #   else
  #     define LIBRARY_ABI __declspec(dllimport)
  #   endif
  # elseif defined(__linux__) && !defined(__ANDROID__)
  #   define LIBRARY_ABI __attribute__((__visibility__("protected")))
  # else
  #   define LIBRARY_ABI __attribute__((__visibility__("default")))
  # endif
  #endif
  ```

For AIX this would require an additional flag to be specified
(`-mdefault-visibility-export-mapping=explicit`). The same applies for
other non-AIX, non-Windows platforms with a different set of flags:
`-fvisibility=hidden -fvisibility-inlines-hidden`.

This is required to start trying to build the standard library
statically on Windows (which also requires further changes to the
Swift compiler).
2024-12-12 10:06:21 -08:00
Evan Wilde
78914e987a Add ErrorObject and SwiftObject to all builds
These files are required in order to link libswiftCore regardless of
whether ObjectiveC is required.
2024-12-11 19:49:31 -08:00
Evan Wilde
979697eb13 CMake: Fix expanding the default variable
`defaulted_set` wasn't expanding the default variable, just setting the
value of the variable the name of the variable that should have been
doing the defaulting.
2024-12-11 19:48:36 -08:00
Justice Adams
f1f3604cca remove cmake color diagnostic flags (#78098) 2024-12-11 13:37:59 -08:00
Justice Adams
c6556d8d38 [Cmake] hook up SWIFT_STDLIB_TRACING arg (#77785)
* move tracing flags to the runtime cmake definition

* remove -DSWIFT_STDLIB_CONCURRENCY_TRACING
2024-12-10 14:42:17 -08:00
Justice Adams
acb2a4483e [Cmake] add toolchain and cache files for Darwin platforms (#77958)
* add toolchain and cache files for Darwin platforms

* cleanup SDKROOT check and remove explicit check for CMAKE_MAKE_PROGRAM
2024-12-10 08:34:18 -08:00
Evan Wilde
949a0ae186 Merge pull request #77819 from etcwilde/ewilde/stdlib-rebuild-enable-unicode-data
[CMake] Enable unicode data support
2024-12-09 15:30:33 -08:00
Dave Lee
463b615a07 [Debug] Remove unnecessary DebugDescriptionMacro feature references (NFC) (#77738) (#77953)
The `DebugDescription` macro has been accepted. Additionally, the `DebugDescriptionMacro` feature was not providing conditional declaration as I originally intended. References to the feature are not needed and can be removed.

(cherry-picked from #77738)
2024-12-05 06:57:17 -08:00
Justice Adams
4ac0bfd8e2 Merge pull request #77782 from swiftlang/jadams/set-inlines-hidden
[cmake] set CMAKE_VISIBILITY_INLINES_HIDDEN on libSwiftCore
2024-12-02 08:35:31 -08:00
Evan Wilde
f273a2e283 [CMake] Enable unicode data support
Stubs has a macro define for enabling or disabling the embedded
unicode data tables, which are required for doing things like counting
characters in strings. Add that option and default it to 'on' for full
unicode support.
2024-11-22 15:43:10 -08:00
justiceadams
4494138c37 set CMAKE_VISIBILITY_INLINES_HIDDEN 2024-11-21 09:21:54 -08:00
justiceadams
f0392dbce4 add debugdescription source file when needed 2024-11-21 09:12:16 -08:00
Meghana Gupta
5b5acc64e0 Promote Nonescapable types to a language feature 2024-11-18 18:09:17 -08:00
Evan Wilde
f9ea3bd471 [CMake] Disable RTTI and exceptions in stdlib
The C++ runtime bits should not have RTTI or exceptions enabled.
Disabling those now, but keeping the unwind tables to match the old
build.
2024-11-14 11:55:27 -08:00
Evan Wilde
d87a293e80 [CMake] Add backdeployment symbols
Hooks up the definition for back-deployment support and the missing
library name needed to get the magic symbols set up right.
2024-11-12 13:18:00 -08:00
Evan Wilde
e160e23dde [CMake] Connecting more flags and options
Making a more in-depth pass over the definition macros and flags in
SwiftSource.cmake _add_target_variant_swift_compile_flags.
These are only flags that actually matter for swiftCore though. This
does not include concurrency flags.
2024-11-12 11:31:10 -08:00
Evan Wilde
1701775ecd [CMake] Hide C/C++ symbols by default
The Swift stdlib shouldn't be exposing C/C++ symbols by default.
There are select functions that should be exposed, like the
`_swift_allocObject` and the retain/release functions, but this should
be an explicit decision in the sources.
2024-11-12 08:41:30 -08:00
Justice Adams
59d3af1dff Merge pull request #77543 from swiftlang/fix-vector-symbols-support
[cmake] Define -DSWIFT_STDLIB_ENABLE_VECTOR_TYPES when needed
2024-11-12 08:27:16 -08:00
Evan Wilde
dc66e8d262 Merge pull request #77544 from etcwilde/ewilde/stdlib-rebuild-pass-CommandLine-Support-macro
[cmake] Set SWIFT_STDLIB_HAS_COMMANDLINE
2024-11-12 08:23:25 -08:00
Evan Wilde
87b44cf927 [cmake] Set SWIFT_STDLIB_HAS_COMMANDLINE
Set the SWIFT_STDLIB_HAS_COMMANDLINE macro when the stdlib has command
line support. This is needed while building SwiftCore to ensure that it
exports the appropriate symbols.
2024-11-11 15:36:37 -08:00
justiceadams
d54ecf6f6d define -DSWIFT_STDLIB_ENABLE_VECTOR_TYPES when needed 2024-11-11 15:35:00 -08:00
Evan Wilde
2df8a185b8 [cmake] Add private build extension points
Adding vendor-specific extension points to the build system, giving
vendors a place to put their internal settings and defaults, without
having to modify the build directly. This helps reduce the chances of
merge conflicts and public changes breaking internal settings.

The location of the macros are set with `SwiftCore_PRIVATE_MODULE_DIR`,
so vendors can keep their private extensions in a separate location if
desired. Otherwise, it defaults to `cmake/modules/private`, which
intentionally does not exist at this time.

Currently, we have extensions for the default settings and global
settings.
2024-11-08 17:05:41 -08:00
Evan Wilde
148a910d7b [nfc] Add documentation to default macros
Adding documentation on the behavior of the `defaulted_option` and
`defaulted_set` macros.
2024-11-08 16:41:30 -08:00
Evan Wilde
9185606027 [cmake] Add macro to create defaulted settings
Adding a macro to tie non-boolean variables into the defaulting
mechanism.
2024-11-08 15:58:27 -08:00
Evan Wilde
794a96f206 Merge pull request #77469 from etcwilde/ewilde/stdlib-rebuild-elf-swiftrt-paths
[CMake] Get ELF SwiftRT building
2024-11-08 08:19:53 -08:00
Evan Wilde
bd63b21fd9 Merge pull request #77467 from etcwilde/ewilde/stdlib-rebuild-function-counters
[CMake] Add option to enable runtime function counters
2024-11-08 08:19:40 -08:00
Evan Wilde
08daac6466 Adding C/C++ portion of CommandLine support
Hooking up the bits of the build to link the swift commandline support
C++ bits into swiftCore.
2024-11-07 20:05:56 -08:00
Evan Wilde
2a8bb9db93 Adding ELF swiftrt for BSD and Android
BSD and Android also need to build swiftrt.o so adding it to the
default settings.
2024-11-07 15:23:52 -08:00
Evan Wilde
ccb2fcd436 Add missing header search paths for swiftrt
The ELF SwiftRT includes some headers from the compiler include
directories. Adding those search paths so that it builds.
2024-11-07 15:22:55 -08:00
Evan Wilde
ac5768341f Add option to enable runtime function counters 2024-11-07 15:03:51 -08:00
Evan Wilde
12fb294cce Remove SwiftCore_SWIFTC_CLANGIMPORTER_RESOURCE_DIR
The SwiftCore_SWIFTC_CLANGIMPORTER_RESOURCE_DIR is not being used so I'm
deleting it for now. This means we only grab the target info once.
2024-11-07 00:11:08 -08:00
Evan Wilde
2c07a23a45 Cleanup WMO forcing
This patch cleans up the handling of WMO-forcing in the workaround file.
`-wmo` is passed in each of the link jobs in the non-CMP0157-enabled
configuration to keep it matching the behavior of the CMP0157-enabled
builds.

This also moves the commentary about num-threads and WMO to the top of
the file to make it clearer what is going on. Ideally the file wouldn't
have to exist, but it does.

The file also contains the target install-name fix that landed in CMake
3.29.8 and CMake 3.30.2, so earlier versions of CMake 3.29 will work
with this build as well.
2024-11-07 00:00:33 -08:00
Evan Wilde
dad1ea8ed2 Shuffle definitions around
De-duping some of the definitions. We can pass most of the definitions
to both the Swift and C/C++ compilers in the same form if we don't
assign anything. C/C++ will set the macro value to `1` if there is no
`=` as part of the definition, and `#if` recognizes a non-existent macro
to be false. With this logic, we can unify some of these.
2024-11-06 21:27:54 -08:00
Evan Wilde
1aeab071d0 Fix rpath flag 2024-11-06 21:27:54 -08:00
Evan Wilde
8385137bfa Auto populate runtime source directory
This patch causes the convenient flow to automatically populate the
sources into the new runtime directory layout. This is run at build-time
so that it repopulates on each build. Since the resync script uses
`COPY_IF_DIFFERENT`, only files that change in the main source directory
are copied over, so incremental builds should still work.

Fixed a small bug in the resync script to ensure that it creates the
subdirectories in the right places.
2024-11-06 21:27:54 -08:00
Evan Wilde
50871f9f11 Get Android building 2024-11-06 21:27:53 -08:00
Evan Wilde
4f6489f746 Fixing comments
Fixing some of the comments in DefaultSettings.cmake and
PlatformInfo.cmake.

I haven't added any vendor cache files yet, so the comment doesn't point
anywhere. Also fixing the reference to the location of the clang
resource headers in PlatformInfo.cmake.
2024-11-06 21:27:53 -08:00
Evan Wilde
2a3e6d53a0 Moving compiler-src-dir refs
Moving the rest of the references to the compiler source directory to
use the `SwiftCore_SWIFTC_SOURCE_DIR` variable instead of
`${PROJECT_SOURCE_DIR}/../../`.
2024-11-06 21:27:53 -08:00
Evan Wilde
e2b878b4e9 Setup reasonable defaults
This patch makes it simpler to setup reasonable defaults for a given
platform. The standard library has many knobs for configuration
purposes. This is great for providing cache files to configure specific
builds, but the build system should still generally work if someone runs
a minimal CMake invocation against the build without futzing with
various options.
2024-11-06 21:27:53 -08:00