public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
@ 2010-12-08 15:54 Thomas Schwinge
  2010-12-08 16:45 ` Joseph S. Myers
  0 siblings, 1 reply; 9+ messages in thread
From: Thomas Schwinge @ 2010-12-08 15:54 UTC (permalink / raw)
  To: gcc-patches, gcc-patches; +Cc: maxim, joseph, thomas

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2451 bytes --]

Hallo!

This patch makes GNU/Hurd buildable again.  Previously, I had made this
Linux libc switch depend on Linux kernel only, but when Maxim added
support for bionic on 2010-05-27 in r159917, then it broke again, and I'm
now finally giving in...  Let the libc options be there at run-time; we
simply won't use them.

gcc/

	PR target/28102
	* config.gcc <GNU based systems> (extra_options): Include linux.opt
	unconditionally.

OK to commit?


This issue is very likely to also affect (in the same way of being
un-buildable at the moment) other GNU-based configurations (kFreeBSD,
OpenSolaris), as suspected by Joseph and me.


The underlying problem is still as stated in
<http://gcc.gnu.org/ml/gcc/2007-11/msg00289.html>.  Contrary to what I
stated in there, I have not yet continued to work on untangling this.


I had come up with this patch already some weeks ago, but didn't post it
at that time, as I'm currently not able to GCC's testsuite tom
completion.  The testsuite will reproducibly hang around the moment that
an expect process is doing its 65535's fork invocation.  This is a bug,
and I'm (slowly, due to ENOTIME...) working on fixing this.  (There is a
port leak in glibc in the Hurd's fork implementation, and after 65535
leaked ports in one process, the microkernel will deny any further.)
Now, Joseph has prompted me to submit the patch anyways, for he ran into
the same problem.  The patch allows the build to succeed (last tested
with the Git mirror's 1fb531df5602228c903ff640ab6ecac3b8107a1a
(2010-11-27) sources), and I'm confident that it's correct, even without
a complete testsuite run.


Grüße,
 Thomas

---
 gcc/config.gcc |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 646e676..fb76d17 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -558,12 +558,9 @@ case ${target} in
   esac
   # glibc / uclibc / bionic switch.
   # uclibc and bionic aren't usable for GNU/Hurd and neither for GNU/k*BSD.
-  case $target in
-    *linux*)
-      extra_options="$extra_options linux.opt";;
-    *)
-      tm_defines="$tm_defines OPTION_GLIBC=1";;
-  esac
+  # But then, providing the options doesn't hurt either, and simplifies the
+  # underlying logic.
+  extra_options="$extra_options linux.opt"
   case $target in
     *-*-*android*)
       tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC"
-- 
tg: (2f78a7c..) hurd/config/libc (depends on: master)

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

* Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-08 15:54 [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems Thomas Schwinge
@ 2010-12-08 16:45 ` Joseph S. Myers
  2010-12-08 16:58   ` Thomas Schwinge
                     ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Joseph S. Myers @ 2010-12-08 16:45 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches, maxim, thomas

On Wed, 8 Dec 2010, Thomas Schwinge wrote:

> Hallo!
> 
> This patch makes GNU/Hurd buildable again.  Previously, I had made this
> Linux libc switch depend on Linux kernel only, but when Maxim added
> support for bionic on 2010-05-27 in r159917, then it broke again, and I'm
> now finally giving in...  Let the libc options be there at run-time; we
> simply won't use them.

This alternative patch limits use of linux.opt to those targets for
which it is relevant - that is, *-*-linux* (systems using the Linux
kernel and an MMU-based ABI), as those are the systems for which
alternative libcs may be available withing a single compiler
configuration.

This patch works by defining SINGLE_LIBC (along with DEFAULT_LIBC) for
the configurations without libc switching that might however use
linux.h.  In addition to those configurations fixed by your patch it
also avoids problems with uClinux configurations that use linux.h
needing to use linux.opt and define DEFAULT_LIBC individually; thus,
it fixes the problems I recently noticed building for lm32-uclinux.
It does not fix the underlying problem with linux.h being used for an
ill-defined set of targets and needing splitting into "Linux kernel",
"MMU-based Linux kernel" and "may use glibc" (or similar) parts.

Tested building cc1 and xgcc for crosses to: i686-gnu
i686-kfreebsd-gnu i686-knetbsd-gnu i686-kopensolaris-gnu bfin-uclinux
moxie-uclinux lm32-uclinux m68k-uclinux alpha-linux-gnu
powerpc-linux-gnu powerpc64-linux-gnu.  OK to commit?

2010-12-08  Joseph Myers  <joseph@codesourcery.com>

	* config/alpha/linux.h (OPTION_GLIBC): Define differently if
	SINGLE_LIBC.
	* config/linux.h (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC):
	Define differently if SINGLE_LIBC.
	* config/rs6000/linux.h (OPTION_GLIBC): Define differently if
	SINGLE_LIBC.
	* config/rs6000/linux64.h (OPTION_GLIBC): Define differently if
	SINGLE_LIBC.
	* config.gcc (*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu |
	*-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu): Define
	DEFAULT_LIBC and SINGLE_LIBC instead of OPTION_GLIBC.
	(*-*-uclinux*): Define DEFAULT_LIBC and SINGLE_LIBC.
	(bfin*-uclinux*, moxie-*-uclinux*, m68k-*-uclinux*): Don't define
	DEFAULT_LIBC or use linux.opt.

diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/alpha/linux.h gcc-mainline/gcc/config/alpha/linux.h
--- gcc-mainline-3/gcc/config/alpha/linux.h	2010-11-19 13:20:56.000000000 -0800
+++ gcc-mainline/gcc/config/alpha/linux.h	2010-12-08 07:36:21.000000000 -0800
@@ -61,7 +61,11 @@ along with GCC; see the file COPYING3.  
 #undef WCHAR_TYPE
 #define WCHAR_TYPE "int"
 
+#ifdef SINGLE_LIBC
+#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
+#else
 #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
+#endif
 
 /* Determine whether the entire c99 runtime is present in the
    runtime library.  */
diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/linux.h gcc-mainline/gcc/config/linux.h
--- gcc-mainline-3/gcc/config/linux.h	2010-12-06 06:39:42.000000000 -0800
+++ gcc-mainline/gcc/config/linux.h	2010-12-08 07:35:55.000000000 -0800
@@ -80,9 +80,15 @@ see the files COPYING3 and COPYING.RUNTI
 #define LIB_SPEC LINUX_TARGET_LIB_SPEC
 
 /* C libraries supported on Linux.  */
+#ifdef SINGLE_LIBC
+#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
+#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
+#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
+#else
 #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
 #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
 #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
+#endif
 
 #define LINUX_TARGET_OS_CPP_BUILTINS()				\
     do {							\
diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/rs6000/linux.h gcc-mainline/gcc/config/rs6000/linux.h
--- gcc-mainline-3/gcc/config/rs6000/linux.h	2010-12-06 06:41:23.000000000 -0800
+++ gcc-mainline/gcc/config/rs6000/linux.h	2010-12-08 07:36:41.000000000 -0800
@@ -27,7 +27,11 @@
 /* We use glibc _mcount for profiling.  */
 #define NO_PROFILE_COUNTERS 1
 
+#ifdef SINGLE_LIBC
+#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
+#else
 #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
+#endif
 
 /* glibc has float and long double forms of math functions.  */
 #undef  TARGET_C99_FUNCTIONS
diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/rs6000/linux64.h gcc-mainline/gcc/config/rs6000/linux64.h
--- gcc-mainline-3/gcc/config/rs6000/linux64.h	2010-12-06 06:41:42.000000000 -0800
+++ gcc-mainline/gcc/config/rs6000/linux64.h	2010-12-08 07:36:53.000000000 -0800
@@ -308,7 +308,11 @@ extern int dot_symbols;
    process.  */
 #define OS_MISSING_POWERPC64 !TARGET_64BIT
 
+#ifdef SINGLE_LIBC
+#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
+#else
 #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
+#endif
 
 /* glibc has float and long double forms of math functions.  */
 #undef  TARGET_C99_FUNCTIONS
diff -rupN --exclude=.svn gcc-mainline-3/gcc/config.gcc gcc-mainline/gcc/config.gcc
--- gcc-mainline-3/gcc/config.gcc	2010-12-06 03:31:49.000000000 -0800
+++ gcc-mainline/gcc/config.gcc	2010-12-08 07:49:50.000000000 -0800
@@ -562,7 +562,7 @@ case ${target} in
     *linux*)
       extra_options="$extra_options linux.opt";;
     *)
-      tm_defines="$tm_defines OPTION_GLIBC=1";;
+      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC SINGLE_LIBC";;
   esac
   case $target in
     *-*-*android*)
@@ -657,6 +657,7 @@ case ${target} in
   ;;
 *-*-uclinux*)
   use_gcc_stdint=wrap
+  tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC"
   ;;
 *-*-solaris2*)
   extra_options="${extra_options} sol2.opt"
@@ -906,8 +907,6 @@ bfin*-elf*)
 bfin*-uclinux*)
 	tm_file="${tm_file} dbxelf.h elfos.h bfin/elf.h linux.h glibc-stdint.h bfin/uclinux.h"
 	tmake_file=bfin/t-bfin-uclinux
-	tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
-	extra_options="${extra_options} linux.opt"
 	use_collect2=no
 	;;
 bfin*-linux-uclibc*)
@@ -989,8 +988,6 @@ moxie-*-uclinux*)
 	tm_file="dbxelf.h elfos.h svr4.h ${tm_file} linux.h glibc-stdint.h moxie/uclinux.h"
 	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
 	tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp"
-	tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
-	extra_options="${extra_options} linux.opt"
 	;;
 moxie-*-rtems*)
 	tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp t-rtems"
@@ -1726,8 +1723,7 @@ m68k-*-uclinux*)		# Motorola m68k/ColdFi
 	default_m68k_cpu=68020
 	default_cf_cpu=5206
 	tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h glibc-stdint.h flat.h m68k/linux.h m68k/uclinux.h ./sysroot-suffix.h"
- 	tm_defines="${tm_defines} MOTOROLA=1 DEFAULT_LIBC=LIBC_UCLIBC"
-	extra_options="${extra_options} linux.opt"
+ 	tm_defines="${tm_defines} MOTOROLA=1"
 	tmake_file="m68k/t-floatlib m68k/t-uclinux m68k/t-mlibs"
 	;;
 m68k-*-linux*)		# Motorola m68k's running GNU/Linux

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-08 16:45 ` Joseph S. Myers
@ 2010-12-08 16:58   ` Thomas Schwinge
  2010-12-08 17:28     ` Joseph S. Myers
  2010-12-10 12:34   ` Thomas Schwinge
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Thomas Schwinge @ 2010-12-08 16:58 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches, maxim, thomas

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

Hallo!

On 2010-12-08 16:33, Joseph S. Myers wrote:
> On Wed, 8 Dec 2010, Thomas Schwinge wrote:
>> This patch makes GNU/Hurd buildable again.  Previously, I had made this
>> Linux libc switch depend on Linux kernel only, but when Maxim added
>> support for bionic on 2010-05-27 in r159917, then it broke again, and I'm
>> now finally giving in...  Let the libc options be there at run-time; we
>> simply won't use them.
>
> This alternative patch limits use of linux.opt to those targets for
> which it is relevant - that is, *-*-linux* (systems using the Linux
> kernel and an MMU-based ABI), as those are the systems for which
> alternative libcs may be available withing a single compiler
> configuration.
>
> This patch works by defining SINGLE_LIBC (along with DEFAULT_LIBC) for

Why not just SINGLE_LIBC for (a) triggering this single libc case, and
(b) specifying which one to use?  That is:

> +#ifdef SINGLE_LIBC
> +#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)

Use ``SINGLE_LIBC == [...]'' instead.  Etc.

> -      tm_defines="$tm_defines OPTION_GLIBC=1";;
> +      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC SINGLE_LIBC";;

Use ``SINGLE_LIBC=LIBC_GLIBC'' instead.  Etc.

Or did you have a specific reason to use two #define:s for that?  (I have
not tested this suggestion, so perhaps I'm missing some detail.)


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-08 16:58   ` Thomas Schwinge
@ 2010-12-08 17:28     ` Joseph S. Myers
  0 siblings, 0 replies; 9+ messages in thread
From: Joseph S. Myers @ 2010-12-08 17:28 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches, maxim, thomas

On Wed, 8 Dec 2010, Thomas Schwinge wrote:

> > This patch works by defining SINGLE_LIBC (along with DEFAULT_LIBC) for
> 
> Why not just SINGLE_LIBC for (a) triggering this single libc case, and
> (b) specifying which one to use?  That is:

Because of the existing conditionals defining CHOOSE_DYNAMIC_LINKER, users 
of linux.h need to define DEFAULT_LIBC anyway (see the definitions for 
various uClinux targets that I replaced by a single central definition for 
uClinux targets) and it seemed simplest to have a single macro specifying 
the default in all cases rather than different macros for the default in 
different cases.

(I see the first definition of DEFAULT_LIBC in my patch is actually 
redundant with the one a few lines below

  case $target in
    *-*-*android*)
      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_BIONIC"
      ;;
    *-*-*uclibc*)
      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC"
      ;;
    *)
      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC"
      ;;
  esac

so reviewers should feel free to review my patch on the basis of the 
duplicate being removed, i.e.

-      tm_defines="$tm_defines OPTION_GLIBC=1";;
+      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC SINGLE_LIBC";;

being changed to

-      tm_defines="$tm_defines OPTION_GLIBC=1";;
+      tm_defines="$tm_defines SINGLE_LIBC";;

 .)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-08 16:45 ` Joseph S. Myers
  2010-12-08 16:58   ` Thomas Schwinge
@ 2010-12-10 12:34   ` Thomas Schwinge
  2010-12-14 18:09   ` Ping " Joseph S. Myers
  2010-12-20 17:04   ` Maxim Kuvyrkov
  3 siblings, 0 replies; 9+ messages in thread
From: Thomas Schwinge @ 2010-12-10 12:34 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: gcc-patches, maxim, thomas

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

Hallo!

On 2010-12-08 16:33, Joseph S. Myers wrote:
> This alternative patch limits use of linux.opt to those targets for
> which it is relevant - that is, *-*-linux* (systems using the Linux
> kernel and an MMU-based ABI), as those are the systems for which
> alternative libcs may be available withing a single compiler
> configuration.

I reviewed this patch (with Joseph's additional change to not duplicate
the DEFAULT_LIBC definition in certain cases), and it appears correct to
me.  (I cannot formally approve it, however.)

I also tested this one instead of my original patch, and successfully
built GCC natively on i686 GNU/Hurd.


> 2010-12-08  Joseph Myers  <joseph@codesourcery.com>
>
> 	* config/alpha/linux.h (OPTION_GLIBC): Define differently if
> 	SINGLE_LIBC.
> 	* config/linux.h (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC):
> 	Define differently if SINGLE_LIBC.
> 	* config/rs6000/linux.h (OPTION_GLIBC): Define differently if
> 	SINGLE_LIBC.
> 	* config/rs6000/linux64.h (OPTION_GLIBC): Define differently if
> 	SINGLE_LIBC.
> 	* config.gcc (*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu |
> 	*-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu): Define
> 	DEFAULT_LIBC and SINGLE_LIBC instead of OPTION_GLIBC.

s%DEFAULT_LIBC and %% as per your follow-up email.

> 	(*-*-uclinux*): Define DEFAULT_LIBC and SINGLE_LIBC.
> 	(bfin*-uclinux*, moxie-*-uclinux*, m68k-*-uclinux*): Don't define
> 	DEFAULT_LIBC or use linux.opt.


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

* Ping Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-08 16:45 ` Joseph S. Myers
  2010-12-08 16:58   ` Thomas Schwinge
  2010-12-10 12:34   ` Thomas Schwinge
@ 2010-12-14 18:09   ` Joseph S. Myers
  2010-12-20 14:46     ` Ping^2 " Joseph S. Myers
  2010-12-20 17:04   ` Maxim Kuvyrkov
  3 siblings, 1 reply; 9+ messages in thread
From: Joseph S. Myers @ 2010-12-14 18:09 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches, maxim, thomas

Ping.  This patch 
<http://gcc.gnu.org/ml/gcc-patches/2010-12/msg00672.html> (with the 
obvious removal of a redundant DEFAULT_LIBC definition noted at 
<http://gcc.gnu.org/ml/gcc-patches/2010-12/msg00678.html>) is pending 
review.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Ping^2 Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-14 18:09   ` Ping " Joseph S. Myers
@ 2010-12-20 14:46     ` Joseph S. Myers
  0 siblings, 0 replies; 9+ messages in thread
From: Joseph S. Myers @ 2010-12-20 14:46 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches, maxim, thomas

Ping^2.  This patch 
<http://gcc.gnu.org/ml/gcc-patches/2010-12/msg00672.html> (with the 
obvious removal of a redundant DEFAULT_LIBC definition noted at 
<http://gcc.gnu.org/ml/gcc-patches/2010-12/msg00678.html>) is pending 
review.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-08 16:45 ` Joseph S. Myers
                     ` (2 preceding siblings ...)
  2010-12-14 18:09   ` Ping " Joseph S. Myers
@ 2010-12-20 17:04   ` Maxim Kuvyrkov
  2010-12-20 21:06     ` Mark Mitchell
  3 siblings, 1 reply; 9+ messages in thread
From: Maxim Kuvyrkov @ 2010-12-20 17:04 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Thomas Schwinge, Mark Mitchell, gcc-patches, thomas

On Dec 8, 2010, at 7:33 PM, Joseph S. Myers wrote:

> On Wed, 8 Dec 2010, Thomas Schwinge wrote:
> 
>> Hallo!
>> 
>> This patch makes GNU/Hurd buildable again.  Previously, I had made this
>> Linux libc switch depend on Linux kernel only, but when Maxim added
>> support for bionic on 2010-05-27 in r159917, then it broke again, and I'm
>> now finally giving in...  Let the libc options be there at run-time; we
>> simply won't use them.
> 
> This alternative patch limits use of linux.opt to those targets for
> which it is relevant - that is, *-*-linux* (systems using the Linux
> kernel and an MMU-based ABI), as those are the systems for which
> alternative libcs may be available withing a single compiler
> configuration.

The patch looks OK to me, thanks for cleaning this up!  Any global maintainer wishes to bless it?

Even though it may be debatable that MMU-less systems may benefit from multiple C libraries supported within a single compiler configuration, it's very clear that definitions of such C libraries and corresponding -m<library> options should be located outside of linux.opt.

--
Maxim Kuvyrkov
CodeSourcery
+1-650-331-3385 x724

> 
> This patch works by defining SINGLE_LIBC (along with DEFAULT_LIBC) for
> the configurations without libc switching that might however use
> linux.h.  In addition to those configurations fixed by your patch it
> also avoids problems with uClinux configurations that use linux.h
> needing to use linux.opt and define DEFAULT_LIBC individually; thus,
> it fixes the problems I recently noticed building for lm32-uclinux.
> It does not fix the underlying problem with linux.h being used for an
> ill-defined set of targets and needing splitting into "Linux kernel",
> "MMU-based Linux kernel" and "may use glibc" (or similar) parts.
> 
> Tested building cc1 and xgcc for crosses to: i686-gnu
> i686-kfreebsd-gnu i686-knetbsd-gnu i686-kopensolaris-gnu bfin-uclinux
> moxie-uclinux lm32-uclinux m68k-uclinux alpha-linux-gnu
> powerpc-linux-gnu powerpc64-linux-gnu.  OK to commit?
> 
> 2010-12-08  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* config/alpha/linux.h (OPTION_GLIBC): Define differently if
> 	SINGLE_LIBC.
> 	* config/linux.h (OPTION_GLIBC, OPTION_UCLIBC, OPTION_BIONIC):
> 	Define differently if SINGLE_LIBC.
> 	* config/rs6000/linux.h (OPTION_GLIBC): Define differently if
> 	SINGLE_LIBC.
> 	* config/rs6000/linux64.h (OPTION_GLIBC): Define differently if
> 	SINGLE_LIBC.
> 	* config.gcc (*-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu |
> 	*-*-knetbsd*-gnu | *-*-gnu* | *-*-kopensolaris*-gnu): Define
> 	DEFAULT_LIBC and SINGLE_LIBC instead of OPTION_GLIBC.
> 	(*-*-uclinux*): Define DEFAULT_LIBC and SINGLE_LIBC.
> 	(bfin*-uclinux*, moxie-*-uclinux*, m68k-*-uclinux*): Don't define
> 	DEFAULT_LIBC or use linux.opt.
> 
> diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/alpha/linux.h gcc-mainline/gcc/config/alpha/linux.h
> --- gcc-mainline-3/gcc/config/alpha/linux.h	2010-11-19 13:20:56.000000000 -0800
> +++ gcc-mainline/gcc/config/alpha/linux.h	2010-12-08 07:36:21.000000000 -0800
> @@ -61,7 +61,11 @@ along with GCC; see the file COPYING3.  
> #undef WCHAR_TYPE
> #define WCHAR_TYPE "int"
> 
> +#ifdef SINGLE_LIBC
> +#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> +#else
> #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
> +#endif
> 
> /* Determine whether the entire c99 runtime is present in the
>    runtime library.  */
> diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/linux.h gcc-mainline/gcc/config/linux.h
> --- gcc-mainline-3/gcc/config/linux.h	2010-12-06 06:39:42.000000000 -0800
> +++ gcc-mainline/gcc/config/linux.h	2010-12-08 07:35:55.000000000 -0800
> @@ -80,9 +80,15 @@ see the files COPYING3 and COPYING.RUNTI
> #define LIB_SPEC LINUX_TARGET_LIB_SPEC
> 
> /* C libraries supported on Linux.  */
> +#ifdef SINGLE_LIBC
> +#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> +#define OPTION_UCLIBC (DEFAULT_LIBC == LIBC_UCLIBC)
> +#define OPTION_BIONIC (DEFAULT_LIBC == LIBC_BIONIC)
> +#else
> #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
> #define OPTION_UCLIBC (linux_libc == LIBC_UCLIBC)
> #define OPTION_BIONIC (linux_libc == LIBC_BIONIC)
> +#endif
> 
> #define LINUX_TARGET_OS_CPP_BUILTINS()				\
>     do {							\
> diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/rs6000/linux.h gcc-mainline/gcc/config/rs6000/linux.h
> --- gcc-mainline-3/gcc/config/rs6000/linux.h	2010-12-06 06:41:23.000000000 -0800
> +++ gcc-mainline/gcc/config/rs6000/linux.h	2010-12-08 07:36:41.000000000 -0800
> @@ -27,7 +27,11 @@
> /* We use glibc _mcount for profiling.  */
> #define NO_PROFILE_COUNTERS 1
> 
> +#ifdef SINGLE_LIBC
> +#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> +#else
> #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
> +#endif
> 
> /* glibc has float and long double forms of math functions.  */
> #undef  TARGET_C99_FUNCTIONS
> diff -rupN --exclude=.svn gcc-mainline-3/gcc/config/rs6000/linux64.h gcc-mainline/gcc/config/rs6000/linux64.h
> --- gcc-mainline-3/gcc/config/rs6000/linux64.h	2010-12-06 06:41:42.000000000 -0800
> +++ gcc-mainline/gcc/config/rs6000/linux64.h	2010-12-08 07:36:53.000000000 -0800
> @@ -308,7 +308,11 @@ extern int dot_symbols;
>    process.  */
> #define OS_MISSING_POWERPC64 !TARGET_64BIT
> 
> +#ifdef SINGLE_LIBC
> +#define OPTION_GLIBC  (DEFAULT_LIBC == LIBC_GLIBC)
> +#else
> #define OPTION_GLIBC  (linux_libc == LIBC_GLIBC)
> +#endif
> 
> /* glibc has float and long double forms of math functions.  */
> #undef  TARGET_C99_FUNCTIONS
> diff -rupN --exclude=.svn gcc-mainline-3/gcc/config.gcc gcc-mainline/gcc/config.gcc
> --- gcc-mainline-3/gcc/config.gcc	2010-12-06 03:31:49.000000000 -0800
> +++ gcc-mainline/gcc/config.gcc	2010-12-08 07:49:50.000000000 -0800
> @@ -562,7 +562,7 @@ case ${target} in
>     *linux*)
>       extra_options="$extra_options linux.opt";;
>     *)
> -      tm_defines="$tm_defines OPTION_GLIBC=1";;
> +      tm_defines="$tm_defines DEFAULT_LIBC=LIBC_GLIBC SINGLE_LIBC";;
>   esac
>   case $target in
>     *-*-*android*)
> @@ -657,6 +657,7 @@ case ${target} in
>   ;;
> *-*-uclinux*)
>   use_gcc_stdint=wrap
> +  tm_defines="$tm_defines DEFAULT_LIBC=LIBC_UCLIBC SINGLE_LIBC"
>   ;;
> *-*-solaris2*)
>   extra_options="${extra_options} sol2.opt"
> @@ -906,8 +907,6 @@ bfin*-elf*)
> bfin*-uclinux*)
> 	tm_file="${tm_file} dbxelf.h elfos.h bfin/elf.h linux.h glibc-stdint.h bfin/uclinux.h"
> 	tmake_file=bfin/t-bfin-uclinux
> -	tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
> -	extra_options="${extra_options} linux.opt"
> 	use_collect2=no
> 	;;
> bfin*-linux-uclibc*)
> @@ -989,8 +988,6 @@ moxie-*-uclinux*)
> 	tm_file="dbxelf.h elfos.h svr4.h ${tm_file} linux.h glibc-stdint.h moxie/uclinux.h"
> 	extra_parts="crti.o crtn.o crtbegin.o crtend.o"
> 	tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp"
> -	tm_defines="${tm_defines} DEFAULT_LIBC=LIBC_UCLIBC"
> -	extra_options="${extra_options} linux.opt"
> 	;;
> moxie-*-rtems*)
> 	tmake_file="${tmake_file} moxie/t-moxie moxie/t-moxie-softfp soft-fp/t-softfp t-rtems"
> @@ -1726,8 +1723,7 @@ m68k-*-uclinux*)		# Motorola m68k/ColdFi
> 	default_m68k_cpu=68020
> 	default_cf_cpu=5206
> 	tm_file="${tm_file} dbxelf.h elfos.h svr4.h linux.h glibc-stdint.h flat.h m68k/linux.h m68k/uclinux.h ./sysroot-suffix.h"
> - 	tm_defines="${tm_defines} MOTOROLA=1 DEFAULT_LIBC=LIBC_UCLIBC"
> -	extra_options="${extra_options} linux.opt"
> + 	tm_defines="${tm_defines} MOTOROLA=1"
> 	tmake_file="m68k/t-floatlib m68k/t-uclinux m68k/t-mlibs"
> 	;;
> m68k-*-linux*)		# Motorola m68k's running GNU/Linux
> 
> -- 
> Joseph S. Myers
> joseph@codesourcery.com


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

* Re: [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems
  2010-12-20 17:04   ` Maxim Kuvyrkov
@ 2010-12-20 21:06     ` Mark Mitchell
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Mitchell @ 2010-12-20 21:06 UTC (permalink / raw)
  To: Maxim Kuvyrkov; +Cc: Joseph S. Myers, Thomas Schwinge, gcc-patches, thomas

On 12/20/2010 6:39 AM, Maxim Kuvyrkov wrote:

>> This alternative patch limits use of linux.opt to those targets
>> for which it is relevant - that is, *-*-linux* (systems using the
>> Linux kernel and an MMU-based ABI), as those are the systems for
>> which alternative libcs may be available withing a single compiler 
>> configuration.
> 
> The patch looks OK to me, thanks for cleaning this up!  Any global
> maintainer wishes to bless it?

Looks good to me.

> Even though it may be debatable that MMU-less systems may benefit
> from multiple C libraries supported within a single compiler
> configuration, it's very clear that definitions of such C libraries
> and corresponding -m<library> options should be located outside of
> linux.opt.

And, I think it's clear that MMU-less systems do benefit from this kind
of functionality in general, though perhaps from different libraries.
Various RTOSes ship with various C libraries, and it's entirely
reasonable that a *-elf configuration have support for multiple run-time
libraries as well.

Thank you,

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713

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

end of thread, other threads:[~2010-12-20 18:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-08 15:54 [PATCH] glibc / uclibc / bionic switch vs. non-Linux, GNU-based systems Thomas Schwinge
2010-12-08 16:45 ` Joseph S. Myers
2010-12-08 16:58   ` Thomas Schwinge
2010-12-08 17:28     ` Joseph S. Myers
2010-12-10 12:34   ` Thomas Schwinge
2010-12-14 18:09   ` Ping " Joseph S. Myers
2010-12-20 14:46     ` Ping^2 " Joseph S. Myers
2010-12-20 17:04   ` Maxim Kuvyrkov
2010-12-20 21:06     ` Mark Mitchell

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 read-only IMAP folder(s) and NNTP newsgroup(s).