Bootstrapping Rust on new platform?


#1

I’ve been working to get some previous Rust patches to bootstrap under Haiku included. Now that they’ve been merged upstream i’ve been trying to bootstrap the rust stage0 for the platform. I have instructions from another developer circa rust 1.6.0, however after the 1.10.0 rust bootstrapping changes I haven’t been able to find any general guidelines on where to get started creating the bootstrapped rustc binaries created.

anyone know an overview on how to bootstrap?

The original 1.6.0 instructions are here: http://rust-on-haiku.com/wiki/PortingRust

Thinks have changed enough since 1.6.0 that those are completely invalid now :slight_smile:


#2

The easiest way to bootstrap a new platform nowadays is:

$ ./configure --enable-rustbuild --host=x86_64-unknown-haiku
$ make dist

This needs to be run on a platform that can cross-compile to Haiku, but that’ll create a tarball which can then be used to bootstrap on Haiku itself


#3

–host vs --target?


#4

weird… I got a stage0 rust with support for Haiku, but the triple looks wrong and has _'s:

kallisti5@ares generated.haiku :slight_smile: $ build/x86_64-unknown-linux-gnu/stage0/bin/rustc --print target-list | grep haiku i686_unknown_haiku x86_64_unknown_haiku


#5

cough the _ issue is my bad :slight_smile:

https://github.com/rust-lang/rust/pull/36865


#6

Hm, getting closer. The libc git submodule in rust keeps reverting back to this libc commit:

commit d4f6a19c55a03e3f9f6fb7377911b37ed807eb6c
Merge: 574b293 0b5bdba
Author: bors <bors@rust-lang.org>
Date:   Wed Sep 7 12:26:36 2016 -0700

    Auto merge of #383 - uweigand:master, r=alexcrichton
    
    Add more s390x definitions
    
    This adds more Linux-specific definitions for s390x, to match the
    defines provided for other Linux targets.  Many of these will be
    required to build std, rustc, and cargo.
    
    In addition, this changes the type of sigaction.sa_flags to "int"
    to match current glibc after this bug fix was applied:
    https://sourceware.org/bugzilla/show_bug.cgi?id=16713
    
    Some other (cosmetic) changes to bring types in line with the
    exact types used in the glibc headers (e.g. ino64_t instead
    of ino_t in statfs64).
    
    Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>

Any way to force libc master?


#7

Try: ./configure --disable-manage-submodules

Or perhaps just git add the submodule to update your index.


#8

I see things heading in the right direction, but it’s missing some base libraries. I have the proper .so’s but it I can’t find the correct way to tell the rust build system about them.

Also, it appears to be using the system’s CC when it could be using the cross compiler?

export PATH=$PATH:/home/kallisti5/Code/haiku/generated.x86_64/cross-tools-x86_64/bin
./configure --enable-rustbuild --host=x86_64-unknown-haiku --disable-jemalloc
make dist

Build error:

Documenting stage2 error index (x86_64-unknown-linux-gnu)
Dist docs stage2 (x86_64-unknown-linux-gnu)
gen-installer: looking for programs
gen-installer: 
gen-installer: found tar
gen-installer: found cp
gen-installer: found rm
gen-installer: found mkdir
gen-installer: found echo
gen-installer: found tr
gen-installer: found awk
gen-installer: 
gen-installer: processing arguments
gen-installer: 
gen-installer: CFG_PRODUCT_NAME     := Rust-Documentation 
gen-installer: CFG_COMPONENT_NAME   := rust-docs 
gen-installer: CFG_PACKAGE_NAME     := rust-docs-1.14.0-dev-x86_64-unknown ...
gen-installer: CFG_REL_MANIFEST_DIR := rustlib 
gen-installer: CFG_SUCCESS_MESSAGE  := Rust-documentation-is-installed. 
gen-installer: CFG_LEGACY_MANIFEST_DIRS := rustlib,cargo 
gen-installer: CFG_NON_INSTALLED_OVERLAY :=  
gen-installer: CFG_BULK_DIRS        := share/doc/rust/html 
gen-installer: CFG_IMAGE_DIR        := /home/kallisti5/Code/rust/build/tmp ...
gen-installer: CFG_WORK_DIR         := /home/kallisti5/Code/rust/build/tmp ...
gen-installer: CFG_OUTPUT_DIR       := /home/kallisti5/Code/rust/build/dis ...
gen-installer: 
gen-installer: validating arguments
gen-installer: 
gen-install-script: looking for install programs
gen-install-script: 
gen-install-script: found sed
gen-install-script: found chmod
gen-install-script: found cat
gen-install-script: 
gen-install-script: processing arguments
gen-install-script: 
gen-install-script: CFG_PRODUCT_NAME     := Rust-Documentation 
gen-install-script: CFG_REL_MANIFEST_DIR := rustlib 
gen-install-script: CFG_SUCCESS_MESSAGE  := Rust-documentation-is-installed. 
gen-install-script: CFG_OUTPUT_SCRIPT    := /home/kallisti5/Code/rust/build/tmp ...
gen-install-script: CFG_LEGACY_MANIFEST_DIRS := rustlib,cargo 
gen-install-script: 
gen-install-script: validating arguments
gen-install-script: 
Dist std stage2 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
gen-installer: looking for programs
gen-installer: 
gen-installer: found tar
gen-installer: found cp
gen-installer: found rm
gen-installer: found mkdir
gen-installer: found echo
gen-installer: found tr
gen-installer: found awk
gen-installer: 
gen-installer: processing arguments
gen-installer: 
gen-installer: CFG_PRODUCT_NAME     := Rust 
gen-installer: CFG_COMPONENT_NAME   := rust-std-x86_64-unknown-linux-gnu 
gen-installer: CFG_PACKAGE_NAME     := rust-std-1.14.0-dev-x86_64-unknown- ...
gen-installer: CFG_REL_MANIFEST_DIR := rustlib 
gen-installer: CFG_SUCCESS_MESSAGE  := std-is-standing-at-the-ready. 
gen-installer: CFG_LEGACY_MANIFEST_DIRS := rustlib,cargo 
gen-installer: CFG_NON_INSTALLED_OVERLAY :=  
gen-installer: CFG_BULK_DIRS        :=  
gen-installer: CFG_IMAGE_DIR        := /home/kallisti5/Code/rust/build/tmp ...
gen-installer: CFG_WORK_DIR         := /home/kallisti5/Code/rust/build/tmp ...
gen-installer: CFG_OUTPUT_DIR       := /home/kallisti5/Code/rust/build/dis ...
gen-installer: 
gen-installer: validating arguments
gen-installer: 
gen-install-script: looking for install programs
gen-install-script: 
gen-install-script: found sed
gen-install-script: found chmod
gen-install-script: found cat
gen-install-script: 
gen-install-script: processing arguments
gen-install-script: 
gen-install-script: CFG_PRODUCT_NAME     := Rust 
gen-install-script: CFG_REL_MANIFEST_DIR := rustlib 
gen-install-script: CFG_SUCCESS_MESSAGE  := std-is-standing-at-the-ready. 
gen-install-script: CFG_OUTPUT_SCRIPT    := /home/kallisti5/Code/rust/build/tmp ...
gen-install-script: CFG_LEGACY_MANIFEST_DIRS := rustlib,cargo 
gen-install-script: 
gen-install-script: validating arguments
gen-install-script: 
Documenting stage2 standalone (x86_64-unknown-haiku)
Building stage2 std artifacts (x86_64-unknown-linux-gnu -> x86_64-unknown-haiku)
   Compiling core v0.0.0 (file:///home/kallisti5/Code/rust/src/libcore)
   Compiling unwind v0.0.0 (file:///home/kallisti5/Code/rust/src/libunwind)
   Compiling libc v0.0.0 (file:///home/kallisti5/Code/rust/src/rustc/libc_shim)
   Compiling compiler_builtins v0.0.0 (file:///home/kallisti5/Code/rust/src/libcompiler_builtins)
   Compiling std v0.0.0 (file:///home/kallisti5/Code/rust/src/libstd)
   Compiling alloc v0.0.0 (file:///home/kallisti5/Code/rust/src/liballoc)
   Compiling rustc_unicode v0.0.0 (file:///home/kallisti5/Code/rust/src/librustc_unicode)
   Compiling rand v0.0.0 (file:///home/kallisti5/Code/rust/src/librand)
   Compiling alloc_system v0.0.0 (file:///home/kallisti5/Code/rust/src/liballoc_system)
   Compiling panic_unwind v0.0.0 (file:///home/kallisti5/Code/rust/src/libpanic_unwind)
   Compiling panic_abort v0.0.0 (file:///home/kallisti5/Code/rust/src/libpanic_abort)
   Compiling collections v0.0.0 (file:///home/kallisti5/Code/rust/src/libcollections)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-m64" "-L" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-haiku/lib" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-haiku/release/deps/std-d8a6cc1478c5db9d.0.o" "-o" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-haiku/release/deps/libstd-d8a6cc1478c5db9d.so" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-haiku/release/deps/std-d8a6cc1478c5db9d.metadata.o" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-haiku/release/deps" "-L" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-haiku/release/build/std-07b7501857e2a858/out/.libs" "-L" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2-std/x86_64-unknown-haiku/release/build/compiler_builtins-9734521b54594229/out" "-L" "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-haiku/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "backtrace" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/libpanic_unwind-eb34f7fa41054e2f.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/libcollections-9733680f2020ce9f.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/liballoc-ed58344ca3d700e9.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/liballoc_system-15c47616c189f14f.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/librustc_unicode-f4b8177343581733.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/libunwind-daa256cef88cf5fa.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/liblibc-b7c62ebc89012cfb.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/librand-accc4b4a4017bf13.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.UQLCwR6S7PWF/libcore-254b2218cd876a2a.rlib" "-Wl,--no-whole-archive" "/tmp/rustc.UQLCwR6S7PWF/libcompiler_builtins-caf9eea0439968c2.rlib" "-l" "root" "-l" "network" "-shared" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /usr/bin/ld: cannot find -lroot
/usr/bin/ld: cannot find -lnetwork
collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: Could not compile `std`.

To learn more, run the command again with --verbose.


command did not execute successfully: "/home/kallisti5/Code/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "-j" "4" "--target" "x86_64-unknown-haiku" "--release" "--features" " backtrace" "--manifest-path" "/home/kallisti5/Code/rust/src/rustc/std_shim/Cargo.toml"
expected success, got: exit code: 101


Makefile:53: recipe for target 'dist' failed
make: *** [dist] Error 1


#9

You need to put our libs into the sysroot for the cross compiler.

Copy libs from our packages to cross-tools-<arch>/sysroot/boot/system/develop/lib (or perhaps system/lib). That got around the linking error for me.

I’m trying to build using the x.py script (no configure). In config.toml, you can configure the CC/CXX variables there for the build system to use.