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

Fix linking to 64-bit time_t versions of functions on musl #14895

Merged
merged 1 commit into from
Feb 20, 2023

Conversation

CyberShadow
Copy link
Member

#14794 retargeted to stable.

musl switched to 64-bit time_t across all architectures in version
1.2.0:

https://musl.libc.org/time64.html

This change was done in a way which attempted to preserve ABI
compatibility. To achieve this, the 32-bit versions of functions were
left at their original names in the compiled library, and new 64-bit
versions of functions were introduced. The header files then
redirected calls to the standard function names to use the new 64-bit
versions using the __asm__("name") construct, which is similar to D's
pragma(mangle, "name").

This change is a fix-up for commit
ca0b670, which tried addressing this
change in musl by changing time_t to 64-bit when targeting new musl
versions (the default). However, that change was incomplete, as it did
not implement the function redirection part of the change, which is
required to actually call the implementations using 64-bit time_t. As
a result, it caused programs to link but return incorrect results at
runtime on 32-bit architectures when targeting new musl versions.

Fix this by adjusting the mangled name of the D declarations of
affected functions when targeting musl on 32-bit platforms.  Affected
functions in musl can be found by grepping for _REDIR_TIME64 and uses
of the __REDIR macro.

Fixes issue 23608.
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @CyberShadow!

Bugzilla references

Auto-close Bugzilla Severity Description
23608 regression [musl 32-bit] Time functions linked incorrectly on musl >=1.2.0 / 32-bit

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#14895"

@thewilsonator thewilsonator merged commit bacf62c into dlang:stable Feb 20, 2023
@ibuclaw ibuclaw mentioned this pull request Feb 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants