mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] config.mak: add AR/RANLIB and delete ASMSUBARCH
@ 2019-05-17 15:35 Fangrui Song
  2019-05-17 16:43 ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Fangrui Song @ 2019-05-17 15:35 UTC (permalink / raw)
  To: musl

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

By default, if I specify --target=aarch64, AR=aarch64-ar is used, which is apparently not available.

With this patch, I am able to build an aarch64 musl with:

  ../configure --target=aarch64 AR=llvm-ar RANLIB=true CC=clang CFLAGS=--target=aarch64-linux-musl LDFLAGS="-fuse-ld=lld -L/path/to/aarch64/libgcc.a/and/libgcc_eh.a" --enable-debug

ASMSUBARCH is no longer in use as of commit 0f814a4e57e80d2512934820b878211e9d71c93e.

You may also delete the following line

  test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt

because compiler-rt (part of which is nearly a replacement of libgcc) is something like:

  /home/ray/llvm/Release/lib/clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a

not libcompiler_rt.a

  % clang -print-resource-dir
  /home/ray/llvm/Release/lib/clang/9.0.0
  % clang -rtlib=compiler-rt -print-libgcc-file-name
  /home/ray/llvm/Release/lib/clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a

BTW, I am not sure if libgcc_eh.a is needed.

[-- Attachment #2: musl.patch --]
[-- Type: text/x-diff, Size: 1336 bytes --]

From 1a9f27d0a311210829a021384eb36332bc7456d0 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i@maskray.me>
Date: Fri, 17 May 2019 08:15:52 -0700
Subject: [PATCH] config.mak: add AR/RANLIB and delete ASMSUBARCH

---
 configure | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 2123ddce..2c866955 100755
--- a/configure
+++ b/configure
@@ -172,6 +172,8 @@ case "$arg" in
 --host=*|--target=*) target=${arg#*=} ;;
 --build=*) build=${arg#*=} ;;
 -* ) echo "$0: unknown option $arg" ;;
+AR=*) AR=${arg#*=} ;;
+RANLIB=*) RANLIB=${arg#*=} ;;
 CC=*) CC=${arg#*=} ;;
 CFLAGS=*) CFLAGS=${arg#*=} ;;
 CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
@@ -680,11 +682,6 @@ fi
 test "$SUBARCH" \
 && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH"
 
-case "$ARCH$SUBARCH" in
-arm) ASMSUBARCH=el ;;
-*) ASMSUBARCH=$SUBARCH ;;
-esac
-
 #
 # Some archs (powerpc) have different possible long double formats
 # that the compiler can be configured for. The logic for whether this
@@ -728,9 +725,10 @@ cat << EOF
 # This version of config.mak was generated by:
 # $cmdline
 # Any changes made here will be lost if configure is re-run
+AR = $AR
+RANLIB = $RANLIB
 ARCH = $ARCH
 SUBARCH = $SUBARCH
-ASMSUBARCH = $ASMSUBARCH
 srcdir = $srcdir
 prefix = $prefix
 exec_prefix = $exec_prefix
-- 
2.21.0


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

* Re: [PATCH] config.mak: add AR/RANLIB and delete ASMSUBARCH
  2019-05-17 15:35 [PATCH] config.mak: add AR/RANLIB and delete ASMSUBARCH Fangrui Song
@ 2019-05-17 16:43 ` Rich Felker
  2019-07-03  8:53   ` [PATCH] configure: make AR and RANLIB customizable Fangrui Song
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2019-05-17 16:43 UTC (permalink / raw)
  To: musl

On Fri, May 17, 2019 at 11:35:37PM +0800, Fangrui Song wrote:
> By default, if I specify --target=aarch64, AR=aarch64-ar is used, which is apparently not available.
> 
> With this patch, I am able to build an aarch64 musl with:
> 
>  ../configure --target=aarch64 AR=llvm-ar RANLIB=true CC=clang CFLAGS=--target=aarch64-linux-musl LDFLAGS="-fuse-ld=lld -L/path/to/aarch64/libgcc.a/and/libgcc_eh.a" --enable-debug
> 
> ASMSUBARCH is no longer in use as of commit 0f814a4e57e80d2512934820b878211e9d71c93e.
> 
> You may also delete the following line
> 
>  test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
> 
> because compiler-rt (part of which is nearly a replacement of libgcc) is something like:
> 
>  /home/ray/llvm/Release/lib/clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a
> 
> not libcompiler_rt.a
> 
>  % clang -print-resource-dir
>  /home/ray/llvm/Release/lib/clang/9.0.0
>  % clang -rtlib=compiler-rt -print-libgcc-file-name
>  /home/ray/llvm/Release/lib/clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a

I think this was discussed before and there were suggestions for
improving the behavior overall. That might include removing
-lcompiler_rt search, but there may be cases where it makes sense
(maybe using gcc with libgcc intentionally replaced?)

> BTW, I am not sure if libgcc_eh.a is needed.

At one point, some archs' libgcc had a gratuitous dependency on
libgcc_eh due to soft division functions pulling in exception crap for
divide-by-zero. This is obviously wrong, but I felt it was outside the
scope of musl to try to fix it. Since libgcc_eh is an archive library,
including it in the link is a nop as long as nothing pulls in a
dependency on it, so it shouldn't hurt with non-broken libgcc.

> From 1a9f27d0a311210829a021384eb36332bc7456d0 Mon Sep 17 00:00:00 2001
> From: Fangrui Song <i@maskray.me>
> Date: Fri, 17 May 2019 08:15:52 -0700
> Subject: [PATCH] config.mak: add AR/RANLIB and delete ASMSUBARCH

These are independent, unrelated changes and shouldn't be in a commit
together.

> ---
>  configure | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/configure b/configure
> index 2123ddce..2c866955 100755
> --- a/configure
> +++ b/configure
> @@ -172,6 +172,8 @@ case "$arg" in
>  --host=*|--target=*) target=${arg#*=} ;;
>  --build=*) build=${arg#*=} ;;
>  -* ) echo "$0: unknown option $arg" ;;
> +AR=*) AR=${arg#*=} ;;
> +RANLIB=*) RANLIB=${arg#*=} ;;
>  CC=*) CC=${arg#*=} ;;
>  CFLAGS=*) CFLAGS=${arg#*=} ;;
>  CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
> @@ -680,11 +682,6 @@ fi
>  test "$SUBARCH" \
>  && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH"
>  
> -case "$ARCH$SUBARCH" in
> -arm) ASMSUBARCH=el ;;
> -*) ASMSUBARCH=$SUBARCH ;;
> -esac
> -
>  #
>  # Some archs (powerpc) have different possible long double formats
>  # that the compiler can be configured for. The logic for whether this
> @@ -728,9 +725,10 @@ cat << EOF
>  # This version of config.mak was generated by:
>  # $cmdline
>  # Any changes made here will be lost if configure is re-run
> +AR = $AR
> +RANLIB = $RANLIB

This completely breaks the behavior with AR and RANLIB not specified
explicitly, including a plain default ./configure command. They'll now
be blank rather than $(CROSS_COMPILE)-{ar,ranlib} evaluated at
make-time.

Rich


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

* [PATCH] configure: make AR and RANLIB customizable
  2019-05-17 16:43 ` Rich Felker
@ 2019-07-03  8:53   ` Fangrui Song
  2019-07-03 20:37     ` Rich Felker
  0 siblings, 1 reply; 5+ messages in thread
From: Fangrui Song @ 2019-07-03  8:53 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

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


On 2019-05-17, Rich Felker wrote:
>On Fri, May 17, 2019 at 11:35:37PM +0800, Fangrui Song wrote:
>> By default, if I specify --target=aarch64, AR=aarch64-ar is used, which is apparently not available.
>>
>> With this patch, I am able to build an aarch64 musl with:
>>
>>  ../configure --target=aarch64 AR=llvm-ar RANLIB=true CC=clang CFLAGS=--target=aarch64-linux-musl LDFLAGS="-fuse-ld=lld -L/path/to/aarch64/libgcc.a/and/libgcc_eh.a" --enable-debug
>>
>> ASMSUBARCH is no longer in use as of commit 0f814a4e57e80d2512934820b878211e9d71c93e.
>>
>> You may also delete the following line
>>
>>  test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
>>
>> because compiler-rt (part of which is nearly a replacement of libgcc) is something like:
>>
>>  /home/ray/llvm/Release/lib/clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a
>>
>> not libcompiler_rt.a
>>
>>  % clang -print-resource-dir
>>  /home/ray/llvm/Release/lib/clang/9.0.0
>>  % clang -rtlib=compiler-rt -print-libgcc-file-name
>>  /home/ray/llvm/Release/lib/clang/9.0.0/lib/linux/libclang_rt.builtins-x86_64.a
>
>I think this was discussed before and there were suggestions for
>improving the behavior overall. That might include removing
>-lcompiler_rt search, but there may be cases where it makes sense
>(maybe using gcc with libgcc intentionally replaced?)
>
>> BTW, I am not sure if libgcc_eh.a is needed.
>
>At one point, some archs' libgcc had a gratuitous dependency on
>libgcc_eh due to soft division functions pulling in exception crap for
>divide-by-zero. This is obviously wrong, but I felt it was outside the
>scope of musl to try to fix it. Since libgcc_eh is an archive library,
>including it in the link is a nop as long as nothing pulls in a
>dependency on it, so it shouldn't hurt with non-broken libgcc.
>
>> From 1a9f27d0a311210829a021384eb36332bc7456d0 Mon Sep 17 00:00:00 2001
>> From: Fangrui Song <i@maskray.me>
>> Date: Fri, 17 May 2019 08:15:52 -0700
>> Subject: [PATCH] config.mak: add AR/RANLIB and delete ASMSUBARCH
>
>These are independent, unrelated changes and shouldn't be in a commit
>together.
>
>> ---
>>  configure | 10 ++++------
>>  1 file changed, 4 insertions(+), 6 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 2123ddce..2c866955 100755
>> --- a/configure
>> +++ b/configure
>> @@ -172,6 +172,8 @@ case "$arg" in
>>  --host=*|--target=*) target=${arg#*=} ;;
>>  --build=*) build=${arg#*=} ;;
>>  -* ) echo "$0: unknown option $arg" ;;
>> +AR=*) AR=${arg#*=} ;;
>> +RANLIB=*) RANLIB=${arg#*=} ;;
>>  CC=*) CC=${arg#*=} ;;
>>  CFLAGS=*) CFLAGS=${arg#*=} ;;
>>  CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
>> @@ -680,11 +682,6 @@ fi
>>  test "$SUBARCH" \
>>  && printf "configured for %s variant: %s\n" "$ARCH" "$ARCH$SUBARCH"
>>
>> -case "$ARCH$SUBARCH" in
>> -arm) ASMSUBARCH=el ;;
>> -*) ASMSUBARCH=$SUBARCH ;;
>> -esac
>> -
>>  #
>>  # Some archs (powerpc) have different possible long double formats
>>  # that the compiler can be configured for. The logic for whether this
>> @@ -728,9 +725,10 @@ cat << EOF
>>  # This version of config.mak was generated by:
>>  # $cmdline
>>  # Any changes made here will be lost if configure is re-run
>> +AR = $AR
>> +RANLIB = $RANLIB
>
>This completely breaks the behavior with AR and RANLIB not specified
>explicitly, including a plain default ./configure command. They'll now
>be blank rather than $(CROSS_COMPILE)-{ar,ranlib} evaluated at
>make-time.

Sorry, didn't notice that.

New patch attached.


With 2 local llvm/clang patches, I am able to build musl powerpc64le with the following command:

../configure --target=powerpc64le AR=~/llvm/Release/bin/llvm-ar RANLIB=true CC=~/llvm/Release/bin/clang CFLAGS='-target powerpc64le-linux -mlong-double-64' LDFLAGS=-fuse-ld=lld --enable-debug

# "-linux" in "powerpc64le-linux" is important.
# If -target powerpc64le is used instead, clang will invoke gcc instead of itself in the linker stage, which will not work.

[-- Attachment #2: musl.patch --]
[-- Type: text/x-diff, Size: 1364 bytes --]

From 4415adea632ca0fee80e10b6cd73b590417a2266 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i@maskray.me>
Date: Thu, 27 Jun 2019 08:10:04 +0000
Subject: [PATCH] configure: make AR and RANLIB customizable

---
 Makefile  | 2 --
 configure | 4 ++++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index b46f8ca4..6842983b 100644
--- a/Makefile
+++ b/Makefile
@@ -51,8 +51,6 @@ CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
 
 LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
 
-AR      = $(CROSS_COMPILE)ar
-RANLIB  = $(CROSS_COMPILE)ranlib
 INSTALL = $(srcdir)/tools/install.sh
 
 ARCH_INCLUDES = $(wildcard $(srcdir)/arch/$(ARCH)/bits/*.h)
diff --git a/configure b/configure
index 60e0b1fc..86801281 100755
--- a/configure
+++ b/configure
@@ -172,6 +172,8 @@ case "$arg" in
 --host=*|--target=*) target=${arg#*=} ;;
 --build=*) build=${arg#*=} ;;
 -* ) echo "$0: unknown option $arg" ;;
+AR=*) AR=${arg#*=} ;;
+RANLIB=*) RANLIB=${arg#*=} ;;
 CC=*) CC=${arg#*=} ;;
 CFLAGS=*) CFLAGS=${arg#*=} ;;
 CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
@@ -734,6 +736,8 @@ cat << EOF
 # This version of config.mak was generated by:
 # $cmdline
 # Any changes made here will be lost if configure is re-run
+AR = ${AR:-\$(CROSS_COMPILE)ar}
+RANLIB = ${RANLIB:-\$(CROSS_COMPILE)ranlib}
 ARCH = $ARCH
 SUBARCH = $SUBARCH
 ASMSUBARCH = $ASMSUBARCH
-- 
2.22.0


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

* Re: [PATCH] configure: make AR and RANLIB customizable
  2019-07-03  8:53   ` [PATCH] configure: make AR and RANLIB customizable Fangrui Song
@ 2019-07-03 20:37     ` Rich Felker
  2019-07-04  4:38       ` Fangrui Song
  0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2019-07-03 20:37 UTC (permalink / raw)
  To: musl

On Wed, Jul 03, 2019 at 08:53:12AM +0000, Fangrui Song wrote:
> New patch attached.
> 
> 
> With 2 local llvm/clang patches, I am able to build musl powerpc64le with the following command:
> 
> .../configure --target=powerpc64le AR=~/llvm/Release/bin/llvm-ar RANLIB=true CC=~/llvm/Release/bin/clang CFLAGS='-target powerpc64le-linux -mlong-double-64' LDFLAGS=-fuse-ld=lld --enable-debug
> 
> # "-linux" in "powerpc64le-linux" is important.
> # If -target powerpc64le is used instead, clang will invoke gcc instead of itself in the linker stage, which will not work.

> >From 4415adea632ca0fee80e10b6cd73b590417a2266 Mon Sep 17 00:00:00 2001
> From: Fangrui Song <i@maskray.me>
> Date: Thu, 27 Jun 2019 08:10:04 +0000
> Subject: [PATCH] configure: make AR and RANLIB customizable
> 
> ---
>  Makefile  | 2 --
>  configure | 4 ++++
>  2 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index b46f8ca4..6842983b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -51,8 +51,6 @@ CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
>  
>  LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
>  
> -AR      = $(CROSS_COMPILE)ar
> -RANLIB  = $(CROSS_COMPILE)ranlib
>  INSTALL = $(srcdir)/tools/install.sh

I think you can omit the changes to Makefile. They break running make
with an existing config.mak not updated by new configure, and since
the assignments are before "include config.mak", the ones from
config.mak will override if present.

>  ARCH_INCLUDES = $(wildcard $(srcdir)/arch/$(ARCH)/bits/*.h)
> diff --git a/configure b/configure
> index 60e0b1fc..86801281 100755
> --- a/configure
> +++ b/configure
> @@ -172,6 +172,8 @@ case "$arg" in
>  --host=*|--target=*) target=${arg#*=} ;;
>  --build=*) build=${arg#*=} ;;
>  -* ) echo "$0: unknown option $arg" ;;
> +AR=*) AR=${arg#*=} ;;
> +RANLIB=*) RANLIB=${arg#*=} ;;
>  CC=*) CC=${arg#*=} ;;
>  CFLAGS=*) CFLAGS=${arg#*=} ;;
>  CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
> @@ -734,6 +736,8 @@ cat << EOF
>  # This version of config.mak was generated by:
>  # $cmdline
>  # Any changes made here will be lost if configure is re-run
> +AR = ${AR:-\$(CROSS_COMPILE)ar}
> +RANLIB = ${RANLIB:-\$(CROSS_COMPILE)ranlib}
>  ARCH = $ARCH
>  SUBARCH = $SUBARCH
>  ASMSUBARCH = $ASMSUBARCH
> -- 
> 2.22.0
> 

Looks ok otherwise. Would you like me to apply with the above change?

Rich


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

* Re: [PATCH] configure: make AR and RANLIB customizable
  2019-07-03 20:37     ` Rich Felker
@ 2019-07-04  4:38       ` Fangrui Song
  0 siblings, 0 replies; 5+ messages in thread
From: Fangrui Song @ 2019-07-04  4:38 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

On 2019-07-03, Rich Felker wrote:
>On Wed, Jul 03, 2019 at 08:53:12AM +0000, Fangrui Song wrote:
>> New patch attached.
>>
>>
>> With 2 local llvm/clang patches, I am able to build musl powerpc64le with the following command:
>>
>> .../configure --target=powerpc64le AR=~/llvm/Release/bin/llvm-ar RANLIB=true CC=~/llvm/Release/bin/clang CFLAGS='-target powerpc64le-linux -mlong-double-64' LDFLAGS=-fuse-ld=lld --enable-debug
>>
>> # "-linux" in "powerpc64le-linux" is important.
>> # If -target powerpc64le is used instead, clang will invoke gcc instead of itself in the linker stage, which will not work.
>
>> >From 4415adea632ca0fee80e10b6cd73b590417a2266 Mon Sep 17 00:00:00 2001
>> From: Fangrui Song <i@maskray.me>
>> Date: Thu, 27 Jun 2019 08:10:04 +0000
>> Subject: [PATCH] configure: make AR and RANLIB customizable
>>
>> ---
>>  Makefile  | 2 --
>>  configure | 4 ++++
>>  2 files changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index b46f8ca4..6842983b 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -51,8 +51,6 @@ CFLAGS_ALL += $(CPPFLAGS) $(CFLAGS_AUTO) $(CFLAGS)
>>
>>  LDFLAGS_ALL = $(LDFLAGS_AUTO) $(LDFLAGS)
>>
>> -AR      = $(CROSS_COMPILE)ar
>> -RANLIB  = $(CROSS_COMPILE)ranlib
>>  INSTALL = $(srcdir)/tools/install.sh
>
>I think you can omit the changes to Makefile. They break running make
>with an existing config.mak not updated by new configure, and since
>the assignments are before "include config.mak", the ones from
>config.mak will override if present.
>
>>  ARCH_INCLUDES = $(wildcard $(srcdir)/arch/$(ARCH)/bits/*.h)
>> diff --git a/configure b/configure
>> index 60e0b1fc..86801281 100755
>> --- a/configure
>> +++ b/configure
>> @@ -172,6 +172,8 @@ case "$arg" in
>>  --host=*|--target=*) target=${arg#*=} ;;
>>  --build=*) build=${arg#*=} ;;
>>  -* ) echo "$0: unknown option $arg" ;;
>> +AR=*) AR=${arg#*=} ;;
>> +RANLIB=*) RANLIB=${arg#*=} ;;
>>  CC=*) CC=${arg#*=} ;;
>>  CFLAGS=*) CFLAGS=${arg#*=} ;;
>>  CPPFLAGS=*) CPPFLAGS=${arg#*=} ;;
>> @@ -734,6 +736,8 @@ cat << EOF
>>  # This version of config.mak was generated by:
>>  # $cmdline
>>  # Any changes made here will be lost if configure is re-run
>> +AR = ${AR:-\$(CROSS_COMPILE)ar}
>> +RANLIB = ${RANLIB:-\$(CROSS_COMPILE)ranlib}
>>  ARCH = $ARCH
>>  SUBARCH = $SUBARCH
>>  ASMSUBARCH = $ASMSUBARCH
>> --
>> 2.22.0
>>
>
>Looks ok otherwise. Would you like me to apply with the above change?

Sure. Thanks!



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

end of thread, other threads:[~2019-07-04  4:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 15:35 [PATCH] config.mak: add AR/RANLIB and delete ASMSUBARCH Fangrui Song
2019-05-17 16:43 ` Rich Felker
2019-07-03  8:53   ` [PATCH] configure: make AR and RANLIB customizable Fangrui Song
2019-07-03 20:37     ` Rich Felker
2019-07-04  4:38       ` Fangrui Song

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).