Subject: [bug#28433] [WIP] Rust update

From: Danny Milosavljevic <[email-masked]>
Date: Thu, 26 Oct 2017 10:17:28 +0200

Hi,

Rust as I posted it fails with the text below.  It tries to compile and link rustc via bootstrap rustc and gcc, via a i686 compiler (also on x86_64).  What the error message means is that it is only picking up the x86_64 glibc - and not the i686 glibc - even though the "cc" command line contains "-m32".  I've even added a custom linker command to the rust config (also in the patch) but that doesn't help either - apparently that setting is not even picked up.  Maybe that's the reason... 

Rust has support for Nix somewhat, and I've enabled it in the bootstrapper.  I've also added cross-libc for i686 and fixed up environment variables (in a hacky way - maybe that's the reason).

So I guess my actual question is how to do this cross compilation correctly.  Note that the rust bootstrap compiler are binaries from upstream.  (There's a project "mrust" <https://github.com/thepowersgang/mrustc> that is a reimplementation of Rust in C++ that we could use in the long term in order to remove this binary)

----------------------------------------------------------
     Running `/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/bin/rustc --crate-name rustdoc src/bootstrap/bin/rustdoc.rs --crate-type bin --emit=dep-info,link -C 
debug-assertions=off -C metadata=83218ce7652a40a2 -C extra-filename=-83218ce7652a40a2 --out-dir /tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps -L depe
ndency=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps --extern rustc_serialize=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/deb
ug/deps/librustc_serialize-5c8c719f8cb442df.rlib --extern getopts=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libgetopts-781edef4d7eacd14.rlib --ex
tern gcc=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libgcc-3c79a13fa356000a.rlib --extern libc=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src
/build/bootstrap/debug/deps/liblibc-1ece201356dd0812.rlib --extern toml=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libtoml-3495572d91ba2dfe.rlib -
-extern num_cpus=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libnum_cpus-d81d39a56ecc4645.rlib --extern build_helper=/tmp/guix-build-rustc-1.18.0.d
rv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libbuild_helper-d1189496287db707.rlib --extern filetime=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libfiletime-1fba24aeada37bf3.rlib --extern cmake=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libcmake-4feacbf6844c5e86.rlib --extern bootstrap=/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libbootstrap-3ebfecab87ea2884.rlib`
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m32" "-L" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/rustdoc-83218ce7652a40a2.0.o" "-o" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/rustdoc-83218ce7652a40a2" "-Wl,--gc-sections" "-pie" "-nodefaultlibs" "-L" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps" "-L" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libbootstrap-3ebfecab87ea2884.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libtoml-3495572d91ba2dfe.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/librustc_serialize-5c8
 c719f8cb442df.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libnum_cpus-d81d39a56ecc4645.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libcmake-4feacbf6844c5e86.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libgcc-3c79a13fa356000a.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libbuild_helper-d1189496287db707.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libfiletime-1fba24aeada37bf3.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/liblibc-1ece201356dd0812.rlib" "/tmp/guix-build-rustc-1.18.0.drv-0/rustc-1.18.0-src/build/bootstrap/debug/deps/libgetopts-781edef4d7eacd14.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/libstd-f4594d3e53dcb114.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq
 -rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/libpanic_unwind-a0157c0ca919c364.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/libunwind-488b4ab4bd53a138.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/librand-1efbcfd8938372b6.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/libcollections-532a3dbf317eff86.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc-ca07b617414dd0fa.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc_jemalloc-492d8ea7fa3384ff.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/liblibc-88c194c15fdb6521.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-ru
 stc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/libstd_unicode-cfbd6648f7db2ee5.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/libcore-687e6a964d22cbb4.rlib" "/gnu/store/zmcc9gizicl91qvpcnl7ric2klnqhsdq-rustc-bootstrap-1.17.0/lib/rustlib/i686-unknown-linux-gnu/lib/libcompiler_builtins-987729be881d4d32.rlib" "-l" "util" "-l" "dl" "-l" "rt" "-l" "pthread" "-l" "gcc_s" "-l" "pthread" "-l" "c" "-l" "m" "-l" "rt" "-l" "util"

  = note: ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libutil.so when searching for -lutil
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libutil.a when searching for -lutil
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libutil.so when searching for -lutil
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libutil.a when searching for -lutil
          ld: cannot find -lutil
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libdl.so when searching for -ldl
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libdl.a when searching for -ldl
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libdl.so when searching for -ldl
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libdl.a when searching for -ldl
          ld: cannot find -ldl
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/librt.so when searching for -lrt
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/librt.a when searching for -lrt
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/librt.so when searching for -lrt
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/librt.a when searching for -lrt
          ld: cannot find -lrt
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libpthread.so when searching for -lpthread
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libpthread.a when searching for -lpthread
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libpthread.so when searching for -lpthread
          ld: skipping incompatible /gnu/store/n6nvxlk2j8ysffjh3jphn1k5silnakh6-glibc-2.25/lib/libpthread.a when searching for -lpthread
          ld: cannot find -lpthread
          ld: skipping incompatible /gnu/store/3x53yv4v144c9xp02rs64z7j597kkqax-gcc-5.4.0-lib/lib/gcc/x86_64-unknown-linux-gnu/5.4.0/../../../libgcc_s.so when searching for -lgcc_s
          ld: cannot find -lgcc_s
----------------------------------------------------------