mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Isaac Dunham <idunham@lavabit.com>
To: musl@lists.openwall.com
Subject: [RFC] pcc support for configure
Date: Mon, 15 Oct 2012 21:12:31 -0700	[thread overview]
Message-ID: <20121015211231.08cbd071.idunham@lavabit.com> (raw)

[-- 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 ="

             reply	other threads:[~2012-10-16  4:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-16  4:12 Isaac Dunham [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121015211231.08cbd071.idunham@lavabit.com \
    --to=idunham@lavabit.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).