Skip to content

[concurrency] Provide missing header file. #37004

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 13, 2021

Conversation

3405691582
Copy link
Member

@3405691582 3405691582 commented Apr 22, 2021

HAVE_PTHREAD_H is supplied in this config file.

The __has_include pattern is discouraged, but there is no other way of
conditioning on pthread_np.h, which is required for pthread_main_np
on OpenBSD. Therefore, use it, but call it out in a comment.

I don't know where HAVE_PTHREAD_H comes from on other platforms, but this
seems like a flaky strategy. While we are here, since we are relying on
pthread_main_np, include pthread_np.h if it is present, since it is
required on some platforms.

(This is a buildfix for OpenBSD.)

@3405691582
Copy link
Member Author

cc @DougGregor

@3405691582
Copy link
Member Author

ping.

@3405691582
Copy link
Member Author

ping. It would be nice if we could resolve this, since it is breaking out-of-the-box builds on this platform.

@gottesmm gottesmm requested a review from ktoso May 12, 2021 18:14
@tbkka
Copy link
Contributor

tbkka commented May 12, 2021

__has_include is not the best way to determine whether or not a header should be included, since it does not provide a way to suppress broken headers. (On some platforms, it is impossible to compile programs that include certain combinations of system headers. It is easy to check for this at configuration time, but __has_include can't handle this.)

@3405691582 3405691582 force-pushed the UseHasIncludeInstead branch from 33bc813 to e8fe456 Compare May 12, 2021 20:32
@3405691582
Copy link
Member Author

As mentioned, the trouble is that HAVE_PTHREAD_H isn't defined on other platforms, so the alternative is to define those symbols statically from the build system on the platform. Here, the approach was taken to just add some cflags in the right library rather than trying to push these defines across the entire build, but if doing the latter is the preferred approach let me know and I'll make the necessary changes.

@3405691582 3405691582 changed the title [concurrency] Use _has_include for pthread.h. [concurrency] Drive HAVE_PTHREAD_H from CMake. May 12, 2021
HAVE_PTHREAD_H is supplied in this config file.

The `__has_include` pattern is discouraged, but there is no other way of
conditioning on `pthread_np.h`, which is required for `pthread_main_np`
on OpenBSD. Therefore, use it, but call it out in a comment.
@3405691582 3405691582 force-pushed the UseHasIncludeInstead branch 2 times, most recently from 6401e05 to b930831 Compare May 12, 2021 21:23
@3405691582 3405691582 changed the title [concurrency] Drive HAVE_PTHREAD_H from CMake. [concurrency] Provide missing header file. May 12, 2021
@tbkka
Copy link
Contributor

tbkka commented May 12, 2021

Thank you for making those changes.
Does this work for you on OpenBSD? If not, let me know and I'll help you work out something better.

@3405691582
Copy link
Member Author

Sorry for the confusion; thank you for finding the symbol. I agree that just supplying the missing include is the right fix. I've called out the __has_include usage in a comment as you suggest.

Does this work for you on OpenBSD? If not, let me know and I'll help you work out something better.

Just rerunning the build now, though I don't anticipate breakage.

@tbkka
Copy link
Contributor

tbkka commented May 12, 2021

Nicely worded comment! Someday, when I have a chance to work on this, I'll be able to search for HAVE_PTHREAD_NP_H and see where that needs to go.

Copy link
Contributor

@tbkka tbkka left a comment

Choose a reason for hiding this comment

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

Assuming the tests pass (I'm sure they will), this looks good. Thank you!

@3405691582
Copy link
Member Author

FYI: builds clean/this change works on this platform now.

@tbkka
Copy link
Contributor

tbkka commented May 12, 2021

@swift-ci Please test

@3405691582
Copy link
Member Author

Windows failure appears unrelated.

@tbkka tbkka merged commit eb945c8 into swiftlang:main May 13, 2021
@tbkka
Copy link
Contributor

tbkka commented May 13, 2021

Merged. Thank you for patiently working through this!

DougGregor pushed a commit to DougGregor/swift that referenced this pull request Sep 23, 2021
HAVE_PTHREAD_H is supplied in this config file.

The `__has_include` pattern is discouraged, but there is no other way of
conditioning on `pthread_np.h`, which is required for `pthread_main_np`
on OpenBSD. Therefore, use it, but call it out in a comment.

(cherry picked from commit eb945c8)
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