All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
@ 2016-05-03  1:10 Christopher Friedt
  2016-05-03  7:06 ` Richard Henderson
  2016-09-14  7:30 ` Michael Tokarev
  0 siblings, 2 replies; 8+ messages in thread
From: Christopher Friedt @ 2016-05-03  1:10 UTC (permalink / raw)
  To: famz, mst; +Cc: Christopher Friedt, qemu-devel, qemu-trivial

Currently, at least on Mac OS X 10.11.4 (El Capitan), Qemu fails to build for a few reasons.

One of those reasons is that Apple's ld (at least ld64) does not properly process archive files created with ar (even Apple's ar).

After some RTFM'ing, I came upon this tidbit, which is unfortunate. Luckily, autotools packages are not broken.

"Libtool with -static is intended to replace ar(5) and ranlib."
http://www.manpages.info/macosx/libtool.1.html

In any case, this change takes Apple's recommendations into account and allows Qemu to build on Mac OS X El Capitan.

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
---
 rules.mak | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/rules.mak b/rules.mak
index d1ff311..44421af 100644
--- a/rules.mak
+++ b/rules.mak
@@ -105,7 +105,11 @@ modules:
 	$(call LINK,$(filter %.o %.a %.mo, $^))
 
 %.a:
+ifdef CONFIG_DARWIN
+	$(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"  libtool    $(TARGET_DIR)$@")
+else
 	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")
+endif
 
 quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
 
-- 
2.6.4 (Apple Git-63)

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

* Re: [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
  2016-05-03  1:10 [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin Christopher Friedt
@ 2016-05-03  7:06 ` Richard Henderson
  2016-05-03 13:50   ` Christopher Friedt
  2016-09-14  7:30 ` Michael Tokarev
  1 sibling, 1 reply; 8+ messages in thread
From: Richard Henderson @ 2016-05-03  7:06 UTC (permalink / raw)
  To: Christopher Friedt, famz, mst; +Cc: qemu-trivial, qemu-devel

On 05/02/2016 03:10 PM, Christopher Friedt wrote:
>  %.a:
> +ifdef CONFIG_DARWIN
> +	$(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"  libtool    $(TARGET_DIR)$@")
> +else
>  	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")
> +endif
>

Does it work to use libtool -static everywhere?


r~

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

* Re: [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
  2016-05-03  7:06 ` Richard Henderson
@ 2016-05-03 13:50   ` Christopher Friedt
  2016-05-03 14:12     ` Peter Maydell
  2016-05-04  0:07     ` Christopher Friedt
  0 siblings, 2 replies; 8+ messages in thread
From: Christopher Friedt @ 2016-05-03 13:50 UTC (permalink / raw)
  To: Richard Henderson; +Cc: famz, mst, qemu-trivial, QEMU Developers

On Tue, May 3, 2016 at 3:06 AM, Richard Henderson <rth@twiddle.net> wrote:
> On 05/02/2016 03:10 PM, Christopher Friedt wrote:
>>
>>  %.a:
>> +ifdef CONFIG_DARWIN
>> +       $(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"
>> libtool    $(TARGET_DIR)$@")
>> +else
>>         $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR
>> $(TARGET_DIR)$@")
>> +endif
>>
>
> Does it work to use libtool -static everywhere?

That *would* be nice... yeah, it would be nice if Apple's tools could
work the same as *all* of the other unices out there. Unfortunately,
that's not the case, since at least GNU libtool does *not* accept the
"-static" argument.

To be honest, if it weren't for the man page for libtool on Mac OS X
[1] dating all the way back to Snow Leopard saying that libtool is the
preferred tool on Mac for creating static archives, I'm left wondering
if this is just a massive oversight / bug in Apple's ld64.

[1] http://www.unix.com/man-page/osx/1/libtool/

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

* Re: [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
  2016-05-03 13:50   ` Christopher Friedt
@ 2016-05-03 14:12     ` Peter Maydell
  2016-05-04  0:07     ` Christopher Friedt
  1 sibling, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2016-05-03 14:12 UTC (permalink / raw)
  To: Christopher Friedt
  Cc: Richard Henderson, QEMU Trivial, Fam Zheng, QEMU Developers,
	Michael S. Tsirkin

On 3 May 2016 at 14:50, Christopher Friedt <chrisfriedt@gmail.com> wrote:
> To be honest, if it weren't for the man page for libtool on Mac OS X
> [1] dating all the way back to Snow Leopard saying that libtool is the
> preferred tool on Mac for creating static archives, I'm left wondering
> if this is just a massive oversight / bug in Apple's ld64.

I think it's definitely a bug -- if "ar" and "ld" don't work
together Apple should remove "ar", not just unhelpfully break it.
We probably need to work around the bug anyway though.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
  2016-05-03 13:50   ` Christopher Friedt
  2016-05-03 14:12     ` Peter Maydell
@ 2016-05-04  0:07     ` Christopher Friedt
  2016-05-04  9:03       ` Peter Maydell
  1 sibling, 1 reply; 8+ messages in thread
From: Christopher Friedt @ 2016-05-04  0:07 UTC (permalink / raw)
  To: Richard Henderson; +Cc: QEMU Trivial, Michael S. Tsirkin, famz, QEMU Developers

[-- Attachment #1: Type: text/plain, Size: 844 bytes --]

On May 3, 2016 9:50 AM, "Christopher Friedt" <chrisfriedt@gmail.com> wrote:
>
> On Tue, May 3, 2016 at 3:06 AM, Richard Henderson <rth@twiddle.net> wrote:
> > On 05/02/2016 03:10 PM, Christopher Friedt wrote:
> >>
> >>  %.a:
> >> +ifdef CONFIG_DARWIN
> >> +       $(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"
> >> libtool    $(TARGET_DIR)$@")
> >> +else
> >>         $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR
> >> $(TARGET_DIR)$@")
> >> +endif
> >>
> >
> > Does it work to use libtool -static everywhere?

One possibility for future-proofing the link stage that applies to most
(all?) platforms that Qemu runs on would be to switch to libtool for all
arch's and just adjust the "libtool flags" as necessary.

Would require checking for libtool.

Fallback to ar?

©

Sent from my Android

[-- Attachment #2: Type: text/html, Size: 1279 bytes --]

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

* Re: [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
  2016-05-04  0:07     ` Christopher Friedt
@ 2016-05-04  9:03       ` Peter Maydell
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2016-05-04  9:03 UTC (permalink / raw)
  To: Christopher Friedt
  Cc: Richard Henderson, QEMU Trivial, Fam Zheng, QEMU Developers,
	Michael S. Tsirkin

On 4 May 2016 at 01:07, Christopher Friedt <chrisfriedt@gmail.com> wrote:
>
> On May 3, 2016 9:50 AM, "Christopher Friedt" <chrisfriedt@gmail.com> wrote:
>>
>> On Tue, May 3, 2016 at 3:06 AM, Richard Henderson <rth@twiddle.net> wrote:
>> > On 05/02/2016 03:10 PM, Christopher Friedt wrote:
>> >>
>> >>  %.a:
>> >> +ifdef CONFIG_DARWIN
>> >> +       $(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"
>> >> libtool    $(TARGET_DIR)$@")
>> >> +else
>> >>         $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR
>> >> $(TARGET_DIR)$@")
>> >> +endif
>> >>
>> >
>> > Does it work to use libtool -static everywhere?
>
> One possibility for future-proofing the link stage that applies to most
> (all?) platforms that Qemu runs on would be to switch to libtool for all
> arch's and just adjust the "libtool flags" as necessary.
>
> Would require checking for libtool.

This is more complicated than we need. OSX "libtool" and GNU
"libtool" are really completely different things. We don't
(these days) do anything that we need GNU libtool for, so
there's no need to depend on it or use it optionally -- we should
just use "ar". If we need to special case the "program for creating
static libraries" for OSX that's annoying but we can do that.

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
  2016-05-03  1:10 [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin Christopher Friedt
  2016-05-03  7:06 ` Richard Henderson
@ 2016-09-14  7:30 ` Michael Tokarev
  2016-09-20 17:58   ` Peter Maydell
  1 sibling, 1 reply; 8+ messages in thread
From: Michael Tokarev @ 2016-09-14  7:30 UTC (permalink / raw)
  To: Christopher Friedt, famz, mst; +Cc: qemu-trivial, qemu-devel

03.05.2016 04:10, Christopher Friedt wrote:
> Currently, at least on Mac OS X 10.11.4 (El Capitan), Qemu fails to build for a few reasons.
>
> One of those reasons is that Apple's ld (at least ld64) does not properly process archive files created with ar (even Apple's ar).
>
> After some RTFM'ing, I came upon this tidbit, which is unfortunate. Luckily, autotools packages are not broken.
>
> "Libtool with -static is intended to replace ar(5) and ranlib."
> http://www.manpages.info/macosx/libtool.1.html
>
> In any case, this change takes Apple's recommendations into account and allows Qemu to build on Mac OS X El Capitan.
>
> Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
> ---
>  rules.mak | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/rules.mak b/rules.mak
> index d1ff311..44421af 100644
> --- a/rules.mak
> +++ b/rules.mak
> @@ -105,7 +105,11 @@ modules:
>  	$(call LINK,$(filter %.o %.a %.mo, $^))
>
>  %.a:
> +ifdef CONFIG_DARWIN
> +	$(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"  libtool    $(TARGET_DIR)$@")
> +else
>  	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")
> +endif
>
>  quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))

Hmm.  Is this patch still relevant?  Apparently I missed it back then.

Thanks,

/mjt

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

* Re: [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin.
  2016-09-14  7:30 ` Michael Tokarev
@ 2016-09-20 17:58   ` Peter Maydell
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Maydell @ 2016-09-20 17:58 UTC (permalink / raw)
  To: Michael Tokarev
  Cc: Christopher Friedt, Fam Zheng, Michael S. Tsirkin, QEMU Trivial,
	QEMU Developers

On 14 September 2016 at 08:30, Michael Tokarev <mjt@tls.msk.ru> wrote:
> 03.05.2016 04:10, Christopher Friedt wrote:
>>
>> Currently, at least on Mac OS X 10.11.4 (El Capitan), Qemu fails to build
>> for a few reasons.
>>
>> One of those reasons is that Apple's ld (at least ld64) does not properly
>> process archive files created with ar (even Apple's ar).
>>
>> After some RTFM'ing, I came upon this tidbit, which is unfortunate.
>> Luckily, autotools packages are not broken.
>>
>> "Libtool with -static is intended to replace ar(5) and ranlib."
>> http://www.manpages.info/macosx/libtool.1.html
>>
>> In any case, this change takes Apple's recommendations into account and
>> allows Qemu to build on Mac OS X El Capitan.
>>
>> Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
>> ---
>>  rules.mak | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/rules.mak b/rules.mak
>> index d1ff311..44421af 100644
>> --- a/rules.mak
>> +++ b/rules.mak
>> @@ -105,7 +105,11 @@ modules:
>>         $(call LINK,$(filter %.o %.a %.mo, $^))
>>
>>  %.a:
>> +ifdef CONFIG_DARWIN
>> +       $(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"
>> libtool    $(TARGET_DIR)$@")
>> +else
>>         $(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR
>> $(TARGET_DIR)$@")
>> +endif
>>
>>  quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
>
>
> Hmm.  Is this patch still relevant?  Apparently I missed it back then.

I don't have El Capitan, but I can confirm that it doesn't break
the build on Yosemite, so I guess we should have it.

I'd like to know the error message the linker produces first,
though (and we should put that in the commit message).

The progress string argument to quiet-command is slightly wrong:
we capitalize the shortname of the command being run, so it
ought to look like "  LIBTOOL $(TARGET_DIR)$@" so it lines up
and looks nice with the other output.

thanks
-- PMM

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

end of thread, other threads:[~2016-09-20 17:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-03  1:10 [Qemu-devel] [PATCH 1/2v2] [RESENT-INLINE] Use libtool instead of ar to create static libraries on Darwin Christopher Friedt
2016-05-03  7:06 ` Richard Henderson
2016-05-03 13:50   ` Christopher Friedt
2016-05-03 14:12     ` Peter Maydell
2016-05-04  0:07     ` Christopher Friedt
2016-05-04  9:03       ` Peter Maydell
2016-09-14  7:30 ` Michael Tokarev
2016-09-20 17:58   ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.