PR26107, Compilation failure in pdp11.c

Message ID 20200611062249.GR8533@bubble.grove.modra.org
State New
Headers show
Series
  • PR26107, Compilation failure in pdp11.c
Related show

Commit Message

Alan Modra via Binutils June 11, 2020, 6:22 a.m.
PR 26107
	* pdp11.c (is_stab): Replace legacy "index" function with "strchr".


-- 
Alan Modra
Australia Development Lab, IBM

Comments

Stephen Casner June 11, 2020, 5:11 p.m. | #1
On Thu, 11 Jun 2020, Alan Modra via Binutils wrote:

> 	PR 26107

> 	* pdp11.c (is_stab): Replace legacy "index" function with "strchr".


Alan,

Thanks for fixing this for me, I didn't see it earlier.  Again this
problem was not exposed when I built the pdp11-aout target with clang.
(I also am surprised that building bfd/vax1knetbsd.c hits an error in
bfd/pdp11.c, but nevermind.)

After the earlier bug that Nick found I tried to build gcc-9 but hit
the compilation error shown below that I had not solved yet.  If this
happens to be something you've seen before, any hints you can provide
would be appreciated.

I assume that both the warnings about the 'unavailable' attribute and
the errors for undefined items are caused by the inclusion of
/opt/local/include/unwind.h rather than ./include/unwind.h -- why
doesn't the compile command include -I./include or something
equivalent?  I would expect that to be first choice.

                                                        -- Steve

Configure:

/Users/casner/src/gnu/gcc-9/configure --prefix=/usr/local/gcc-9 --enable-checking=release --disable-multilib --with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk --program-suffix=-9 --disable-libgfortran --disable-libobjc --with-gmp=/opt/local/ --with-mpfr=/opt/local/ --with-mpc=/opt/local/ --with-libiconv-prefix=/opt/local --enable-languages=c,c++

Compilation errors:

libtool: compile:  /Users/casner/src/gnu/gcc-9/build/./gcc/xgcc -shared-libgcc -B/Users/casner/src/gnu/gcc-9/build/./gcc -nostdinc++ -L/Users/casner/src/gnu/gcc-9/build/x86_64-apple-darwin18.7.0/libstdc++-v3/src -L/Users/casner/src/gnu/gcc-9/build/x86_64-apple-darwin18.7.0/libstdc++-v3/src/.libs -L/Users/casner/src/gnu/gcc-9/build/x86_64-apple-darwin18.7.0/libstdc++-v3/libsupc++/.libs -B/usr/local/gcc-9/x86_64-apple-darwin18.7.0/bin/ -B/usr/local/gcc-9/x86_64-apple-darwin18.7.0/lib/ -isystem /usr/local/gcc-9/x86_64-apple-darwin18.7.0/include -isystem /usr/local/gcc-9/x86_64-apple-darwin18.7.0/sys-include -fno-checking -I/Users/casner/src/gnu/gcc-9/libstdc++-v3/../libgcc -I/Users/casner/src/gnu/gcc-9/build/x86_64-apple-darwin18.7.0/libstdc++-v3/include/x86_64-apple-darwin18.7.0 -I/Users/casner/src/gnu/gcc-9/build/x86_64-apple-darwin18.7.0/libstdc++-v3/include -I/Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++ -I/opt/local/include -I/opt/local/include -D_GLIBCXX_SHARED -fno-!
 implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=eh_alloc.lo -g -O2 -c /Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++/eh_alloc.cc  -fno-common -DPIC -D_GLIBCXX_SHARED -o eh_alloc.o
In file included from /Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++/unwind-cxx.h:36,
                 from /Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++/eh_alloc.cc:35:
/opt/local/include/unwind.h:23:57: warning: ‘unavailable’ attribute directive ignored [-Wattributes]
   23 | #define LIBUNWIND_UNAVAIL __attribute__ (( unavailable ))
      |                                                         ^
/opt/local/include/unwind.h:351:5: note: in expansion of macro ‘LIBUNWIND_UNAVAIL’
  351 |     LIBUNWIND_UNAVAIL;
      |     ^~~~~~~~~~~~~~~~~

[snip multiple instances of the warning]


In file included from /Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++/eh_alloc.cc:35:
/Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++/unwind-cxx.h:92:3: error: ‘_Unwind_Ptr’ does not name a type; did you mean ‘_Unwind_SetIP’?
   92 |   _Unwind_Ptr catchTemp;
      |   ^~~~~~~~~~~
      |   _Unwind_SetIP
/Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++/unwind-cxx.h:146:3: error: ‘_Unwind_Ptr’ does not name a type; did you mean ‘_Unwind_SetIP’?
  146 |   _Unwind_Ptr catchTemp;
      |   ^~~~~~~~~~~
      |   _Unwind_SetIP
/Users/casner/src/gnu/gcc-9/libstdc++-v3/libsupc++/unwind-cxx.h:320:7: error: ‘_Unwind_Exception_Class’ does not name a type; did you mean ‘_Unwind_Exception’?
  320 | const _Unwind_Exception_Class __gxx_primary_exception_class
      |       ^~~~~~~~~~~~~~~~~~~~~~~
      |       _Unwind_Exception

[snip more similar errors]
Alan Modra via Binutils June 12, 2020, 2:50 a.m. | #2
On Thu, Jun 11, 2020 at 10:11:39AM -0700, Stephen Casner wrote:
> On Thu, 11 Jun 2020, Alan Modra via Binutils wrote:

> 

> > 	PR 26107

> > 	* pdp11.c (is_stab): Replace legacy "index" function with "strchr".

> 

> Thanks for fixing this for me, I didn't see it earlier.


I didn't see it either, as it depends on whether host headers declare
"index".

> /opt/local/include/unwind.h rather than ./include/unwind.h -- why

> doesn't the compile command include -I./include or something

> equivalent?  I would expect that to be first choice.


My guess would be that it is due to your use of
--with-libiconv-prefix=/opt/local, and presumably having more than
just libiconv headers in /opt/local/include.

-- 
Alan Modra
Australia Development Lab, IBM
Stephen Casner June 15, 2020, 9:28 p.m. | #3
On Fri, 12 Jun 2020, Alan Modra wrote:
> On Thu, Jun 11, 2020 at 10:11:39AM -0700, Stephen Casner wrote:

> > /opt/local/include/unwind.h rather than ./include/unwind.h -- why

> > doesn't the compile command include -I./include or something

> > equivalent?  I would expect that to be first choice.

>

> My guess would be that it is due to your use of

> --with-libiconv-prefix=/opt/local, and presumably having more than

> just libiconv headers in /opt/local/include.


Your guess was correct.  The reason that I used that option is that
without it the link picks up the macOS system /usr/lib/libiconv which
is old and has a different API resulting in undefined symbols.  An
alternative fix is to edit the Makefiles to replace "-liconv" with
"/opt/local/lib/libconv.2.dylib", but since the Makefiles are not
generated at lower levels until the top level Makefile invokes
configure at those levels that means the gcc build becomes an
iterative process rather than one that will run to completion.

The same problem exists for binutils builds that include gdb.

                                                        -- Steve

Patch

diff --git a/bfd/pdp11.c b/bfd/pdp11.c
index fecaa21ef5..c9b26c2052 100644
--- a/bfd/pdp11.c
+++ b/bfd/pdp11.c
@@ -336,8 +336,8 @@  static int
 is_stab (int type, const char *name)
 {
   if (type == N_GSYM || type == N_FUN)
-    return (index(name, ':') != NULL);
-  return (type > N_FUN);
+    return strchr (name, ':') != NULL;
+  return type > N_FUN;
 }
 
 static int