[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFC: drop __GLIBC__ on gcc/kbsd



Hi!

On Tue, 2012-11-06 at 13:05:02 +0100, Pino Toscano wrote:
> years ago, when Robert Millan improved the support for k*bsd* in gcc, he 
> added the __GLIBC__ define as part of the ones provided by gcc itself 
> (see [1][2]).
> Unfortunately, __GLIBC__ is one of the defines provided by glibc itself 
> (in the internal <features.h> included in any public header), and 
> because of this (e)glibc on debian/kfreebsd has to carry the patch 
> local-undef-glibc.diff. Indeed, compiling trying to compile the simple:
>   #ifdef __GLIBC__
>   # error __GLIBC__ defined with no includes!
>   #endif
>   int main() { return 0; }
> fails on kFreeBSD while it succeeds on Linux and Hurd.
> This also causes that porting code like:
> -#if defined(__linux__)
> +#if defined(__linux__) || defined(__GLIBC__)
> makes it work on kFreeBSD but still failing on Hurd (in situation where 
> there is no #include of stdlib headers prior to that), and in the past 
> I've been personally hit by this few times (and I'm not the only Hurd 
> porter to have hit such situation).
> 
> Since IMHO it is awkward for a compiler to claim to be a libc,

Well, yes and no, it might seem weird because as you say gcc != glibc,
but then the compiler is built targetting a specfic libc, which trickles
into the triplet (as seen from -dumpmachine), because it needs to know
how to interact with it, among other things.

For me the biggest issues are:

That the macro is defined even when using -ffreestanding (which is just
wrong, although as wrong is to build kernels w/o it, and at least Linux
is doing just that), and the possible problem of kernel headers exposed
to userland that might need to change userland (but not kernel-space)
behaviour (something like
<http://lists.debian.org/debian-bsd/2012/02/msg00025.html> comes to
mind).

And that it's not consistent across GNU systems, currently upstream gcc
on GNU/kFreeBSD, GNU/kNetBSD and GNU/kOpenSolaris define __GLIBC__,
other systems might not (which can create portability issues due to the
uncertainty as has been pointed out in the past, an example that came to
mind could be <http://lists.debian.org/debian-bsd/2010/02/msg00097.html>,
or the examples that you mention about problems for GNU/Hurd).

> my suggestion (as also shown in the topic) is to drop the definition of 
> __GLIBC__ done in the k*bsd* configuration of gcc.
> My proposal would be to remove it upstream and, once Whezy is released, 
> backport the patch for any gcc version in Debian. This should leave 
> plenty of time (at least 1-1½ years) to fix the (few?) kFreeBSD-specific 
> build failures and issues that could arise because of that (note that 
> some of the cases were fixed in the past with Hurd porting).

I think -ffreestanding should never define those, after or while that
is fixed in whatever way, all GNU systems should be unified in either
direction, because otherwise it just creates confusion. But that would
require the porters for those systems to agree on either direction,
because as you mention it might cause build failures for them.
GNU/kNetBSD is a non-issue as it's not currently under development.
For GNU/kFreeBSD I'd support either solution, although I think it'd
be better to just stop defining the macro.

thanks,
guillem


Reply to: