Subject: bin/5946: cpp doesn't work very well for cross-compiling
To: None <gnats-bugs@gnats.netbsd.org>
From: Bill Studenmund <wrstuden@vespasia.stanford.edu>
List: netbsd-bugs
Date: 08/09/1998 22:51:37
>Number:         5946
>Category:       bin
>Synopsis:       cpp doesn't work very well for cross-compiling
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Aug  9 22:50:00 1998
>Last-Modified:
>Originator:     Bill Studenmund
>Organization:
	
>Release:        1.3F, current as of 1998-8-8
>Environment:
	
System: NetBSD vespasia 1.3F NetBSD 1.3F (VESPASIA) #25: Tue Jun 23 16:31:39 PDT 1998 wrstuden@vespasia:/y2/cur.build/src/sys/arch/i386/compile/VESPASIA i386


>Description:
There are two different cpp's in NetBSD. One, a shell script in /usr/bin,
the other, a program from gcc in /usr/libexec/cpp. The latter's really
cccp.

The shell script takes its arguments, parses them, and then calls CCCP
in /usr/libexec/cpp.

When cross-compiling, we have a problem. We only get a cccp-equivalent
cpp from the gcc package. If we use it in place of cpp, things can
break in subtle ways as we don't get the -traditional behavior.

This pr includes patches to help with this. I introduce a new variable to
the make environment, CCCP, which points to the CCCP we get from gcc.
The usr.bin.cpp.sh script is modified to check for this variable,
and use /usr/libexec/cpp if it's not set.

So for cross-compiling, you just set CCCP to your cross-cpp, and leave CPP
alone.
>How-To-Repeat:
	
>Fix:
Here are unified diffs to make the change.

--- /sup/src/gnu/usr.bin/gcc/cpp/usr.bin.cpp.sh	Mon Dec 11 12:19:28 1995
+++ usr.bin.cpp.sh	Sun Aug  9 22:27:02 1998
@@ -42,7 +42,10 @@
 #	doesn't search gcc-include
 #
 PATH=/usr/bin:/bin
-CPP=/usr/libexec/cpp
+if [ x"$CCCP" = x ]
+then
+	CCCP=/usr/libexec/cpp
+fi
 ALST="-traditional -D__GNUC__ -$ "
 NSI=no
 OPTS=""
@@ -80,7 +83,7 @@
 			INCS="$INCS -I/usr/include"
 			NSI=skip
 		fi
-		eval $CPP $ALST $INCS $OPTS $A || exit $?
+		eval $CCCP $ALST $INCS $OPTS $A || exit $?
 		;;
 	esac
 done
@@ -92,7 +95,7 @@
 	then
 		INCS="$INCS -I/usr/include"
 	fi
-	eval exec $CPP $ALST $INCS $OPTS
+	eval exec $CCCP $ALST $INCS $OPTS
 fi
 
 exit 0
--- /sup/src/share/mk/sys.mk	Sat May 23 04:12:10 1998
+++ sys.mk	Sun Aug  9 22:32:47 1998
@@ -35,6 +35,11 @@
 
 CPP?=		cpp
 CPPFLAGS?=	
+CCCP?=		/usr/libexec/cpp
+#
+# Note: cpp is the front end to CCCP to make it behave like (Reiser) CCP.
+# For cross-compiling, set CCCP to the cross-cpp.
+#
 
 FC?=		f77
 FFLAGS?=	-O
>Audit-Trail:
>Unformatted: