Description
Summary
During a cross-bootstrap from NetBSD/amd64 to NetBSD/aarch64, the libz-sys crate tries to use the aarch64 compiler, aarch64--netbsd-gcc, to compile for the amd64 target using amd64-specific compiler options like -m64. It does not appear to respect the --set=target.* options I passed to set the host compiler paths.
However, if I set HOST_CC/CXX/AR to corresponding paths, then the build seems to make progress past this point. In other words, it seems that the bootstrap is failing to transmit the --set=target.* options I passed originally down through to the libz-sys crate build.
Command used
src/bootstrap/configure.py --prefix=/usr/pkg --mandir=/usr/pkg/man --sysconfdir=/usr/pkg/etc --python=/home/riastradh/pkgsrc/git/cross/pkg/bin/python3.12 --release-channel=stable --local-rust-root=/home/riastradh/pkgsrc/git/cross/pkg/rust-aarch64-unknown-netbsd --enable-extended --enable-rpath --disable-codegen-tests --disable-compiler-docs --disable-llvm-static-stdcpp --disable-ninja --dist-compression-formats=xz --set dist.vendor=false --enable-vendor --host=aarch64-unknown-netbsd --set=target.x86_64-unknown-netbsd.cc=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cc --set=target.x86_64-unknown-netbsd.cxx=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cxx --set=target.x86_64-unknown-netbsd.linker=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cc --set=target.x86_64-unknown-netbsd.ar=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-ar --enable-cargo-native-static --disable-docs
/home/riastradh/pkgsrc/git/cross/pkg/bin/python3.12 ./x.py -v dist -j 4
Build environment:
CHECK_PORTABILITY=no
PYTHON=/home/riastradh/pkgsrc/git/cross/pkg/bin/python3.12
LC_MONETARY=C
CXX=aarch64--netbsd-g++
MAKEINFO=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/makeinfo
MAKEFLAGS= .MAKE.LEVEL.ENV=MAKELEVEL ALLOW_VULNERABLE_PACKAGES= BUILD_TARGET=dist CHECK_PORTABILITY=no CROSS_MACHINE_ARCH=aarch64 HOST_MACHINE_ARCH=amd64 LOWER_OPSYS=netbsd NATIVE_LOWER_OPSYS=netbsd NATIVE_OPSYS=NetBSD NATIVE_OPSYS_VERSION=100000 NATIVE_OS_VERSION=10.0 OPSYS=NetBSD OPSYS_VERSION=100000 OS_VERSION=10.0 PKGTOOLS_VERSION=20240126 UNPRIVILEGED_GROUP=riastradh UNPRIVILEGED_GROUPS=riastradh\ wheel\ operator\ nvmm\ ftp UNPRIVILEGED_USER=riastradh USE_CROSS_COMPILE=yes _MAKE=/home/riastradh/pkgsrc/git/cross/pkg/bin/bmake _PATH_ORIG=/bin:/usr/bin:/home/riastradh/pkgsrc/git/cross/pkg/bin _PKGSRCDIR=/home/riastradh/pkgsrc/git/cross/pkgsrc _PKGSRC_BARRIER=yes
BSD_INSTALL_GAME_DIR=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -d -o riastradh -g riastradh -m 0755
_MAKE=/home/riastradh/pkgsrc/git/cross/pkg/bin/bmake
PKGGNUDIR=gnu/
ALLOW_VULNERABLE_PACKAGES=
BSD_INSTALL_SCRIPT_DIR=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -d -o riastradh -g riastradh -m 755
USE_CROSS_COMPILE=yes
PWD=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/rustc-1.83.0-src
BSD_INSTALL_MAN=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -c -o riastradh -g riastradh -m 644
BSD_INSTALL_LIB=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -c -o riastradh -g riastradh -m 755
BSD_INSTALL_PROGRAM=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -c -o riastradh -g riastradh -m 755
FLEX=
BSD_INSTALL_PROGRAM_DIR=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -d -o riastradh -g riastradh -m 755
LANG=C
LD_LIBRARY_PATH=/home/riastradh/pkgsrc/git/cross/pkg/rust-aarch64-unknown-netbsd/lib
HOME=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.home
PKGINFODIR=info
ITSTOOL=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/itstool
BSD_INSTALL_GAME_DATA=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -c -o riastradh -g riastradh -m 0644
LC_ALL=C
BSD_INSTALL_DATA=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -c -o riastradh -g riastradh -m 644
HOST_CXXFLAGS=
PATH=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.cwrapper/bin:/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.buildlink/bin:/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.gcc/bin:/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin:/home/riastradh/pkgsrc/git/cross/pkg/bin:/bin:/usr/bin:/home/riastradh/pkgsrc/git/cross/pkg/bin:/home/riastradh/pkgsrc/git/cross/pkg/bin
CXXFLAGS=-O2 -I/usr/include
LC_MESSAGES=C
BSD_INSTALL_GAME=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -c -o riastradh -g riastradh -m 0755
PTHREADBASE=/usr
BISON=
MAKELEVEL=0
BSD_INSTALL_SCRIPT=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -c -o riastradh -g riastradh -m 755
PTHREAD_CFLAGS= -pthread
UNPRIVILEGED_GROUP=riastradh
NATIVE_LOWER_OPSYS=netbsd
LIBTOOL=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.cwrapper/bin/libtool
NATIVE_OS_VERSION=10.0
LC_NUMERIC=C
OLDPWD=/home/riastradh/pkgsrc/git/cross/pkgsrc/wip/rust183
CC=aarch64--netbsd-gcc
FC=f77
LINKER_RPATH_FLAG=-R
X11BASE=/usr/pkg
CFLAGS=-O2 -I/usr/include
CWRAPPERS_CONFIG_DIR=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.cwrapper/config
PKG_CONFIG=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/pkg-config
USETOOLS=no
LC_CTYPE=C
PREFIX=/usr/pkg
CONFIG_SITE=
CROSS_MACHINE_ARCH=aarch64
CARGO_BUILD_JOBS=4
NATIVE_OPSYS=NetBSD
FFLAGS=-O
OS_VERSION=10.0
PTHREAD_LIBS=
BSD_INSTALL_DATA_DIR=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -d -o riastradh -g riastradh -m 755
PTHREAD_LDFLAGS= -pthread
LC_COLLATE=C
no_proxy=
http_proxy=downloads-forbidden-except-during-fetch
HOST_MACHINE_ARCH=amd64
PKG_SYSCONFDIR=/usr/pkg/etc
OPSYS_VERSION=100000
GDBUS_CODEGEN=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/gdbus-codegen
CPPFLAGS=-I/usr/include
_PKGSRCDIR=/home/riastradh/pkgsrc/git/cross/pkgsrc
UNPRIVILEGED_GROUPS=riastradh wheel operator nvmm ftp
UNPRIVILEGED_USER=riastradh
ftp_proxy=downloads-forbidden-except-during-fetch
INSTALL_INFO=
NATIVE_OPSYS_VERSION=100000
BUILD_TARGET=dist
BSD_INSTALL=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install
LOWER_OPSYS=netbsd
LC_TIME=C
OPSYS=NetBSD
.MAKE.LEVEL.ENV=MAKELEVEL
LOCALBASE=/usr/pkg
PKGTOOLS_VERSION=20240126
_PATH_ORIG=/bin:/usr/bin:/home/riastradh/pkgsrc/git/cross/pkg/bin
F77=f77
LZMA_API_STATIC=1
COMPILER_RPATH_FLAG=-Wl,-R
PKG_CONFIG_LIBDIR=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.buildlink/lib/pkgconfig:/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.buildlink/share/pkgconfig
HOST_LDFLAGS=
PKG_CONFIG_LOG=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.pkg-config.log
LDFLAGS=-Wl,-zrelro -L/usr/lib -Wl,-R/usr/lib -Wl,-R/usr/pkg/lib
PKGMANDIR=man
HOST_CFLAGS=
PKG_CONFIG_PATH=
https_proxy=downloads-forbidden-except-during-fetch
BSD_INSTALL_MAN_DIR=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -d -o riastradh -g riastradh -m 755
BSD_INSTALL_LIB_DIR=/home/riastradh/netbsd/10/obj.arm64/tooldir/bin/aarch64--netbsd-install -d -o riastradh -g riastradh -m 755
_PKGSRC_BARRIER=yes
MAKECONF=/dev/null
CPP=cpp
OBJECT_FMT=ELF
Expected behaviour
Rust builds a bootstrap distriution.
Actual behaviour
Deep inside the build, it fails with:
warning: [email protected]: ToolExecError: Command "aarch64--netbsd-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "src/zlib" "-fvisibility=hidden" "-DZ_SOLO" "-DSTDC" "-D_LARGEFILE64_SOURCE" "-D_POSIX_SOURCE" "-o" "/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1-tools/release/build/libz-sys-bfca60dc728da21b/out/lib/0dc752f03a07a721-zutil.o" "-c" "src/zlib/zutil.c" with args aarch64--netbsd-gcc did not execute successfully (status code exit status: 1).
error: failed to run custom build command for `libz-sys v1.1.18`
Caused by:
process didn't exit successfully: `/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/rustc-1.83.0-src/build/x86_64-unknown-netbsd/stage1-tools/release/build/libz-sys-f4e66731319f71b4/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=LIBZ_SYS_STATIC
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=zng/cmake.rs
cargo:rerun-if-changed=zng/cc.rs
TARGET = Some(x86_64-unknown-netbsd)
OPT_LEVEL = Some(0)
HOST = Some(x86_64-unknown-netbsd)
cargo:rerun-if-env-changed=CC_x86_64-unknown-netbsd
CC_x86_64-unknown-netbsd = None
cargo:rerun-if-env-changed=CC_x86_64_unknown_netbsd
CC_x86_64_unknown_netbsd = None
cargo:rerun-if-env-changed=HOST_CC
HOST_CC = None
cargo:rerun-if-env-changed=CC
CC = Some(aarch64--netbsd-gcc)
cargo:rerun-if-env-changed=CC_KNOWN_WRAPPER_CUSTOM
CC_KNOWN_WRAPPER_CUSTOM = None
RUSTC_WRAPPER = Some(/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/rustc-1.83.0-src/build/bootstrap/debug/rustc)
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some(false)
CARGO_CFG_TARGET_FEATURE = Some(fxsr,sse,sse2)
cargo:rerun-if-env-changed=CFLAGS_x86_64-unknown-netbsd
CFLAGS_x86_64-unknown-netbsd = None
cargo:rerun-if-env-changed=CFLAGS_x86_64_unknown_netbsd
CFLAGS_x86_64_unknown_netbsd = None
cargo:rerun-if-env-changed=HOST_CFLAGS
HOST_CFLAGS = Some()
cargo:rerun-if-env-changed=CC_SHELL_ESCAPED_FLAGS
CC_SHELL_ESCAPED_FLAGS = None
cargo:warning=aarch64--netbsd-gcc: error: unrecognized command-line option '-m64'
exit status: 1
Bootstrap configuration (config.toml)
Everything passed on command line. Generated file:
# Use different pre-set defaults than the global defaults.
#
# See `src/bootstrap/defaults` for more information.
# Note that this has no default value (x.py uses the defaults in `config.example.toml`).
profile = 'dist'
[llvm]
# When true, link libstdc++ statically into the rustc_llvm.
# This is useful if you don't want to use the dynamic version of that
# library provided by LLVM.
static-libstdcpp = false
# Whether to use Ninja to build LLVM. This runs much faster than make.
ninja = false
[build]
# Which triples to produce a compiler toolchain for. Each of these triples will be bootstrapped from
# the build triple themselves. In other words, this is the list of triples for which to build a
# compiler that can RUN on that triple.
#
# Defaults to just the `build` triple.
host = ['aarch64-unknown-netbsd']
# Instead of downloading the src/stage0 version of Cargo specified, use
# this Cargo binary instead to build all Rust code
# If you set this, you likely want to set `rustc` as well.
cargo = '/home/riastradh/pkgsrc/git/cross/pkg/rust-aarch64-unknown-netbsd/bin/cargo'
# Instead of downloading the src/stage0 version of the compiler
# specified, use this rustc binary instead as the stage0 snapshot compiler.
# If you set this, you likely want to set `cargo` as well.
rustc = '/home/riastradh/pkgsrc/git/cross/pkg/rust-aarch64-unknown-netbsd/bin/rustc'
# Whether to build documentation by default. If false, rustdoc and
# friends will still be compiled but they will not be used to generate any
# documentation.
#
# You can still build documentation when this is disabled by explicitly passing paths,
# e.g. `x doc library`.
docs = false
# Indicate whether to build compiler documentation by default.
# You can still build documentation when this is disabled by explicitly passing a path: `x doc compiler`.
compiler-docs = false
# Python interpreter to use for various tasks throughout the build, notably
# rustdoc tests, the lldb python interpreter, and some dist bits and pieces.
#
# Defaults to the Python interpreter used to execute x.py.
python = '/home/riastradh/pkgsrc/git/cross/pkg/bin/python3.12'
# Indicate whether the vendored sources are used for Rust dependencies or not.
#
# Vendoring requires additional setup. We recommend using the pre-generated source tarballs if you
# want to use vendoring. See
# https://forge.rust-lang.org/infra/other-installation-methods.html#source-code.
vendor = true
# Enable a build of the extended Rust tool set which is not only the compiler
# but also tools such as Cargo. This will also produce "combined installers"
# which are used to install Rust and Cargo together.
# The `tools` (check `config.example.toml` to see its default value) option specifies
# which tools should be built if `extended = true`.
#
# This is disabled by default.
extended = true
# Indicates whether the native libraries linked into Cargo will be statically
# linked or not.
cargo-native-static = true
# Arguments passed to the `./configure` script, used during distcheck. You
# probably won't fill this in but rather it's filled in by the `./configure`
# script. Useful for debugging.
configure-args = ['--prefix=/usr/pkg', '--mandir=/usr/pkg/man', '--sysconfdir=/usr/pkg/etc', '--python=/home/riastradh/pkgsrc/git/cross/pkg/bin/python3.12', '--release-channel=stable', '--local-rust-root=/home/riastradh/pkgsrc/git/cross/pkg/rust-aarch64-unknown-netbsd', '--enable-extended', '--enable-rpath', '--disable-codegen-tests', '--disable-compiler-docs', '--disable-llvm-static-stdcpp', '--disable-ninja', '--dist-compression-formats=xz', '--set', 'dist.vendor=false', '--enable-vendor', '--host=aarch64-unknown-netbsd', '--set=target.x86_64-unknown-netbsd.cc=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cc', '--set=target.x86_64-unknown-netbsd.cxx=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cxx', '--set=target.x86_64-unknown-netbsd.linker=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cc', '--set=target.x86_64-unknown-netbsd.ar=/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-ar', '--enable-cargo-native-static', '--disable-docs']
[install]
# Where to install the generated toolchain. Must be an absolute path.
prefix = '/usr/pkg'
# Where to install system configuration files.
# If this is a relative path, it will get installed in `prefix` above
sysconfdir = '/usr/pkg/etc'
# Where to install man pages in `prefix` above
mandir = '/usr/pkg/man'
[rust]
# The "channel" for the Rust build to produce. The stable/beta channels only
# allow using stable features, whereas the nightly and dev channels allow using
# nightly features
#
# If using tarball sources, default value for `channel` is taken from the `src/ci/channel` file;
# otherwise, it's "dev".
channel = 'stable'
# By default the `rustc` executable is built with `-Wl,-rpath` flags on Unix
# platforms to ensure that the compiler is usable by default from the build
# directory (as it links to a number of dynamic libraries). This may not be
# desired in distributions, for example.
rpath = true
# Flag indicating whether codegen tests will be run or not. If you get an error
# saying that the FileCheck executable is missing, you may want to disable this.
# Also see the target's llvm-filecheck option.
codegen-tests = false
[target.x86_64-unknown-netbsd]
# C compiler to be used to compile C code. Note that the
# default value is platform specific, and if not specified it may also depend on
# what platform is crossing to what platform.
# See `src/bootstrap/cc_detect.rs` for details.
cc = '/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cc'
# C++ compiler to be used to compile C++ code (e.g. LLVM and our LLVM shims).
# This is only used for host targets.
# See `src/bootstrap/cc_detect.rs` for details.
cxx = '/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cxx'
# Archiver to be used to assemble static libraries compiled from C/C++ code.
# Note: an absolute path should be used, otherwise LLVM build will break.
ar = '/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-ar'
# Linker to be used to bootstrap Rust code. Note that the
# default value is platform specific, and if not specified it may also depend on
# what platform is crossing to what platform.
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
linker = '/home/riastradh/pkgsrc/current/crosswork/wip/rust183/work.NetBSD-10.0-aarch64/.tools/bin/native-cc'
[target.aarch64-unknown-netbsd]
[dist]
# List of compression formats to use when generating dist tarballs. The list of
# formats is provided to rust-installer, which must support all of them.
#
# This list must be non-empty.
compression-formats = ['xz']
# Whether to vendor dependencies for the dist tarball.
vendor = false
Operating system
NetBSD 9
HEAD
Additional context
We have some local patches in pkgsrc: https://github.com/NetBSD/pkgsrc-wip/tree/dade0a30d9ba39f52dba0f807ac72691b4c39e9f/rust183/patches
On top of that, I have another small local patch to the rpath patch for a different approach to cross-compilation I'm testing.
Build Log
(The build log is many megabytes, is this worth sharing beyond the excerpt I quoted?)