public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Luke <hazelnusse@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: TARGET undefined in bucomm.c
Date: Mon, 06 Jun 2011 19:32:00 -0000	[thread overview]
Message-ID: <BANLkTinC7UprModhOipLd1_dXayYjpwBHQ@mail.gmail.com> (raw)
In-Reply-To: <BANLkTimmGLx8XTPnoYbjueaQw-CLci5V_g@mail.gmail.com>

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

  reply	other threads:[~2011-06-06 19:32 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-06 17:46 Luke
2011-06-06 17:58 ` H.J. Lu
2011-06-06 18:19   ` Luke
2011-06-06 19:32     ` Luke [this message]
2011-06-06 20:04       ` Ian Lance Taylor
2011-06-07  3:14         ` Luke
2011-06-07 12:11           ` Ian Lance Taylor
2011-06-07 12:24             ` Andreas Schwab
2011-06-07 18:27             ` Luke
2011-06-07 18:58               ` H.J. Lu
2011-06-08  0:41                 ` Luke
2011-06-08  8:03                   ` Andreas Schwab
2011-06-08  8:28                     ` Luke
2011-06-08  9:20                       ` Alan Modra
2011-06-08 10:08                         ` Luke
2011-06-08 11:07                           ` Andreas Schwab
2011-06-08 16:28                             ` Luke
2011-06-08 13:26                           ` Ian Lance Taylor
2011-06-08 16:55                             ` Luke
2011-06-08 18:02                               ` Ian Lance Taylor
2011-06-08 21:59                                 ` Luke
2011-06-08  8:49                     ` Luke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTinC7UprModhOipLd1_dXayYjpwBHQ@mail.gmail.com \
    --to=hazelnusse@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).