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

mingw: avoid fallback for {local,gm}time_r() #3398

Merged
merged 1 commit into from
Aug 31, 2021

Conversation

carenas
Copy link

@carenas carenas commented Aug 29, 2021

mingw-w64's pthread_unistd.h had a bug that mistakenly (because there is
no support for the *lockfile() functions required[1]) defined
_POSIX_THREAD_SAFE_FUNCTIONS and that was being worked around since
3ecd153 (compat/mingw: support MSys2-based MinGW build, 2016-01-14).

the bug was fixed in winphtreads, but as a sideeffect, leaves the
reentrant functions from time.h not longer visible and therefore breaks
the build.

since the intention all along was to avoid using the fallback functions,
formalize the use of POSIX by setting the corresponding feature flag and
to make the intention clearer compile out the fallback functions.

[1] https://unix.org/whitepapers/reentrant.html

Signed-off-by: Carlo Marcelo Arenas Belón [email protected]

Thanks for taking the time to contribute to Git!

Those seeking to contribute to the Git for Windows fork should see
http://gitforwindows.org/#contribute on how to contribute Windows specific
enhancements.

If your contribution is for the core Git functions and documentation
please be aware that the Git community does not use the github.com issues
or pull request mechanism for their contributions.

Instead, we use the Git mailing list ([email protected]) for code and
documentation submissions, code reviews, and bug reports. The
mailing list is plain text only (anything with HTML is sent directly
to the spam folder).

Nevertheless, you can use GitGitGadget (https://gitgitgadget.github.io/)
to conveniently send your Pull Requests commits to our mailing list.

Please read the "guidelines for contributing" linked above!

mingw-w64's pthread_unistd.h had a bug that mistakenly (because there is
no support for the *lockfile() functions required[1]) defined
_POSIX_THREAD_SAFE_FUNCTIONS and that was being worked around since
3ecd153 (compat/mingw: support MSys2-based MinGW build, 2016-01-14).

the bug was fixed in winphtreads, but as a sideeffect, leaves the
reentrant functions from time.h not longer visible and therefore breaks
the build.

since the intention all along was to avoid using the fallback functions,
formalize the use of POSIX by setting the corresponding feature flag and
to make the intention clearer compile out the fallback functions.

[1] https://unix.org/whitepapers/reentrant.html

Signed-off-by: Carlo Marcelo Arenas Belón <[email protected]>
#if defined(__sun__)
#ifdef __MINGW64__
#define _POSIX_C_SOURCE 1
#elif defined(__sun__)
Copy link
Member

Choose a reason for hiding this comment

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

Would this break compiling Git with older mingw-w64? I ask because I have to do precisely that sometimes, e.g. when building MinGit backports.

Copy link
Author

Choose a reason for hiding this comment

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

no; I obviously tested this change is safe both with the old (from SDK 1.0.8 as released) and new (currently updated) mingw-w64 headers and forgot to mention it.

I am doing an additional test with SDK 1.0.7 (even older releases won't install because of bintray or key issues), but I would be surprised that it wouldn't work.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, thanks for confirming!

@dscho dscho merged commit 0d6923f into git-for-windows:main Aug 31, 2021
@dscho dscho added this to the Next release milestone Aug 31, 2021
@dscho
Copy link
Member

dscho commented Aug 31, 2021

Thank you @carenas!

git-for-windows-ci pushed a commit that referenced this pull request Aug 31, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Aug 31, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Aug 31, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Aug 31, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Aug 31, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Aug 31, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Aug 31, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 1, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 2, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 2, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 2, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 2, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 3, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 3, 2021
mingw: avoid fallback for {local,gm}time_r()
@carenas carenas deleted the pthread-unistd branch September 5, 2021 01:25
dscho added a commit that referenced this pull request Sep 6, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Sep 6, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 8, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 8, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Sep 8, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Sep 8, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Sep 9, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Sep 9, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Sep 9, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Sep 9, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 22, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 23, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Nov 23, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit to dscho/git that referenced this pull request Nov 23, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 23, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 23, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 23, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 24, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 24, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 24, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit to dscho/git that referenced this pull request Nov 24, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 25, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 25, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 25, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Nov 25, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Nov 25, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 27, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 27, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 27, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 27, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Nov 30, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Nov 30, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Dec 3, 2021
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Dec 15, 2021
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Jan 12, 2022
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Jan 12, 2022
mingw: avoid fallback for {local,gm}time_r()
git-for-windows-ci pushed a commit that referenced this pull request Jan 14, 2022
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Jan 16, 2022
mingw: avoid fallback for {local,gm}time_r()
dscho added a commit that referenced this pull request Jan 20, 2022
mingw: avoid fallback for {local,gm}time_r()
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