Created attachment 252086 [details] patch According to this comment (https://github.com/rust-lang/rust/issues/127727#issuecomment-2229073731), the --target xx option, turned on by CARGO_BUILD_TARGET in cargo.mk, enables the cross-comilation mode in the Rust compiler. Cross compilation shouldn't be turned on by default in the FreeBSD ports. If cross-compilation is desired, it should be turned on by dedicated variables in ports' makefiles or in /etc/make.conf. According to the linked above conversation cross-compilation causes some RUSTFLAGS to not be passed to some rustc commands. In particular, removal of cross-compilation would fix build failures in many rust-based ports on the i386 architecture, for example in devel/cargo-spellcheck. The attached patch removes cross-compilation options from cargo.mk
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=f99a708957bdb6dbd26af0a561d00589337e0c6e commit f99a708957bdb6dbd26af0a561d00589337e0c6e Author: Yuri Victorovich <yuri@FreeBSD.org> AuthorDate: 2024-10-23 03:00:55 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2024-10-23 03:11:24 +0000 Mk/Uses/cargo.mk: Remove cross-compilation options for Rust-based ports Reasons: * Port build shouldn't use cross-compilation mode because it buids for the same architecture. * RUSTFLAGS isn't passed to the build of all or some Rust ports in the cross-compilation mode. Essential changes: * Remove the CARGO_BUILD_TARGET make variable. * Remove CARGO_BUILD_TARGET and CARGO_TARGET_* from CARGO_ENV. * Update many ports that used CARGO_BUILD_TARGET. * Build paths now don't include the architecture triplet part. Immadiate benefits: * Unbreak build on architectures like i386 that sometimes require special RUSTFLAGS that were not effective in the cross-compilation mode. Ports that really need cross-compilation for some reason should enable it on case-by-case basis. Example: net-p2p/cncli (Not sure why does net-p2p/cncli actually need it, but it only builds with these options.) PR: 280305 Approved by: rust@FreeBSD.org (maintainer's timeout; 98 days) Mk/Uses/cargo.mk | 5 ----- audio/amberol/Makefile | 1 - audio/gnome-metronome/Makefile | 1 - audio/gnome-podcasts/Makefile | 1 - audio/mousai/Makefile | 1 - audio/shortwave/Makefile | 1 - databases/greptimedb/Makefile | 2 +- databases/redisjson/Makefile | 2 +- deskutils/health/Makefile | 1 - deskutils/rwpspread/Makefile | 6 +++--- deskutils/solanum/Makefile | 1 - devel/evcxr-jupyter/Makefile | 4 ++-- devel/jetbrains-restarter/Makefile | 2 +- devel/jujutsu/Makefile | 2 +- devel/libdatadog/Makefile | 11 ++++++----- devel/libdatadog/pkg-plist | 3 +++ devel/librashader/Makefile | 4 ++-- devel/libwasmtime/Makefile | 4 ++-- devel/nextest/Makefile | 2 +- devel/pijul/Makefile | 2 +- devel/ruff/Makefile | 12 +++++------- devel/rustc-demangle/Makefile | 4 ++-- devel/rye/Makefile | 2 +- devel/signal-fts5-extension/Makefile | 2 +- devel/spr/Makefile | 2 +- devel/tabby/Makefile | 2 +- devel/uv/Makefile | 2 +- devel/xtensa-esp-elf/Makefile | 2 +- editors/parinfer-rust/Makefile | 2 +- finance/hyperswitch/Makefile | 2 +- games/veloren-weekly/Makefile | 2 +- graphics/librsvg2-rust/Makefile | 6 ------ graphics/ocrs/Makefile | 2 +- graphics/oxipng/Makefile | 2 +- graphics/resvg-capi/Makefile | 4 ++-- japanese/sudachi/Makefile | 2 +- lang/cairo/Makefile | 2 +- lang/inko/Makefile | 4 ++-- lang/numbat/Makefile | 2 +- lang/prql/Makefile | 2 +- lang/starlark-rust/Makefile | 2 +- math/fend/Makefile | 2 +- misc/py-pyqir/Makefile | 2 +- misc/quary/Makefile | 2 +- multimedia/helvum/Makefile | 1 - multimedia/kooha/Makefile | 1 - multimedia/ringrtc/Makefile | 2 +- multimedia/video-trimmer/Makefile | 1 - multimedia/wl-screenrec/Makefile | 2 +- net-im/fractal/files/patch-scripts_cargo.sh | 4 ++-- net-im/libsignal-client/Makefile | 2 +- net-im/zkgroup/Makefile | 2 +- net-mgmt/gping/Makefile | 2 +- net-p2p/cncli/Makefile | 5 +++++ net/narrowlink/Makefile | 2 +- net/ntpd-rs/Makefile | 2 +- net/quiche/Makefile | 10 +++++----- net/trippy/Makefile | 2 +- ports-mgmt/sccache-overlay/Makefile | 4 ++-- security/arti/Makefile | 2 +- security/authenticator/Makefile | 1 - security/pam_rssh/Makefile | 2 +- security/rage-encryption/Makefile | 2 +- security/rpm-sequoia/Makefile | 2 +- security/solana/Makefile | 2 +- shells/atuin/Makefile | 2 +- sysutils/bkt/Makefile | 2 +- sysutils/fd/Makefile | 4 ++-- sysutils/rust-coreutils/Makefile | 24 ++++++++++++------------ sysutils/systeroid/Makefile | 2 +- textproc/jql/Makefile | 2 +- textproc/tokay/Makefile | 2 +- textproc/typst/Makefile | 2 +- www/deno-dom/Makefile | 2 +- www/deno/Makefile | 2 +- www/varnish-libvmod-fileserver/Makefile | 2 +- x11/clipcat/Makefile | 2 +- x11/rio/Makefile | 2 +- x11/shotman/Makefile | 2 +- x11/squeekboard/files/patch-cargo__build.py | 2 +- x11/swww/Makefile | 2 +- x11/xdg-desktop-portal-luminous/Makefile | 2 +- 82 files changed, 110 insertions(+), 125 deletions(-)
Committed.
This regresses https://github.com/lu-zero/cargo-c/issues/223 which affects $ rg -l :devel/cargo-c | sed 's,/[^/]*$,,' audio/ebur128 audio/lewton graphics/libimagequant japanese/cskk multimedia/gstreamer1-plugins-rust multimedia/librav1e security/rustls-ffi
(In reply to Jan Beich from comment #3) Hi Jan, devel/cargo-c succeeds for me on 14.1-STABLE, and dependent ports succeed too. What is the error message that you are seeing? Yuri
(In reply to Yuri Victorovich from comment #4) cargo-c consumers no longer respect CC thus cannot use native-xtoolchain (bug 257588) to cross-build aarch64 packages on amd64 machine (assuming bug 221185 is fixed or worked around). rustc needs CC to link binaries but native-xtoolchain sets CC to /nxb-bin/usr/bin/cc. https://docs.freebsd.org/en/books/porters-handbook/porting-dads/#dads-cc To reproduce simply set CC then abort build if CC is ignored e.g., $ ln -s `which false` /tmp/cc $ env PATH=/tmp:$PATH USE_GCC=yes make clean all -C /usr/ports/graphics/libimagequant [...] error: linking with `cc` failed: exit status: 1
(In reply to Jan Beich from comment #5) Hi Jan, The command suggested by you above fails with non-existent cc for me: > $ env PATH=/tmp:$PATH USE_GCC=yes make clean all -C /usr/ports/graphics/libimagequant > [...skipped...] > error: linking with `cc` failed: exit status: 1 It succeeds with the original cc. This means that the build does respect the CC variable. Yuri
(In reply to Yuri Victorovich from comment #6) > It succeeds with the original cc. USE_GCC=yes sets CC=gcc13, so /usr/bin/cc shouldn't be used. Back in ports 93924a20b38e until ports 96118b60cdc3 USES=cargo implicitly added USE_GCC=yes on FreeBSD < 13 powerpc64.
(In reply to Jan Beich from comment #7) I can reproduce the problem, but I don't have a solution yet. Please also note that CC is printed as gcc13 by this command both before and after the commit: > $ env PATH=/tmp:$PATH USE_GCC=yes make -C /usr/ports/graphics/libimagequant -V CC The invalid "cc" is somehow used by the build after the commit in question but not before it.
devel/cargo-c uses the Rust crate "cc" which explicitly looks for the C compiler by the hard-coded name. The list of names is in cargo-crates/cc-1.1.30/src/lib.rs line 2881: > let (env, msvc, gnu, traditional, clang) = if self.cpp { > ("CXX", "cl.exe", "g++", "c++", "clang++") > } else { > ("CC", "cl.exe", "gcc", "cc", "clang") > }; It doesn't just use the CC environment variable as expected in the ports framework. It looks like it might be looking up the "cc" executable through PATH and using it instead of CC when cross-compilation isn't enabled.
I asked upstream the relevant question: https://github.com/lu-zero/cargo-c/issues/419
Hi Jan, Based on the answer that I received for my question in the Rust ML this should be a solution: > RUSTFLAGS+="-Clinker=${CC}" But adding this to Mk/Uses/cargo.mk would probably require an exp-run. Yuri
(In reply to Yuri Victorovich from comment #11) >> RUSTFLAGS+="-Clinker=${CC}" It doesn't help cargo-c. Also, was already passed before ports 93924a20b38e which you failed to restore in ports f99a708957bd.
(In reply to Jan Beich from comment #12) > It doesn't help cargo-c. Upstream reason is documented in https://github.com/lu-zero/cargo-c/commit/a68c8c3f57e9 per https://github.com/lu-zero/cargo-c/issues/223 (mentioned in comment 3 here).
A commit in branch 2024Q4 references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=dbd1f33e374d07a1b5f16a282bf3eb7ee78913b5 commit dbd1f33e374d07a1b5f16a282bf3eb7ee78913b5 Author: Yuri Victorovich <yuri@FreeBSD.org> AuthorDate: 2024-10-23 03:00:55 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2024-11-05 08:08:25 +0000 Mk/Uses/cargo.mk: Remove cross-compilation options for Rust-based ports Reasons: * Port build shouldn't use cross-compilation mode because it buids for the same architecture. * RUSTFLAGS isn't passed to the build of all or some Rust ports in the cross-compilation mode. Essential changes: * Remove the CARGO_BUILD_TARGET make variable. * Remove CARGO_BUILD_TARGET and CARGO_TARGET_* from CARGO_ENV. * Update many ports that used CARGO_BUILD_TARGET. * Build paths now don't include the architecture triplet part. Immadiate benefits: * Unbreak build on architectures like i386 that sometimes require special RUSTFLAGS that were not effective in the cross-compilation mode. Ports that really need cross-compilation for some reason should enable it on case-by-case basis. Example: net-p2p/cncli (Not sure why does net-p2p/cncli actually need it, but it only builds with these options.) PR: 280305 Approved by: rust@FreeBSD.org (maintainer's timeout; 98 days) Mk/Uses/cargo.mk | 5 ----- audio/amberol/Makefile | 1 - audio/gnome-metronome/Makefile | 1 - audio/gnome-podcasts/Makefile | 1 - audio/mousai/Makefile | 1 - audio/shortwave/Makefile | 1 - databases/greptimedb/Makefile | 2 +- databases/redisjson/Makefile | 2 +- deskutils/health/Makefile | 1 - deskutils/rwpspread/Makefile | 6 +++--- deskutils/solanum/Makefile | 1 - devel/evcxr-jupyter/Makefile | 4 ++-- devel/jetbrains-restarter/Makefile | 2 +- devel/jujutsu/Makefile | 2 +- devel/libdatadog/Makefile | 12 ++++++------ devel/libdatadog/pkg-plist | 3 +++ devel/librashader/Makefile | 4 ++-- devel/libwasmtime/Makefile | 4 ++-- devel/nextest/Makefile | 2 +- devel/pijul/Makefile | 2 +- devel/ruff/Makefile | 12 +++++------- devel/rustc-demangle/Makefile | 4 ++-- devel/rye/Makefile | 2 +- devel/signal-fts5-extension/Makefile | 2 +- devel/spr/Makefile | 2 +- devel/tabby/Makefile | 2 +- devel/uv/Makefile | 2 +- devel/xtensa-esp-elf/Makefile | 2 +- editors/parinfer-rust/Makefile | 2 +- finance/hyperswitch/Makefile | 2 +- games/veloren-weekly/Makefile | 2 +- graphics/librsvg2-rust/Makefile | 6 ------ graphics/ocrs/Makefile | 2 +- graphics/oxipng/Makefile | 2 +- graphics/resvg-capi/Makefile | 4 ++-- japanese/sudachi/Makefile | 2 +- lang/cairo/Makefile | 2 +- lang/inko/Makefile | 4 ++-- lang/numbat/Makefile | 2 +- lang/prql/Makefile | 2 +- lang/starlark-rust/Makefile | 2 +- math/fend/Makefile | 2 +- misc/py-pyqir/Makefile | 2 +- misc/quary/Makefile | 2 +- multimedia/helvum/Makefile | 1 - multimedia/kooha/Makefile | 1 - multimedia/ringrtc/Makefile | 2 +- multimedia/video-trimmer/Makefile | 1 - multimedia/wl-screenrec/Makefile | 2 +- net-im/fractal/files/patch-scripts_cargo.sh | 4 ++-- net-im/libsignal-client/Makefile | 2 +- net-im/zkgroup/Makefile | 2 +- net-mgmt/gping/Makefile | 2 +- net-p2p/cncli/Makefile | 5 +++++ net/narrowlink/Makefile | 2 +- net/ntpd-rs/Makefile | 2 +- net/quiche/Makefile | 10 +++++----- net/trippy/Makefile | 2 +- ports-mgmt/sccache-overlay/Makefile | 4 ++-- security/arti/Makefile | 2 +- security/authenticator/Makefile | 1 - security/pam_rssh/Makefile | 2 +- security/rage-encryption/Makefile | 2 +- security/rpm-sequoia/Makefile | 2 +- security/solana/Makefile | 2 +- shells/atuin/Makefile | 2 +- sysutils/bkt/Makefile | 2 +- sysutils/fd/Makefile | 4 ++-- sysutils/rust-coreutils/Makefile | 24 ++++++++++++------------ sysutils/systeroid/Makefile | 2 +- textproc/jql/Makefile | 2 +- textproc/tokay/Makefile | 2 +- textproc/typst/Makefile | 2 +- www/deno-dom/Makefile | 2 +- www/deno/Makefile | 2 +- www/varnish-libvmod-fileserver/Makefile | 2 +- x11/clipcat/Makefile | 2 +- x11/rio/Makefile | 2 +- x11/shotman/Makefile | 2 +- x11/squeekboard/files/patch-cargo__build.py | 2 +- x11/swww/Makefile | 2 +- 81 files changed, 109 insertions(+), 125 deletions(-)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=33610ebde0d5033268c2f299084331aba133324e commit 33610ebde0d5033268c2f299084331aba133324e Author: Jan Beich <jbeich@FreeBSD.org> AuthorDate: 2024-11-24 11:30:45 +0000 Commit: Jan Beich <jbeich@FreeBSD.org> CommitDate: 2024-11-24 11:52:42 +0000 Remove remnant comments/code after f99a708957bd PR: 280305 audio/amberol/Makefile | 1 - audio/gnome-metronome/Makefile | 1 - audio/gnome-podcasts/Makefile | 1 - audio/mousai/Makefile | 1 - audio/shortwave/Makefile | 1 - deskutils/health/Makefile | 1 - deskutils/solanum/Makefile | 1 - multimedia/helvum/Makefile | 1 - multimedia/kooha/Makefile | 1 - multimedia/video-trimmer/Makefile | 1 - security/authenticator/Makefile | 1 - x11/squeekboard/files/patch-cargo__build.py (gone) | 21 --------------------- x11/xdg-desktop-portal-luminous/Makefile | 1 - 13 files changed, 33 deletions(-)