public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Patching autoconf to support static binutils?
@ 2011-08-23  3:04 Bryan Ischo
  2011-08-24  5:09 ` Bryan Ischo
  0 siblings, 1 reply; 10+ messages in thread
From: Bryan Ischo @ 2011-08-23  3:04 UTC (permalink / raw)
  To: binutils

Hello.  I am trying to figure out how to build a statically linked 
version of binutils (starting with binutils source version 2.21.1).  I 
have found some old discussions of this topic via search results, but 
there was never any real resolution to this issue as far as I can tell.

A while ago people were suggesting that playing with LDFLAGS during the 
appropriate stage of the configure/make configure-host/make sequence 
could do the trick, but if these instructions ever worked, they don't 
work any more.

I have spent hours trying to find the magic incantations that would make 
this work, but have failed, and I believe that there are in fact no 
magic incantations that will work in the current binutils configure 
script and makefiles.

The basic problem, as far as I can tell, is that some Makefiles within 
binutils use the compiler to link executables, and some Makefiles use 
libtool to do the same.  The option that would need to be passed to the 
compiler (ostensibly being gcc, which accepts the -static option) are 
different than that which would need to be passed to libtool 
(-all-static); but the environment variable that can be used for 
specifing linker flags to the compiler, LDFLAGS, is passed to both the 
compiler and libtool.

Does it seem right that LDFLAGS would be passed to libtool?  It doesn't 
seem right to me, since LDFLAGS suggest being used for the 'ld' program, 
and that program doesn't have compatible arguments with libtool.  It 
would seem cleaner to use LIBTOOLFLAGS for this purpose, however, 
LIBTOOLFLAGS is used for several different 'flavors' of libtool 
invocation, some of which do not accept -all-static (e.g. libtool 
--mode=compile).  In fact the logical conclusion of this train of 
thought would seem to be that there should be a separate LIBTOOLFLAGS 
variable in use for each of the modes of libtool invocation, e.g. 
LIBTOOLFLAGS_LINK, LIBTOOLFLAGS_COMPILE, etc, and additionally, as was 
already mentioned, there is no way to pass linker arguments just to 
invocations of the compiler without also passing those flags to libtool.

I believe that the following *might* be sufficient to allow static 
binutils to be built:

1) Make sure that all invocations of the compiler used as a linker use 
only LDFLAGS (not LIBTOOLFLAGS)
2) Make sure that all invocations of libtool use the appropriate flavor 
of the LIBTOOLFLAGS (i.e. LIBTOOLFLAGS_LINK, LIBTOOLFLAGS_COMPILE, etc), 
and do NOT use LDFLAGS
3) Specify LDFLAGS=-static and LIBTOOLFLAGS_LINK=-all-static when 
running make (and possibly when running configure)

Another alternative might be to encode the users' wishes more explicitly 
in a configure argument, something like --enable-static-executables, 
which would turn on Makefile variables that have the same effect as (1) 
and (2) above, without requiring that the user play with environment 
variables when executing configure and/or make.  However, for this 
option, I am not clear about how this configuration option gets 
specified; does it only need to be specified in the top-level binutils 
configure, or would it need to be present in each configure of each 
sub-directory?  Would this option be 'inherited' in some way in the 
sub-directories (possibly via Makefile variables), or would it need to 
be encoded individually in each sub-directory configure script?  And if 
so, would it naturally be specified to executions of configure in 
sub-directories by the main configure script?  I'm afraid that I am 
pretty unfamiliar with autoconf and mostly go on what I can grok by 
reading the scripts, and these aspects are not obvious to me.  Forgive 
me for not RTFA, but the less I know about autoconf the happier I will 
be, I believe, so I'd rather rely on others' expertise in the tool than 
acquiring such expertise myself :)

I'm happy to do the work to make this happen and to submit patches, but 
I'd like some direction to ensure that I implement a solution that would 
be acceptable to the binutils maintainers.

Thanks, and best wishes,
Bryan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-23  3:04 Patching autoconf to support static binutils? Bryan Ischo
@ 2011-08-24  5:09 ` Bryan Ischo
  2011-08-24  9:21   ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Bryan Ischo @ 2011-08-24  5:09 UTC (permalink / raw)
  To: binutils

On 08/22/11 14:40, Bryan Ischo wrote:
> Hello.  I am trying to figure out how to build a statically linked 
> version of binutils (starting with binutils source version 2.21.1).  I 
> have found some old discussions of this topic via search results, but 
> there was never any real resolution to this issue as far as I can tell.

Hello out there ... is anyone steering this ship????

Bryan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-24  5:09 ` Bryan Ischo
@ 2011-08-24  9:21   ` Mike Frysinger
  2011-08-24 13:02     ` Bryan Ischo
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2011-08-24  9:21 UTC (permalink / raw)
  To: binutils; +Cc: Bryan Ischo

[-- Attachment #1: Type: Text/Plain, Size: 748 bytes --]

On Tuesday, August 23, 2011 18:32:00 Bryan Ischo wrote:
> On 08/22/11 14:40, Bryan Ischo wrote:
> > Hello.  I am trying to figure out how to build a statically linked
> > version of binutils (starting with binutils source version 2.21.1).  I
> > have found some old discussions of this topic via search results, but
> > there was never any real resolution to this issue as far as I can tell.
> 
> Hello out there ... is anyone steering this ship????

wow, 24 hours w/out a response and you're already getting punchy ?  this is 
open source which means you get to figure things out yourself if you cant find 
help.  not bug people even more for their free assistance.

./configure
make configure-host
make LDFLAGS=-all-static
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-24  9:21   ` Mike Frysinger
@ 2011-08-24 13:02     ` Bryan Ischo
  2011-08-24 16:33       ` Ian Lance Taylor
  2011-08-24 17:14       ` Mike Frysinger
  0 siblings, 2 replies; 10+ messages in thread
From: Bryan Ischo @ 2011-08-24 13:02 UTC (permalink / raw)
  To: binutils

On 8/23/2011 8:25 PM, Mike Frysinger wrote:
> On Tuesday, August 23, 2011 18:32:00 Bryan Ischo wrote:
>> On 08/22/11 14:40, Bryan Ischo wrote:
>>> Hello.  I am trying to figure out how to build a statically linked
>>> version of binutils (starting with binutils source version 2.21.1).  I
>>> have found some old discussions of this topic via search results, but
>>> there was never any real resolution to this issue as far as I can tell.
>> Hello out there ... is anyone steering this ship????
> wow, 24 hours w/out a response and you're already getting punchy ?  this is
> open source which means you get to figure things out yourself if you cant find
> help.  not bug people even more for their free assistance.

It was meant to be tongue-in-cheek, and I don't think your response is 
warranted.  Additionally, it is disappointing that you put more effort 
into writing this paragraph than to your response below ...

> ./configure
> make configure-host
> make LDFLAGS=-all-static
> -mike

If you'll read my original email you'll note that the above doesn't work 
because LDFLAGS is passed to gcc by some of the binutils Makefiles and 
gcc doesn't like the -all-static option.

Bryan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-24 13:02     ` Bryan Ischo
@ 2011-08-24 16:33       ` Ian Lance Taylor
  2011-08-24 17:14       ` Mike Frysinger
  1 sibling, 0 replies; 10+ messages in thread
From: Ian Lance Taylor @ 2011-08-24 16:33 UTC (permalink / raw)
  To: Bryan Ischo; +Cc: binutils

Bryan Ischo <bryan@ischo.com> writes:

> On 8/23/2011 8:25 PM, Mike Frysinger wrote:
>> On Tuesday, August 23, 2011 18:32:00 Bryan Ischo wrote:
>>> On 08/22/11 14:40, Bryan Ischo wrote:
>>>> Hello.  I am trying to figure out how to build a statically linked
>>>> version of binutils (starting with binutils source version 2.21.1).  I
>>>> have found some old discussions of this topic via search results, but
>>>> there was never any real resolution to this issue as far as I can tell.
>>> Hello out there ... is anyone steering this ship????
>> wow, 24 hours w/out a response and you're already getting punchy ?  this is
>> open source which means you get to figure things out yourself if you cant find
>> help.  not bug people even more for their free assistance.
>
> It was meant to be tongue-in-cheek, and I don't think your response is
> warranted.  Additionally, it is disappointing that you put more effort
> into writing this paragraph than to your response below ...
>
>> ./configure
>> make configure-host
>> make LDFLAGS=-all-static
>> -mike
>
> If you'll read my original email you'll note that the above doesn't
> work because LDFLAGS is passed to gcc by some of the binutils
> Makefiles and gcc doesn't like the -all-static option.

It sounds like you have already investigated and analyzed the problem
more than any of the binutils developers.  It's not a typical request
and I would not be surprised in the least if there were no simple way to
do it.  Since this seems to matter to you I would encourage you to
figure out a patch.

Ian

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-24 13:02     ` Bryan Ischo
  2011-08-24 16:33       ` Ian Lance Taylor
@ 2011-08-24 17:14       ` Mike Frysinger
  2011-08-24 22:09         ` Bryan Ischo
  1 sibling, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2011-08-24 17:14 UTC (permalink / raw)
  To: binutils; +Cc: Bryan Ischo

[-- Attachment #1: Type: Text/Plain, Size: 1632 bytes --]

On Wednesday, August 24, 2011 01:09:17 Bryan Ischo wrote:
> On 8/23/2011 8:25 PM, Mike Frysinger wrote:
> > On Tuesday, August 23, 2011 18:32:00 Bryan Ischo wrote:
> >> On 08/22/11 14:40, Bryan Ischo wrote:
> >>> Hello.  I am trying to figure out how to build a statically linked
> >>> version of binutils (starting with binutils source version 2.21.1).  I
> >>> have found some old discussions of this topic via search results, but
> >>> there was never any real resolution to this issue as far as I can tell.
> >> 
> >> Hello out there ... is anyone steering this ship????
> > 
> > wow, 24 hours w/out a response and you're already getting punchy ?  this
> > is open source which means you get to figure things out yourself if you
> > cant find help.  not bug people even more for their free assistance.
> 
> It was meant to be tongue-in-cheek, and I don't think your response is
> warranted.

might want to try a bit harder then in properly expressing yourself

> Additionally, it is disappointing that you put more effort
> into writing this paragraph than to your response below ...

that's what "free" gets you

> > ./configure
> > make configure-host
> > make LDFLAGS=-all-static
> 
> If you'll read my original email you'll note that the above doesn't work
> because LDFLAGS is passed to gcc by some of the binutils Makefiles and
> gcc doesn't like the -all-static option.

i tested this sequence and it seemed to work just fine for me.  gcc generally 
shouldnt be invoked directly by the makefiles ... the compiles should all be 
going through libtool.  and they do on my system.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-24 17:14       ` Mike Frysinger
@ 2011-08-24 22:09         ` Bryan Ischo
  2011-08-25  1:30           ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Bryan Ischo @ 2011-08-24 22:09 UTC (permalink / raw)
  To: binutils

On 08/24/11 09:03, Mike Frysinger wrote:
>
>> Additionally, it is disappointing that you put more effort
>> into writing this paragraph than to your response below ...
> that's what "free" gets you
>
>>> ./configure
>>> make configure-host
>>> make LDFLAGS=-all-static
>> If you'll read my original email you'll note that the above doesn't work
>> because LDFLAGS is passed to gcc by some of the binutils Makefiles and
>> gcc doesn't like the -all-static option.
> i tested this sequence and it seemed to work just fine for me.  gcc generally
> shouldnt be invoked directly by the makefiles ... the compiles should all be
> going through libtool.  and they do on my system.
> -mike

OK I will try again and take a harder look at why it is failing for me.  
I apologize for any perceived impatience on my part in this exchange and 
I appreciate your taking the time to test the scenario and report your 
results.

Bryan


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-24 22:09         ` Bryan Ischo
@ 2011-08-25  1:30           ` Mike Frysinger
  2011-08-26  9:41             ` Bryan Ischo
  0 siblings, 1 reply; 10+ messages in thread
From: Mike Frysinger @ 2011-08-25  1:30 UTC (permalink / raw)
  To: binutils; +Cc: Bryan Ischo

[-- Attachment #1: Type: Text/Plain, Size: 1057 bytes --]

On Wednesday, August 24, 2011 12:33:28 Bryan Ischo wrote:
> On 08/24/11 09:03, Mike Frysinger wrote:
> >> Additionally, it is disappointing that you put more effort
> >> into writing this paragraph than to your response below ...
> > 
> > that's what "free" gets you
> > 
> >>> ./configure
> >>> make configure-host
> >>> make LDFLAGS=-all-static
> >> 
> >> If you'll read my original email you'll note that the above doesn't work
> >> because LDFLAGS is passed to gcc by some of the binutils Makefiles and
> >> gcc doesn't like the -all-static option.
> > 
> > i tested this sequence and it seemed to work just fine for me.  gcc
> > generally shouldnt be invoked directly by the makefiles ... the compiles
> > should all be going through libtool.  and they do on my system.
> 
> OK I will try again and take a harder look at why it is failing for me.
> I apologize for any perceived impatience on my part in this exchange and
> I appreciate your taking the time to test the scenario and report your
> results.

np.  g'luck.
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils?
  2011-08-25  1:30           ` Mike Frysinger
@ 2011-08-26  9:41             ` Bryan Ischo
  2011-08-26 12:48               ` Patching autoconf to support static binutils? - SOLVED Bryan Ischo
  0 siblings, 1 reply; 10+ messages in thread
From: Bryan Ischo @ 2011-08-26  9:41 UTC (permalink / raw)
  To: binutils

On 08/24/11 10:13, Mike Frysinger wrote:
> On Wednesday, August 24, 2011 12:33:28 Bryan Ischo wrote:
>> On 08/24/11 09:03, Mike Frysinger wrote:
>>>> Additionally, it is disappointing that you put more effort
>>>> into writing this paragraph than to your response below ...
>>> that's what "free" gets you
>>>
>>>>> ./configure
>>>>> make configure-host
>>>>> make LDFLAGS=-all-static
>>>> If you'll read my original email you'll note that the above doesn't work
>>>> because LDFLAGS is passed to gcc by some of the binutils Makefiles and
>>>> gcc doesn't like the -all-static option.
>>> i tested this sequence and it seemed to work just fine for me.  gcc
>>> generally shouldnt be invoked directly by the makefiles ... the compiles
>>> should all be going through libtool.  and they do on my system.
>> OK I will try again and take a harder look at why it is failing for me.
>> I apologize for any perceived impatience on my part in this exchange and
>> I appreciate your taking the time to test the scenario and report your
>> results.
> np.  g'luck.
> -mike

OK I tried again; with your instructions, there are no errors reported, 
but then again, the LDFLAGS argument is ignored and the result is not a 
static build of binutils as desired.

Can you please check whether your test build actually produced 
statically linked binaries?

As far as I can tell, forcing the static build requires setting 
LIBTOOLFLAGS to -all-static, but this causes the errors that I mentioned 
in my previous email, because LIBTOOLFLAGS is passed to libtool for all 
invocations regardless of the mode, and libtool with -mode=compile does 
not accept -all-static.

With no other feedback on my proposal, I guess I'll have to do what I 
think is best and hope that the binutil maintainers agree with my idea.  
I will split LIBTOOLFLAGS into separate LIBTOOLFLAGS for each libtool 
mode (i.e. LIBTOOLFLAGS_COMPILE, LIBTOOLFLAGS_LINK, etc), passing the 
appropriate one for each invocation of libtool, and also making each one 
include a reference to LIBTOOLFLAGS so that the change is backwards 
compatible.

Thanks,
Bryan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Patching autoconf to support static binutils? - SOLVED
  2011-08-26  9:41             ` Bryan Ischo
@ 2011-08-26 12:48               ` Bryan Ischo
  0 siblings, 0 replies; 10+ messages in thread
From: Bryan Ischo @ 2011-08-26 12:48 UTC (permalink / raw)
  To: binutils

On 08/25/11 12:51, Bryan Ischo wrote:
> On 08/24/11 10:13, Mike Frysinger wrote:
>> On Wednesday, August 24, 2011 12:33:28 Bryan Ischo wrote:
>>> On 08/24/11 09:03, Mike Frysinger wrote:
>>>>> Additionally, it is disappointing that you put more effort
>>>>> into writing this paragraph than to your response below ...
>>>> that's what "free" gets you
>>>>
>>>>>> ./configure
>>>>>> make configure-host
>>>>>> make LDFLAGS=-all-static
>>>>> If you'll read my original email you'll note that the above 
>>>>> doesn't work
>>>>> because LDFLAGS is passed to gcc by some of the binutils Makefiles 
>>>>> and
>>>>> gcc doesn't like the -all-static option.
>>>> i tested this sequence and it seemed to work just fine for me.  gcc
>>>> generally shouldnt be invoked directly by the makefiles ... the 
>>>> compiles
>>>> should all be going through libtool.  and they do on my system.
>>> OK I will try again and take a harder look at why it is failing for me.
>>> I apologize for any perceived impatience on my part in this exchange 
>>> and
>>> I appreciate your taking the time to test the scenario and report your
>>> results.
>> np.  g'luck.
>> -mike
>
> OK I tried again; with your instructions, there are no errors 
> reported, but then again, the LDFLAGS argument is ignored and the 
> result is not a static build of binutils as desired.

Sorry, the cause was my own mistake.  In fact your instructions *do* 
produce a static binutils.  I made the mistake of thinking that doing 
"export LDFLAGS=-all-static" was the same as passing LDFLAGS=-all-static 
to the make command, and apparently it is not.  Make variables are not 
picked up from the environment unless explicitly requested in the 
Makefile, and I often forget that detail.  The confusing thing is that 
the configure script talks about using LDFLAGS from the environment, 
which it does, but that doesn't mean that the subsequent make will pick 
the variable up from the environment, and I should have realized that.

Using your instructions verbatim did produce static binaries.

Sorry for the noise, and thanks again for your help.

Bryan

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-08-25 19:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-23  3:04 Patching autoconf to support static binutils? Bryan Ischo
2011-08-24  5:09 ` Bryan Ischo
2011-08-24  9:21   ` Mike Frysinger
2011-08-24 13:02     ` Bryan Ischo
2011-08-24 16:33       ` Ian Lance Taylor
2011-08-24 17:14       ` Mike Frysinger
2011-08-24 22:09         ` Bryan Ischo
2011-08-25  1:30           ` Mike Frysinger
2011-08-26  9:41             ` Bryan Ischo
2011-08-26 12:48               ` Patching autoconf to support static binutils? - SOLVED Bryan Ischo

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).