Pkgsrc changes: * Sadly, I had to reinstate the "make tar files" rust code to make it possible to build cross-compiled bootstrap kits. * Add an adjustable "BUILD_TARGET", "dist" for cross-building a bootstrap kit, "build" for a normal native build. * New bootstrap kits built for NetBSD/powerpc, NetBSD/earmv7hf, and NetBSD/sparc64 version 1.31.1. * gcc-wrap script amended to also drop -Wl,--enable-new-dtags (so it could be used outside pkgsrc) * Worked around use of AtomicU64 in release build tool (ugly band-aid patch). Some platforms lack support for that type and associated operations. Upstream changes: - [Fix Rust failing to build on `powerpc-unknown-netbsd`][56562] - [Fix broken go-to-definition in RLS][rls/1171] - [Fix infinite loop on hover in RLS][rls/1170] [56562]: https://github.com/rust-lang/rust/pull/56562 [rls/1171]: https://github.com/rust-lang/rls/issues/1171 [rls/1170]: https://github.com/rust-lang/rls/pull/1170
161 lines
3.6 KiB
Bash
161 lines
3.6 KiB
Bash
#! /bin/sh
|
|
|
|
# Root of targets tools + dest directories
|
|
# or unset to default to a native build.
|
|
|
|
# This script assumes target tools in $root/tools
|
|
# and target's destdir in $root/dest, the result of a NetBSD build.sh.
|
|
# ...or the native root, when we don't cross-compile
|
|
root=${CROSS_ROOT:-/}
|
|
|
|
native=false
|
|
if [ $root = "/" ]; then
|
|
native=true
|
|
else
|
|
# What's the tools/bin prefix (if we're cross-building)?
|
|
gnuarch=${GNU_CROSS_TARGET:?}
|
|
fi
|
|
|
|
# Who are we a wrapper for? (Typically either gcc or c++)
|
|
who=$(basename $0 | sed -e 's/-wrap$//')
|
|
|
|
args=""
|
|
|
|
# May need to add $linkadd before first -l or fist -L
|
|
linkadd="-Wl,--sysroot=${root}/dest"
|
|
# (perhaps this is overly cautious, other adjustments we do
|
|
# below may be sufficient...)
|
|
# Lib directories to ensure we search and have in run-path
|
|
libs="/lib /usr/lib /usr/pkg/lib"
|
|
|
|
for d in $libs; do
|
|
if ! $native; then
|
|
linkadd="$linkadd -L=$d"
|
|
linkadd="$linkadd -Wl,-rpath-link=${root}/dest/$d"
|
|
fi
|
|
# Run-path is for when we execute on the target,
|
|
# so no $root prefix
|
|
linkadd="$linkadd -Wl,-rpath,$d"
|
|
done
|
|
|
|
# ...and add a placeholder so we can tweak RPATH with chrpath,
|
|
# since chrpath can't extend the length of the run path
|
|
# (This may also not be needed, we use LD_LIBRARY_PATH instead)
|
|
placeholder="placeholder-$(date | openssl dgst -sha1 | \
|
|
awk '{ print $2 }')"
|
|
linkadd="$linkadd -Wl,-rpath,/$placeholder"
|
|
# the / is a sneaky attempt to let it past cwrapper...
|
|
|
|
# More debugging
|
|
linkadd="$linkadd -Wl,--verbose"
|
|
|
|
linktweaked=false
|
|
|
|
# Step through args, tweak where required
|
|
set -- "$@"
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
# Insert = at the front of -isystem args.
|
|
# This is to get --sysroot prepended, so that
|
|
# we pick up the correct set of header files.
|
|
# (I thought this wasn't reqired, but apparently it is...)
|
|
-isystem)
|
|
shift
|
|
args="$args -isystem =$1"
|
|
;;
|
|
# Also doctor -I directives of known paths and
|
|
# redirect them to the --sysroot.
|
|
-I/usr/include)
|
|
args="$args -I=/usr/include"
|
|
;;
|
|
-I/usr/include/krb5)
|
|
args="$args -I=/usr/include/krb5"
|
|
;;
|
|
-I/usr/pkg/include)
|
|
args="$args -I=/usr/pkg/include"
|
|
;;
|
|
-I)
|
|
if [ $2 = "/usr/include" ]; then
|
|
args="$args -I=/usr/include"
|
|
shift
|
|
elif [ $2 = "/usr/include/krb5" ]; then
|
|
args="$args -I=/usr/include/krb5"
|
|
shift
|
|
elif [ $2 = "/usr/pkg/include" ]; then
|
|
args="$args -I=/usr/pkg/include"
|
|
shift
|
|
else
|
|
args="$args -I"
|
|
fi
|
|
;;
|
|
-l*)
|
|
if ! $linktweaked; then
|
|
args="$args $linkadd"
|
|
linktweaked=true
|
|
fi
|
|
args="$args $1"
|
|
;;
|
|
-L)
|
|
if ! $linktweaked; then
|
|
args="$args $linkadd"
|
|
linktweaked=true
|
|
fi
|
|
shift
|
|
tweaked=false
|
|
# redirect these to -Wl,--sysroot
|
|
for d in /lib /usr/lib /usr/pkg/lib; do
|
|
if [ $1 = $d ]; then
|
|
args="$args -L =$d"
|
|
tweaked=true
|
|
fi
|
|
done
|
|
# Not redirected? If so we need to add
|
|
if ! $tweaked; then
|
|
args="$args -L $1"
|
|
fi
|
|
;;
|
|
|
|
-L/lib)
|
|
if ! $linktweaked; then
|
|
args="$args $linkadd"
|
|
linktweaked=true
|
|
fi
|
|
args="$args -L=/lib"
|
|
;;
|
|
-L/usr/lib)
|
|
if ! $linktweaked; then
|
|
args="$args $linkadd"
|
|
linktweaked=true
|
|
fi
|
|
args="$args -L=/usr/lib"
|
|
;;
|
|
-L/usr/pkg/lib)
|
|
if ! $linktweaked; then
|
|
args="$args $linkadd"
|
|
linktweaked=true
|
|
fi
|
|
args="$args -L=/usr/pkg/lib"
|
|
;;
|
|
-Wl,--enable-new-dtags)
|
|
# ignore
|
|
;;
|
|
*)
|
|
args="$args $1"
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if $native; then
|
|
# Try to avoid cwrappers, which does "undocumented magic"
|
|
# by invoking the compiler "directly".
|
|
cmd="/usr/bin/${who} $args"
|
|
else
|
|
cmd="${root}/tools/bin/${gnuarch}-${who} \
|
|
--sysroot=${root}/dest \
|
|
$args"
|
|
fi
|
|
|
|
# Cannot echo to stdout, messes up e.g. "gcc -print-prog-name=ld" output...
|
|
#echo $cmd >&2
|
|
exec $cmd
|