diff mbox

Fix building several uclinux target

Message ID 4C473ECF.2040502@codesourcery.com
State New
Headers show

Commit Message

Maxim Kuvyrkov July 21, 2010, 6:39 p.m. UTC
On 7/20/10 10:20 PM, Nathan Froyd wrote:
> On Thu, Jul 15, 2010 at 08:00:24PM +0400, Maxim Kuvyrkov wrote:
>>> The following patch should fix the build of moxie-uclinux toolchain. The
>>> problem was that the piece of config.gcc defining supported linux C
>>> libraries isn't executed for most uclinux targets, moxie included.
>>> Still, many uclinux targets includes linux.h and linux.opt, which
>>> yielded an error.
>
> This patch breaks building a cross to powerpc-eabispe (possibly other
> powerpc SysV4-ish non-Linux targets).
...
> I think this is because of this hunk in config/rs6000/sysv4.h:
>
> #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
> #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
> #if DEFAULT_LIBC == LIBC_UCLIBC
> #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
> #elif DEFAULT_LIBC == LIBC_GLIBC
> #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
> #else
> #error "Unsupported DEFAULT_LIBC"
> #endif
> #define LINUX_DYNAMIC_LINKER \
>    CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
>
> After your patch, LIBC_{UCLIBC,GLIBC} are defined unconditionally;
> DEFAULT_LIBC is not defined, so we now fall through to the #error case.
>
> Perhaps the toplevel code should now be:
>
> case $target in
> *-*-*linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu)
>    # Common C libraries.
>    tm_defines="$tm_defines LIBC_GLIBC=1 LIBC_UCLIBC=2 LIBC_BIONIC=3"
>    ;;
> esac
>
> to catch the uclinux targets as well?

Nathan,

Thanks for the analysis.

I would rather not duplicate the case statement which matches a 
non-trivial list of targets.  It would be just too error prone.

How about instead we make the implicit effects of config/rs6000/sysv4.h 
explicit?  I.e., default to GLIBC when no C library is specified.  This 
was the behavior before UCLIBC_DEFAULT was replaced with DEFAULT_LIBC.

David,

Does the attached patch look OK?

Thank you,

Comments

David Edelsohn July 21, 2010, 11:09 p.m. UTC | #1
On Wed, Jul 21, 2010 at 2:39 PM, Maxim Kuvyrkov <maxim@codesourcery.com> wrote:

> I would rather not duplicate the case statement which matches a non-trivial
> list of targets.  It would be just too error prone.
>
> How about instead we make the implicit effects of config/rs6000/sysv4.h
> explicit?  I.e., default to GLIBC when no C library is specified.  This was
> the behavior before UCLIBC_DEFAULT was replaced with DEFAULT_LIBC.

That seems like a reasonable solution.

Okay.

Thanks, David
diff mbox

Patch

Index: config/rs6000/sysv4.h
===================================================================
--- config/rs6000/sysv4.h	(revision 162345)
+++ config/rs6000/sysv4.h	(working copy)
@@ -905,7 +905,7 @@  SVR4_ASM_SPEC \
 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
 #if DEFAULT_LIBC == LIBC_UCLIBC
 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
-#elif DEFAULT_LIBC == LIBC_GLIBC
+#elif !defined (DEFAULT_LIBC) || DEFAULT_LIBC == LIBC_GLIBC
 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{muclibc:" U ";:" G "}"
 #else
 #error "Unsupported DEFAULT_LIBC"