Re: Cross Architecture Compiling

From: Michael Vale <masked_at_internode.on.net>
Date: Fri, 2 Nov 2012 17:39:08 +1100
just for what it’s worth.  busybox and some other gmake ports don’t have 
configure but do have cross-compiling support in the gMakefile.

make install -C /usr/ports/sysutils/busybox CROSS_COMPILE=mips-freebsd- 
DESTDIR=/tmp CHROOTED=no PREFIX=/tmp

this actually doesn’t install with the default install program but the 
singular required binary does retain itself in 
/usr/ports/sysutils/busybox/work/busybox/busybox.

change ‘mips-freebsd-‘ to the xdev compiler of your choice.

-----Original Message----- 
From: Michael Vale
Sent: Friday, November 02, 2012 3:26 PM
To: Garrett Cooper ; freebsd-current_at_freebsd.org
Cc: Baptiste Daroussin
Subject: Re: Cross Architecture Compiling



From: Garrett Cooper
Sent: Friday, November 02, 2012 3:05 PM
To: Michael Vale
Cc: Baptiste Daroussin
Subject: Re: Cross Architecture Compiling

On Thu, Nov 1, 2012 at 8:05 PM, Michael Vale <masked_at_internode.on.net> 
wrote:

  Forwarding my latest zrouter redmine submission, where I have been working 
on updating zRouter's ports cross-arch-compilation automation system.

  --------

  Adding:

  CONFIGURE_HOST?=        ${TARGET_ARCH}-portbld-freebsd${OSREL}
  CONFIGURE_HOST:=        ${CONFIGURE_HOST:S/^/--host=/}

  to /usr/ports/Mk/bsd.port.mk allows many ports to pickup a cross compiler 
simply by having the user pass TARGET_ARCH=${ARCH} at the command-line.

  I've been using XDEV (/usr/src# make xdev XDEV=${ARCH} XDEV_ARCH={$ARCH}) 
as my most current cross-compiler.

  CC can be overridden by specifying your CROSS_CC's PATH first in the PATH 
environment variable e.g. export PATH=/usr/mips-freebsd/usr/bin/:$PATH

  I AM NOT USING DESTDIR PORTS JAILS TO COMPLETE THESE TASKS, PLEASE MAKE 
GOOD NOTE AS THERE IS SOME GREAT DIFFERENCES AND MUCH WORK TO BE DONE IN 
THIS DEPARTMENT.

  Assuming above bsd.ports.mk patch one can cross compile many ports simply:

  TARGET=mips TARGET_ARCH=mips make -C install CHROOTED=no 
DESTDIR=/path/to/target/rootfs PREFIX=/

  this will get you started.  PREFIX MUST == / for correct pkgconfig entries 
and many much other things I do not wish to discuss in detail right now, 
please understand!

  CHROOTED=no is the IMPORTANT PART HERE!  We cannot run a jail on a build 
machine with foreign binaries such as /bin/sh!  THIS IS FUNDAMENTAL.

  I will continue to hack away at bsd.port.mk until my work is complete, I 
would appreciate any help as to prefixing DESTDIR transparently to PREFIX in 
order for proper installation of cross-compiled ports.  I will submit any 
following patches in a more formal manner.

  I am open to questions and willing to expand muchly on the plethora of 
variables needed to be passed to build multiple ports with dependancies in 
more complicated scenarios.

  Some ports with GNU Makefiles have a different means of cross-compiling, 
e.g. busybox.  I'll post those findings next.

  Regards,

  Michael Vale.
  surfnet.co

  -----Original Message----- From: redmine_at_zrouter.org
  Sent: Friday, November 02, 2012 1:42 PM Subject: [zrouter - Bug #37] bsd 
ports


  Issue #37 has been updated by Michael Vale.

  File zrouter.ports.mk.diff added

  you need to have xdev mips installed.

  /usr/src# make xdev XDEV=mips XDEV_ARCH=mips.

  you also need to add these two lines to bsd.ports.mk (I will submit this 
to the -current mailing list)

  CONFIGURE_HOST?=        ${TARGET_ARCH}-portbld-freebsd${OSREL}
  CONFIGURE_HOST:=        ${CONFIGURE_HOST:S/^/--host=/}

  between the CONFIGURE_TARGET:=      ${CONFIGURE_TARGET:S/--build=//} and 
CONFIGURE_LOG lines.

  I did make other changes to bsd.ports.mk but i don't believe they are 
required here.  Let me know if it seems there is something missing.
  ----------------------------------------
  Bug #37: bsd ports
  http://redmine.zrouter.org/issues/37#change-41

  Author: Michael Vale
  Status: New
  Priority: Normal
  Assignee: Michael Vale
  Category: Project
  Target version:


  fixed bsd ports make building and install

  this is my first attempt at any such contribution to any project.

  please find the attached patch for share/mk/zrouter.ports.mk.

  ALSO - zrouter/ports/www/zhttpd/distinfo was deleted due to an invalid 
SHA256 sum.


    Very cool. One thing that you'll run into soon that's a problem is that 
pkgng groks /bin/sh's ELF format in order to determine its architecture 
(which unfortunately makes things difficult when cross-compiling). I've CCed 
bapt_at_ so this item hopefully doesn't get lost.
    The way I was thinking of solving this was compiling host binaries, 
nullfs mounting them in a chroot, chrooting into it with the appropriate 
variables set, then dropping out of the chroot once the package is built, 
but this is another avenue for fixing the problem (just requires more work).
Thanks!
-Garrett

Garrett,

Yes I’ve already run into a fair bit of pkgng’s stubbornness as there is a 
few other issues with it too, again I will try and fix it myself but it 
would be great if bapt would chime in and we can bowl this one over!
_______________________________________________
freebsd-current_at_freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org" 
Received on Fri Nov 02 2012 - 05:39:12 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:31 UTC