Date: Tue, 16 Jun 2015 23:48:53 +1030 From: Michael Vale <m.vale@live.com.au> To: Adrian Chadd <adrian@freebsd.org>, Warner Losh <imp@bsdimp.com> Cc: "freebsd-embedded@freebsd.org" <embedded@freebsd.org>, "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org> Subject: RE: Starting to cross-compile non-base software for MIPS - what it's like Message-ID: <COL130-W1459933AF469DF96988866C4A70@phx.gbl> In-Reply-To: <CAJ-Vmo=8oyyWiRBS9EU%2BKicz_jm90gO46cu_QRu9Az2RHU7zRw@mail.gmail.com> References: <CAJ-VmonSXYdLP_VpGh%2B3N_WfGwDLqWGcuPvOCf4VkOd0pJ5QWg@mail.gmail.com>, <B29CEB72-367C-4295-BD93-2A5C417D0553@bsdimp.com>, <CAJ-Vmo=8oyyWiRBS9EU%2BKicz_jm90gO46cu_QRu9Az2RHU7zRw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Here is onething that can be added under .if defined(X_BUILD_FOR)=2C either= as an .include e.g. bsd.cross.mk. or just paste it in there. if X_BUILD_F= OR /is/ defined=2C configure --host mips-freebsd-* etc will already be done= if you just invoke a normal ports build rather than running configure manu= ally from port/work/. =20 I know it's not perfect=2C but the only thing that needs and overview is th= e declaration of SYSROOT. I used ${LOCALBASE} to define the right position= =2C i'm unsure if this is correct. =20 ---------------------------- bsd.cross.mk ---------------------------------= ------------------------------------------- =20 .if exist(/usr/${X_BUILD_FOR}/usr/bin/${X_BUILD_FOR}-portbld-freebsd11.0-gc= c) then \ MAKE_ENV+=3D CPU_ARGS=3D"-march=3D${X_BUILD_FOR}" INCS=3D"-l${SRCDIR}/../root/${X_BUILD_FOR} .else IGNORE=3D Install gcc with mips support from ports first. .if FLOAT=3D"hard" then \ MAKE_ENV+=3D CPU_ARGS=3D"-mhard-float=2C -Wa=2C-mhard-float" .else \ MAKE_ENV+=3D CPU_ARGS=3D"-msoft-float=2C -Wa=2C-msoft-float" MAKE_ENV+=3D CROSS_COMPILE=3D"${X_BUILD_FOR}-portbld-freebsd${OS_REL} \ CC=3D${CROSS_COMPILE}-gcc \ CXX=3D${CROSS_COMPILE}-g++ \ LD=3D${X_BUILD_FOR}-freebsd-ld \ AR=3D${X_BUILD_FOR}-freebsd-ar \ RANLIB=3D${X_BUILD_FOR}-freebsd-ranlib \ STRIP=3D${X_BUILD_FOR}-freebsd-strip \ SYSROOT=3D${LOCALBASE}/${X_BUILD_FOR}/ \ CFLAGS=3D"--sysroot=3D$SYSROOT ${CPU_ARGS} ${INCS} -O" CXXFLAGS=3D"--sysroot=3D$SYSROOM ${CPU_ARGS} ${INCS} -O" =20 > Date: Mon=2C 15 Jun 2015 11:45:00 -0700 > Subject: Re: Starting to cross-compile non-base software for MIPS - what = it's like > From: adrian@freebsd.org > To: imp@bsdimp.com > CC: embedded@freebsd.org=3B freebsd-mips@freebsd.org >=20 > On 15 June 2015 at 10:23=2C Warner Losh <imp@bsdimp.com> wrote: > > > >> On Jun 14=2C 2015=2C at 1:13 PM=2C Adrian Chadd <adrian@freebsd.org> w= rote: > >> > >> Hi! > >> > >> I've been hacking at cross compiling things on FreeBSD for a while=2C > >> and I have made some progress. This email is less of a "how you can do > >> it" and more of a "these are the roadblocks that prevent it from > >> working out of the box." > >> > >> I'm using gcc-4.9.2 from ports - there's a cross compiler for > >> mips/mips64=2C and there's mips-binutils/mips64-binutils. I'm using > >> those to compile world and kernel. The kernel works=3B world requires > >> some patching to compile. I'll write a post when I have a complete > >> system booting/running from gcc-4.9.2. > >> > >> My test application is dropbear. Ie=2C I'm cross-compiling dropbear fo= r > >> mips from freebsd/i386. > >> > >> * There are some issues in libgcc - I have a patch that I've emailed > >> out for review. I'll do some more testing and commit it next week when > >> I know it works. > >> * There are some environment variables that need to be set before I > >> compile dropbear. Here's what it looks like: > >> > >> CPU_ARGS=3D"-march=3Dmips32 -msoft-float -Wa=2C-msoft-float" > >> INCS=3D"-I/home/adrian/work/freebsd/head-embedded-2/root/mips/usr/incl= ude" > >> > >> export CROSS_COMPILE=3Dmips-portbld-freebsd11.0 > >> export CC=3D${CROSS_COMPILE}-gcc > >> export CXX=3D${CROSS_COMPILE}-g++ > >> #export LD=3D${CROSS_COMPILE}-ld > >> #export AR=3D${CROSS_COMPILE}-ar > >> #export RANLIB=3D${CROSS_COMPILE}-ranlib > >> #export STRIP=3D${CROSS_COMPILE}-strip > >> export LD=3Dmips-freebsd-l > >> export AR=3Dmips-freebsd-ar > >> export RANLIB=3Dmips-freebsd-ranlib > >> export STRIP=3Dmips-freebsd-strip > >> export SYSROOT=3D/home/adrian/work/freebsd/head-embedded-2/root/mips/ > >> export CFLAGS=3D"--sysroot=3D$SYSROOT ${CPU_ARGS} ${INCS} -O" > >> export CXXFLAGS=3D"--sysroot=3D$SYSROOT ${CPU_ARGS} ${INCS} -O" > >> export CPPFLAGS=3D"--sysroot=3D$SYSROOT ${CPU_ARGS} ${INCS} -O" > >> export LDFLAGS=3D--sysroot=3D$SYSROOT > >> > >> # now run: > >> # /configure --host=3Dmips-portbld-freebsd11.0 > >> # gmake > >> > >> ... then I hit a problem with how we populate links in /usr/lib and > >> such. TL=3BDR - the symlinks we use are not relative paths=2C they're > >> absolute paths - and this makes cross building using sysroot / > >> explicit library paths fail to work right. Sigh. In particular=2C I > >> needed to manually undo the libgcc symlink for it to compile. > >> compilation complained about other libraries=2C but the resulting > >> binaries did run. > > > > That=92s one of about 6 reasons that what we produce isn=92t a > > sysroot. We need to create a sysroot target that=92s very close > > to the xdev targets with all the compiler bits stripped out. We=92re > > close though. I have about 1/2 of the patch needed to remove > > xdev entirely and replace it with sysroot. >=20 > Sweet. >=20 > > You shouldn=92t need the INCS args if you have a proper sysroot. > > And the CPU_ARGS is an indication we=92re building our port > > incorrectly. This is the same feedback I gave on the kernel > > make changes you suggested. >=20 > It looks like a proper sysroot - I think it's just the dynamic sysroot > stuff being broken. >=20 > > I=92ve had hacks like this for =93simple=94 arts for years. It=92s why = I wrote > > xdev in the first place. I had it working in the FreeBSD 6 time frame > > for cross building some ports. But once you get past a certain > > class of very well behaved ports=2C it goes to hell in a hurry. >=20 >=20 > >> * I'll try to wrangle juli/bsdimp to review the kernel changes needed > >> to compile up the kernel with gcc-4.9. > > > > I=92ve already reviewed that one. gcc isn=92t being compiled correctly > > and that need to be fixed. This is the forth time I=92ve given this > > feedback. >=20 > There are some other issues too. The softfloat/hardfloat stuff reared > its head - in order to avoid assembler warnings we have to manually > set it=2C but then the floating point register accesses in fp.S / > swtch.S generate errors. I've worked around that for now=2C but I need > to dig into why the warnings are generated in the first case. >=20 > >> * I'd like some help / comments on what we can do about the absolute > >> symlinks used for various things inside an installed root. Ideally > >> we'd have an option that would let us populate only relative links - > >> that'd instantly make this problem go away. > > > > All installworld-ish targets should use relative path symbolic links. > > The fact they are using absolute paths is a bug. In the FreeBSD 6 > > time frame=2C I fought this battle at work and it wasn=92t hard to fix.= I > > no longer have access to those sources=2C and I honestly can=92t > > recall how I fixed it (it may have been in a post-processing > > step). >=20 > I'd love to get this fixed and into the tree. >=20 > >> * I'll go hit up bapt and some netbsd friends for some help with > >> expected sysroot behaviour on gcc/binutils. It's possible there are > >> still bugs with the dynamic sysroot (ie=2C when you don't compile your > >> toolchain with an explicit sysroot to something other than '/') that > >> need addressing. > > > > bapt and I have been talking about this for a while. We=92ve both been > > busy doing other things so haven=92t focused on it other than in off > > moments. > > > >> Then I'll worry about starting to convert a few ports to be native > >> cross building. > > > > You should talk to bapt about the rather extensive work he=92s done > > in this area=2C which is why I=92ve looked at transitioning the xdev > > support to just sysroot support. >=20 > I have been too! fear not. That's how I got this far! >=20 >=20 > -a > _______________________________________________ > freebsd-embedded@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-embedded > To unsubscribe=2C send any mail to "freebsd-embedded-unsubscribe@freebsd.= org" =
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?COL130-W1459933AF469DF96988866C4A70>