Bug 235063 - devel/rust-cbindgen: fix build on tier2 arches
Summary: devel/rust-cbindgen: fix build on tier2 arches
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-gecko mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-19 16:32 UTC by mikael.urankar
Modified: 2019-02-18 15:58 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (gecko)


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 2019-01-19 16:32:51 UTC
Created attachment 201270 [details]
patch

fix build on aarch64 and powerpc64
Comment 1 Jan Beich freebsd_committer 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 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 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 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 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 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 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 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 2019-02-11 13:19:04 UTC
same error with sysutils/exa
Comment 10 Tobias Kortkamp freebsd_committer 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