[Glibc-bsd-devel] workaround for gcc macro fuckage

Robert Millan zeratul2@wanadoo.es
Tue, 2 Dec 2003 02:38:31 +0100


--0OAP2g/MAC+5xKAE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline


Hi there!

As discussed on IRC, gcc-3.4 preprocessor macros (e.g, __NetBSD_kernel__,
__FreeBSD_kernel__) not being parsed by cpp-3.4. Guillem said he'd handle
this bug.

In the meantime, I wrote this simple /usr/bin/gcc wrapper that execs gcc
after adding the proper flags to define the missing macros (e.g,
-D__NetBSD_kernel__). It is attached.

Santiago, please could you add the /usr/bin/gcc wrapper for the
gcc-defaults-kbsd package on your next upload?

P.S: the wrapper needs bootstrap, first compile must be with:
     $ gcc -D__NetBSD_kernel__ gcc.c -o gcc

-- 
Robert Millan

"[..] but the delight and pride of Aule is in the deed of making, and in the
thing made, and neither in possession nor in his own mastery; wherefore he
gives and hoards not, and is free from care, passing ever on to some new work."

 -- J.R.R.T, Ainulindale (Silmarillion)

--0OAP2g/MAC+5xKAE
Content-Type: text/x-csrc; charset=us-ascii
Content-Disposition: attachment; filename="gcc.c"

#include <stdio.h>
#include <unistd.h>

#undef macro_kernel
#undef macro_userland

/* this obviously needs bootstrap */
#if defined(__NetBSD_kernel__)
#define macro_kernel "-D__NetBSD_kernel__"
#elif defined(__FreeBSD_kernel__)
#define macro_kernel "-D__FreeBSD_kernel__"
#else
/* only for testing purposes */
#define macro_kernel "-D__Unknown_kernel__"
#endif

/* always be gnu */
#define macro_userland "-D__GNU_userland__"

int
main (int argc, char **argv)
{
  int i;
  char *new_argv[argc + 2];
  new_argv[0] = strdup ("gcc-3.4");
  new_argv[1] = strdup (macro_kernel);
  new_argv[2] = strdup (macro_userland);
  for (i = 1 ; i < argc ; i++)
    new_argv[i + 2] = strdup (argv[i]);
  new_argv[argc] = NULL;

  execvp ("gcc-3.4", new_argv);
}

--0OAP2g/MAC+5xKAE--