Skip to content

config, os: add support for Musl libc #771

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
Jan 18, 2023
Merged

config, os: add support for Musl libc #771

merged 3 commits into from
Jan 18, 2023

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Jan 5, 2023

According to Musl's FAQ document, __BEGIN_DECLS and __END_DECLS macros come from Glibc private headers, thus we need to define them manually in case those aren't defined.

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@@ -25,14 +25,6 @@
typedef int mode_t;
typedef void pthread_attr_t;

#if defined(__cplusplus)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this instead just be added to os/generic_unix_base.h instead? This seems a platform specific thing instead of moving it to os/object.h - this declaration has nothing to do with os objects.

Copy link
Contributor Author

@MaxDesiatov MaxDesiatov Jan 18, 2023

Choose a reason for hiding this comment

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

This was previously only needed for Windows, now it's needed for Musl-based Linux too. I moved it to a new <os/generic_base.h> header, I hope that addresses your feedback.

config/config.h Outdated
@@ -47,7 +47,9 @@

/* Define to 1 if you have the declaration of `program_invocation_short_name',
and to 0 if you don't. */
#ifndef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
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 see similar ifndef stuff for other knobs that could be configured - I'm not very familiar with this part of the dispatch build system but this feels like it might not be the place to add this.

cc: @compnerd to weigh in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right. In fact, when _GNU_SOURCE is defined (on a level above, in the Swift build system) related errors go away and I don't have to add an #ifndef here. That's cleaned up now.

According to Musl's FAQ, `__BEGIN_DECLS` and `__END_DECLS` macros come from Glibc private headers. Because of that, we need to define them manually in case those aren't defined.
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@@ -3,9 +3,10 @@
# voucher_private.h are included in the source tarball

install(FILES
object.h
generic_base.h
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the unix and windows base.h versions just import generic_base.h?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see that they already do that. So we shouldn't need this additional install step then? Either way, doesn't hurt I guess.

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 assume this new header needs to be installed to be importable at the expected install location.

@MaxDesiatov MaxDesiatov merged commit 6242e80 into main Jan 18, 2023
@MaxDesiatov MaxDesiatov deleted the maxd/musl-support branch January 18, 2023 21:00
@compnerd
Copy link
Member

This regressed the Windows release. You introduced a new distributed header but did not update the Windows installer manifest.

@MaxDesiatov
Copy link
Contributor Author

MaxDesiatov commented Jan 25, 2023

@compnerd Sorry about that, could you point to the installer manifest to be updated? Additionally, is there a Swift CI setup on this repository I could use in subsequent PRs to verify this?

@compnerd
Copy link
Member

The manifests are now in apple/swift-installer-scripts. I think that setting up CI here is a great idea, @shahmishal should be able to help with that. However, that alone would be insufficient, you should also do a cross-repository test with a full toolchain build. The dispatch builds are tested as part of the regular PR tests on apple/swift and on a toolchain build.

compnerd added a commit to swiftlang/swift-installer-scripts that referenced this pull request Jan 25, 2023
swiftlang/swift-corelibs-libdispatch#771 introduced a new header and broke the Windows toolchain due to the missing header.  Update the SDK manifest accordingly which is required to get SPM to work again.
compnerd added a commit to swiftlang/swift-installer-scripts that referenced this pull request Jan 25, 2023
swiftlang/swift-corelibs-libdispatch#771 introduced a new header and broke the Windows toolchain due to the missing header.  Update the SDK manifest accordingly which is required to get SPM to work again.

Co-authored-by: Max Desiatov <[email protected]>
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