Skip to content

[Backtracing] Add missing CxxStdlib dependency. #79057

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
merged 1 commit into from
Feb 3, 2025

Conversation

al45tair
Copy link
Contributor

To do this we also need to fix AddSwiftStdlib because if you set the INSTALL_WITH_SHARED flag, the CMake scripts don't make a target with the -static suffix, but AddSwiftStdlib also assumes that it should dad -static to any module dependencies when building a static library.

@al45tair al45tair requested review from mikeash and a team as code owners January 30, 2025 19:48
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

Gah. Somehow doing that has broken the static build of the backtracer by pulling in some shared objects. Continuing to look at the problem.

@al45tair
Copy link
Contributor Author

Ah. It's CMake again; because I just added the -static target as an alias, it's picking up the dependencies from the original CxxStdlib, but the dependencies are set to point at the dynamic libraries, which is causing it to pull the dynamic libraries into the static build of the backtracer :-(

@al45tair al45tair force-pushed the backtracing-cxxstdlib-dep branch from e2b3307 to e239ed2 Compare January 31, 2025 11:51
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test macOS platform

@al45tair
Copy link
Contributor Author

macOS is failing to clone now :-(

But I think I need an extra dependency declaration, which might also break things again. Testing locally now.

To do this we also need to fix AddSwiftStdlib because if you set the
`INSTALL_WITH_SHARED` flag, the CMake scripts don't make a target
with the `-static` suffix, but AddSwiftStdlib also assumes that it
should dad `-static` to any module dependencies when building a
static library.
@al45tair al45tair force-pushed the backtracing-cxxstdlib-dep branch from e239ed2 to 884cf75 Compare January 31, 2025 14:52
@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented Feb 1, 2025

@swift-ci Please smoke test macOS platform

@al45tair
Copy link
Contributor Author

al45tair commented Feb 3, 2025

I'd ideally like approval from @edymtt or @etcwilde before merging this, since it involves a build system change.

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

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

This LGTM in the context of C++ interop and CxxStdlib. Thanks!

I'm not very familiar with the other static Swift libraries that are INSTALL_WITH_SHARED though.

Copy link
Contributor

@edymtt edymtt left a comment

Choose a reason for hiding this comment

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

This makes sense to me -- thanks a lot for tackling this!

@@ -1317,38 +1317,46 @@ function(add_swift_target_library_single target name)
# Set compile and link flags for the non-static target.
# Do these LAST.
set(target_static)
if(SWIFTLIB_SINGLE_IS_STDLIB AND SWIFTLIB_SINGLE_STATIC AND NOT SWIFTLIB_SINGLE_INSTALL_WITH_SHARED)
if(SWIFTLIB_SINGLE_IS_STDLIB AND SWIFTLIB_SINGLE_STATIC)
Copy link
Member

Choose a reason for hiding this comment

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

Wait, when is SWIFTLIB_SINGLE_STATIC set, but we're not building static libraries?

Copy link
Member

Choose a reason for hiding this comment

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

Oh, when building swiftCxx. Neat.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think it's the only "normal" case where that happens. The compatibility libraries use these flags also, I think, but they probably aren't being used as a dependency (swiftCxxStdlib presumably wasn't either until now).

@al45tair al45tair merged commit 615f884 into swiftlang:main Feb 3, 2025
3 checks passed
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.

4 participants