Skip to content
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

[SR-5026] pthread_key_t differs on FreeBSD #47602

Closed
swift-ci opened this issue May 26, 2017 · 6 comments
Closed

[SR-5026] pthread_key_t differs on FreeBSD #47602

swift-ci opened this issue May 26, 2017 · 6 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. runtime The Swift Runtime standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5026
Radar None
Original Reporter _BrandonBradley (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

FreeBSD 11 | Swift 3.1

Additional Detail from JIRA
Votes 0
Component/s Standard Library
Labels Bug, FreeBSD, Runtime
Assignee None
Priority Medium

md5: a2c50465e1faeac3529591fbeea98969

Issue Description:

I'm Compiling Swift from the swift-3.1 branch on FreeBSD 11. Most of the compilation process is already complete. The hangup comes when building:

swift/stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-freebsd-x86_64.dir/LibcShims.cpp.o

Which fails with the following error:

swift/stdlib/public/stubs/LibcShims.cpp:103:1: error: static_assert failed "This platform's pthread_key_t differs. If you hit this assert, fix __swift_pthread_key_t's typedef in LibcShims.h by adding an #if guard and definition for your platform"
static_assert(std::is_same<__swift_pthread_key_t, pthread_key_t>::value,

Followed by (what I believe to be) a related error:

swift/stdlib/public/stubs/LibcShims.cpp:113:10: error: no matching function for call to 'pthread_key_create'
return pthread_key_create(key, destructor);

What is pthread_key_t, and is there any way to determine what its value should be on FreeBSD?

@belkadan
Copy link
Contributor

Hi, Brandon. pthread_key_t is a type used to identify thread-local data using the "pthread" library that's available on most platforms. You can find out what pthread_key_t is for FreeBSD by looking in the C header pthread.h for a typedef that defines that type…or by just compiling an invalid C program like this one:

#include <pthread.h>
void test(void) {
  pthread_key_t incorrect = "incorrect value";
}

On my machine, this results in a warning:

warning: incompatible pointer to integer conversion initializing
      'pthread_key_t' (aka 'unsigned long') with an expression of type
      'void (*)(void)' [-Wint-conversion]

which tells me what the type of pthread_key_t is (unsigned long).

@belkadan
Copy link
Contributor

If you do pick this up, we'd love to get a pull request from you when you've made the necessary changes!

@swift-ci
Copy link
Collaborator Author

Comment by Brandon Bradley (JIRA)

@belkadan Where is swift/stdlib/public//SwiftSchims/LibSchims.h getting the answer to this evaluation?:

#if defined(__linux__)

That is, is the 'defined' function generated by Swift, or is it a platform function?

For FreeBSD pthread_key_t is an int, but to make an acceptable pull, I need to add another if after the above code.

@belkadan
Copy link
Contributor

This is C++ code, not Swift code. #if defined(__linux__) is equivalent to #ifdef __linux__, where __linux__ is a macro defined by the compiler when compiling for Linux.

It looks like someone else may have taken this up already: #9940

@swift-ci
Copy link
Collaborator Author

Comment by Brandon Bradley (JIRA)

Implementing the changes in the Pull Request resolve the issue.

@belkadan
Copy link
Contributor

PR merged!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. runtime The Swift Runtime standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

2 participants