Skip to content

Commit 8a7630a

Browse files
committed
resurrection
1 parent e9da963 commit 8a7630a

File tree

3 files changed

+45
-37
lines changed

3 files changed

+45
-37
lines changed

host/scripts/mkimg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ if (($# != 2)) || [[ ! -d $1 ]] || [[ ! -d $2 ]]; then
55
echo "expected arguments: [output directory] [sysroot]"
66
exit 1
77
fi
8-
OUT=$(realpath -s $1)
9-
SYSROOT=$(realpath -s $2)
8+
OUT=$(realpath $1)
9+
SYSROOT=$(realpath $2)
1010
IMAGE=${OUT}/beans.img
1111
MNT=${OUT}/mnt
1212
LOADK=${OUT}/loadk

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AS:=$(PREFIX)/bin/i686-elf-as
33
CC:=$(PREFIX)/bin/i686-elf-gcc
44
LD:=$(PREFIX)/bin/i686-elf-ld
55
OBJCOPY:=$(PREFIX)/bin/i686-elf-objcopy
6-
HOSTCC:=/usr/bin/gcc
6+
HOSTCC:=/usr/local/gcc-13.2.0/bin/gcc-13.2
77

88
BUILD_DIR:=build
99
BIN_DIR:=$(BUILD_DIR)/bin

readme.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,74 +4,82 @@ in early on the next big quarantine hobby :'-)
44

55
----
66

7-
i'm running macos 10.14.6, with gcc 4.2.1. before setting up our cross
8-
toolchain, let's grab latest gcc (10.2.0):
7+
i'm on an m1 running macos 13.13.1. we'll need gcc--i built and installed 13.2.0.
8+
as stated in gcc's docs, build _outside_ the source directory. there are
9+
also some build and runtime dependencies to be wary of.
910

1011
```sh
11-
mkdir gccbuild
12-
cd gccbuild
13-
../gcc-10.2.0/configure \
14-
--prefix=/usr/local/gcc-10.2.0 \
15-
--program-suffix=-10.2 \
12+
mkdir gcc-13.2.0.host.build
13+
cd gcc-13.2.0.host.build
14+
../gcc-13.2.0/configure \
15+
--prefix=/usr/local/gcc-13.2.0 \
16+
--program-suffix=-13.2 \
1617
--enable-checking=release \
17-
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
18+
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
19+
--with-gmp-include=... \
20+
--with-gmp-lib=... \
21+
--with-mpc=... \
22+
--with-mpfr-include=... \
23+
--with-mpfr-lib=...
1824

19-
# this took 16? hours on my poor lil laptop :'-)
2025
make -j8
2126
sudo make install-strip
2227
```
2328

24-
and use it:
29+
next, set up the environment:
2530

2631
```sh
27-
export CC=/usr/local/gcc-10.2.0/bin/gcc-10.2
28-
export CXX=/usr/local/gcc-10.2.0/bin/g++-10.2
29-
export CPP=/usr/local/gcc-10.2.0/bin/cpp-10.2
30-
export LD=/usr/local/gcc-10.2.0/bin/gcc-10.2
31-
```
32-
33-
next, set a home for our cross builds so that they're isolated from host
34-
tools, and what we're targeting:
32+
# use gcc we just installed
33+
export CC=/usr/local/gcc-13.2.0/bin/gcc-13.2
34+
export CXX=/usr/local/gcc-13.2.0/bin/g++-13.2
35+
export CPP=/usr/local/gcc-13.2.0/bin/cpp-13.2
36+
export LD=/usr/local/gcc-13.2.0/bin/gcc-13.2
3537

36-
```sh
38+
# home for our cross toolchain so that its isolated from the hosts'
3739
export PREFIX=/usr/local/cross
3840
export PATH="$PREFIX/bin:$PATH"
41+
3942
export TARGET=i686-elf
4043
```
4144

42-
now build binutils for our cross compiler. do this before building gcc,
43-
which presumably links target libraries--i ran into issues when i tried using
44-
gcc built without cross binutils:
45+
build cross binutils. do this before building cross gcc, which will link
46+
target libraries. i had to install texinfo first.
4547

4648
```sh
47-
mkdir crossbin
48-
cd crossbin
49-
../binutils-2.35/configure \
49+
mkdir binutils-2.41.cross.build
50+
cd binutils-2.41.cross.build
51+
../binutils-2.41/configure \
5052
--target=$TARGET \
5153
--prefix="$PREFIX" \
5254
--with-sysroot \
5355
--disable-nls \
54-
--disable-werror
56+
--disable-werror \
57+
--with-gmp-include=... \
58+
--with-gmp-lib=... \
59+
--with-mpfr-include=... \
60+
--with-mpfr-lib=...
5561

5662
make -j8
5763
sudo make install
5864
```
5965

60-
and the cross compiler:
66+
finally, our cross compiler::
6167

6268
```sh
63-
cd gcc-10.2.0
64-
./contrib/download_prequisites
65-
cd ..
66-
mkdir crossgcc
67-
cd crossgcc
68-
../gcc-10.2.0/configure \
69+
mkdir gcc-13.2.0.cross.build
70+
cd gcc-13.2.0.cross.build
71+
../gcc-13.2.0/configure \
6972
--prefix="$PREFIX" \
7073
--target=$TARGET \
7174
--disable-nls \
7275
--enable-languages=c,c++ \
7376
--without-headers \
74-
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
77+
--with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
78+
--with-gmp-include=... \
79+
--with-gmp-lib=... \
80+
--with-mpc=... \
81+
--with-mpfr-include=... \
82+
--with-mpfr-lib=...
7583

7684
make -j8 all-gcc
7785
make -j8 all-target-libgcc

0 commit comments

Comments
 (0)