Discussion:
[Bug gdb/23663] New: gdb 8.1.1: undefined rpl_stat function with musl toolchains
romain.naour at gmail dot com
2018-09-15 07:56:29 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23663

Bug ID: 23663
Summary: gdb 8.1.1: undefined rpl_stat function with musl
toolchains
Product: gdb
Version: 8.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: romain.naour at gmail dot com
Target Milestone: ---

Hi,

There is the following build issue with gdb 8.1.1 and 8.2:

/opt/x86-core2--musl--bleeding-edge-2018.09-1/bin/i686-buildroot-linux-musl-g++
-shared -fPIC -Wl,--soname=libinproctrace.so -Wl,--no-undefined
-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -I.
-I. -I./../common -I./../regformats -I./.. -I./../../include
-I./../gnulib/import -Ibuild-gnulib-gdbserver/import -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wpointer-arith -Wno-unused
-Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body
-Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare
-Wno-narrowing -Wno-error=maybe-uninitialized -DGDBSERVER \
-Wl,--dynamic-list=./proc-service.list -o libinproctrace.so ax-ipa.o
common-utils-ipa.o errors-ipa.o format-ipa.o print-utils-ipa.o regcache-ipa.o
remote-utils-ipa.o rsp-low-ipa.o tdesc-ipa.o tracepoint-ipa.o utils-ipa.o
vec-ipa.o linux-i386-ipa.o linux-x86-tdesc-ipa.o arch/i386-ipa.o -ldl -pthread


/opt/x86-core2--musl--bleeding-edge-2018.09-1/lib/gcc/i686-buildroot-linux-musl/8.2.0/../../../../i686-buildroot-linux-musl/bin/ld:
common-utils-ipa.o: in function `is_regular_file(char const*, int*)':
common-utils.c:(.text+0x695): undefined reference to `rpl_stat'
collect2: error: ld returned 1 exit status
Makefile:413: recipe for target 'libinproctrace.so' failed
make[1]: *** [libinproctrace.so] Error 1

The issue is related to this patch:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2441702a72f324e41a1624dc042b334f375e2d81

See the discussion on the mailing list:
https://sourceware.org/ml/gdb-patches/2018-09/msg00306.html

The patch provided by Sergio Durigan Junior should be backported to gdb 8.1.x
and 8.2.x stable branch:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=3c025cfe5efc44eb4dfb03b53dca28e75096dd1e

Best regards,
Romain
--
You are receiving this mail because:
You are on the CC list for the bug.
sergiodj at redhat dot com
2018-09-15 20:41:34 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23663

Sergio Durigan Junior <sergiodj at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |sergiodj at redhat dot com
Target Milestone|--- |8.2.1
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-09-15 20:42:23 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23663

--- Comment #1 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.2-branch branch has been updated by Sergio Durigan Junior
<***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5de69bdbd0bbd7941b4cd93d4571f5e22cdb28be

commit 5de69bdbd0bbd7941b4cd93d4571f5e22cdb28be
Author: Sergio Durigan Junior <***@redhat.com>
Date: Sat Sep 15 16:40:13 2018 -0400

Move 'is_regular_file' from common-utils.c to filestuff.c

There is no reason for 'is_regular_file' to be in common-utils.c; it
belongs to 'filestuff.c'. This commit moves the function definition
and its prototype to the appropriate files.

The motivation behind this move is a failure that happens on certain
cross-compilation environments when compiling the IPA library, due to
the way gnulib probes the need for a 'stat' call replacement. Because
configure checks when cross-compiling are more limited, gnulib decides
that it needs to substitute the 'stat' calls its own 'rpl_stat';
however, the IPA library doesn't link with gnulib, which leads to an
error when compiling 'common-utils.c':

...

/opt/x86-core2--musl--bleeding-edge-2018.09-1/bin/i686-buildroot-linux-musl-g++
-shared -fPIC -Wl,--soname=libinproctrace.so -Wl,--no-undefined
-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -I.
-I. -I./../common -I./../regformats -I./.. -I./../../include
-I./../gnulib/import -Ibuild-gnulib-gdbserver/import -D_LARGEFILE_SOURCE
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Wall -Wpointer-arith -Wno-unused
-Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body
-Wunused-but-set-parameter -Wunused-but-set-variable -Wno-sign-compare
-Wno-narrowing -Wno-error=maybe-uninitialized -DGDBSERVER \
-Wl,--dynamic-list=./proc-service.list -o libinproctrace.so ax-ipa.o
common-utils-ipa.o errors-ipa.o format-ipa.o print-utils-ipa.o regcache-ipa.o
remote-utils-ipa.o rsp-low-ipa.o tdesc-ipa.o tracepoint-ipa.o utils-ipa.o
vec-ipa.o linux-i386-ipa.o linux-x86-tdesc-ipa.o arch/i386-ipa.o -ldl -pthread

/opt/x86-core2--musl--bleeding-edge-2018.09-1/lib/gcc/i686-buildroot-linux-musl/8.2.0/../../../../i686-buildroot-linux-musl/bin/ld:
common-utils-ipa.o: in function `is_regular_file(char const*, int*)':
common-utils.c:(.text+0x695): undefined reference to `rpl_stat'
collect2: error: ld returned 1 exit status
Makefile:413: recipe for target 'libinproctrace.so' failed
make[1]: *** [libinproctrace.so] Error 1
...

More details can also be found at:

https://sourceware.org/ml/gdb-patches/2018-09/msg00304.html

The most simple fix for this problem is to move 'is_regular_file' to
'filestuff.c', which is not used by IPA. This ends up making the
files more logically organized as well, since 'is_regular_file' is a
file operation.

No regressions found.

gdb/ChangeLog:
2018-09-15 Sergio Durigan Junior <***@redhat.com>

PR gdb/23663
* common/common-utils.c: Don't include '<sys/stat.h>'.
(is_regular_file): Move to...
* common/filestuff.c (is_regular_file): ... here.
* common/common-utils.h (is_regular_file): Move to...
* common/filestuff.h (is_regular_file): ... here.
--
You are receiving this mail because:
You are on the CC list for the bug.
brobecker at gnat dot com
2018-11-07 19:21:30 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23663

Joel Brobecker <brobecker at gnat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
CC| |brobecker at gnat dot com
Resolution|--- |FIXED

--- Comment #2 from Joel Brobecker <brobecker at gnat dot com> ---
Now fixed (by Sergio's changes)
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...