diff mbox

[1/2] Use libtool instead of ar to create static libraries on Darwin.

Message ID 1462236478-61645-2-git-send-email-chrisfriedt@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Christopher Friedt May 3, 2016, 12:47 a.m. UTC
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(+)

Comments

Peter Maydell May 3, 2016, 12:53 a.m. UTC | #1
On 3 May 2016 at 01:47, Christopher Friedt <chrisfriedt@gmail.com> wrote:
>
> Currently, at least on Mac OS X 10.11.4 (El Capitan), Qemu fails
> to build for a few reasons.

I guess this is a new-in-ElCapitan thing? I run Yosemite, which is
fine.

thanks
-- PMM
Fam Zheng May 3, 2016, 1:04 a.m. UTC | #2
Cc'ing Peter Maydell, who must have better ideas than me on building on Mac.

On Mon, 05/02 20:47, 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:
> +ifeq ($(shell uname),Darwin)

I think you can use "ifdef CONFIG_DARWIN" here.

> +	$(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"  libtool    $(TARGET_DIR)$@")

Is libtool always available on Mac OS X? If not, we may need to add the
detection to ./configure.

Fam

> +else
>  	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")
> +endif
>  
>  quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
>
Christopher Friedt May 3, 2016, 1:08 a.m. UTC | #3
On Mon, May 2, 2016 at 8:53 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 3 May 2016 at 01:47, Christopher Friedt <chrisfriedt@gmail.com> wrote:
>>
>> Currently, at least on Mac OS X 10.11.4 (El Capitan), Qemu fails
>> to build for a few reasons.
>
> I guess this is a new-in-ElCapitan thing? I run Yosemite, which is
> fine.

I think you're partially correct, although the information on the man page dates
back to at least Snow Leopard (10.6.2) [1], so Apple has preferred the
libtool method for a very long time.

It's possible that it only finally broke in El Capitan.

[1] http://www.unix.com/man-page/osx/1/libtool/
Christopher Friedt May 3, 2016, 1:08 a.m. UTC | #4
On Mon, May 2, 2016 at 9:04 PM, Fam Zheng <famz@redhat.com> wrote:
> Cc'ing Peter Maydell, who must have better ideas than me on building on Mac.
>
> On Mon, 05/02 20:47, 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:
>> +ifeq ($(shell uname),Darwin)
>
> I think you can use "ifdef CONFIG_DARWIN" here.

Good suggestion. I missed that entirely.

>> +     $(call quiet-command,rm -f $@ && libtool -static -o $@ $^,"  libtool    $(TARGET_DIR)$@")
>
> Is libtool always available on Mac OS X? If not, we may need to add the
> detection to ./configure.

Apple's libtool should be installed with their command line tools, at
least as far back as Snow Leopard.
Michael Tokarev May 6, 2016, 7:07 p.m. UTC | #5
Hmm.  We removed libtool support just two moths ago... :)

/mjt
Peter Maydell May 6, 2016, 10:26 p.m. UTC | #6
On 6 May 2016 at 20:07, Michael Tokarev <mjt@tls.msk.ru> wrote:
> Hmm.  We removed libtool support just two moths ago... :)

That was GNU libtool, which is a completely different thing
from OSX libtool. They just have an unhelpful name clash.

thanks
-- PMM
diff mbox

Patch

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:
+ifeq ($(shell uname),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))