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

GCC for GNU Hurd: MACH built-in preprocessor macro (was: gdb: FTBFS on hurd-i386 (for review))



Hi!

On Fri, 28 Sep 2012 09:56:41 +0200, Samuel Thibault <samuel.thibault@gnu.org> wrote:
> Thomas Schwinge, le Thu 27 Sep 2012 09:15:23 +0200, a écrit :
> > On Wed, 26 Sep 2012 16:02:29 +0200, Svante Signell <svante.signell@telia.com> wrote:
> > > gdb does not build from source any longer since gdb-multiarch packages
> > > was enabled in 7.4.1-1. The build problems are due to two reasons:
> > 
> > I also once had a look and came to the same conclusion.
> > 
> > > First the reserved keyword MACH is defined in include/objcode/h8300.h
> > > causing problems since gcc defines it for GNU/Hurd. 
> > 
> > Correct.  And I wonder if that isn't a name-space violation?  This is
> > what I meant to look up when working on this two months ago, but then it
> > seems I again got distracted by other issues.  Roland, do you have any
> > comments regarding that?
> > 
> > [GCC]/gcc/config/gnu.h:
> >     [...]
> >     #undef GNU_USER_TARGET_OS_CPP_BUILTINS
> >     #define GNU_USER_TARGET_OS_CPP_BUILTINS()               \
> >         do {                                        \
> >             builtin_define ("__gnu_hurd__");        \
> >             builtin_define ("__GNU__");             \
> >             builtin_define_std ("unix");            \
> >             builtin_define_std ("MACH");            \
> >             builtin_assert ("system=gnu");          \
> >             builtin_assert ("system=mach");         \
> >             builtin_assert ("system=unix");         \
> >             builtin_assert ("system=posix");        \
> >         } while (0)
> > 
> >     $ gcc -dM -E -x c - < /dev/null | grep -i mach
> >     #define __MACH 1
> >     #define __MACH__ 1
> >     #define MACH 1
> 
> On Linux i386, both "linux" and "i386" macros are defined, which poses
> its own problems too.

(Let's pause for a moment in remembrance of the »glibc vs. i686 defined«
issue that would nearly have seen its 10th anniversary these days.)

> I'd indeed tend to say that defining a non-underscored macro is only a
> way for troubles.
> 
> > Could we/should we remove the latter one?  Though, I have no idea how
> > much user code is relying on MACH being #defined.  I had a colleague
> > check, and Apple/Darwin systems do *only* #define __MACH__ (as well as
> > __APPLE__).

Here is the straightforward patch.  With it, only the __MACH__ built-in
preprocessor macro remains, and we get:

    [...]
     Fixing headers into /home/thomas/tmp/gnu-0/obj/gcc/gcc/include-fixed for
     i686-pc-gnu target
    -Forbidden identifiers: MACH i386 unix
    +Forbidden identifiers: i386 unix
    [...]

These two are to remain.

diff --git gcc/config/gnu.h gcc/config/gnu.h
index dddbcbf..4d9449e 100644
--- gcc/config/gnu.h
+++ gcc/config/gnu.h
@@ -34,7 +34,7 @@ along with GCC.  If not, see <http://www.gnu.org/licenses/>.
 	builtin_define ("__gnu_hurd__");	\
 	builtin_define ("__GNU__");		\
 	builtin_define_std ("unix");		\
-	builtin_define_std ("MACH");		\
+	builtin_define ("__MACH__");		\
 	builtin_assert ("system=gnu");		\
 	builtin_assert ("system=mach");		\
 	builtin_assert ("system=unix");		\

Samuel, is there any way you can unpack all Debian source packages on a
Debian machine, and run a recursive grep command (I can work out a
suitable regex) to see where removing the MACH or __MACH built-in
preprocessor macros might cause trouble?


Grüße,
 Thomas

Attachment: pgpeghXDEaD5J.pgp
Description: PGP signature


Reply to: