mailing list of musl libc
 help / color / mirror / code / Atom feed
* [RFC] pcc support for configure
@ 2012-10-16  4:12 Isaac Dunham
  2012-10-16  9:39 ` Luca Barbato
  2012-10-16 10:17 ` Szabolcs Nagy
  0 siblings, 2 replies; 9+ messages in thread
From: Isaac Dunham @ 2012-10-16  4:12 UTC (permalink / raw)
  To: musl

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

Now that pcc can build a working libc.so*, I thought I'd try adding pcc to the configure script.
I don't anticipate these changes to be the final version; feel free to suggest improvements.
-m* is tested for link success with this patch; this fixes the "Unrecognized emulation mode" when using pcc, while letting gcc add the 
-m* options.

*Note: pcc can be built with binutils (default) or yasm (--with-yasm). Apparently yasm is missing quite a few instructions, as even when I used yasm from git I got a quite spectacular FTBFS using pcc+yasm as compiler.
Only pcc with binutils is supported.
Also, pcc-libs must be built with -fPIC.
HTH,
Isaac Dunham <idunham@lavabit.com>

[-- Attachment #2: pcc.diff --]
[-- Type: text/x-diff, Size: 1978 bytes --]

diff --git a/configure b/configure
index 9b06d2b..828b156 100755
--- a/configure
+++ b/configure
@@ -162,6 +162,7 @@ printf "checking for C compiler... "
 trycc ${CROSS_COMPILE}gcc
 trycc ${CROSS_COMPILE}c99
 trycc ${CROSS_COMPILE}cc
+trycc ${CROSS_COMPILE}pcc
 printf "%s\n" "$CC"
 test -n "$CC" || { echo "$0: cannot find a C compiler" ; exit 1 ; }
 
@@ -219,6 +220,14 @@ tryflag CFLAGS_C99FSE -fexcess-precision=standard \
 tryflag CFLAGS_C99FSE -frounding-math
 
 #
+# Older PCC versions don't define __PIC__ with -fPIC
+#
+tryflag CFLAG_TEST "-x c"
+printf '#ifndef __PIC__\n__PIC__=0\n#endif\n' | \
+$CC -E $CFLAG_TEST -fPIC - | grep __PIC__ && \
+CFLAGS_SHARED_ALL="$CFLAGS_SHARED_ALL -D__PIC__=1"
+
+#
 # Setup basic default CFLAGS: debug, optimization, and -pipe
 #
 if fnmatch '-O*|*\ -O*' "$CFLAGS_AUTO $CFLAGS" ; then :
@@ -269,8 +278,8 @@ tryflag CFLAGS_AUTO -falign-jumps=1
 # work anyway (issues with atomic ops).
 #
 if test "$ARCH" = "i386" ; then
-fnmatch '-march=*|*\ -march=*' "$CFLAGS" || tryflag CFLAGS_AUTO -march=i486
-fnmatch '-mtune=*|*\ -mtune=*' "$CFLAGS" || tryflag CFLAGS_AUTO -mtune=generic
+fnmatch '-march=*|*\ -march=*' "$CFLAGS" || tryldflag CFLAGS_AUTO -march=i486
+fnmatch '-mtune=*|*\ -mtune=*' "$CFLAGS" || tryldflag CFLAGS_AUTO -mtune=generic
 fi
 
 if test "x$warnings" = xyes ; then
@@ -299,6 +308,7 @@ shared=no
 # Find compiler runtime library
 test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
 test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
+test -z "$LIBCC" && tryldflag LIBCC `$CC -print-file-name=libpcc.a || true`
 printf "using compiler runtime libraries: %s\n" "$LIBCC"
 
 
@@ -325,6 +335,7 @@ LDFLAGS = $LDFLAGS_AUTO $LDFLAGS
 CROSS_COMPILE = $CROSS_COMPILE
 LIBCC = $LIBCC
 EOF
+test "x$CFLAGS_ALL_SHARED" != x && echo "CFLAGS_ALL_SHARED += $CFLAGS_ALL_SHARED"
 test "x$static" = xno && echo "STATIC_LIBS ="
 test "x$shared" = xno && echo "SHARED_LIBS ="
 test "x$wrapper" = xno && echo "ALL_TOOLS ="

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

* Re: [RFC] pcc support for configure
  2012-10-16  4:12 [RFC] pcc support for configure Isaac Dunham
@ 2012-10-16  9:39 ` Luca Barbato
  2012-10-16 19:08   ` idunham
  2012-10-16 10:17 ` Szabolcs Nagy
  1 sibling, 1 reply; 9+ messages in thread
From: Luca Barbato @ 2012-10-16  9:39 UTC (permalink / raw)
  To: musl

On 10/16/2012 06:12 AM, Isaac Dunham wrote:
> *Note: pcc can be built with binutils (default) or yasm (--with-yasm).
> Apparently yasm is missing quite a few instructions, as even when I used yasm
> from git I got a quite spectacular FTBFS using pcc+yasm as compiler.

I thought yasm was just for the win32 target.

lu


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

* Re: [RFC] pcc support for configure
  2012-10-16  4:12 [RFC] pcc support for configure Isaac Dunham
  2012-10-16  9:39 ` Luca Barbato
@ 2012-10-16 10:17 ` Szabolcs Nagy
  2012-10-16 13:21   ` Rich Felker
  1 sibling, 1 reply; 9+ messages in thread
From: Szabolcs Nagy @ 2012-10-16 10:17 UTC (permalink / raw)
  To: musl

* Isaac Dunham <idunham@lavabit.com> [2012-10-15 21:12:31 -0700]:
> +# Older PCC versions don't define __PIC__ with -fPIC
> +#
> +tryflag CFLAG_TEST "-x c"
> +printf '#ifndef __PIC__\n__PIC__=0\n#endif\n' | \
> +$CC -E $CFLAG_TEST -fPIC - | grep __PIC__ && \
> +CFLAGS_SHARED_ALL="$CFLAGS_SHARED_ALL -D__PIC__=1"
> +

i don't think it's worth adding such checks

pcc is still in development and the last
release was very much broken

when it gets more stable and widely used then
such ckecks will make sense, right now we can
just depend on the latest pcc

even with clang we can easily say that we
only support clang+llvm >= 3.1
(i assume the -ffreestanding bug is fixed in that)


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

* Re: [RFC] pcc support for configure
  2012-10-16 10:17 ` Szabolcs Nagy
@ 2012-10-16 13:21   ` Rich Felker
  2012-10-16 18:55     ` idunham
  0 siblings, 1 reply; 9+ messages in thread
From: Rich Felker @ 2012-10-16 13:21 UTC (permalink / raw)
  To: musl

On Tue, Oct 16, 2012 at 12:17:43PM +0200, Szabolcs Nagy wrote:
> * Isaac Dunham <idunham@lavabit.com> [2012-10-15 21:12:31 -0700]:
> > +# Older PCC versions don't define __PIC__ with -fPIC
> > +#
> > +tryflag CFLAG_TEST "-x c"
> > +printf '#ifndef __PIC__\n__PIC__=0\n#endif\n' | \
> > +$CC -E $CFLAG_TEST -fPIC - | grep __PIC__ && \
> > +CFLAGS_SHARED_ALL="$CFLAGS_SHARED_ALL -D__PIC__=1"
> > +
> 
> i don't think it's worth adding such checks
> 
> pcc is still in development and the last
> release was very much broken
> 
> when it gets more stable and widely used then
> such ckecks will make sense, right now we can
> just depend on the latest pcc
> 
> even with clang we can easily say that we
> only support clang+llvm >= 3.1
> (i assume the -ffreestanding bug is fixed in that)

Agreed. I don't think there's a point in supporting old compiler
versions except when there are possibly-compelling reasons to use
them. For old GCC's, the reasons are either bloat, speed, or license
issues... or just the fact that upgrading gcc is a nightmare if you
don't have new packages for it. None of these apply to pcc.

Rich


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

* Re: [RFC] pcc support for configure
  2012-10-16 13:21   ` Rich Felker
@ 2012-10-16 18:55     ` idunham
  2012-10-26 20:35       ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: idunham @ 2012-10-16 18:55 UTC (permalink / raw)
  To: musl

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

> On Tue, Oct 16, 2012 at 12:17:43PM +0200, Szabolcs Nagy wrote:
>> * Isaac Dunham <idunham@lavabit.com> [2012-10-15 21:12:31 -0700]:
>> > +# Older PCC versions don't define __PIC__ with -fPIC
>> > +#
>> > +tryflag CFLAG_TEST "-x c"
>> > +printf '#ifndef __PIC__\n__PIC__=0\n#endif\n' | \
>> > +$CC -E $CFLAG_TEST -fPIC - | grep __PIC__ && \
>> > +CFLAGS_SHARED_ALL="$CFLAGS_SHARED_ALL -D__PIC__=1"
>> > +
>>
>> i don't think it's worth adding such checks
>>
> Agreed. I don't think there's a point in supporting old compiler
> versions except when there are possibly-compelling reasons to use
> them.

Dropping that.

[-- Attachment #2: pcc.diff --]
[-- Type: text/plain, Size: 1169 bytes --]

diff --git a/configure b/configure
index 9b06d2b..f45b87a 100755
--- a/configure
+++ b/configure
@@ -162,6 +162,7 @@ printf "checking for C compiler... "
 trycc ${CROSS_COMPILE}gcc
 trycc ${CROSS_COMPILE}c99
 trycc ${CROSS_COMPILE}cc
+trycc ${CROSS_COMPILE}pcc
 printf "%s\n" "$CC"
 test -n "$CC" || { echo "$0: cannot find a C compiler" ; exit 1 ; }
 
@@ -269,8 +270,8 @@ tryflag CFLAGS_AUTO -falign-jumps=1
 # work anyway (issues with atomic ops).
 #
 if test "$ARCH" = "i386" ; then
-fnmatch '-march=*|*\ -march=*' "$CFLAGS" || tryflag CFLAGS_AUTO -march=i486
-fnmatch '-mtune=*|*\ -mtune=*' "$CFLAGS" || tryflag CFLAGS_AUTO -mtune=generic
+fnmatch '-march=*|*\ -march=*' "$CFLAGS" || tryldflag CFLAGS_AUTO -march=i486
+fnmatch '-mtune=*|*\ -mtune=*' "$CFLAGS" || tryldflag CFLAGS_AUTO -mtune=generic
 fi
 
 if test "x$warnings" = xyes ; then
@@ -299,6 +300,7 @@ shared=no
 # Find compiler runtime library
 test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
 test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
+test -z "$LIBCC" && tryldflag LIBCC `$CC -print-file-name=libpcc.a || true`
 printf "using compiler runtime libraries: %s\n" "$LIBCC"
 
 

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

* Re: [RFC] pcc support for configure
  2012-10-16  9:39 ` Luca Barbato
@ 2012-10-16 19:08   ` idunham
  0 siblings, 0 replies; 9+ messages in thread
From: idunham @ 2012-10-16 19:08 UTC (permalink / raw)
  To: musl

> On 10/16/2012 06:12 AM, Isaac Dunham wrote:
>> *Note: pcc can be built with binutils (default) or yasm (--with-yasm).
>> Apparently yasm is missing quite a few instructions, as even when I used
>> yasm
>> from git I got a quite spectacular FTBFS using pcc+yasm as compiler.
>
> I thought yasm was just for the win32 target.

I know it can be configured that way with a linux target.




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

* Re: [RFC] pcc support for configure
  2012-10-16 18:55     ` idunham
@ 2012-10-26 20:35       ` Rich Felker
  2012-10-26 21:59         ` Szabolcs Nagy
  0 siblings, 1 reply; 9+ messages in thread
From: Rich Felker @ 2012-10-26 20:35 UTC (permalink / raw)
  To: musl

On Tue, Oct 16, 2012 at 11:55:36AM -0700, idunham@lavabit.com wrote:
> > On Tue, Oct 16, 2012 at 12:17:43PM +0200, Szabolcs Nagy wrote:
> >> * Isaac Dunham <idunham@lavabit.com> [2012-10-15 21:12:31 -0700]:
> >> > +# Older PCC versions don't define __PIC__ with -fPIC
> >> > +#
> >> > +tryflag CFLAG_TEST "-x c"
> >> > +printf '#ifndef __PIC__\n__PIC__=0\n#endif\n' | \
> >> > +$CC -E $CFLAG_TEST -fPIC - | grep __PIC__ && \
> >> > +CFLAGS_SHARED_ALL="$CFLAGS_SHARED_ALL -D__PIC__=1"
> >> > +
> >>
> >> i don't think it's worth adding such checks
> >>
> > Agreed. I don't think there's a point in supporting old compiler
> > versions except when there are possibly-compelling reasons to use
> > them.
> 
> Dropping that.

As of latest commit, pcc should work out of the box.

> diff --git a/configure b/configure
> index 9b06d2b..f45b87a 100755
> --- a/configure
> +++ b/configure
> @@ -162,6 +162,7 @@ printf "checking for C compiler... "
>  trycc ${CROSS_COMPILE}gcc
>  trycc ${CROSS_COMPILE}c99
>  trycc ${CROSS_COMPILE}cc
> +trycc ${CROSS_COMPILE}pcc

This part was not included; use CC=pcc explicitly or have c99
symlinked to pcc.

>  printf "%s\n" "$CC"
>  test -n "$CC" || { echo "$0: cannot find a C compiler" ; exit 1 ; }
>  
> @@ -269,8 +270,8 @@ tryflag CFLAGS_AUTO -falign-jumps=1
>  # work anyway (issues with atomic ops).
>  #
>  if test "$ARCH" = "i386" ; then
> -fnmatch '-march=*|*\ -march=*' "$CFLAGS" || tryflag CFLAGS_AUTO -march=i486
> -fnmatch '-mtune=*|*\ -mtune=*' "$CFLAGS" || tryflag CFLAGS_AUTO -mtune=generic
> +fnmatch '-march=*|*\ -march=*' "$CFLAGS" || tryldflag CFLAGS_AUTO -march=i486
> +fnmatch '-mtune=*|*\ -mtune=*' "$CFLAGS" || tryldflag CFLAGS_AUTO -mtune=generic

This was committed a day or two ago.

>  fi
>  
>  if test "x$warnings" = xyes ; then
> @@ -299,6 +300,7 @@ shared=no
>  # Find compiler runtime library
>  test -z "$LIBCC" && tryldflag LIBCC -lgcc && tryldflag LIBCC -lgcc_eh
>  test -z "$LIBCC" && tryldflag LIBCC -lcompiler_rt
> +test -z "$LIBCC" && tryldflag LIBCC `$CC -print-file-name=libpcc.a || true`

This was replaced with a simple test for -lpcc, which works with my
version of pcc. See the comments in the commit and let me know if it
doesn't work for you.

Rich


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

* Re: [RFC] pcc support for configure
  2012-10-26 20:35       ` Rich Felker
@ 2012-10-26 21:59         ` Szabolcs Nagy
  2012-10-26 22:05           ` Rich Felker
  0 siblings, 1 reply; 9+ messages in thread
From: Szabolcs Nagy @ 2012-10-26 21:59 UTC (permalink / raw)
  To: musl

* Rich Felker <dalias@aerifal.cx> [2012-10-26 16:35:23 -0400]:
> > +test -z "$LIBCC" && tryldflag LIBCC `$CC -print-file-name=libpcc.a || true`
> 
> This was replaced with a simple test for -lpcc, which works with my
> version of pcc. See the comments in the commit and let me know if it
> doesn't work for you.
> 

even with -nostdlib ?

here
 pcc -nostdlib -lpcc main.o
fails but
 pcc -lpcc main.o
works

(-nostdlib removes all -L search path even those
where -lpcc can be found and the configure script
uses -nostdlib for testing ldflags)



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

* Re: [RFC] pcc support for configure
  2012-10-26 21:59         ` Szabolcs Nagy
@ 2012-10-26 22:05           ` Rich Felker
  0 siblings, 0 replies; 9+ messages in thread
From: Rich Felker @ 2012-10-26 22:05 UTC (permalink / raw)
  To: musl

On Fri, Oct 26, 2012 at 11:59:30PM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@aerifal.cx> [2012-10-26 16:35:23 -0400]:
> > > +test -z "$LIBCC" && tryldflag LIBCC `$CC -print-file-name=libpcc.a || true`
> > 
> > This was replaced with a simple test for -lpcc, which works with my
> > version of pcc. See the comments in the commit and let me know if it
> > doesn't work for you.
> > 
> 
> even with -nostdlib ?
> 
> here
>  pcc -nostdlib -lpcc main.o
> fails but
>  pcc -lpcc main.o
> works
> 
> (-nostdlib removes all -L search path even those
> where -lpcc can be found and the configure script
> uses -nostdlib for testing ldflags)

Ah, you're right. Thanks for catching this. Let's see if we can work
out a better test, then...

Rich


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

end of thread, other threads:[~2012-10-26 22:05 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-16  4:12 [RFC] pcc support for configure Isaac Dunham
2012-10-16  9:39 ` Luca Barbato
2012-10-16 19:08   ` idunham
2012-10-16 10:17 ` Szabolcs Nagy
2012-10-16 13:21   ` Rich Felker
2012-10-16 18:55     ` idunham
2012-10-26 20:35       ` Rich Felker
2012-10-26 21:59         ` Szabolcs Nagy
2012-10-26 22:05           ` Rich Felker

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