Skip to content

CMake: SwiftCore Install Story #79548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

etcwilde
Copy link
Member

Adding an installation story, complete with a generated SwiftCoreConfig.cmake file that allows pulling the just-built standard library into the downstream projects using find_package(SwiftCore). This will make it easier to ensure that the overlays and supplemental libraries are built against the expected runtimes.

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:

These are the files needed to interface with the standard library while doing development.
These include the shims headers as well as the swift modules and swift interfaces.

  • 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.

Note

We will need to clean up how we find shims. As it stands today, if the Swift shims are copied into the build directory next to the compiler as the current builds are, those will be picked up in addition to the shims from the standard library resulting in build failures due to duplicate SwiftShims modules. Still looking for a way around that.

@etcwilde
Copy link
Member Author

@swift-ci please smoke test

@etcwilde etcwilde force-pushed the ewilde/stdlib-rebuild-install-story branch from 5124e7c to 37512a1 Compare February 22, 2025 00:19
@etcwilde
Copy link
Member Author

@swift-ci please smoke test

@compnerd
Copy link
Member

@swift-ci please smoke test

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.
@etcwilde etcwilde force-pushed the ewilde/stdlib-rebuild-install-story branch from 37512a1 to 7870db6 Compare February 22, 2025 18:33
@etcwilde
Copy link
Member Author

Windows bot caught something. Neat. install(FILES ...) doesn't have an EXPORT option.

@etcwilde
Copy link
Member Author

@swift-ci please smoke test

@@ -143,7 +143,6 @@ add_compile_definitions(
$<$<BOOL:${SwiftCore_ENABLE_OBJC_INTEROP}>:-DSWIFT_OBJC_INTEROP>
$<$<BOOL:${SwiftCore_ENABLE_LIBRARY_EVOLUTION}>:-DSWIFT_LIBRARY_EVOLUTION>
$<$<BOOL:${SwiftCore_ENABLE_CRASH_REPORTER_CLIENT}>:-DSWIFT_HAVE_CRASHREPORTERCLIENT>
$<$<BOOL:${SwiftCore_ENABLE_VECTOR_TYPES}>:-DSWIFT_STDLIB_ENABLE_VECTOR_TYPES>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To double check my understanding: are we pushing this setting to runtime and core because those are the only artifacts for which it makes sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved it to the public interface of runtime so that it affects runtime and anything that links against it. The issue is that runtime is privately linked into core, so the macro won't get carried out to products that link against swiftCore externally.

Then I made it part of the INTERFACE of swiftCore. It doesn't get re-applied to swiftCore, but is forwarded to anything that links against swiftCore using the config file. This means that the overlays and supplemental libraries that are using this config file will also get the flag set without needing to do anything.

@etcwilde etcwilde merged commit 71f9aac into swiftlang:main Feb 26, 2025
3 checks passed
@etcwilde etcwilde deleted the ewilde/stdlib-rebuild-install-story branch February 26, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants