gdb build problem (gdb/unittests/scoped_mmap-selftests.c)

Message ID 87wot092xy.fsf@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Aug. 8, 2018, 5:35 p.m. UTC
  >>>>> "Steve" == Steve Ellcey <sellcey@cavium.com> writes:

Steve> Is anyone else still having a problem building gdb?  I saw the 
Steve> mail about remote.c but I currently get this failure when
Steve> building gdb with gcc 5.4.0 on an aarch64 linux box.

I haven't seen this, but IIRC some distros enable _FORTIFY_SOURCE  by
default, which changes which unused-result warnings are emitted.

Does the appended work for you?

I wonder if we should enable _FORTIFY_SOURCE for development builds.

Tom
  

Comments

Simon Marchi Aug. 8, 2018, 5:39 p.m. UTC | #1
On 2018-08-08 13:35, Tom Tromey wrote:
>>>>>> "Steve" == Steve Ellcey <sellcey@cavium.com> writes:
> 
> Steve> Is anyone else still having a problem building gdb?  I saw the 
> Steve> mail about remote.c but I currently get this failure when
> Steve> building gdb with gcc 5.4.0 on an aarch64 linux box.
> 
> I haven't seen this, but IIRC some distros enable _FORTIFY_SOURCE  by
> default, which changes which unused-result warnings are emitted.
> 
> Does the appended work for you?
> 
> I wonder if we should enable _FORTIFY_SOURCE for development builds.
> 
> Tom
> 
> diff --git a/gdb/unittests/scoped_mmap-selftests.c
> b/gdb/unittests/scoped_mmap-selftests.c
> index d70a56a1862..e9d4afdffc5 100644
> --- a/gdb/unittests/scoped_mmap-selftests.c
> +++ b/gdb/unittests/scoped_mmap-selftests.c
> @@ -91,7 +91,7 @@ test_normal ()
>    int fd = mkstemp (filename);
>    SELF_CHECK (fd >= 0);
> 
> -  write (fd, "Hello!", 7);
> +  SELF_CHECK (write (fd, "Hello!", 7) == 7);
>    close (fd);
> 
>    gdb::unlinker unlink_test_file (filename);

Oops, sorry for the breakage.  Tom's fix LGTM.

I think that enabling _FORTIFY_SOURCE can only do some good.

Simon
  
Steve Ellcey Aug. 8, 2018, 5:48 p.m. UTC | #2
On Wed, 2018-08-08 at 11:35 -0600, Tom Tromey wrote:

> I haven't seen this, but IIRC some distros enable _FORTIFY_SOURCE  by
> default, which changes which unused-result warnings are emitted.
> 
> Does the appended work for you?
> 
> I wonder if we should enable _FORTIFY_SOURCE for development builds.
> 
> Tom
> 
> diff --git a/gdb/unittests/scoped_mmap-selftests.c
> b/gdb/unittests/scoped_mmap-selftests.c
> index d70a56a1862..e9d4afdffc5 100644
> --- a/gdb/unittests/scoped_mmap-selftests.c
> +++ b/gdb/unittests/scoped_mmap-selftests.c
> @@ -91,7 +91,7 @@ test_normal ()
>    int fd = mkstemp (filename);
>    SELF_CHECK (fd >= 0);
> 
> -  write (fd, "Hello!", 7);
> +  SELF_CHECK (write (fd, "Hello!", 7) == 7);
>    close (fd);
> 
>    gdb::unlinker unlink_test_file (filename);

Yes, this patch fixed the build problem I was having.  I was building
on Ubuntu 16.04 so I guess that one of the platforms that enables
_FORTIFY_SOURCE by default.

Steve Ellcey
sellcey@cavium.com
  

Patch

diff --git a/gdb/unittests/scoped_mmap-selftests.c b/gdb/unittests/scoped_mmap-selftests.c
index d70a56a1862..e9d4afdffc5 100644
--- a/gdb/unittests/scoped_mmap-selftests.c
+++ b/gdb/unittests/scoped_mmap-selftests.c
@@ -91,7 +91,7 @@  test_normal ()
   int fd = mkstemp (filename);
   SELF_CHECK (fd >= 0);
 
-  write (fd, "Hello!", 7);
+  SELF_CHECK (write (fd, "Hello!", 7) == 7);
   close (fd);
 
   gdb::unlinker unlink_test_file (filename);