Subject: Re: cross build on leopard with xcode 3.0
To: Current Users <current-users@netbsd.org>
From: matthew sporleder <msporleder@gmail.com>
List: current-users
Date: 12/26/2007 12:20:06
On 12/20/07, matthew sporleder <msporleder@gmail.com> wrote:
> Hey, guys.  I haven't been able to build tools on leopard.  Is anyone
> else doing this?
>
> /Users/msporleder/Documents/netbsd/src/tools/gcc/../../gnu/dist/gcc4/gcc/config/rs6000/host-darwin.c:120:
> error: 'struct __darwin_mcontext' has no member named 'es'
> /Users/msporleder/Documents/netbsd/src/tools/gcc/../../gnu/dist/gcc4/gcc/config/rs6000/host-darwin.c:120:
> error: 'struct __darwin_mcontext' has no member named 'ss'
> /Users/msporleder/Documents/netbsd/src/tools/gcc/../../gnu/dist/gcc4/gcc/config/rs6000/host-darwin.c:
> In function 'darwin_rs6000_extra_signals':
> /Users/msporleder/Documents/netbsd/src/tools/gcc/../../gnu/dist/gcc4/gcc/config/rs6000/host-darwin.c:134:
> warning: passing argument 1 of 'sigaltstack' from incompatible pointer
> type
> nbgmake[1]: *** [host-ppc-darwin.o] Error 1
> nbgmake[1]: Leaving directory
> `/Users/msporleder/Documents/netbsd/obj/Users/msporleder/Documents/netbsd/src/tools/gcc/build/gcc'
> nbgmake: *** [all-gcc] Error 2
>
> *** Failed target:  .build_done
> *** Failed command: (cd build && /usr/bin/env -i
> gcc_cv_libc_provides_ssp=yes CC=cc CFLAGS=-O2\ -no-cpp-precomp
> CPPFLAGS= CXX=c++ CXXFLAGS=-O
> INSTALL=/Users/msporleder/Documents/netbsd/tools/bin/i386--netbsdelf-install\
> -c\ \ -r LDFLAGS= AR=ar RANLIB=ranlib
> LEX=/Users/msporleder/Documents/netbsd/tools/bin/nblex
> MAKE=/Users/msporleder/Documents/netbsd/tools/bin/nbgmake
> PATH="/Users/msporleder/Documents/netbsd/tools/bin:$PATH"
> YACC=/Users/msporleder/Documents/netbsd/tools/bin/nbyacc MACHINE=
> MAKEINFO=/Users/msporleder/Documents/netbsd/tools/bin/nbmakeinfo
> LIBGCC= LIBGCC1= LIBGCC1_TEST= LIBGCC2= INSTALL_LIBGCC= EXTRA_PARTS=
> CPPFLAGS=-DNETBSD_TOOLS AR=ar RANLIB=ranlib BISON=true DESTDIR=
> INSTALL=/Users/msporleder/Documents/netbsd/tools/bin/i386--netbsdelf-install\
> -c\ \ -r /Users/msporleder/Documents/netbsd/tools/bin/nbgmake -e
> MACHINE= MAKEINFO=/Users/msporleder/Documents/netbsd/tools/bin/nbmakeinfo
> LIBGCC= LIBGCC1= LIBGCC1_TEST= LIBGCC2= INSTALL_LIBGCC= EXTRA_PARTS=
> CPPFLAGS=-DNETBSD_TOOLS AR=ar RANLIB=ranlib BISON=true DESTDIR=
> INSTALL=/Users/msporleder/Documents/netbsd/tools/bin/i386--netbsdelf-install\
> -c\ \ -r all-gcc)
> *** Error code 2
>
> Stop.
> nbmake: stopped in /Users/msporleder/Documents/netbsd/src/tools/gcc
>
> *** Failed target:  dependall
> *** Failed command: cd
> /Users/msporleder/Documents/netbsd/src/tools/gcc;
> /Users/msporleder/Documents/netbsd/tools/bin/nbmake realall
> *** Error code 1
>
> Stop.
> nbmake: stopped in /Users/msporleder/Documents/netbsd/src/tools/gcc
>
> *** Failed target:  dependall-gcc
> *** Failed command: _makedirtarget() { dir="$1"; shift; target="$1";
> shift; case "${dir}" in /*) this="${dir}/"; real="${dir}" ;; .)
> this=""; real="/Users/msporleder/Documents/netbsd/src/tools" ;; *)
> this="${dir}/";
> real="/Users/msporleder/Documents/netbsd/src/tools/${dir}" ;; esac;
> show=${this:-.}; echo "${target} ===> ${show%/}${1:+ (with: $@)}"; cd
> "${real}" && /Users/msporleder/Documents/netbsd/tools/bin/nbmake
> _THISDIR_="${this}" "$@" ${target}; }; _makedirtarget gcc dependall
> *** Error code 1
>
> Stop.
> nbmake: stopped in /Users/msporleder/Documents/netbsd/src/tools
>
> ERROR: Failed to make dependall tools
> *** BUILD ABORTED ***
>

I was able to fix this by changing:
src/gnu/dist/gcc4/gcc/config/rs6000/host-darwin.c

--- host-darwin.c.orig  2007-12-26 11:26:23.000000000 -0500
+++ host-darwin.c       2007-12-26 11:22:45.000000000 -0500
@@ -35,7 +35,7 @@

 /* This doesn't have a prototype in signal.h in 10.2.x and earlier,
   fixed in later releases.  */
-extern int sigaltstack(const struct sigaltstack *, struct sigaltstack *);
+/* extern int sigaltstack(const struct sigaltstack *, struct sigaltstack *); */

 #undef HOST_HOOKS_EXTRA_SIGNALS
 #define HOST_HOOKS_EXTRA_SIGNALS darwin_rs6000_extra_signals
@@ -68,7 +68,7 @@
  sigaddset (&sigset, SIGSEGV);
  sigprocmask (SIG_UNBLOCK, &sigset, NULL);

-  faulting_insn = *(unsigned *)uc->uc_mcontext->ss.srr0;
+  faulting_insn = *(unsigned *)uc->uc_mcontext->__ss.__srr0;

  /* Note that this only has to work for GCC, so we don't have to deal
     with all the possible cases (GCC has no AltiVec code, for
@@ -117,7 +117,7 @@
    }

  fprintf (stderr, "[address=%08lx pc=%08x]\n",
-          uc->uc_mcontext->es.dar, uc->uc_mcontext->ss.srr0);
+          uc->uc_mcontext->__es.__dar, uc->uc_mcontext->__ss.__srr0);
  internal_error ("Segmentation Fault");
  exit (FATAL_EXIT_CODE);
 }



See files: (in leopard)
/usr/include/ppc/_structs.h
/usr/include/mach/ppc/_structs.h

I also tried: #undef __DARWIN_UNIX03 so it would try to use the non __
stuff, but it didn't work.