NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/43219: Use MKCROSSGDB to cross-build gdb on linux host



>Number:         43219
>Category:       toolchain
>Synopsis:       Use MKCROSSGDB to cross-build gdb on linux host
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 28 08:20:00 +0000 2010
>Originator:     Jan Kobler
>Release:        5.0.2
>Organization:
Kobler Systems GmbH
>Environment:
Linux 2.6.29-gentoo-r5 i686
>Description:
1. When I try to cross-build gdb with:

MKCROSSGDB=yes
build.sh tools

I got the error message:

/bin/sh: 
/home/jan/netbsd/system/usr/src/tools/gdb/../../gnu/dist/gdb6/gdb/observer.sh: 
Permission denied                                         

*** Failed target:  observer.h
*** Failed command: 
/home/jan/netbsd/system/usr/src/tools/gdb/../../gnu/dist/gdb6/gdb/observer.sh h 
/home/jan/netbsd/system/usr/src/tools/gdb/../../gnu/dist/gdb6/gdb/doc/observer.texi
 observer.h                                                                     
                             
*** Error code 126                                                              
                                                                                
               

Stop.
nbmake: stopped in /home/jan/netbsd/obj/evbppc/tools/gdb/build/gdb

*** Failed target:  all-gdb


2. The variable MKCROSSGDB is described nowhere.
The variable MKCROSSGDB is used nowhere else.

>How-To-Repeat:
# cross build environment for netbsd on the linux host

MY_NETBSD=~/netbsd; export MY_NETBSD   # define your own folder here

# create folders
mkdir  ${MY_NETBSD}           # root of the download, build, tools and 
installation folders for netbsd
mkdir  ${MY_NETBSD}/system       # source sets are extracted into this folder, 
contains usr/src and etc, netbsd build tree
mkdir  ${MY_NETBSD}/obj       # object dir
mkdir  ${MY_NETBSD}/dest      # destination dir
mkdir  ${MY_NETBSD}/tools     # tools running on the host
mkdir  ${MY_NETBSD}/release   # release dir
mkdir  ${MY_NETBSD}/log       # log files
mkdir  ${MY_NETBSD}/download  # download folder for the source sets

mkdir  ${MY_NETBSD}/obj/evbppc       # object dir of arch evbppc
mkdir  ${MY_NETBSD}/dest/evbppc      # destination dir of arch evbppc

# put source sets into  ${MY_NETBSD}/download

# extract source sets into ${MY_NETBSD}/system

cd ${MY_NETBSD}/system

tar -xzf ${MY_NETBSD}/download/gnusrc.tgz
tar -xzf ${MY_NETBSD}/download/sharesrc.tgz
tar -xzf ${MY_NETBSD}/download/src.tgz
tar -xzf ${MY_NETBSD}/download/syssrc.tgz
tar -xzf ${MY_NETBSD}/download/xsrc.tgz


# create the etc/mk.conf file

mkdir ${MY_NETBSD}/system/etc

# create and edit the file ${MY_NETBSD}/system/etc/mk.conf
# fill mk.conf with:
MKCROSSGDB=yes

#define environment variable MAKECONF

MAKECONF=${MY_NETBSD}/system/etc/mk.conf; export MAKECONF

# build tool chain
cd ${MY_NETBSD}/system/usr/src
./build.sh  -u -m evbppc -D ${MY_NETBSD}/dest/evbppc -O ${MY_NETBSD}/obj/evbppc 
-R ${MY_NETBSD}/release -T ${MY_NETBSD}/tools -X ${MY_NETBSD}/system/usr/xsrc 
tools 2>&1 | tee ${MY_NETBSD}/log/build.sh.tools.out 

## build.sh stops with the above error message
>Fix:
1. In order to build a cross debugger e.g. powerpc--netbsd-gdb on a linux host, 
the file usr/src/gnu/dist/gdb6/gdb/observer.sh needs to be made executable.

ls -l usr/src/gnu/dist/gdb6/gdb/observer.sh
-rw-r--r-- 1 jan jan 4020  2. Jul 2006  usr/src/gnu/dist/gdb6/gdb/observer.sh

chmod a+x usr/src/gnu/dist/gdb6/gdb/observer.sh

2. The variable MKCROSSGDB is used only in the file "usr/src/tools/Makefile",
but it is not used or described anywhere else.

I suggest to add MKCROSSGDB to 

usr/src/share/mk/bsd.README   # documentation 
usr/src/share/man/man5/mk.conf.5  # documentation

usr/src/etc/Makefile # then its value is shown in 'build.sh params'

usr/src/share/mk/bsd.own.mk # then the default value is defined

usr/src/build.sh # then its value is set in nbmake-${MACHINE}

I have provided patches for these files.

# observer.sh needs to be executable
chmod a+x usr/src/gnu/dist/gdb6/gdb/observer.sh


# apply patches

--- old/usr/src/share/mk/bsd.README     2009-06-07 00:10:49.000000000 +0200    
+++ new/usr/src/share/mk/bsd.README     2010-04-27 11:42:43.000000000 +0200    
@@ -129,6 +129,10 @@                                                           
 MKCOMPLEX      If "no", don't build libm support for <complex.h>              
                Default: yes                                                   
                                                                               
+MKCROSSGDB     If not "no", cross-build gdb(1) as part of the in-tree 
toolchain.
+               Default: no                                                     
 
+                                                                               
 
+                                                                               
 
 MKCRYPTO       If "no", no cryptography support will be built into the system, 
 
                and also acts as "MKKERBEROS=no".                               
 
                Default: yes                                                    
 
@@ -592,7 +596,7 @@                                                             
 
                TOOLCHAIN_MISSING is conditionally assigned the value "yes".    
 
                Otherwise, the variable is unconditionally assigned the         
 
                value "no".                                                     
 
-               If not "no", ${MKBFD}, ${MKGCC}, and ${MKGDB} are               
 
+               If not "no", ${MKBFD}, ${MKGCC}, ${MKGDB}, and ${MKCROSSGDB} 
are 
                unconditionally assigned the value "no".                        
 
                                                                                
 
 EXTERNAL_TOOLCHAIN                                                             
 
--- old/usr/src/share/man/man5/mk.conf.5        2009-01-16 22:41:10.000000000 
+0100
+++ new/usr/src/share/man/man5/mk.conf.5        2010-04-27 11:48:25.000000000 
+0200
@@ -233,6 +233,14 @@                                                            
   
 .In complex.h .                                                                
   
 .DFLTy                                                                         
   
 .                                                                              
   
+.It Sy MKCROSSGDB                                                              
   
+.YorN                                                                          
   
+Indicates whether                                                              
   
+.Xr gdb 1                                                                      
   
+is cross-built as part of the toolchain.                                       
   
+.DFLTn                                                                         
   
+                                                                               
   
+.                                                                              
   
 .It Sy MKCRYPTO                                                                
   
 .YorN                                                                          
   
 Indicates whether cryptographic code will be included in a build;              
   
--- old/usr/src/share/mk/bsd.own.mk     2009-03-18 06:39:06.000000000 +0100     
   
+++ new/usr/src/share/mk/bsd.own.mk     2010-04-27 11:35:20.000000000 +0200     
   
@@ -479,6 +479,7 @@                                                             
   
 MKBFD:= no                                                                     
   
 MKGDB:= no                                                                     
   
 MKGCC:= no                                                                     
   
+MKCROSSGDB:= no                                                                
   
 .endif                                                                         
   
                                                                                
   
 #                                                                              
   
@@ -664,6 +665,7 @@                                                             
   
 # MK* options which default to "no".                                           
   
 #                                                                              
   
 .for var in \                                                                  
   
+       MKCROSSGDB \                                                            
   
        MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKDEBUG MKDEBUGLIB \           
   
        MKMANZ MKMODULAR MKOBJDIRS \                                            
   
        MKPCC MKPCCCMDS \                                                       
   
--- old/usr/src/build.sh        2009-03-18 06:39:06.000000000 +0100             
   
+++ new/usr/src/build.sh        2010-04-27 13:17:27.000000000 +0200
@@ -844,7 +844,7 @@

        # Set up default make(1) environment.
        #
-       makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
+       makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS MKCROSSGDB"
        [ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID"
        MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS} 
MKOBJDIRS=${MKOBJDIRS-yes}"
        export MAKEFLAGS MACHINE MACHINE_ARCH
@@ -1076,13 +1076,14 @@
        DESTDIR=$(getmakevar DESTDIR)
        RELEASEDIR=$(getmakevar RELEASEDIR)
        RELEASEMACHINEDIR=$(getmakevar RELEASEMACHINEDIR)
+       MKCROSSGDB=$(getmakevar MKCROSSGDB)
        if ! $do_expertmode; then
                _SRC_TOP_OBJ_=$(getmakevar _SRC_TOP_OBJ_)
                : ${DESTDIR:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}}
                : ${RELEASEDIR:=${_SRC_TOP_OBJ_}/releasedir}
                makeenv="${makeenv} DESTDIR RELEASEDIR"
        fi
-       export TOOLDIR DESTDIR RELEASEDIR
+       export TOOLDIR DESTDIR RELEASEDIR MKCROSSGDB
        statusmsg "DESTDIR path:     ${DESTDIR}"
        statusmsg "RELEASEDIR path:  ${RELEASEDIR}"

--- old/usr/src/etc/Makefile    2009-10-15 10:21:05.000000000 +0200
+++ new/usr/src/etc/Makefile    2010-04-27 11:29:39.000000000 +0200
@@ -184,6 +184,7 @@
                MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
                MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
                MKBFD MKCATPAGES \
+               MKCROSSGDB \
                MKCRYPTO MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKCVS \
                MKDEBUG MKDEBUGLIB MKDOC MKDYNAMICROOT \
                MKGCC MKGCCCMDS MKGDB \


######## end of patches #########

After these changes it is possilbe to build netbsd for evbppc on a x86 linux 
host:

# gdb is in ${MY_NETBSD}/tools/bin
ls -l ${MY_NETBSD}/tools/bin/powerpc--netbsd-gdb

# test gdb on linux host:

${MY_NETBSD}/tools/bin/powerpc--netbsd-gdb
GNU gdb 6.5
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=powerpc--netbsd".

# build make target 'release' 
cd ${MY_NETBSD}/system/usr/src
./build.sh -U -u -m evbppc -D ${MY_NETBSD}/dest/evbppc -O 
${MY_NETBSD}/obj/evbppc -R ${MY_NETBSD}/release -T ${MY_NETBSD}/tools -X 
${MY_NETBSD}/system/usr/xsrc release 2>&1 | tee 
${MY_NETBSD}/log/build.sh.release.out 

###############

make release started at:  Fri Apr 23 17:26:09 CEST 2010                         
                                                                                
               
make release finished at: Fri Apr 23 22:14:19 CEST 2010                         
                                                                                
               
===> Successful make release                                                    
                                                                                
               
===> build.sh ended:   Fri Apr 23 22:14:19 CEST 2010
===> Summary of results:
         build.sh command: ./build.sh -U -u -m evbppc -D 
/home/jan/netbsd/dest/evbppc -O /home/jan/netbsd/obj/evbppc -R 
/home/jan/netbsd/release -T /home/jan/netbsd/tools -X 
/home/jan/netbsd/sys/usr/xsrc release
         build.sh started: Fri Apr 23 17:25:55 CEST 2010
         NetBSD version:   5.0.2
         MACHINE:          evbppc
         MACHINE_ARCH:     powerpc
         Build platform:   Linux 2.6.29-gentoo-r5 i686
         HOST_SH:          /bin/sh
         No /home/jan/netbsd/tools/bin/nbmake, needs building.
         Bootstrapping nbmake
         TOOLDIR path:     /home/jan/netbsd/tools
         DESTDIR path:     /home/jan/netbsd/dest/evbppc
         RELEASEDIR path:  /home/jan/netbsd/release
         Created /home/jan/netbsd/tools/bin/nbmake
         makewrapper:      /home/jan/netbsd/tools/bin/nbmake-evbppc
         Updated /home/jan/netbsd/tools/bin/nbmake-evbppc
         Successful make release
         build.sh ended:   Fri Apr 23 22:14:19 CEST 2010
===> .




Home | Main Index | Thread Index | Old Index