From: Mark W. <ma...@kl...> - 2024-11-24 11:40:07
|
Hi Paul, On Sun, Nov 24, 2024 at 07:37:29AM +0000, Paul Floyd wrote: > https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=6fda9e5dbe01cfbf596f3809d321323405b9a57f > > commit 6fda9e5dbe01cfbf596f3809d321323405b9a57f > Author: Paul Floyd <pj...@wa...> > Date: Sun Nov 24 08:36:32 2024 +0100 > > Solaris and Illumos: fix build due to use of memset in zstd code. By using VG_(memset). This works on most other setups since the compiler will see the second argument (zero) and last argument (length given by sizeof) are constant and so the call is transformed into a __builtin_memset and completely inlined. But theoretically (and on Solaris/Illumos) this could result in library call. I had the same issue recently and solved it similarly: commit d7db69fbf482149e18ed1977df41fe320f5cbef2 Author: Mark Wielaard <ma...@kl...> Date: Thu Nov 14 12:25:27 2024 +0100 coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy Where I also used VG_(memset). But I now think that might not have been the best fix. Both that gdbserver code, and this zstd code come from somewhere else, which does use the standard library calls. So resyncing that source code with newer upstream versions becomes a little harder. The solution for some other imported code (the demangler) is in coregrind/m_demangle/vg_libciface.h which contains a #define memset(_ss,_cc,_sz) VG_(memset)((_ss),(_cc),(_sz)) Which seems a nicer way to keep the code as similar as our upstreams as possible. I'll make a similar change for the m_gdbserver code. And it seems a good idea for this zstd code too. Longer term I am wondering if we shouldn't just define these standard str/mem library calls directly outselves by simply calling the VG_(...) variant. We are building -freestanding. So can simply define these function symbols ourselves. Then all code can just use the standard library names for these str/mem functions. And the compiler is free to optimize them when possible. Cheers, Mark |