Skip to content

[embedded] Resolve a circular dependency problem in SwiftShims when using pico-libc #81857

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
May 30, 2025

Conversation

kubamracek
Copy link
Contributor

Since we started building Builtin_Float overlay for Embedded Swift and including it in the nightly toolchains (under lib/swift/embedded), we broke building agains the pico libc -- this is a popular libc distributed for example by the official LLVM embedded ARM toolchain as well. The problem is that for non-Linux ARM embedded targets, SwiftShims includes stdint.h, and in pico libc that transitively includes float.h which triggers a dependency on the overlay. See #81594:

When updating swift-embedded-examples to main-snapshots from May, we see a new issue trying to use the llvm toolchain: error: circular dependency between modules 'Swift' and '_Builtin_float'

Let's simply avoid depending on stdint.h from SwiftShims because we already have other platforms avoiding that (for possibly a similar or same reason).

Fixes #81594.

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@@ -513,6 +513,10 @@ void importer::getNormalInvocationArguments(
"-isystem", searchPathOpts.RuntimeResourcePath,
});

if (LangOpts.hasFeature(Feature::Embedded)) {
invocationArgStrs.insert(invocationArgStrs.end(), {"-D__swift_embedded__"});
Copy link
Member

Choose a reason for hiding this comment

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

Does this apply to all clang importer calls now? If so we need to add it to the docs. (But I'm supportive)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, all ClangImporter calls.

@kubamracek kubamracek enabled auto-merge May 30, 2025 04:12
@kubamracek kubamracek merged commit 5ea9b7d into swiftlang:main May 30, 2025
4 of 5 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.

Circular dependency between modules 'Swift' and '_Builtin_float'
4 participants