summaryrefslogtreecommitdiff
path: root/doc/README.CrossCompiling
blob: 74f31cee3f3f889e964d275505365de5a7dc440e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
Intro
-----

You can compile AbaOS from a 32-bit host or chroot (e.g. Arch32 chroot).
But you have to be extremly careful that nothing ceeps into the kernel
from the host system.

You can also create a cross-compilation environment. Now, we don't need
a full fledged chain, linker and C compiler is enough. AbaOs has a small
integrated C library which is sufficient to build the kernel.

gcc
---

mkdir -p $HOME/cross-compilers/gcc
cd $HOME/cross-compilers/gcc
wget https://ftp.gnu.org/gnu/binutils/binutils-2.28.tar.gz
tar xf binutils-2.28.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-2.28/configure --target=i486-elf --prefix=$HOME/cross-compilers --disable-nls -v
make all
make check
make install
cd ..

wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.lz
tar xf gmp-6.1.2.tar.lz
mkdir gmp-build
cd gmp-build
../gmp-6.1.2/configure --build=i486-elf --host=i486-elf --prefix=$HOME/cross-compilers
make all
make check
make install
cd ..

wget http://www.mpfr.org/mpfr-current/mpfr-3.1.5.tar.gz
tar xf mpfr-3.1.5.tar.gz
mkdir mpfr-build
cd mpfr-build
../mpfr-3.1.5/configure --build=i486-elf --host=i486-elf --prefix=$HOME/cross-compilers \
	--with-gmp=$HOME/cross-compilers
make all
make check
make install
cd ..

wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
tar xf mpc-1.0.3.tar.gz
mkdir mpc-build
cd mpc-build
../mpc-1.0.3/configure --host=i486-elf --target=i486-elf \
	--prefix=$HOME/cross-compilers \
	--with-gmp=$HOME/cross-compilers \
	--with-mpfr=$HOME/cross-compilers
make all
make check
make install
cd ..

wget ftp://ftp.mpi-sb.mpg.de/pub/gnu/mirror/gcc.gnu.org/pub/gcc/releases/gcc-7.1.0/gcc-7.1.0.tar.gz
tar zxf gcc-7.1.0.tar.gz
mkdir gcc-build
cd gcc-build
../gcc-7.1.0/configure --target=i486-elf --prefix=$HOME/cross-compilers \
	--with-gnu-as --with-gnu-ld \
	--disable-nls --enable-languages=c --disable-libgcj --without-headers \
	--with-gmp=$HOME/cross-compilers \
	--with-mpfr=$HOME/cross-compilers \
	--with-mpc=$HOME/cross-compilers
make all-gcc
make all-target-libgcc
make install-gcc
make install-target-libgcc

Compile abaos and libc tests with:

setenv PATH "${PATH}:$HOME/cross-compilers"
make clean all CC=i486-elf-gcc LD=i486-elf-ld


tcc
---

mkdir -p $HOME/cross-compilers/tcc
cd $HOME/cross-compilers/tcc
wget https://ftp.gnu.org/gnu/binutils/binutils-2.28.tar.gz
tar xf binutils-2.28.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-2.28/configure --target=i486-elf --prefix=$HOME/cross-compilers --disable-nls -v
make all
make check
make install
cd ..

mkdir -p $HOME/cross-compilers/tcc
cd $HOME/cross-compilers/tcc
git clone git://repo.or.cz/tinycc.git
cd tinycc
./configure --cpu=i386 --enable-cross --prefix=$HOME/cross-compilers
make
cd ..

Compile abaos and libc tests with:

setenv PATH "${PATH}:$HOME/cross-compilers"
make clean all CC=i386-tcc LD=i486-elf-ld

pcc
---

mkdir -p $HOME/cross-compilers/pcc
cd $HOME/cross-compilers/pcc
wget https://ftp.gnu.org/gnu/binutils/binutils-2.28.tar.gz
tar xf binutils-2.28.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-2.28/configure --target=i486-unknown-linux-gnu --prefix=$HOME/cross-compilers --disable-nls -v
make all
make check
make install
cd ..

mkdir -p $HOME/cross-compilers/pcc
cvs -d :pserver:anonymous@pcc.ludd.ltu.se:/cvsroot co pcc-libs
mkdir pcc-libs-build
cd pcc-libs-build
../pcc-libs/configure --target=i486-unknown-linux-gnu --prefix=$HOME/cross-compilers
make
make install
cd ..

cvs -d :pserver:anonymous@pcc.ludd.ltu.se:/cvsroot co pcc
mkdir pcc-build
cd pcc-build
../pcc/configure --target=i486-unknown-linux-gnu --prefix=$HOME/cross-compilers
make
make install

Compile abaos and libc tests with:

setenv PATH "${PATH}:$HOME/cross-compilers"
make clean all CC=i486-unknown-linux-gnu-pcc LD=i486-unknown-linux-gnu-ld

clang
-----

Clang is easy, usually it already supports common targets. Just
for the kernel we need a i486 linker from binutils:

mkdir -p $HOME/cross-compilers/pcc
cd $HOME/cross-compilers/pcc
wget https://ftp.gnu.org/gnu/binutils/binutils-2.28.tar.gz
tar xf binutils-2.28.tar.gz
mkdir binutils-build
cd binutils-build
../binutils-2.28/configure --target=i486-unknown-linux-gnu --prefix=$HOME/cross-compilers --disable-nls -v
make all
make check
make install
cd ..

Compile abaos and libc tests with:

setenv PATH "${PATH}:$HOME/cross-compilers"
make clean all run-qemu CC='clang -target i386-pc-none-abi' LD=i486-unknown-linux-gnu-ld

Links
-----

https://ftp.gnu.org/gnu/binutils/
http://wiki.osdev.org/Target_Triplet
http://wiki.osdev.org/GCC_Cross-Compiler