Skip to content

Commit cbc9031

Browse files
committed
ci: introduce haiku x86_64 builder
1 parent a209539 commit cbc9031

File tree

4 files changed

+171
-0
lines changed

4 files changed

+171
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM ubuntu:16.04
2+
3+
RUN apt-get update && apt-get install -y --no-install-recommends \
4+
autoconf \
5+
automake \
6+
bison \
7+
bzip2 \
8+
ca-certificates \
9+
cmake \
10+
curl \
11+
file \
12+
flex \
13+
g++ \
14+
gawk \
15+
git \
16+
libcurl4-openssl-dev \
17+
libssl-dev \
18+
make \
19+
nasm \
20+
pkg-config \
21+
python2.7 \
22+
sudo \
23+
texinfo \
24+
wget \
25+
xz-utils \
26+
zlib1g-dev
27+
28+
COPY dist-x86_64-haiku/llvm-config /bin/llvm-config-haiku
29+
30+
ENV ARCH=x86_64
31+
32+
WORKDIR /tmp
33+
COPY dist-x86_64-haiku/build-toolchain.sh /tmp/
34+
RUN /tmp/build-toolchain.sh $ARCH
35+
36+
COPY dist-x86_64-haiku/fetch-packages.sh /tmp/
37+
RUN /tmp/fetch-packages.sh
38+
39+
COPY scripts/sccache.sh /scripts/
40+
RUN sh /scripts/sccache.sh
41+
42+
ENV HOST=x86_64-unknown-haiku
43+
ENV TARGET=target.$HOST
44+
45+
ENV RUST_CONFIGURE_ARGS --host=$HOST --target=$HOST --disable-jemalloc \
46+
--set=$TARGET.cc=x86_64-unknown-haiku-gcc \
47+
--set=$TARGET.cxx=x86_64-unknown-haiku-g++ \
48+
--set=$TARGET.llvm-config=/bin/llvm-config-haiku
49+
ENV SCRIPT python2.7 ../x.py dist
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
set -ex
13+
14+
ARCH=$1
15+
16+
TOP=$(pwd)
17+
18+
BUILDTOOLS=$TOP/buildtools
19+
HAIKU=$TOP/haiku
20+
OUTPUT=/tools
21+
SYSROOT=$OUTPUT/cross-tools-$ARCH/sysroot
22+
PACKAGE_ROOT=/system
23+
24+
hide_output() {
25+
set +x
26+
on_err="
27+
echo ERROR: An error was encountered with the build.
28+
cat /tmp/build.log
29+
exit 1
30+
"
31+
trap "$on_err" ERR
32+
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
33+
PING_LOOP_PID=$!
34+
$@ &> /tmp/build.log
35+
trap - ERR
36+
kill $PING_LOOP_PID
37+
set -x
38+
}
39+
40+
# First up, build a cross-compiler
41+
git clone --depth=1 https://git.haiku-os.org/haiku
42+
git clone --depth=1 https://git.haiku-os.org/buildtools
43+
cd $BUILDTOOLS/jam
44+
hide_output make
45+
hide_output ./jam0 install
46+
mkdir -p $OUTPUT
47+
cd $OUTPUT
48+
hide_output $HAIKU/configure --build-cross-tools $ARCH $TOP/buildtools
49+
50+
# Set up sysroot to redirect to /system
51+
mkdir -p $SYSROOT/boot
52+
mkdir -p $PACKAGE_ROOT
53+
ln -s $PACKAGE_ROOT $SYSROOT/boot/system
54+
55+
# Build needed packages and tools for the cross-compiler
56+
hide_output jam -q haiku.hpkg haiku_devel.hpkg '<build>package'
57+
58+
# Set up our sysroot
59+
cp $OUTPUT/objects/linux/lib/*.so /lib/x86_64-linux-gnu
60+
cp $OUTPUT/objects/linux/x86_64/release/tools/package/package /bin/
61+
find $SYSROOT/../bin/ -type f -exec ln -s {} /bin/ \;
62+
63+
# Extract packages
64+
package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/$ARCH/packaging/packages/haiku.hpkg
65+
package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/$ARCH/packaging/packages/haiku_devel.hpkg
66+
find $OUTPUT/download/ -name '*.hpkg' -exec package extract -C $PACKAGE_ROOT {} \;
67+
68+
# Fix libgcc_s so we can link to it
69+
cd $PACKAGE_ROOT/develop/lib
70+
ln -s ../../lib/libgcc_s.so libgcc_s.so
71+
72+
# Clean up
73+
rm -rf $BUILDTOOLS $HAIKU $OUTPUT/Jamfile $OUTPUT/attributes $OUTPUT/build \
74+
$OUTPUT/build_packages $OUTPUT/download $OUTPUT/objects
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
wget http://packages.haiku-os.org/haikuports/master/hpkg/llvm-4.0.1-2-x86_64.hpkg
13+
wget http://packages.haiku-os.org/haikuports/master/hpkg/llvm_libs-4.0.1-2-x86_64.hpkg
14+
15+
package extract -C /system llvm-4.0.1-2-x86_64.hpkg
16+
package extract -C /system llvm_libs-4.0.1-2-x86_64.hpkg
17+
18+
rm -f *.hpkg
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
case $1 in
13+
--version) echo 4.0.1;;
14+
--prefix) echo $SCRATCH/haiku-cross/sysroot/boot/system;;
15+
--bindir) echo $SCRATCH/haiku-cross/sysroot/boot/system/bin;;
16+
--includedir) echo $SCRATCH/haiku-cross/sysroot/boot/system/develop/headers;;
17+
--libdir) echo $SCRATCH/haiku-/cross/sysroot/boot/system/develop/lib;;
18+
--cmakedir) echo $SCRATCH/haiku-/cross/sysroot/boot/system/develop/lib/cmake/llvm;;
19+
--cppflags) echo -I$SCRATCH/haiku-/cross/sysroot/boot/system/develop/headers -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;;
20+
--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;;
21+
--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;;
22+
--ldflags) echo -L$SCRATCH/haiku-cross/sysroot/boot/system/develop/lib ;;
23+
--system-libs) echo ;;
24+
--libs) echo -lLLVM-4.0;;
25+
--libfiles) echo $SCRATCH/haiku-cross/sysroot/boot/system/develop/lib/libLLVM-4.0.so;;
26+
--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;;
27+
--host-target) echo x86_64-unknown-haiku;;
28+
--has-rtti) echo YES;;
29+
--shared-mode) echo shared;;
30+
esac

0 commit comments

Comments
 (0)