Added support for cross compiling packages on x86_64.
Two new options for the configuration file were added: * XBPS_CROSS_TARGET * XBPS_CROSS_DIR XBPS_CROSS_TARGET should be set to the target triplet that you build with the mktoolchain script. XBPS_CROSS_DIR should point to the cross directory that mktoolchain created if you've built one. As proof of concept the glibc32 package has been added for x86_64, and it works perfectly even in the chroot! with glibc32 in place that means that I can build a gcc multilib and use -m32 to build 32bit packages! OH YEAH I LOVE THAT SHIT!!!! --HG-- extra : convert_revision : 6b0008865e084674a1c4b58266f681871e519c66
This commit is contained in:
@@ -36,7 +36,7 @@ else
|
||||
fi
|
||||
|
||||
REQDIRS="bin sbin tmp var sys proc dev xbps xbps_builddir \
|
||||
xbps_destdir xbps_srcdistdir"
|
||||
xbps_destdir xbps_srcdistdir xbps_crossdir"
|
||||
for f in ${REQDIRS}; do
|
||||
[ ! -d $XBPS_MASTERDIR/$f ] && mkdir -p $XBPS_MASTERDIR/$f
|
||||
done
|
||||
@@ -52,6 +52,11 @@ echo "XBPS_CXXFLAGS=\"\$XBPS_CFLAGS\"" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||
if [ -n "$XBPS_MAKEJOBS" ]; then
|
||||
echo "XBPS_MAKEJOBS=$XBPS_MAKEJOBS" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||
fi
|
||||
if [ -n "$XBPS_CROSS_TARGET" -a -d "$XBPS_CROSS_DIR" ]; then
|
||||
echo "XBPS_CROSS_TARGET=$XBPS_CROSS_TARGET" >> \
|
||||
$XBPS_MASTERDIR/etc/xbps.conf
|
||||
echo "XBPS_CROSS_DIR=/xbps_crossdir" >> $XBPS_MASTERDIR/etc/xbps.conf
|
||||
fi
|
||||
|
||||
rebuild_ldso_cache()
|
||||
{
|
||||
@@ -88,6 +93,11 @@ mount_chroot_fs()
|
||||
local cnt=
|
||||
|
||||
REQFS="sys proc dev xbps xbps_builddir xbps_destdir xbps_srcdistdir"
|
||||
if [ -d "$XBPS_CROSS_DIR" ]; then
|
||||
local cross=yes
|
||||
REQFS="$REQFS xbps_crossdir"
|
||||
fi
|
||||
|
||||
for f in ${REQFS}; do
|
||||
if [ ! -f $XBPS_MASTERDIR/.${f}_mount_bind_done ]; then
|
||||
echo -n "=> Mounting $f in chroot... "
|
||||
@@ -97,6 +107,9 @@ mount_chroot_fs()
|
||||
xbps_builddir) blah=$XBPS_BUILDDIR;;
|
||||
xbps_destdir) blah=$XBPS_DESTDIR;;
|
||||
xbps_srcdistdir) blah=$XBPS_SRCDISTDIR;;
|
||||
xbps_crossdir)
|
||||
[ -n $cross ] && blah=$XBPS_CROSS_DIR
|
||||
;;
|
||||
*) blah=/$f;;
|
||||
esac
|
||||
mount --bind $blah $XBPS_MASTERDIR/$f
|
||||
|
||||
39
helpers/cross-compilation.sh
Normal file
39
helpers/cross-compilation.sh
Normal file
@@ -0,0 +1,39 @@
|
||||
#
|
||||
# This helper sets some required vars to be able to cross build
|
||||
# packages on xbps. The target is specified in the configuration file
|
||||
# and will be read any time the cross compilation flag is used.
|
||||
#
|
||||
[ -z "$XBPS_CROSS_TARGET" -o ! -d $XBPS_CROSS_DIR/bin ] && return 1
|
||||
|
||||
# Check if all required bins are there.
|
||||
for bin in gcc g++ cpp ar as ranlib ld strip; do
|
||||
if [ ! -x $XBPS_CROSS_DIR/bin/$XBPS_CROSS_TARGET-${bin} ]; then
|
||||
msg_error "cross-compilation: cannot find ${bin}, aborting."
|
||||
fi
|
||||
done
|
||||
|
||||
SAVE_PATH="$PATH"
|
||||
|
||||
cross_compile_setvars()
|
||||
{
|
||||
export CC=$XBPS_CROSS_TARGET-gcc
|
||||
export CXX=$XBPS_CROSS_TARGET-g++
|
||||
export CPP=$XBPS_CROSS_TARGET-cpp
|
||||
export AR=$XBPS_CROSS_TARGET-ar
|
||||
export AS=$XBPS_CROSS_TARGET-as
|
||||
export RANLIB=$XBPS_CROSS_TARGET-ranlib
|
||||
export LD=$XBPS_CROSS_TARGET-ld
|
||||
export STRIP=$XBPS_CROSS_TARGET-strip
|
||||
export PATH="$XBPS_CROSS_DIR/bin:$PATH"
|
||||
}
|
||||
|
||||
cross_compile_unsetvars()
|
||||
{
|
||||
unset CC CXX CPP AR AS RANLIB LD STRIP PATH
|
||||
export PATH="$SAVE_PATH"
|
||||
}
|
||||
|
||||
if [ "$build_style" = "gnu_configure" ]; then
|
||||
configure_args="--build=$XBPS_CROSS_HOST --host=$XBPS_CROSS_TARGET"
|
||||
configure_args="$configure_args --target=$XBPS_CROSS_TARGET"
|
||||
fi
|
||||
Reference in New Issue
Block a user