This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: TARGET undefined in bucomm.c


Upon further inspection, it looks like:
-- in libiberty nearly every .c file has #include "config.h"  or
#include <config.h>
-- in bfd nearly every .c file has #include sysdep.h, which in turn
has #include "config.h"
-- in gas, nearly every .c file has #include "as.h", which in turn
#includes "config.h"

In contrast, in binutils, only these three files #include "config.h":
elfedit.c
readelf.c
syslex.c

In my build case, at least bucomm.c and cxxfilt.c needed some things
that were defined in config.h.  I don't think me just throwing #define
"config.h" statements into other peoples source constitutes a proper
bugfix, but I don't see how else this can be fixed.  How is target
getting defined in bucomm.c when other people build it?  I tried
configure with no options, and this still gives the same error, so it
seems there is something about my system that is maybe causing
configure to generate a makefile which doesn't properly define TARGET
in bucomm.c and TARGET_PREPENDS_UNDERSCORE in cxxfilt.c.

It really seems like that this needs to be taken care of, either by
adjusting the source to correctly #include things, or adjusting the
build to properly #define things in the compiler flags.

I'm not a computer scientist, nor do I really have any clue of how
binutils is designed, organized or built, but I can see that there is
a problem here.

What is the right approach to fixing this?

~Luke

On Mon, Jun 6, 2011 at 11:19 AM, Luke <hazelnusse@gmail.com> wrote:
> After unpacking the source tarball, there is only config.in, and it has this:
>
> #undef TARGET
> #undef TARGET_PREPENDS_UNDERSCORE
>
> after running configure as I described, it has the same thing, and
> config.h has not been generated at this point.
>
> After running make, and failing, config.h is generated and has this:
>
> #define TARGET "arm-none-eabi"
> #define TARGET_PREPENDS_UNDERSCORE 0
>
> bucomm.c does not have a line:
> #include "config.h"
>
> When I add that line to bucomm.c, bucomm.o is built, but then it fails
> again on cxxfilt.c, which also does not #include "config.h". ÂHere is
> the error I get for that:
> gcc -DHAVE_CONFIG_H -I. Â-I. -I. -I../bfd -I./../bfd -I./../include
> -DLOCALEDIR="\"/usr/local/share/locale\""
> -Dbin_dummy_emulation=bin_vanilla_emulation Â-W -Wall
> -Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT cxxfilt.o
> -MD -MP -MF .deps/cxxfilt.Tpo -c -o cxxfilt.o cxxfilt.c
> cxxfilt.c:34:31: error: âTARGET_PREPENDS_UNDERSCOREâ undeclared here
> (not in a function)
> make[4]: *** [cxxfilt.o] Error 1
>
> TARGET_PREPENDS_UNDERSCORE is #defined in config.h. ÂAdding it to
> cxxfilt.c lets it compile, but with a warning:
> gcc -DHAVE_CONFIG_H -I. Â-I. -I. -I../bfd -I./../bfd -I./../include
> -DLOCALEDIR="\"/usr/local/share/locale\""
> -Dbin_dummy_emulation=bin_vanilla_emulation Â-W -Wall
> -Wstrict-prototypes -Wmissing-prototypes -Wshadow -g -O2 -MT cxxfilt.o
> -MD -MP -MF .deps/cxxfilt.Tpo -c -o cxxfilt.o cxxfilt.c
> In file included from cxxfilt.c:32:0:
> config.h:157:0: warning: "PACKAGE" redefined
> ../bfd/config.h:245:0: note: this is the location of the previous definition
>
> and finally binutils finishes compiling, but then gas fails, with
> similar errors that would seemingly be fixed if the appropriate files
> were pound including config.h
>
> Is there some other way I should be compiling so that these define
> statements are inserted correctly, or should these .c files actually
> be #including config.h? ÂOr maybe the config.h needs to be included in
> just one top level header file and that would fix all of this?
>
> ~Luke
>
> On Mon, Jun 6, 2011 at 10:57 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Jun 6, 2011 at 10:45 AM, Luke <hazelnusse@gmail.com> wrote:
>>> I'm trying to compile binutils-2.21 on x86_64 . ÂI configured using:
>>>
>>> $ mkdir build
>>> $ cd build
>>> $ ../configure --target=arm-none-eabi --enable-multilib --with-gnu-as
>>> --with-gnu-ld --disable-nls --disable-werror
>>>
>>> It gets through the compilation of libiterty, bfd, and opcodes. ÂThen,
>>> when building binutils, it fails as follows:
>>>
>>> gcc -DHAVE_CONFIG_H -I. -I../../binutils Â-I. -I../../binutils
>>> -I../bfd -I../../binutils/../bfd -I../../binutils/../include
>>> -DLOCALEDIR="\"/usr/local/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 ../../binutils/bucomm.c
>>> ../../binutils/bucomm.c: In function âset_default_bfd_targetâ:
>>> ../../binutils/bucomm.c:160:24: error: âTARGETâ undeclared (first use
>>> in this function)
>>> ../../binutils/bucomm.c:160:24: note: each undeclared identifier is
>>> reported only once for each function it appears in
>>>
>>> I have grepped all the files for TARGET and don't understand why this
>>> would be happening -- am I using configure wrong, or do I need to
>>> define an environment variable?
>>>
>>> I have filed a bug report here:
>>> http://sourceware.org/bugzilla/show_bug.cgi?id=12844
>>>
>>> Searching the internet has been fruitless, has anybody else seen this behavior?
>>>
>>> Let me know if there is other information I should provide to help
>>> figure this out.
>>
>> Please show
>>
>> # grep TARGET binutils/config.h
>>
>> I got
>>
>> [hjl@gnu-6 build-x86_64-linux]$ grep TARGET binutils/config.h
>> #define TARGET "x86_64-unknown-linux-gnu"
>> #define TARGET_PREPENDS_UNDERSCORE 0
>> [hjl@gnu-6 build-x86_64-linux]$
>>
>>
>> --
>> H.J.
>>
>
>
>
> --
> "Those who would give up essential liberty to purchase a little
> temporary safety deserve neither liberty nor safety."
>
> -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
>



-- 
"Those who would give up essential liberty to purchase a little
temporary safety deserve neither liberty nor safety."

-- Benjamin Franklin, Historical Review of Pennsylvania, 1759


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]