Skip to content

[Platform] Update musl modulemap and improve musl platform support. #71840

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 3 commits into from
May 8, 2024

Conversation

al45tair
Copy link
Contributor

We need to declare separate top-level modules for every header in the musl C library. Note that our set-up here does require some tweaks to musl itself (specifically, the alltypes.h header needs some fairly serious massaging to make it module compatible; in particular, we need to pull out every type declaration into its own separate modularized header in bits/types).

Also update Platform.swift a little for more musl support.

rdar://123503615

@al45tair al45tair requested a review from a team as a code owner February 23, 2024 16:13
@al45tair
Copy link
Contributor Author

This sits on top of #71839.

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

@swift-ci Please smoke test

export *
}

// POSIX
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know how we want to organize the rest of these. One module per header can start to cause performance issues, but having too many headers in a module can also cause performance issues. Is there some kind of logical grouping we might be able to use like filesystem, networking, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess these are less likely than the C library headers to suffer from the circularity issues created by the builtin modules and the C++ library, so we probably could group them. I just broke them all out for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I started looking at the Android module map that's being worked on to see how things were grouped there. I'm wondering if we should try to make things match. Not sure that's a goal right now, but it's an interesting question.

@ian-twilightcoder
Copy link
Contributor

Thank you for doing this one!

@ian-twilightcoder
Copy link
Contributor

We also need to change the clang importer to not pass -fbuiltin-headers-in-system-modules when using musl

@al45tair
Copy link
Contributor Author

al45tair commented May 3, 2024

We also need to change the clang importer to not pass -fbuiltin-headers-in-system-modules when using musl

That is in this changeset as part of #71844.

@al45tair al45tair requested a review from ian-twilightcoder May 3, 2024 12:22
al45tair added 2 commits May 7, 2024 17:00
We need to declare separate top-level modules for every header in
the musl C library.  Note that our set-up here does require some
tweaks to musl itself (specifically, the `alltypes.h` header needs
some fairly serious massaging to make it module compatible; in
particular, we need to pull out every type declaration into its
own separate modularized header in `bits/types`).

Also update `Platform.swift` a little for more musl support.

rdar://123503615
Added the _modules workaround to make the compiler pull in the correct
module when someone does `import stdc_assert` (for instance).

Fix various niggles.

rdar://123503615
@al45tair al45tair force-pushed the eng/PR-123503615 branch from d6a1280 to b6a3d22 Compare May 7, 2024 16:00
@al45tair
Copy link
Contributor Author

al45tair commented May 7, 2024

@swift-ci Please smoke test

Copy link
Contributor

@ian-twilightcoder ian-twilightcoder left a comment

Choose a reason for hiding this comment

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

I really wouldn't do the one module per header thing for the non-libc ones. That's proving to be not very good for performance if more than a small handful get used. But mostly I'd like to rename the libc ones to be consistent with other modules.

// ensures that e.g. `import stdc_float` will result in pulling in the Clang
// or libc++ versions as expected.

module _stdc_assert [system] {
Copy link
Contributor

Choose a reason for hiding this comment

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

The names we've started using in other places are _assert and assert_h. The "_h" pattern is already used in the libc++ modules, and it's also in use in other places. I think it's also a little confusing that stdc_assert would get you C++ headers, so IMO assert_h is probably the best name to go with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated the names of the C library headers to match.

The Darwin headers have a naming convention for these modules; we should
match it.

rdar://123503615
@al45tair
Copy link
Contributor Author

al45tair commented May 7, 2024

@swift-ci Please smoke test

@al45tair
Copy link
Contributor Author

al45tair commented May 8, 2024

@swift-ci Please smoke test

@al45tair al45tair merged commit f6bdbbd into swiftlang:main May 8, 2024
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.

2 participants