bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: test-free: fails with -flto=auto


From: Bernhard Voelker
Subject: Re: test-free: fails with -flto=auto
Date: Sun, 3 Jan 2021 03:51:58 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

Hi Bruno,

On 1/3/21 3:06 AM, Bruno Haible wrote:
> What was the result of
>   'checking whether free is known to preserve errno...'
> in your build?

"... no"

> 
> If it was 'yes', you've got a problem with the configure test.
> 
> If it was 'no', it seems that you are hitting this GCC bug:
>   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98396
> LTO makes it harder to work around it. Can you try it nevertheless (by 
> modifying
> the code in such a way that it disables the wrong optimization, especially in
> lib/free.c)?

hmm, I tried a couple of things like declaring the variable err as static.
The only combination I found to work is:

diff --git a/lib/free.c b/lib/free.c
index 135c3eb..e923ee5 100644
--- a/lib/free.c
+++ b/lib/free.c
@@ -27,7 +27,10 @@ void
 rpl_free (void *p)
 #undef free
 {
-  int err = errno;
+  int err[2];
+  err[0] = errno;
+  err[1] = errno;
+  errno = 0;
   free (p);
-  errno = err;
+  errno = err[errno==0];
 }

It's slow and ugly. ;-(

>> BTW: I noticed that the __linux__ part of this test is only run if 'gltests'
>> is the working directory, because the test relies on "test-free" being 
>> readable.
>> Is that intended?
> 
> Yes. Many of our tests (especially the shell scripts) assume that they get run
> in the build directory. This test is no exception.

Thanks & have a nice day,
Berny



reply via email to

[Prev in Thread] Current Thread [Next in Thread]