tech-pkg archive

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

Re: Cross-compilation problems



On Sat, Jul 06, 2019 at 06:49:02AM -0400, Greg Troxel wrote:
> tlaronde%polynum.com@localhost writes:
> 
> > On Fri, Jul 05, 2019 at 08:51:59PM -0400, Greg Troxel wrote:
> >> tlaronde%polynum.com@localhost writes:
> >> 
> >> > When trying to create the first needed package: cross-libtool-base,
> >> > the configure script chokes because it is unable to create an
> >> > executable.
> >> >
> >> > Indeed, the cross-compiler is invoked with --sysroot=/ and this prevents
> >> > it from finding the crt0.o etc. to link the executable with.
> >> >
> >> > So I force it by adding in the Makefile:
> >> >
> >> > CFLAGS+= --sysroot=${CROSS_DESTDIR}
> >> 
> >> (I have never actually done cross pkgsrc, but it has long been on my
> >> Copious Spare Time todo list.)
> >> 
> >> Where are you getting your cross toolchain from?  My impression is that
> >> the cross tools NetBSD builds as part of the full release build have
> >> sysroot baked in to the destdir.   So rather than adding it to CFLAGS,
> >> I'd want to find out what is going awry with the intended plan, because
> >> fairly obviously (but perhaps incorrectly) it seems that the cross
> >> support is already expecting to deal with what it needs to.
> >
> > I don't think so since you can build the tools before building the
> > release so the tools have to be agnostic about the releasedir.
> >
> > For what I understood from a cursory look to the makefiles, during the
> > builds the object files (crt0.o, crtbegin.o, crtend.o, crti.o) are
> > spefically named with macros in bsd.prog.mk with LIBCRT0 etc.
> >
> > But the cross linker has a sysroot set to '/'.
> 
> Fair points.  I guess it's that nbmake-foo passes down the right
> arguments.
> 
> Still, it seems this pkgsrc cross mechanism was intended to do things
> right, and it seems best to figure how what the intent was and how it
> went wrong.

I'm trying to wrap my head around configure and the like.

I already found this:

---8<---
configure:3871: armv7--netbsdelf-eabihf-gcc -v >&5
Using built-in specs.
COLLECT_GCC=armv7--netbsdelf-eabihf-gcc
COLLECT_LTO_WRAPPER=/data/m/tmp/olimex/tooldir.NetBSD-8.0-amd64/libexec/gcc/armv7--netbsdelf-eabihf/5.5.0/lto-wrapper
Target: armv7--netbsdelf-eabihf
Configured with: /usr/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=armv7--netbsdelf-eabihf --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/Misc/send-pr.html --with-pkgversion='NetBSD nb2 20180327' --with-system-zlib --disable-libstdcxx-dual-abi --enable-__cxa_atexit --enable-libstdcxx-time=rt --enable-libstdcxx-threads --with-diagnostics-color=auto-if-env --with-sysroot=/usr/obj/destdir.evbarm --with-mpc=/data/m/tmp/olimex/tooldir.NetBSD-8.0-amd64 --with-mpfr=/data/m/tmp/olimex/tooldir.NetBSD-8.0-amd64 --with-gmp=/data/m/tmp/olimex/tooldir.NetBSD-8.0-amd64 --disable-nls --disable-multilib --program-transform-name=s,^,armv7--netbsdelf-eabihf-, --enable-languages='c c++ objc' --prefix=/data/m/tmp/olimex/tooldir.NetBSD-8.0-amd64
Thread model: posix
gcc version 5.5.0 (NetBSD nb2 20180327) 
--->8---

So --with-sysroot is set with the default tooldir directory:
"/usr/obj/destdir.evbarm"

and it's wrong.

So I added a symlink in /usr/obj to point to my real tooldir.

I had to add in cross-libtool-base Makefile:

CFLAGS+= --sysroot=${CROSS_DESTDIR}
LDFLAGS+= --sysroot=${CROSS_DESTDI} -L=/usr/lib

the "=" being there in order for the linker to prefix /usr/lib with
the sysroot or it will take the host (MATRIX, build host) shared object
and cries out loud.

Note too that I haven't got checkperms installed, seems needed (but
"natively") and I had to comment out all the cross compile setting
in /etc/mk.conf to be able to get the package natively.

There is something wrong with the conditional:

.if !empty{USE_CROSS_COMPILE:M[yY][eE][sS]}

because it doesn't test for yes or YES, but simply for setting. Even
setting it to no, one gets the cross compile environment. (I don't know
the syntax of BSD make.)
-- 
        Thierry Laronde <tlaronde +AT+ polynum +dot+ com>
                     http://www.kergis.com/
                       http://www.sbfa.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C


Home | Main Index | Thread Index | Old Index