Makefile.cross tweaks

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Makefile.cross tweaks

Miod Vallat
The following diff attempts to cross-build more things, in particular
gnu/lib (except for libiberty). It also passes the proper optimization
flags so that libstdc++-v3 gets built with optimization.

Index: Makefile.cross
===================================================================
RCS file: /OpenBSD/src/Makefile.cross,v
retrieving revision 1.94
diff -u -p -r1.94 Makefile.cross
--- Makefile.cross 23 May 2017 14:57:30 -0000 1.94
+++ Makefile.cross 29 May 2017 20:15:01 -0000
@@ -43,8 +43,9 @@ MACHINE_IS_LP64 =
 
 #CROSSCPPFLAGS?= -nostdinc -I${CROSSDIR}/usr/include
 #CROSSLDFLAGS?= -nostdlib -L${CROSSDIR}/usr/lib -static
+DEBUG?= -g
 CROSSCFLAGS?= ${CROSSCPPFLAGS} -O2 ${PIPE} ${DEBUG}
-CROSSCXXFLAGS?= ${CROSSCPPFLAGS}
+CROSSCXXFLAGS?= ${CROSSCPPFLAGS} -O2 ${PIPE} ${DEBUG}
 #LDSTATIC?= -static
 
 CROSSDIR= ${DESTDIR}/usr/cross/${TARGET}
@@ -75,7 +76,7 @@ CROSSOBJ= ${CROSSDIR}/.obj_done
 CROSSINCLUDES= ${CROSSDIR}/.includes_done
 CROSSBINUTILS= ${CROSSDIR}/.binutils_done
 CROSSGCC= ${CROSSDIR}/.gcc_done
-#NO_CROSS= isakmpd keynote ssh
+NO_CROSS= libiberty
 
 .include <bsd.own.mk>
 
@@ -307,6 +308,7 @@ ${CROSSGCC}: ${CROSSBINUTILS}
  cp -f ${CROSSDIR}/usr/libexec/cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-libexeccpp
  cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
  ln -sf ${TARGET_CANON}-cc ${CROSSDIR}/usr/${TARGET_CANON}/bin/cc
+ ln -sf ${TARGET_CANON}-c++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/c++
 
  cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
  rm -f ${CROSSDIR}/usr/bin/gcc  ${CROSSDIR}/usr/bin/g++  ${CROSSDIR}/usr/bin/cc ${CROSSDIR}/usr/libexec/cpp
@@ -343,6 +345,13 @@ cross-lib: ${CROSSGCC}
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
         SKIPDIR=\"${NO_CROSS}\" \
         ${MAKE} install)
+ (cd ${.CURDIR}/gnu/lib; \
+    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
+        SKIPDIR=\"${NO_CROSS}\" \
+        ${MAKE} depend all ; \
+    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
+        SKIPDIR=\"${NO_CROSS}\" \
+        ${MAKE} install)
 
 cross-bin: ${CROSSOBJ}
  MACHINE=${TARGET} \
@@ -351,10 +360,10 @@ cross-bin: ${CROSSOBJ}
  for i in libexec bin sbin usr.bin usr.sbin; do \
  (cd ${.CURDIR}/$$i; \
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
-        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
+        SKIPDIR=\"${NO_CROSS}\" \
         ${MAKE} depend all ; \
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
-        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
+        SKIPDIR=\"${NO_CROSS}\" \
         ${MAKE} install); \
  done
 
@@ -362,7 +371,7 @@ cross-gnu: ${CROSSOBJ}
  MACHINE=${TARGET} \
     MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU}; \
  export MACHINE MACHINE_ARCH MACHINE_CPU; \
- for i in gnu/lib gnu/usr.sbin gnu/usr.bin ; do \
+ for i in gnu/usr.sbin gnu/usr.bin ; do \
  (cd ${.CURDIR}/$$i; \
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
         SKIPDIR=\"${NO_CROSS}\" \

Reply | Threaded
Open this post in threaded view
|

Re: Makefile.cross tweaks

Patrick Wildt-3
On Mon, May 29, 2017 at 08:18:08PM +0000, Miod Vallat wrote:
> The following diff attempts to cross-build more things, in particular
> gnu/lib (except for libiberty). It also passes the proper optimization
> flags so that libstdc++-v3 gets built with optimization.

Doesn't build for arm64, probably because BUILD_GCC4 is transparently
set by the host and not reset to NO.

===> ../usr.bin/cc/libobjc
`/usr/cross/arm64/usr/aarch64-unknown-openbsd6.1/bin/cc --print-prog-name=cc1obj` -print-objc-runtime-info  < /dev/null > runtime-info.h
make -f /usr/src/gnu/usr.bin/cc/libobjc/../cc_tools/Makefile MFILE=/usr/src/gnu/usr.bin/cc/libobjc/../cc_tools/Makefile GCCDIR=/usr/src/gnu/usr.bin/cc/libobjc/../../../gcc/gcc unwind.h
ln -sf /usr/src/gnu/usr.bin/cc/libobjc/../../../gcc/gcc/unwind-generic.h unwind.h
/bin/sh: cc1obj: not found
*** Error 127 in target 'runtime-info.h'
*** Error 127 in /usr/src/gnu/usr.bin/cc/libobjc (Makefile:34 'runtime-info.h')

>
> Index: Makefile.cross
> ===================================================================
> RCS file: /OpenBSD/src/Makefile.cross,v
> retrieving revision 1.94
> diff -u -p -r1.94 Makefile.cross
> --- Makefile.cross 23 May 2017 14:57:30 -0000 1.94
> +++ Makefile.cross 29 May 2017 20:15:01 -0000
> @@ -43,8 +43,9 @@ MACHINE_IS_LP64 =
>  
>  #CROSSCPPFLAGS?= -nostdinc -I${CROSSDIR}/usr/include
>  #CROSSLDFLAGS?= -nostdlib -L${CROSSDIR}/usr/lib -static
> +DEBUG?= -g
>  CROSSCFLAGS?= ${CROSSCPPFLAGS} -O2 ${PIPE} ${DEBUG}
> -CROSSCXXFLAGS?= ${CROSSCPPFLAGS}
> +CROSSCXXFLAGS?= ${CROSSCPPFLAGS} -O2 ${PIPE} ${DEBUG}
>  #LDSTATIC?= -static
>  
>  CROSSDIR= ${DESTDIR}/usr/cross/${TARGET}
> @@ -75,7 +76,7 @@ CROSSOBJ= ${CROSSDIR}/.obj_done
>  CROSSINCLUDES= ${CROSSDIR}/.includes_done
>  CROSSBINUTILS= ${CROSSDIR}/.binutils_done
>  CROSSGCC= ${CROSSDIR}/.gcc_done
> -#NO_CROSS= isakmpd keynote ssh
> +NO_CROSS= libiberty
>  
>  .include <bsd.own.mk>
>  
> @@ -307,6 +308,7 @@ ${CROSSGCC}: ${CROSSBINUTILS}
>   cp -f ${CROSSDIR}/usr/libexec/cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-libexeccpp
>   cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
>   ln -sf ${TARGET_CANON}-cc ${CROSSDIR}/usr/${TARGET_CANON}/bin/cc
> + ln -sf ${TARGET_CANON}-c++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/c++
>  
>   cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
>   rm -f ${CROSSDIR}/usr/bin/gcc  ${CROSSDIR}/usr/bin/g++  ${CROSSDIR}/usr/bin/cc ${CROSSDIR}/usr/libexec/cpp
> @@ -343,6 +345,13 @@ cross-lib: ${CROSSGCC}
>      eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
>          SKIPDIR=\"${NO_CROSS}\" \
>          ${MAKE} install)
> + (cd ${.CURDIR}/gnu/lib; \
> +    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
> +        SKIPDIR=\"${NO_CROSS}\" \
> +        ${MAKE} depend all ; \
> +    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
> +        SKIPDIR=\"${NO_CROSS}\" \
> +        ${MAKE} install)
>  
>  cross-bin: ${CROSSOBJ}
>   MACHINE=${TARGET} \
> @@ -351,10 +360,10 @@ cross-bin: ${CROSSOBJ}
>   for i in libexec bin sbin usr.bin usr.sbin; do \
>   (cd ${.CURDIR}/$$i; \
>      eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
> -        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
> +        SKIPDIR=\"${NO_CROSS}\" \
>          ${MAKE} depend all ; \
>      eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
> -        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
> +        SKIPDIR=\"${NO_CROSS}\" \
>          ${MAKE} install); \
>   done
>  
> @@ -362,7 +371,7 @@ cross-gnu: ${CROSSOBJ}
>   MACHINE=${TARGET} \
>      MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU}; \
>   export MACHINE MACHINE_ARCH MACHINE_CPU; \
> - for i in gnu/lib gnu/usr.sbin gnu/usr.bin ; do \
> + for i in gnu/usr.sbin gnu/usr.bin ; do \
>   (cd ${.CURDIR}/$$i; \
>      eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
>          SKIPDIR=\"${NO_CROSS}\" \
>

Reply | Threaded
Open this post in threaded view
|

Re: Makefile.cross tweaks

Miod Vallat

>> The following diff attempts to cross-build more things, in particular
>> gnu/lib (except for libiberty). It also passes the proper optimization
>> flags so that libstdc++-v3 gets built with optimization.
>
> Doesn't build for arm64, probably because BUILD_GCC4 is transparently
> set by the host and not reset to NO.

Damn. This diff ought to work better.

Index: Makefile.cross
===================================================================
RCS file: /OpenBSD/src/Makefile.cross,v
retrieving revision 1.94
diff -u -p -r1.94 Makefile.cross
--- Makefile.cross 23 May 2017 14:57:30 -0000 1.94
+++ Makefile.cross 6 Jun 2017 18:15:11 -0000
@@ -43,9 +43,15 @@ MACHINE_IS_LP64 =
 
 #CROSSCPPFLAGS?= -nostdinc -I${CROSSDIR}/usr/include
 #CROSSLDFLAGS?= -nostdlib -L${CROSSDIR}/usr/lib -static
+DEBUG?= -g
 CROSSCFLAGS?= ${CROSSCPPFLAGS} -O2 ${PIPE} ${DEBUG}
-CROSSCXXFLAGS?= ${CROSSCPPFLAGS}
+CROSSCXXFLAGS?= ${CROSSCPPFLAGS} -O2 ${PIPE} ${DEBUG}
 #LDSTATIC?= -static
+.if (${TARGET_ARCH} == "alpha") || (${TARGET_ARCH} == "sparc64")
+CROSSPICFLAG?=-fPIC
+.else
+CROSSPICFLAG?=-fpic
+.endif
 
 CROSSDIR= ${DESTDIR}/usr/cross/${TARGET}
 CROSSENV= AR=${CROSSDIR}/usr/${TARGET_CANON}/bin/ar \
@@ -63,6 +69,7 @@ CROSSENV= AR=${CROSSDIR}/usr/${TARGET_CA
  CFLAGS=\"${CROSSCFLAGS}\" CPPFLAGS=\"${CROSSCPPFLAGS}\" \
  CXXFLAGS=\"${CROSSCXXFLAGS}\" \
  LDFLAGS=\"${CROSSLDFLAGS}\" \
+ PICFLAG=\"${CROSSPICFLAG}\" \
  CROSSDIR=\"${CROSSDIR}\"
 CROSSADDPATH=:${CROSSDIR}/usr/${TARGET_CANON}/bin
 CROSSPATH= /usr/bin:/bin:/usr/sbin:/sbin${CROSSADDPATH}
@@ -75,18 +82,31 @@ CROSSOBJ= ${CROSSDIR}/.obj_done
 CROSSINCLUDES= ${CROSSDIR}/.includes_done
 CROSSBINUTILS= ${CROSSDIR}/.binutils_done
 CROSSGCC= ${CROSSDIR}/.gcc_done
-#NO_CROSS= isakmpd keynote ssh
+NO_CROSS= libiberty
 
 .include <bsd.own.mk>
 
+BUILD_CLANG=no
+BUILD_GCC3=no
+BUILD_GCC4=no
+
 .for _arch in ${TARGET_ARCH}
-.if !empty(CLANG_ARCH:M${_arch})
-COMPILER_VERSION=clang
-BUILD_CLANG=yes
-.elif !empty(GCC3_ARCH:M${_arch})
+.if !empty(GCC3_ARCH:M${_arch})
 COMPILER_VERSION=gcc3
-.else
+.elif !empty(GCC4_ARCH:M${_arch})
 COMPILER_VERSION=gcc4
+.else
+COMPILER_VERSION=clang
+.endif
+
+.if !empty(CLANG_ARCH:M${_arch})
+BUILD_CLANG=yes
+.endif
+.if !empty(GCC3_ARCH:M${_arch})
+BUILD_GCC3=yes
+.endif
+.if !empty(GCC4_ARCH:M${_arch})
+BUILD_GCC4=yes
 .endif
 
 .if !empty(PIE_ARCH:M${_arch})
@@ -101,6 +121,7 @@ PIE_DEFAULT=
 BINUTILS= ar as gasp ld nm objcopy objdump ranlib readelf size \
  strings strip
 BINUTILS_DIR=gnu/usr.bin/binutils-2.17
+
 .endfor
 
 # no libcrypto.... these won't build
@@ -113,6 +134,13 @@ NO_CROSS+=nsd
 NO_CROSS+=bind
 NO_CROSS+=unbound
 
+.if ${BUILD_GCC3:L} != "yes"
+NO_CROSS+=libobjc libstdc++
+.endif
+.if ${BUILD_GCC4:L} != "yes"
+NO_CROSS+=../usr.bin/cc/libobjc libstdc++-v3 libsupc++-v3
+.endif
+
 cross-dirs: ${CROSSDIRS}
 cross-obj: ${CROSSOBJ}
 cross-includes: ${CROSSINCLUDES}
@@ -172,12 +200,18 @@ ${CROSSINCLUDES}: ${CROSSOBJ}
     MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} \
     MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
     TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
+    BUILD_GCC3=${BUILD_GCC3} \
+    BUILD_GCC4=${BUILD_GCC4} \
+    BUILD_CLANG=${BUILD_CLANG} \
     ${MAKE} prereq && \
     COMPILER_VERSION=${COMPILER_VERSION} \
     MACHINE=${TARGET} \
     MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU} \
     MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
     TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
+    BUILD_GCC3=${BUILD_GCC3} \
+    BUILD_GCC4=${BUILD_GCC4} \
+    BUILD_CLANG=${BUILD_CLANG} \
     ${MAKE} DESTDIR=${CROSSDIR} includes)
  @touch ${CROSSINCLUDES}
 
@@ -222,7 +256,7 @@ ${CROSSBINUTILS}: ${CROSSINCLUDES}
 
 
 ${CROSSGCC}: ${CROSSBINUTILS}
-.if ${COMPILER_VERSION:L} == "clang"
+.if ${BUILD_CLANG:L} == "yes"
  (cd ${.CURDIR}/gnu/usr.bin/clang; \
     MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
     MACHINE_ARCH=${TARGET_ARCH} \
@@ -253,7 +287,8 @@ ${CROSSGCC}: ${CROSSBINUTILS}
  chmod +x ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc;
  echo "#!/bin/sh\n${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-clang --driver-mode=g++ --sysroot ${CROSSDIR} \"$$""@\"" > ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++; \
  chmod +x ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-c++;
-.elif ${COMPILER_VERSION:L} == "gcc3"
+.endif
+.if ${BUILD_GCC3:L} == "yes"
  (cd ${.CURDIR}/gnu/usr.bin/gcc; \
     MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
     TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
@@ -280,21 +315,22 @@ ${CROSSGCC}: ${CROSSBINUTILS}
  chmod ${BINMODE} ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp
  chown ${BINOWN}:${BINGRP} ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cpp
  ln -sf ${TARGET_CANON}-cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/cpp
-.else
+.endif
+.if ${BUILD_GCC4:L} == "yes"
  (cd ${.CURDIR}/gnu/usr.bin/cc; \
     env CROSSDIR=${CROSSDIR} \
     PIE_DEFAULT=${PIE_DEFAULT} \
     MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
     TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
     MACHINE=${TARGET} \
-    PATH=${CROSSPATH} ${MAKE} depend  )
+    PATH=${CROSSPATH} ${MAKE} depend)
  (cd ${.CURDIR}/gnu/usr.bin/cc; \
     env CROSSDIR=${CROSSDIR} \
     PIE_DEFAULT=${PIE_DEFAULT} \
     MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
     TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
     MACHINE=${TARGET} \
-    ${MAKE} all )
+    ${MAKE} all)
  (cd ${.CURDIR}/gnu/usr.bin/cc; \
     env CROSSDIR=${CROSSDIR} DESTDIR=${CROSSDIR} \
     PIE_DEFAULT=${PIE_DEFAULT} \
@@ -307,6 +343,7 @@ ${CROSSGCC}: ${CROSSBINUTILS}
  cp -f ${CROSSDIR}/usr/libexec/cpp ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-libexeccpp
  cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
  ln -sf ${TARGET_CANON}-cc ${CROSSDIR}/usr/${TARGET_CANON}/bin/cc
+ ln -sf ${TARGET_CANON}-c++ ${CROSSDIR}/usr/${TARGET_CANON}/bin/c++
 
  cp -f ${CROSSDIR}/usr/bin/gcc ${CROSSDIR}/usr/${TARGET_CANON}/bin/${TARGET_CANON}-cc
  rm -f ${CROSSDIR}/usr/bin/gcc  ${CROSSDIR}/usr/bin/g++  ${CROSSDIR}/usr/bin/cc ${CROSSDIR}/usr/libexec/cpp
@@ -343,6 +380,29 @@ cross-lib: ${CROSSGCC}
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
         SKIPDIR=\"${NO_CROSS}\" \
         ${MAKE} install)
+.if ${BUILD_GCC3:L} == "yes"
+ (cd ${.CURDIR}/gnu/lib; \
+    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
+        SKIPDIR=\"${NO_CROSS}\" \
+ BUILD_GCC3=${BUILD_GCC3} \
+ BUILD_GCC4=${BUILD_GCC4} \
+        COMPILER_VERSION=${COMPILER_VERSION} \
+        ${MAKE} cleandir)
+.endif
+ (cd ${.CURDIR}/gnu/lib; \
+    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
+        SKIPDIR=\"${NO_CROSS}\" \
+        TARGET_ARCH=${TARGET_ARCH} TARGET_CPU=${TARGET_CPU} \
+ BUILD_GCC3=${BUILD_GCC3} \
+ BUILD_GCC4=${BUILD_GCC4} \
+        COMPILER_VERSION=${COMPILER_VERSION} \
+        ${MAKE} depend all; \
+    eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
+        SKIPDIR=\"${NO_CROSS}\" \
+ BUILD_GCC3=${BUILD_GCC3} \
+ BUILD_GCC4=${BUILD_GCC4} \
+        COMPILER_VERSION=${COMPILER_VERSION} \
+        ${MAKE} install)
 
 cross-bin: ${CROSSOBJ}
  MACHINE=${TARGET} \
@@ -351,10 +411,10 @@ cross-bin: ${CROSSOBJ}
  for i in libexec bin sbin usr.bin usr.sbin; do \
  (cd ${.CURDIR}/$$i; \
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
-        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
+        SKIPDIR=\"${NO_CROSS}\" \
         ${MAKE} depend all ; \
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} DESTDIR=${CROSSDIR} \
-        SKIPDIR=\"${BINUTILS} ${NO_CROSS}\" \
+        SKIPDIR=\"${NO_CROSS}\" \
         ${MAKE} install); \
  done
 
@@ -362,7 +422,7 @@ cross-gnu: ${CROSSOBJ}
  MACHINE=${TARGET} \
     MACHINE_ARCH=${TARGET_ARCH} MACHINE_CPU=${TARGET_CPU}; \
  export MACHINE MACHINE_ARCH MACHINE_CPU; \
- for i in gnu/lib gnu/usr.sbin gnu/usr.bin ; do \
+ for i in gnu/usr.sbin gnu/usr.bin ; do \
  (cd ${.CURDIR}/$$i; \
     eval ${CROSSENV} MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
         SKIPDIR=\"${NO_CROSS}\" \
Index: gnu/lib/libstdc++/Makefile.bsd-wrapper
===================================================================
RCS file: /OpenBSD/src/gnu/lib/libstdc++/Makefile.bsd-wrapper,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile.bsd-wrapper
--- gnu/lib/libstdc++/Makefile.bsd-wrapper 5 Nov 2007 17:02:43 -0000 1.8
+++ gnu/lib/libstdc++/Makefile.bsd-wrapper 6 Jun 2017 18:15:11 -0000
@@ -44,6 +44,13 @@ CF_SHARED= --disable-shared
 CF_SHARED= --enable-shared
 .endif
 
+# cross-compilation
+.if defined(TARGET_ARCH)
+CONFIGTARGET=--target=${TARGET_ARCH}-unknown-openbsd${OSREV}
+.else
+CONFIGTARGET=
+.endif
+
 config.status:
  PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
  INSTALL_PROGRAM="${INSTALL} ${INSTALL_COPY} ${INSTALL_STRIP}" \
@@ -57,6 +64,7 @@ config.status:
  --disable-multilib \
  --with-gnu-ld \
  --with-gxx-include-dir=${GXX_INCDIR} \
+ ${CONFIGTARGET} \
  && touch config.status
 
 #CPPFLAGS+=-DHAVE_CONFIG_H -I${.CURDIR}/libstdc++/libmath