Bug 400162 - Patch: Guard against __GLIBC_PREREQ for musl libc
Summary: Patch: Guard against __GLIBC_PREREQ for musl libc
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: memcheck (show other bugs)
Version: 3.14 SVN
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-22 18:00 UTC by Randy MacLeod
Modified: 2023-01-25 11:22 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Guard against __GLIBC_PREREQ for musl libc (5.44 KB, patch)
2018-10-22 18:00 UTC, Randy MacLeod
Details
This is the correct patch for this bug (924 bytes, patch)
2018-10-22 18:22 UTC, Randy MacLeod
Details
Fix none/tests/pth_atfork1 musl compilation error (1.11 KB, patch)
2019-12-20 17:25 UTC, Aleksandar Rikalo
Details
refresh the previous patches by randy (962 bytes, patch)
2021-03-22 16:51 UTC, Yi Fan Yu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Randy MacLeod 2018-10-22 18:00:59 UTC
Created attachment 115830 [details]
Guard against __GLIBC_PREREQ for musl libc

SUMMARY

When building valgrind for Yocto-2.6 and using the musl libc rather than glibc, 

STEPS TO REPRODUCE

On any desktop Linux system such as Ubuntu-18.04,
0. sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
 build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
 xz-utils debianutils iputils-ping libsdl1.2-dev xterm
1. git clone git://git.pokylinux.org/poky.git
2. cd poky.git
3. git checkout bc98a1e89dcd7b3f59f99e4382439d9028ba4db2
4. mkdir ../proj; cd ../proj
5. . ../poky.git/oe-init-build-env vg-bug
6. MACHINE=qemux86-64 TCLIBC=musl bitbake valgrind

OBSERVED RESULT

| ../../../../valgrind-3.14.0/memcheck/tests/linux/sys-statx.c:10:19: error: missing binary operator before token "("
|  #if __GLIBC_PREREQ(2,28)
|                    ^
| Makefile:844: recipe for target 'sys-statx.o' failed


EXPECTED RESULT

valgrind builds without error.


SOFTWARE VERSIONS
(available in About System)
KDE Plasma Version: N/A
KDE Frameworks Version: N/A 
Qt Version: N/A

ADDITIONAL INFORMATION

patch attached. I can figure out Phabricator if needed.
Comment 1 Randy MacLeod 2018-10-22 18:13:09 UTC
Oops, the summary should be:

When building valgrind for Yocto-2.6 and using the musl libc rather than glibc, 
the build fails due to GLIBC-only features not being guarded against.
Comment 2 Randy MacLeod 2018-10-22 18:22:55 UTC
Created attachment 115831 [details]
This is the correct patch for this bug
Comment 3 Aleksandar Rikalo 2019-12-20 17:15:56 UTC
(In reply to Randy MacLeod from comment #2)
> Created attachment 115831 [details]
> This is the correct patch for this bug

Hi Randy,
There is no <linux/stat.h> on musl, struct statx is in <sys/stat.h> which is already included. So, you need to remove the last #else branch.
Comment 4 Aleksandar Rikalo 2019-12-20 17:25:41 UTC
Created attachment 124625 [details]
Fix none/tests/pth_atfork1 musl compilation error

Tested on nanoMIPS/musl/linux and x86/glibc.
Comment 5 Petar Jovanovic 2020-04-17 18:34:08 UTC
Everyone OK to land this?
Comment 6 Mark Wielaard 2020-04-23 15:19:03 UTC
The last patch "Fix none/tests/pth_atfork1 musl compilation error" looks fine. musl libc apparently doesn't provide error.h nor the error function, so just provide our own always.
Comment 8 Yi Fan Yu 2021-03-22 16:51:36 UTC
Created attachment 136948 [details]
refresh the previous patches by randy

the issue wasn't solved by the referenced commit

the patch was also updated.
Comment 9 Yi Fan Yu 2021-03-22 16:51:59 UTC
reopening this bug too.
Comment 10 Paul Floyd 2023-01-25 11:22:59 UTC
I have no recollection of doing this, but the git log can't lie.

Author: Paul Floyd <pjfloyd@wanadoo.fr>  2021-11-22 08:42:53
Committer: Paul Floyd <pjfloyd@wanadoo.fr>  2021-11-22 08:42:53
Parent: 7fe4ff55cce4c62f17262f2cf30b97b23af142b4 (Make sys-statx.c test compile with glibc >= 2.28)
Branches: master, remotes/origin/master
Follows: VALGRIND_3_18_1
Precedes: VALGRIND_3_19_0

    Bug 445300 [PATCH] Fix building tests with Musl
    
    Patch contributed by
       Alyssa Ross <hi@alyssa.is>