Bug 445300 - [PATCH] Fix building tests with Musl
Summary: [PATCH] Fix building tests with Musl
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Paul Floyd
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-10 22:17 UTC by Alyssa Ross
Modified: 2021-11-22 07:46 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patches that fix make check on Musl. (4.30 KB, text/plain)
2021-11-10 22:17 UTC, Alyssa Ross
Details
Patches that fix make check on Musl (V2) (4.48 KB, text/plain)
2021-11-14 12:27 UTC, Alyssa Ross
Details
Output of make regtest on FreeBSD (with my changes) (667.87 KB, text/x-log)
2021-11-21 23:37 UTC, Alyssa Ross
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alyssa Ross 2021-11-10 22:17:04 UTC
Created attachment 143428 [details]
Patches that fix make check on Musl.

SUMMARY

Test suite could not be built on Musl.

STEPS TO REPRODUCE
1. Run ./configure && make && make check on a Musl-based system. 

OBSERVED RESULT

Various compilation errors.

EXPECTED RESULT

Make finishes successfully.

SOFTWARE/OS VERSIONS
Linux: 5.14.15
Musl: 1.2.2 

ADDITIONAL INFORMATION

Attached are three patches in mbox format.  After applying all of them, I was able to make check successfully.
Comment 1 Paul Floyd 2021-11-12 08:54:42 UTC
How big an issue is this?

I can check the patch on FreeBSD Solaris and (just about) macOS.
Comment 2 Alyssa Ross 2021-11-12 10:52:06 UTC
(In reply to Paul Floyd from comment #1)
> How big an issue is this?

I'm not sure it's really for me to say — it was blocking us from having a Valgrind package for musl in Nixpkgs[1], because we run make check to make sure everything's working okay.  It would be nice to have the fix upstream so we don't have to apply the patches ourselves.

I imagine there are potential Valgrind contributors out there running Alpine Linux or Void Linux as well, for whom it would certainly be useful if make check worked.

[1]: https://github.com/NixOS/nixpkgs
Comment 3 Paul Floyd 2021-11-12 11:22:20 UTC
For me the main concern is not to break anything on other platforms. We do have automatic tests that cover Linux (primarily Fedora) pretty well. Testing on other platforms is a bit lacking.

I do have an Alpine VirtualBox image that I occasionally use. I don't know of any other Valgrind developers that use musl.

The reason that I'm concerned is that configure tests are not 100% reliable in my experience. They will check that a feature can be compiled. But I've seen one case (on macOS) where there were link time issues.
Comment 4 Alyssa Ross 2021-11-14 12:27:10 UTC
Created attachment 143535 [details]
Patches that fix make check on Musl (V2)

Nixpkgs CI caught that I'd forgotten an #include "config.h" in my first attempt, which caused a build error on Glibc.  This new revision fixes that, and has successfully passed make check on Musl and GLibc.  I'd usually be able to test Darwin using our CI as well, but unfortunately our Valgrind package is currently broken on Darwin for unrelated reasons I haven't looked into.

I'd be happy to test any other free platforms (FreeBSD, illumos, etc.) that would be helpful — I have VMs set up for most of these already — as long as I know what to be testing for — just make check?
Comment 5 Paul Floyd 2021-11-14 16:16:13 UTC
You need to run

autogen.sh
configure
make
make regtest

(that may need to be gmake)

On FreeBSD I would expect 12 regtest failures on 13.0 amd64 (needs mq, 'kldload mqueuefs')
I haven't tried Illumos in a while. I've run the regression tests for the last several Valgrind releases on Solaris 11.3, and the last one that I have a record of gave 13 fails.
Darwin is the hardest of the bunch. 10.13 is the last supported version. Newer versions won't build. I do have an old macbook with 10.7, and as a rule if I can get everything to build then I'm happy. Typically I get a coupld of hundreg regtest failures.
Comment 6 Alyssa Ross 2021-11-18 13:26:14 UTC
(In reply to Paul Floyd from comment #5)
> On FreeBSD I would expect 12 regtest failures on 13.0 amd64 (needs mq,
> 'kldload mqueuefs')

I got 44 failures on FreeBSD 13 install (with mqueuefs), but my change didn't make a difference to the number of failures.

> I haven't tried Illumos in a while. I've run the regression tests for the
> last several Valgrind releases on Solaris 11.3, and the last one that I have
> a record of gave 13 fails.

On OpenIndiana Hipster 2021.04 I got 94 failures, but again my changes didn't make a difference to the number of failures.
Comment 7 Paul Floyd 2021-11-18 14:13:34 UTC
Hmm. Those figures are fairly high. I guess that you have some things missing like gdb. At the worst this patch should only affect configure and 2 testcases.

Could you please rerun the tests, redirecting the output to a file and attaching the files here?

I'll try to do some tests this weekend as well.
Comment 8 Alyssa Ross 2021-11-18 16:04:48 UTC
(In reply to Paul Floyd from comment #7)
> Hmm. Those figures are fairly high. I guess that you have some things
> missing like gdb. At the worst this patch should only affect configure and 2
> testcases.
> 
> Could you please rerun the tests, redirecting the output to a file and
> attaching the files here?

I can do that, but to save us both some time, is there a list of things I should be making sure are installed before I run the tests?  I didn't know I needed gdb, for example.
Comment 9 Paul Floyd 2021-11-18 19:01:18 UTC
> I can do that, but to save us both some time, is there a list of things I
> should be making sure are installed before I run the tests?  I didn't know I
> needed gdb, for example.

At least you will need gsed and gdb. No harm installing coreutils as well. You'll need to run autogen and configure again.

The gdbserver_tests should contain a symlink to gdb. 'make check' and 'make regtest' should run a script to make this link. If that does not work you can run

gdbserver_tests/make_local_links /path/to//gdb

My latest FreeBSD tests were

== 745 tests, 12 stderr failures, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures ==
memcheck/tests/amd64/insn-pmovmskb       (stderr)
memcheck/tests/clientperm                (stderr)
memcheck/tests/gone_abrt_xml             (stderr)
memcheck/tests/origin5-bz2               (stderr)
memcheck/tests/varinfo2                  (stderr)
memcheck/tests/varinfo5                  (stderr)
memcheck/tests/varinfo6                  (stderr)
helgrind/tests/tls_threads               (stderr)
drd/tests/atomic_var                     (stderr)
drd/tests/omp_matinv                     (stderr)
drd/tests/omp_matinv_racy                (stderr)
drd/tests/omp_prime_racy                 (stderr)

I have noticed that a small number of tests depend on the type of install (e.g., one depends on the filesystem in use).
Comment 10 Alyssa Ross 2021-11-21 23:35:48 UTC
Hi there(In reply to Paul Floyd from comment #9)
> > I can do that, but to save us both some time, is there a list of things I
> > should be making sure are installed before I run the tests?  I didn't know I
> > needed gdb, for example.
> 
> At least you will need gsed and gdb. No harm installing coreutils as well.
> You'll need to run autogen and configure again.

Thanks for the tips!  I was able to get down to 16 failures on FreeBSD, shown before, both before and after my changes:

== 755 tests, 16 stderr failures, 0 stdout failures, 0 stderrB failures, 0 stdoutB failures, 0 post failures ==
memcheck/tests/amd64/insn-pmovmskb       (stderr)
memcheck/tests/clientperm                (stderr)
memcheck/tests/demangle-rust             (stderr)
memcheck/tests/dw4                       (stderr)
memcheck/tests/gone_abrt_xml             (stderr)
memcheck/tests/manuel1                   (stderr)
memcheck/tests/origin5-bz2               (stderr)
memcheck/tests/varinfo2                  (stderr)
memcheck/tests/varinfo5                  (stderr)
memcheck/tests/varinfo6                  (stderr)
helgrind/tests/tls_threads               (stderr)
drd/tests/atomic_var                     (stderr)
drd/tests/omp_matinv                     (stderr)
drd/tests/omp_matinv_racy                (stderr)
drd/tests/omp_prime_racy                 (stderr)
none/tests/fdleak_cmsg                   (stderr)
Comment 11 Alyssa Ross 2021-11-21 23:37:57 UTC
Created attachment 143818 [details]
Output of make regtest on FreeBSD (with my changes)

Oh, and here's the output of make regtest on FreeBSD with my changes applied, incase that's helpful.
Comment 12 Paul Floyd 2021-11-22 07:46:13 UTC
Looks good.

Pushed as
commit e484eee0bdf0a77fc260b69ac7495352e1a972e3