Last active
December 29, 2017 02:27
-
-
Save jessicah/49784be0dd199d5537cb1c701ebc93eb to your computer and use it in GitHub Desktop.
Building rust cross-compiler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install cmake ninja-build curl git python nasm autoconf automake texinfo flex bison gawk build-essential unzip wget zip less zlib1g-dev libcurl4-openssl-dev genisoimage libtool | |
git clone --depth=1 https://github.com:/haiku/buildtools | |
git clone --depth=1 https://github.com:/haiku/haiku | |
git clone https://github.com:/rust-lang/rust --recursive | |
cd ~/buildtools/ | |
make | |
sudo ./jam0 install | |
cd ~/haiku/ | |
git remote add upstream https://git.haiku-os.org/haiku | |
git fetch upstream --tags | |
mkdir generated | |
cd generated/ | |
../configure --build-cross-tools x86_64 ../../buildtools --use-gcc-pipe -j16 | |
jam -q -j16 @nightly-raw | |
cd ~/ | |
cat >package.sh <<-EOF | |
#!/bin/bash | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/haiku/generated/objects/linux/lib | |
$HOME/haiku/generated/objects/linux/x86_64/release/tools/package/package $@ | |
EOF | |
chmod a+x package.sh | |
wget https://gist.githubusercontent.com/jessicah/5bc1da8f72ace11d77a42335951242e6/raw/build_cross_tools_gcc4 | |
chmod a+x build_cross_tools_gcc4 | |
mkdir cross | |
./build_cross_tools_gcc4 x86_64-unknown-haiku ./haiku/ ./buildtools/ cross -j16 | |
sudo ln -s $HOME/cross/sysroot/boot/system/ /system | |
wget http://packages.haiku-os.org/haikuports/master/hpkg/llvm-4.0.1-1-x86_64.hpkg | |
wget http://packages.haiku-os.org/haikuports/master/hpkg/llvm_libs-4.0.1-1-x86_64.hpkg | |
./package.sh extract -C cross/sysroot/boot/system/ llvm-4.0.1-1-x86_64.hpkg | |
./package.sh extract -C cross/sysroot/boot/system/ llvm_libs-4.0.1-1-x86_64.hpkg | |
find haiku/generated/objects/haiku/x86_64/packaging/repositories/ -name '*.hpkg' -exec ./package.sh extract -C cross/sysroot/boot/system/ {} \; | |
./package.sh extract -C cross/sysroot/boot/system/ ~/haiku/generated/download/gcc_syslibs-*.hpkg | |
./package.sh extract -C cross/sysroot/boot/system/ ~/haiku/generated/download/gcc_syslibs_devel-*.hpkg | |
cd ~/cross/sysroot/boot/system/develop/lib/ | |
ln -s ../../lib/libgcc_s.so libgcc_s.so | |
cd ~/ | |
cp ~/cross/sysroot/boot/system/develop/headers/c++/x86_64-unknown-haiku/bits/c++config.h ~/cross/x86_64-unknown-haiku/include/c++/5.4.0/x86_64-unknown-haiku/bits/c++config.h | |
cat >cross/bin/llvm-config <<-EOF | |
#!/bin/sh | |
case $1 in | |
--version) echo 4.0.1;; | |
--prefix) echo $SCRATCH/haiku-cross/sysroot/boot/system;; | |
--bindir) echo $SCRATCH/haiku-cross/sysroot/boot/system/bin;; | |
--includedir) echo $SCRATCH/haiku-cross/sysroot/boot/system/develop/headers;; | |
--libdir) echo $SCRATCH/haiku-/cross/sysroot/boot/system/develop/lib;; | |
--cmakedir) echo $SCRATCH/haiku-/cross/sysroot/boot/system/develop/lib/cmake/llvm;; | |
--cppflags) echo -I$SCRATCH/haiku-/cross/sysroot/boot/system/develop/headers -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;; | |
--cflags) echo -I$SCRATCH/haiku-cross/sysroot/boot/system/develop/headers -fPIC -Wall -W -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment -Werror=date-time -ffunction-sections -fdata-sections -O3 -DNDEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;; | |
--cxxflags) echo -I/$SCRATCH/haiku-cross/sysroot/boot/system/develop/headers -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor -Wno-comment -Werror=date-time -std=c++11 -ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;; | |
--ldflags) echo -L$SCRATCH/haiku-cross/sysroot/boot/system/develop/lib ;; | |
--system-libs) echo ;; | |
--libs) echo -lLLVM-4.0;; | |
--libfiles) echo $SCRATCH/haiku-cross/sysroot/boot/system/develop/lib/libLLVM-4.0.so;; | |
--components) echo aarch64 aarch64asmparser aarch64asmprinter aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils all all-targets amdgpu amdgpuasmparser amdgpuasmprinter amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armasmprinter armcodegen armdesc armdisassembler arminfo asmparser asmprinter bitreader bitwriter bpf bpfasmprinter bpfcodegen bpfdesc bpfdisassembler bpfinfo codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfomsf debuginfopdb demangle engine executionengine globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader lanai lanaiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo lanaiinstprinter libdriver lineeditor linker lto mc mcdisassembler mcjit mcparser mips mipsasmparser mipsasmprinter mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmprinter msp430codegen msp430desc msp430info native nativecodegen nvptx nvptxasmprinter nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit passes powerpc powerpcasmparser powerpcasmprinter powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata riscv riscvcodegen riscvdesc riscvinfo runtimedyld scalaropts selectiondag sparc sparcasmparser sparcasmprinter sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzasmprinter systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target transformutils vectorize x86 x86asmparser x86asmprinter x86codegen x86desc x86disassembler x86info x86utils xcore xcoreasmprinter xcorecodegen xcoredesc xcoredisassembler xcoreinfo;; | |
--host-target) echo x86_64-unknown-haiku;; | |
--has-rtti) echo YES;; | |
--shared-mode) echo shared;; | |
esac | |
EOF | |
chmod a+x cross/bin/llvm-config | |
cd ~/rust/ | |
cat >config.toml <<-EOF | |
[llvm] | |
enabled = true | |
ninja = true | |
link-shared = true | |
[build] | |
host = ["x86_64-unknown-haiku"] | |
target = ["x86_64-unknown-haiku"] | |
docs = false | |
compiler-docs = false | |
submodules = false | |
[install] | |
prefix="$HOME/install" | |
[rust] | |
use-jemalloc = false | |
[target.x86_64-unknown-haiku] | |
cc = "x86_64-unknown-haiku-gcc" | |
cxx = "x86_64-unknown-haiku-g++" | |
llvm-config = "$HOME/cross/bin/llvm-config" | |
[dist] | |
src-tarball = false | |
EOF | |
export PATH=$PATH:$HOME/cross/bin | |
./x.py build | |
./x.py dist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment