Bug 235063 - devel/rust-cbindgen: fix build on tier2 arches
Summary: devel/rust-cbindgen: fix build on tier2 arches
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: FreeBSD Rust Team
URL: https://reviews.freebsd.org/D19309
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-19 16:32 UTC by Mikael Urankar
Modified: 2019-03-14 17:45 UTC (History)
3 users (show)

See Also:
jbeich: maintainer-feedback+


Attachments
patch (3.94 KB, patch)
2019-01-19 16:32 UTC, Mikael Urankar
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mikael Urankar freebsd_committer freebsd_triage 2019-01-19 16:32:51 UTC
Created attachment 201270 [details]
patch

fix build on aarch64 and powerpc64
Comment 1 Jan Beich freebsd_committer freebsd_triage 2019-01-19 19:25:28 UTC
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 2 Jan Beich freebsd_committer freebsd_triage 2019-01-27 02:51:24 UTC
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.
Comment 3 Mikael Urankar freebsd_committer freebsd_triage 2019-01-28 09:16:25 UTC
(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
Comment 4 Mikael Urankar freebsd_committer freebsd_triage 2019-01-28 17:34:30 UTC
Why does the default linker isn't used anyway? where does cc come from? it's supposed to be gcc7 or 8 on ppc.
Comment 5 Jan Beich freebsd_committer freebsd_triage 2019-02-02 15:42:54 UTC
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?
Comment 6 Mikael Urankar freebsd_committer freebsd_triage 2019-02-02 16:00:49 UTC
(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)
Comment 7 Jan Beich freebsd_committer freebsd_triage 2019-02-02 16:28:13 UTC
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.
Comment 8 Mikael Urankar freebsd_committer freebsd_triage 2019-02-02 16:43:54 UTC
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
Comment 9 Mikael Urankar freebsd_committer freebsd_triage 2019-02-11 13:19:04 UTC
same error with sysutils/exa
Comment 10 Tobias Kortkamp freebsd_committer freebsd_triage 2019-02-18 15:58:21 UTC
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
Comment 11 commit-hook freebsd_committer freebsd_triage 2019-02-28 18:48:31 UTC
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
Comment 12 Tobias Kortkamp freebsd_committer freebsd_triage 2019-03-01 12:42:16 UTC
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?
Comment 13 Jan Beich freebsd_committer freebsd_triage 2019-03-01 18:14:04 UTC
(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.
Comment 14 Jan Beich freebsd_committer freebsd_triage 2019-03-01 18:20:15 UTC
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. ;)
Comment 15 commit-hook freebsd_committer freebsd_triage 2019-03-02 00:36:15 UTC
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
Comment 16 Jan Beich freebsd_committer freebsd_triage 2019-03-14 17:45:18 UTC
After bug 236529 fix comment 3 shouldn't occur even if USE_GCC is dropped.