Skip to content

Support for musl libc under Linux#528

Merged
xrme merged 2 commits into
Clozure:masterfrom
se-mz:musl-support
Mar 18, 2025
Merged

Support for musl libc under Linux#528
xrme merged 2 commits into
Clozure:masterfrom
se-mz:musl-support

Conversation

@se-mz
Copy link
Copy Markdown
Contributor

@se-mz se-mz commented Mar 13, 2025

I hope the commit messages explain the exact changes well enough.

I'm not super happy with the solution for mcheck.h, but as I understand it, start-mtrace and stop-mtrace are intended to be called manually for debugging purposes anyway, so it's not a big deal if the functions exist but fail.

se-mz added 2 commits March 13, 2025 14:14
Notably, this allows loading shared libraries on Linux systems using musl libc,
which uses displacements for DT_STRTAB.

The old logic based on negative displacements was nonsense because the dynamic
string table can't possibly come before the base address, so effectively, we
always assumed an absolute address under non-Android Linux. The new logic should
be mostly free of false positives, but since it's still guesswork, we only use
it when absolutely necessary.

Technically, the code for FreeBSD/Solaris/Android also changes here because the
displacement is no longer signed, but as explained above, displacements should
never be negative.
- Don't use the glibc-specific struct _libc_xmmreg

- Dummy out gnu_get_libc_version() if unavailable

- Remove unused fpu_control.h include

- Correct a typo in _LARGEFILE64_SOURCE (did nothing ever rely on lseek64?)

- Guard the glibc-specific mcheck.h behind __GLIBC__
@xrme xrme merged commit 1cca5bb into Clozure:master Mar 18, 2025
@xrme
Copy link
Copy Markdown
Member

xrme commented Mar 18, 2025

Thank you for your patch.

I am not worried about the mcheck stuff; as you note, it's for unusual debugging situations only anyway.

@se-mz se-mz deleted the musl-support branch March 18, 2025 20:11
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