Hello Folks

         This is a follow-up to a previous post about "error:
‘TARGET_ALIAS’ undeclared"....

         I think I figured out the problem... there is definitely a bug...
let me explain...  there was another similar post on the Internet and their
problem was gcc was including ../bfd/config.h instead of ./config.h when
ran from gas/ . Running the offending command with --save-temps confirms my
problem is the same. When I rename ../bfd/config.h (to avoid conflict)
suddenly 'make' in the gas directory works... so it seems the real problem
is in how #includes are resolved... this also occurred when compiling in
binutils/ again the fix was the same and magically it all worked...

         Now I have the luxury of having access to computers with different
compiler versions. With older compilers 4.4.x it works. On newer compilers
( v4.8.3 ) it does not work. So either one of two things are wrong, there
is a new bug in GCC in how it handles include file resolution, or there is
a bug in the binutils source code where the include statements are not
correct and the old version of gcc erroneously did the right thing. Even if
this is a bug in gcc I think it would make binutils more robust if the
correct config.h was specified explicitly. I noticed that this undefined
macro problem pops up a lot and it seems users just give-up before solving
the problem...

        Could someone here confirm whether this is a binutils bug or
whether I should post something on the gcc bug tracker... Thanks

        If the problem is really in binutils it can be stated simple as
follows: gcc includes the wrong 'config.h' when it is included indirectly
through 'include/alloca-conf.h'. Instead of including the local version of
'config.h' it finds bfd/config.h first. This occurs when running make in
both 'gas/' and 'binutils/'. The problem is avoided in both cases by
temporarily removing 'bfd/config.h'

        So let me give some nitty-gritty details to help you understand my
problem in greater detail:

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> gcc --version
gcc (SUSE Linux) 4.8.3 20140627 [gcc-4_8-branch revision 212064]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> ./configure
--prefix=/opt/gcc-4.9.3/install --with-mpc=/opt/gcc-4.9.3/install
--with-mpfr=/opt/gcc-4.9.3/install --with-gmp=/opt/gcc-4.9.3/install
--with-cloog=/opt/gcc-4.9.3/install --with-isl=/opt/gcc-4.9.3/install
--enable-gold=yes --enable-ld=yes --disable-libquadmath
--disable-libquadmath-support --enable-lto

... <snipped>...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> make

... <snipped>...

gcc -DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./config -I./../include -I./..
-I./../bfd -DLOCALEDIR="\"/opt/gcc-4.9.3/install/share/locale\""  -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT as.o -MD -MP
-MF .deps/as.Tpo -c -o as.o as.c
as.c: In function ‘print_version_id’:
as.c:224:14: error: ‘TARGET_ALIAS’ undeclared (first use in this function)
     VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
              ^
as.c:224:14: note: each undeclared identifier is reported only once for
each function it appears in
as.c: In function ‘parse_args’:
as.c:635:5: error: ‘TARGET_ALIAS’ undeclared (first use in this function)
     TARGET_ALIAS);
     ^
as.c:649:44: error: ‘TARGET_CANONICAL’ undeclared (first use in this
function)
    fprintf (stderr, _("canonical = %s\n"), TARGET_CANONICAL);
                                            ^
as.c:650:43: error: ‘TARGET_CPU’ undeclared (first use in this function)
    fprintf (stderr, _("cpu-type = %s\n"), TARGET_CPU);
                                           ^
Makefile:896: recipe for target 'as.o' failed

... <snipped>...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> cd gas
user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/gas> gcc -DHAVE_CONFIG_H
-I.  -I. -I. -I../bfd -I./config -I./../include -I./.. -I./../bfd
-DLOCALEDIR="\"/opt/gcc-4.9.3/install/share/locale\""  -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT as.o -MD -MP
-MF .deps/as.Tpo -c -o as.o as.c --save-temps

... <same error> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/gas> head as.i -n 20
# 1 "as.c"
# 1 "/opt/gcc-4.9.3/binutils/binutils-2.25/gas//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "as.c"
# 34 "as.c"
# 1 "as.h" 1
# 37 "as.h"
# 1 "./../include/alloca-conf.h" 1
# 16 "./../include/alloca-conf.h"
# 1 "../bfd/config.h" 1
# 17 "./../include/alloca-conf.h" 2

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/gas> mv ../bfd/config.h
../bfd/config.h.bak
user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/gas> make

... <everything compiles perfectly> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/gas> cd ..
user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> make

... <bfd is recompiled which restores bfd/config.h > ...

... <then I get the following error in binutils:> ...

gcc -DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./../bfd -I./../include
-DLOCALEDIR="\"/opt/gcc-4.9.3/install/share/locale\""
-Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -Wshadow -g -O2 -MT bucomm.o -MD -MP -MF
.deps/bucomm.Tpo -c -o bucomm.o bucomm.c
bucomm.c: In function ‘set_default_bfd_target’:
bucomm.c:159:24: error: ‘TARGET’ undeclared (first use in this function)
   const char *target = TARGET;
                        ^
bucomm.c:159:24: note: each undeclared identifier is reported only once for
each function it appears in
Makefile:932: recipe for target 'bucomm.o' failed

... <snipped> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> cd binutils
user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/binutils> gcc
-DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./../bfd -I./../include
-DLOCALEDIR="\"/opt/gcc-4.9.3/install/share/locale\""
-Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -Wshadow -g -O2 -MT bucomm.o -MD -MP -MF
.deps/bucomm.Tpo -c -o bucomm.o bucomm.c --save-temps

... <same error> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/binutils> head bucomm.i -n
20
# 1 "bucomm.c"
# 1 "/opt/gcc-4.9.3/binutils/binutils-2.25/binutils//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "bucomm.c"
# 24 "bucomm.c"
# 1 "sysdep.h" 1
# 23 "sysdep.h"
# 1 "./../include/alloca-conf.h" 1
# 16 "./../include/alloca-conf.h"
# 1 "../bfd/config.h" 1
# 17 "./../include/alloca-conf.h" 2

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/binutils> gcc
-DHAVE_CONFIG_H -I.  -I. -I. -I../bfd -I./../bfd -I./../include
-DLOCALEDIR="\"/opt/gcc-4.9.3/install/share/locale\""
-Dbin_dummy_emulation=bin_vanilla_emulation  -W -Wall -Wstrict-prototypes
-Wmissing-prototypes -Wshadow -g -O2 -MT bucomm.o -MD -MP -MF
.deps/bucomm.Tpo -c -o bucomm.o bucomm.c --save-temps

... <no errors> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/binutils> head bucomm.i -n
20
# 1 "bucomm.c"
# 1 "/opt/gcc-4.9.3/binutils/binutils-2.25/binutils//"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "bucomm.c"
# 24 "bucomm.c"
# 1 "sysdep.h" 1
# 23 "sysdep.h"
# 1 "./../include/alloca-conf.h" 1
# 16 "./../include/alloca-conf.h"
# 1 "./config.h" 1 3                                         <---- now the
correct 'config.h' is included
# 17 "./../include/alloca-conf.h" 2

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/binutils> make

... <everything compiles without error> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25/binutils> cd ..
user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> make

... <everything compiles without error> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> make check

... <all tests pass> ...

user@host:/opt/gcc-4.9.3/binutils/binutils-2.25> make install

... <everything is installed> ...




On Thu, Jul 16, 2015 at 9:23 AM, Mike McWilliam <pilot...@gmail.com> wrote:

> Hello Folks
>
>               Trying to compile binutils on my system and I am getting the
> following error:
>
> as.c: In function ‘print_version_id’:
> as.c:224:14: error: ‘TARGET_ALIAS’ undeclared (first use in this function)
>      VERSION, TARGET_ALIAS, BFD_VERSION_STRING);
>               ^
>
> <...including a few more similar errors...>
>
>              I suppose this is more an error with the configure.... this
> is something that is over my head so hoping you folks could direct me to
> the appropriate channel for help with this problem... this could be a
> bug... or my mistake... I have successfully compiled this version binutils
> in the past on older machines... so not sure why it is not working now...
>
> thanks
> Mike
>
_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to