Commit Graph

46 Commits

Author SHA1 Message Date
Eric Miotto
48fd452cd6 macOS smoketest: enable Distributed and Synchronization in runtimes
To make this work:
* expose SwiftCMakeConfig.h from the Core build
system, to support scenarios in which the downstream Distributed build
is leveraging the config files generated by CMake itself.
* adjust how SwiftShims is defined in `FindSwiftCore.cmake`, so that the
shims are found from C++ and that we don't get redefinition errors
when multiple module maps are in the search paths.

Fixes #83449
Addresses rdar://149241603, rdar://157165530
2025-08-08 13:17:19 -07:00
Eric Miotto
7348469093 Cleanup CMakeConfig.h.in generation across the codebase
Addresses rdar://154230645
2025-07-15 14:44:40 -07:00
Saleem Abdulrasool
c1dbc12587 Runtimes: establish dependency on the registrar
This removes the workaround for the exporting of the registrar and
enables proper dependency tracking across projects (primarily geared
towards the Overlay).
2025-03-25 10:12:31 -07:00
Saleem Abdulrasool
bc45db16fd Runtimes: properly link in swiftrtT?.obj on Windows
`swiftrtT.obj` should be used for statically linking the standard
library (or within the standard library itself). For the other modules,
we need to differentiate between `swiftrt.obj` and `swiftrtT.obj`. This
fixes that oversight. This was not caught by the CI builds as we do not
currently build both the static and dynamic variants of the new
runtimes.
2025-03-20 11:07:46 -07:00
Evan Wilde
7679b6e08f CMake: Fix swiftrt.o install location on Linux
Flipped the conditional here. Was installing swiftrt.o to `swift_static`
when building dynamic libraries and `swift` when building static
archives.
2025-02-28 15:00:51 -08:00
Saleem Abdulrasool
bab2e673d6 Runtime: correct install rules for runtime component
We missed a `$<` leader for the generator expression. Adjust the install
rules to account for that.
2025-02-27 11:13:31 -08:00
Evan Wilde
7ed975aac2 CMake: Fix swiftrt.o install location
The driver just changed where it looks for swiftrt.o when performing a
static-stdlib build from always looking under `/usr/lib/swift` to
`/usr/lib/swift_static`.

This change of behavior comes from:
7156812d251d0f4dd6e7c605940f7e5497eaa795
2025-02-26 10:32:07 -08:00
Evan Wilde
71f9aac6e3 Merge pull request #79548 from etcwilde/ewilde/stdlib-rebuild-install-story
CMake: SwiftCore Install Story
2025-02-26 09:53:02 -08:00
Evan Wilde
7870db67f8 CMake: Runtime Installation Story
Starting to work on a full installation story for the Swift runtimes.
This involves generating the SwiftCoreConfig cmake files to allow
importing the just-built runtimes into the overlays and supplemental
libraries, setting up the flags appropriately for the given SwiftCore
build configuration.

This also separates out the development and runtime components to allow
installing just the runtimes without the headers.

Component List:
 - SwiftCore_runtime

  The runtime libraries that are required for running code.

 - SwiftCore_development

  The interface with the runtime libraries that are required for
  building code against the runtimes.

 - SwiftCore_cmake

  Files for interfacing CMake projects with the built runtimes.
  This includes the target list and flags needed to use the targets
  built by the specific configuration used to build the runtime
  libraries.

  These files are used for mapping flags, definitions, and locations
  into the overlay libraries and supplemental libraries.

This adds install commands for the object libraries contributing to
libswiftCore so that they are represented in SwiftCoreTargets.cmake.
Object libraries do not contribute anything to the files actually
installed.
2025-02-22 10:33:17 -08:00
Saleem Abdulrasool
10c804b0bb runtime: adjust the program name reference
`__progname` is not available on Windows, and is provided by libbsd on
Linux. This provides a replacement for the functional aspect of the
symbol on Windows.
2025-02-22 07:14:26 -08:00
Saleem Abdulrasool
5bb4978b1a runtime: add swiftrtT.obj build
This introduces the new variant of the `swiftrt.obj` - `swiftrtT.obj`
for Windows. This follows the C standard library naming convention as
set forth by GCC.

`crtbegin.o` => used to find constructors
`crtbeginS.o` => used to find constructors in DSOs/PIEs
`crtbeginT.o` => used to find constructors in static executables

The newly minted `swiftrtT.obj` is meant for static linking. The one
exception to this is building the swift runtime itself which locally
defines the symbols and thus should always use the static variant.
2025-02-07 15:29:28 -08:00
Evan Wilde
e17df88cc1 Merge pull request #78963 from etcwilde/ewilde/stdlib-rebuild-extra-malloc-type
CMake: Define DARWIN_LIBMALLOC
2025-01-28 09:17:31 -08:00
Alastair Houghton
96f23e34b0 [Build] Update SWIFT_TARGET_LIBRARY_NAME for swiftRuntime in new build. (#78977)
We need to change `SWIFT_TARGET_LIBRARY_NAME` for the `swiftRuntime`
target in the new build because of changes made to the old build system.
2025-01-28 09:12:36 -08:00
Evan Wilde
3b4dee5cb6 CMake: Define DARWIN_LIBMALLOC
`SWIFT_STDLIB_HAS_MALLOC_TYPE` is defined in terms of
`SWIFT_STDLIB_HAS_DARWIN_LIBMALLOC` in `include/swift/Runtime/Config.h`.
Apple platforms generally have the Darwin libmalloc, so it should be a
safe bet to define it this way. Unfortunately, a lot of things include
the Config.h file, transitively or otherwise, so figuring out exactly
which libraries should have this defined vs ones that should not is
rather tricky, so for now, I've defined it globally.
2025-01-27 15:57:21 -08:00
Evan Wilde
95f4f6ff80 Merge pull request #78497 from etcwilde/ewilde/stdlib-rebuild-backtrace-reporting
CMake: SwiftCore: Add back SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING
2025-01-24 21:59:55 -08:00
Evan Wilde
066dc94786 Merge pull request #78860 from etcwilde/ewilde/stdlib-rebuild-platform-arch-dirs
CMake: Add install platform and architecture subdirs
2025-01-24 20:55:47 -08:00
Evan Wilde
5aadacee41 CMake: SwiftCore: Add back SWIFT_STDLIB_SUPPORTS_BACKTRACE_REPORTING
Add an option to enable emitting a stacktrace on calls to `fatalError`.
This is unrelated to the runtime backtracer for diagnosing normal Swift
crashes.

rdar://142440689
2025-01-23 12:42:28 -08:00
Evan Wilde
f2ddef7601 Merge pull request #78498 from etcwilde/ewilde/stdlib-rebuild-lazy-init-os-trace
CMake: SwiftCore: SWIFT_USE_OS_TRACE_LAZY_INIT
2025-01-23 12:35:18 -08:00
Evan Wilde
a9da4a5c1a CMake: Add install platform and architecture subdirs
In some configurations, libraries are installed under
`<install-prefix>/{libdir}/swift/<platform>/<arch>` and module content
is installed under `<install-prefix>/{libdir}/swift/<platform>`.

This also accounts for the fact that Swift currently looks under
`<install-prefix>/{libdir}/swift_static/**` for the static stdlib
builds.
2025-01-23 12:25:21 -08:00
Evan Wilde
d470565e2d CMake: SwiftCore: SWIFT_USE_OS_TRACE_LAZY_INIT
Adding the SWIFT_USE_OS_TRACE_LAZY_INIT macro to the new build system.

rdar://142440689
2025-01-21 13:49:38 -08:00
Saleem Abdulrasool
46112a992a Runtimes: adjust installation of swifrt.{o,obj}
Install the Swift registrar into the correct location for the SDK. This
file is to be placed into /usr/lib/swift/<platform>/<arch> with the name
`swiftrt.[o|obj]`.
2025-01-16 15:58:56 -08:00
Saleem Abdulrasool
f1b63b2e10 Merge pull request #78502 from compnerd/language
Runtimes: simplify `target_compile_definitions` call
2025-01-09 15:07:05 -08:00
Saleem Abdulrasool
168aa833f6 Runtimes: simplify target_compile_definitions call
The swiftRuntime library is a C++/ObjC++ library. There is no need to
check the compile language for the additional flags allowing us to
simplify the call.
2025-01-08 15:19:21 -08:00
Saleem Abdulrasool
358be09832 stdlib,Runtimes: begin preparing for a static stdlib on Windows
When building the standard library statically on Windows, we should not
use any __declspec(dllimport) or __declspec(dllexport) on the runtime
functions or data. Furthermore, we should internalise all of the
standard library functions so that they are not re-exported if used to
build a shared library. The code generation changes required for this
are easier to identify once a static SDK is available for Windows.
2025-01-08 15:08:14 -08:00
Eric Miotto
b2225b2625 Merge pull request #78490 from edymtt/edymtt/set-swift-inline-namespace-for-core
[CMake] Use separate namespace for demangling symbols used by runtime
2025-01-08 13:45:59 -08:00
Eric Miotto
550ac9ff32 Merge pull request #78478 from edymtt/edymtt/sense-type-printing-for-runtime-as-well
[CMake] Sense `SwiftCore_ENABLE_TYPE_PRINTING` in `swiftRuntime` build
2025-01-08 12:55:27 -08:00
Eric Miotto
d546222f57 [CMake] Use separate namespace for demangling symbols used by runtime
This matches the behavior introduced with #30733 -- quoting the
explanation here for the sake of convenience:

> Since libDemangling is included in the Swift standard library,
> ODR violations can occur on platforms that allow statically
> linking stdlib if Swift code is linked with other compiler
> libraries that also transitively pull in libDemangling, and if
> the stdlib version and compiler version do not match exactly
> (even down to commit drift between releases). This lets the
> runtime conditionally segregate its copies of the libDemangling
> symbols from those in the compiler using an inline namespace
> without affecting usage throughout source.

Addresses rdar://142550635
2025-01-08 09:28:46 -08:00
Evan Wilde
51b3ffdab1 Merge pull request #78453 from etcwilde/ewilde/stdlib-rebuild-has-filesystem
[cmake] Hook up `SWIFT_STDLIB_HAS_FILESYSTEM` macro
2025-01-08 09:17:20 -08:00
Eric Miotto
9ae13cdf7e [CMake] Sense SwiftCore_ENABLE_TYPE_PRINTING in swiftRuntime build
This is needed to build appropriately `Casting.cpp` and `Demangle.cpp`.

Addresses rdar://142499037
2025-01-08 07:31:19 -08:00
Evan Wilde
47abc583ab SwiftCore: CMake: Hook up filesystem flag
This hooks up the SWIFT_STDLIB_HAS_FILESYSTEM, which then requires
setting SWIFT_ARCH and SWIFT_LIB_SUBDIR macros for the backtracer.

Note: `FILESYSTEM` in this case does not refer to the C++ filesystem
header, but whether the platform you're building for has a filesystem.
2025-01-07 09:24:15 -08:00
Evan Wilde
db5ed99b8a CMake: SwiftCore: SWIFT_STDLIB_HAS_ASL
Hooking up the `SWIFT_STDLIB_HAS_ASL` build macro.

rdar://142440689
2025-01-06 18:36:34 -08:00
Evan Wilde
84a1c12fb8 CMake: Set SWIFT_STDLIB_HAS_DLADDR/DLSYM
Parts of the runtime depend on DLADDR/DLSYM. Use CMake to determine if
these functions are available and then define the
`SWIFT_STDLIB_HAS_DLADDR`/`SWIFT_STDLIB_HAS_DLSYM` when the function is
available.

`SWIFT_STDLIB_HAS_DLADDR` is used in several source files in the runtime
library. `SWIFT_STDLIB_HAS_DLSYM` only appears to be used in
`ThreadSanitizer.cpp`.
2025-01-03 16:45:15 -08:00
Saleem Abdulrasool
7aed593047 Merge pull request #78159 from compnerd/user
runtime: add missing linked library
2024-12-16 08:10:10 -08:00
Justice Adams
c5d47f5d2a add option for enabling short mangling lookups (#78122) 2024-12-13 14:47:35 -08:00
Saleem Abdulrasool
a4d894264c runtime: add missing linked library for Windows
The runtime uses functions from User32 and needs to link against it to
fulfill that dependency.
2024-12-13 14:05:18 -08:00
Saleem Abdulrasool
f4851a9ac6 runtime: adjust the style for target_link_libraries
Using a single library per line model allows for an easier time to
adjust the list as well as reduces the diff between revisions.
2024-12-13 14:05:18 -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
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
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
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
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
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
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
03ba118bf3 Add swiftCore library
This patch hooks up the swiftCore library build and gets it installing.
This means that we have library evolution hooked up and vector types.

Building it dynamically found that we had duplicate symbols, so fixed
the swiftDemanglingCR library.

Needed to hook up the availability macros.

The flag configuration is for macOS, so we'll need to go through and
figure out what it should look like for the other platforms too.
2024-11-06 21:27:53 -08:00
Evan Wilde
96429952bb Build runtime library
Getting the runtime libraries building, while also ironing out more of
the macro definitions and flags.
2024-11-06 21:27:53 -08:00