Subject: How to make a cross-cpp
To: None <tech-toolchain@NetBSD.ORG>
From: Bill Studenmund <>
List: tech-toolchain
Date: 12/17/1997 10:30:55

I'm finding more and more problems with cross-compiling. Two have
solutions. Games/hack needed a bit of HOST_CC, and our gcc won't cross

My question is how to make a cpp out of cc. The problem code is from

.if (${MACHINE_ARCH} == "m68k" || ${MACHINE_ARCH} == "i386")
match.o: ${.CURDIR}/match.S
        $(CPP) -D__NetBSD__ ${.CURDIR}/match.S >_match.s
        $(CC) -c _match.s
        mv _match.o match.o
        rm -f _match.s

My xcc environment defines CC as the cross-compiler, but I don't have a
cross-CPP. If I use the code above, the asm code gets fed to the i386 cpp,
and a bunch of #if defined(I386) lines spit out i386 assembly code. The
m68k assembler does not approve. :-)

So I tried "CPP = ${CC} -E", and I got m68k assembly. But there were some
commands with double quotes (") around constants, which the cross-gas
didn't like. Plus one of the macros didn't get substituted.

Is there some better way to do this? I see the Makefile from the kernels
use cc with "-x assembler-with-cpp -traditional-cpp". Would that be better
here? Or does my CPP line just need a -traditional-cpp ??

Thanks for listening!

Take care,


[*] I don't fully understand how all the path stuff works.  Is gcc/common
a place for common source, or for common source and object files? A few of
the files in gcc/common are also used in programs called in gcc/common and
in other programs. Specifically cc and cpp use obstack.o and version.o.
Almost all the programs made in gcc/common use obstack.o There might be
more which I've missed. I guess if only the source is shared, then I can
have an obstack.o in gcc/common for use on the host and an obstack.o in
the other directories for use on the target computer. Sound good?