Created attachment 201270 [details] patch fix build on aarch64 and powerpc64
I'd prefer for this to land upstream first. After that libc crate can be bumped in every USES=cargo consumer. And new ports would be warned if libc is too old, similar to ino64 after ports r472373.
Comment on attachment 201270 [details] patch > -USES= cargo > +USES= cargo compiler:c++11-lang Why? Is this specific to cbindgen (this port)? I've tried to build with in-base GCC 4.2 on 13.0 amd64 but there were no issues.
(In reply to Jan Beich from comment #2) Have you tried on ppc64? /usr/local/bin/rustc -v --crate-name build_script_build /usr/ports/devel/rust-cbindgen/work/cbindgen-0.7.1/cargo-crates/serde-1.0.64/build.rs --color always --crate-type bin --emit=dep-info,link -C opt-level=2 --cfg 'feature="default"' --cfg 'feature="derive"' --cfg 'feature="serde_derive"' --cfg 'feature="std"' -C metadata=915e58bbae8349b8 -C extra-filename=-915e58bbae8349b8 --out-dir /usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8 -L dependency=/usr/ports/devel/rust-cbindgen/work/target/release/deps --cap-lints allow -C linker=cc -C link-arg= error: linking with `cc` failed: exit code: 1 | = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.0.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.1.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.10.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.11.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.12.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.13.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.14.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.15.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.2.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.3.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.4.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.5.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.6.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.7.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.8.rcgu.o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.build_script_build.4g191kcm-cgu.9.rcgu.o" "-o" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8" "/usr/ports/devel/rust-cbindgen/work/target/release/build/serde-915e58bbae8349b8/build_script_build-915e58bbae8349b8.2g41zkk9evkorm4z.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/usr/ports/devel/rust-cbindgen/work/target/release/deps" "-L" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib/libstd-398760fa0f42b403.rlib" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib/libpanic_unwind-b79c23953af9042f.rlib" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib/libunwind-2107fcd3cb22b901.rlib" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib/liblibc-44ad042864fcd9e2.rlib" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib/liballoc-9e80857740486bce.rlib" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib/libcore-670ca0bddc47c93a.rlib" "-Wl,--end-group" "/usr/local/lib/rustlib/powerpc64-unknown-freebsd/lib/libcompiler_builtins-cbe738a36f7f96a5.rlib" "-Wl,-Bdynamic" "-lexecinfo" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "" = note: cc: : No such file or directory. rust requires gcc7 or 8 on pp
Why does the default linker isn't used anyway? where does cc come from? it's supposed to be gcc7 or 8 on ppc.
Is this specific to devel/rust-cbindgen or affects any USES=cargo consumer? If the latter I'd prefer to move the quirk there, so even new ports can benefit from it. As review D18367 adds USE_GCC for powerpc64 USES=compiler:c++11-lang in consumers is probably a chain dependency. However, forcing USE_GCC on amd64 didn't trigger the error in comment 3. Looking more closely, "" just after "-lutil" appears to be the culprit. Can you track it down where "" comes from?
(In reply to Jan Beich from comment #5) I tracked it down to https://reviews.freebsd.org/D18528, $CC is not the default 'rust linker' on ppc64 and it breaks the build. The port builds fine with this patch reverted. I don't have access to my ppc board and can't test other ports, but I assume it will be the same (gcc (cc) is still v4.2.1 on ppc, and I assume USE_GCC won't give you this old version on amd64)
Thanks. I agree default-linker from config.toml and -C linker from USES=cargo should be in sync. At the moment, review D18367 proposes USE_GCC=7 for lang/rust and this bug proposes USE_GCC=yes (lang/gcc8 after bug 231590) via USES=compiler:c++11-lang for consumers. Can you unify on one GCC version, preferably via USES=compiler:c++11-lang? Sorry, my testing on amd64 was flawed as lang/rust doesn't respect CC/CXX after ports r449914.
USE_GCC=7 is only useful for the bootstrap (gcc7 is hardcoded in the bootstrap binary), gcc8 can be used for building rust. I should probably do the same thing we do for lang/ghc:https://svnweb.freebsd.org/ports/head/lang/ghc/bsd.ghc.mk?r1=486978&r2=486977&pathrev=486978 I've regenerated the bootstrap with gcc8 fwiw
same error with sysutils/exa
cargo.mk currently uses ${CC} as selected by the user for the linker. It should be easy to overwrite it on powerpc64 and set it to either gcc8 explicitly or just not pass -C linker to rustc if the user has not overwritten CC or something. As for the libc patches, upstreaming them is the only good way to deal with it. Adding the same patches 30 times (or whatever the current number of Rust ports is) is a bad idea. I see that the some (or all?) of the needed patches are already upstream [1]. Let's hope they release a new libc crate version soon, then we can proceed as Jan has suggested in comment #1. [1] https://github.com/rust-lang/libc/blob/master/src/unix/bsd/freebsdlike/freebsd
A commit references this bug: Author: jbeich Date: Thu Feb 28 18:47:42 UTC 2019 New revision: 494175 URL: https://svnweb.freebsd.org/changeset/ports/494175 Log: USES=cargo to update libc to 0.2.49 for Tier2 PR: 235063 Differential Revision: https://reviews.freebsd.org/D19309 Changes: head/Mk/Uses/cargo.mk head/audio/spotifyd/Makefile head/audio/spotifyd/distinfo head/benchmarks/hyperfine/Makefile head/benchmarks/hyperfine/distinfo head/databases/puppetdb-cli/Makefile head/databases/puppetdb-cli/distinfo head/devel/bingrep/Makefile head/devel/bingrep/distinfo head/devel/git-absorb/Makefile head/devel/git-absorb/distinfo head/devel/interactive_rebase_tool/Makefile head/devel/interactive_rebase_tool/distinfo head/devel/pijul/Makefile head/devel/pijul/distinfo head/devel/racer/Makefile head/devel/racer/distinfo head/devel/racerd/Makefile head/devel/racerd/distinfo head/devel/rust-bindgen/Makefile head/devel/rust-bindgen/distinfo head/devel/rust-cbindgen/Makefile head/devel/rust-cbindgen/distinfo head/devel/sccache/Makefile head/devel/sccache/distinfo head/devel/tokei/Makefile head/devel/tokei/distinfo head/dns/doh-proxy/Makefile head/dns/doh-proxy/distinfo head/editors/kak-lsp/Makefile head/editors/kak-lsp/distinfo head/editors/parinfer-rust/Makefile head/editors/parinfer-rust/distinfo head/editors/xi-core/Makefile head/editors/xi-core/distinfo head/games/genact/Makefile head/games/genact/distinfo head/net/rabbiteer/Makefile head/net/rabbiteer/distinfo head/net/routinator/Makefile head/net/routinator/distinfo head/security/cargo-audit/Makefile head/security/cargo-audit/distinfo head/sysutils/exa/Makefile head/sysutils/exa/distinfo head/sysutils/flowgger/Makefile head/sysutils/flowgger/distinfo head/sysutils/fusefs-sandboxfs/Makefile head/sysutils/fusefs-sandboxfs/distinfo head/sysutils/hexyl/Makefile head/sysutils/hexyl/distinfo head/sysutils/potnet/Makefile head/sysutils/potnet/distinfo head/textproc/bat/Makefile head/textproc/bat/distinfo head/textproc/ripgrep/Makefile head/textproc/ripgrep/distinfo head/textproc/xsv-rs/Makefile head/textproc/xsv-rs/distinfo head/www/firefox/Makefile head/www/geckodriver/Makefile head/www/geckodriver/distinfo head/www/newsboat/Makefile head/www/newsboat/distinfo head/www/websocat/Makefile head/www/websocat/distinfo head/x11/admiral/Makefile head/x11/admiral/distinfo head/x11/alacritty/Makefile head/x11/alacritty/distinfo
So now that every USES=cargo port has libc 0.2.49, how should we fix the error from comment #3 on powerpc64? Do we just add .if ${ARCH} == powerpc64 USE_GCC?= yes .endif to cargo.mk and call it good enough for now?
(In reply to Tobias Kortkamp from comment #12) Yes, USES=cargo should be in sync with lang/rust. Once Clang on powerpc64 is ready we'd need to patch out cargo:rustc-link-lib=static=stdc++ (in bundled LLVM), anyway.
Omitting -C linker=${CC:Q} on powerpc64 is not enough. USE_GCC machinery implies passing -Wl,-rpath. If one of USES=cargo consumers uses libgcc_s or libstdc++ we may end up in the same mess libgfortran incurs on Clang architectures. ;)
A commit references this bug: Author: tobik Date: Sat Mar 2 00:35:34 UTC 2019 New revision: 494349 URL: https://svnweb.freebsd.org/changeset/ports/494349 Log: Mk/Uses/cargo.mk: Require ports gcc on powerpc64 same as lang/rust PR: 235063 Changes: head/Mk/Uses/cargo.mk
After bug 236529 fix comment 3 shouldn't occur even if USE_GCC is dropped.