-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Multiple fixes notably clock_gettime on Apple platforms #1725
base: main
Are you sure you want to change the base?
Conversation
The portability layer here is intended primarily to port other projects, rather than folly itself, so we try to maintain at least the appearance of the standard version of the API. For the issue you're running into here, would something similar to how fnctl functions are handled on windows work? (https://github.com/facebook/folly/blob/main/folly/portability/Fcntl.h) Basically declare them in a namespace and then add a global using namespace to make them appear in the right place. The other changes look good though. Would it be possible to split those off into a different PR? |
Hi @Orvid and thanks for your feedback! |
@Orvid after careful consideration, this would not work on Apple platforms because they define the symbols themselves whereas |
The clock_gettime situation on Apple platforms is complex enough as it is. Linking an incomplete implementation in replacement of the global symbol breaks other libraries including libc++ which uses clock_gettime internally [1]. Depending on the approach taken by the libc++ the current implementation could trigger infinite recursion calls as well. Since the goal of the /portability/ is to make Folly portable, we should adapt and use an approach which is compatible with Apple SDK development while maintaining compatibility on other platforms. This patch does that by adding a folly_ prefix to clock functions to avoid clashing with the native symbol and #define clock_getX folly_clock_getX in order to maintain source compatibility. As a side effect, this also addresses the redefinition issues that this [2] other proposed fix solved. [1] facebook#1602 [2] facebook#1724
It looks like once you start using the FOLLY_NULLABLE or FOLLY_NONNULL macros in a class, it's all or nothing or you get build warnings. This change addresses that based on the assumptions of the underlying code.
The clock_gettime situation on Apple platforms is complex enough as it is.
Linking an incomplete implementation in replacement of the global symbol breaks
other libraries including libc++ which uses clock_gettime internally [1].
Depending on the approach taken by the libc++ the current implementation could
trigger infinite recursion calls as well.
Since the goal of the /portability/ is to make Folly portable, we should adapt
and use an approach which is compatible with Apple SDK development while
maintaining compatibility on other platforms.
This patch does that by adding a folly_ prefix to clock functions to avoid
clashing with the native symbol. Moreover it
#define clock_getX folly_clock_getX
in order to maintain source compatibility.
As a side effect, this also addresses the redefinition issues that this [2]
other proposed fix solved.
[1] #1602
[2] #1724