@@ -4,74 +4,82 @@ in early on the next big quarantine hobby :'-)
4
4
5
5
----
6
6
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.
9
10
10
11
``` 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 \
16
17
--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=...
18
24
19
- # this took 16? hours on my poor lil laptop :'-)
20
25
make -j8
21
26
sudo make install-strip
22
27
```
23
28
24
- and use it :
29
+ next, set up the environment :
25
30
26
31
``` 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
35
37
36
- ``` sh
38
+ # home for our cross toolchain so that its isolated from the hosts'
37
39
export PREFIX=/usr/local/cross
38
40
export PATH=" $PREFIX /bin:$PATH "
41
+
39
42
export TARGET=i686-elf
40
43
```
41
44
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.
45
47
46
48
``` 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 \
50
52
--target=$TARGET \
51
53
--prefix=" $PREFIX " \
52
54
--with-sysroot \
53
55
--disable-nls \
54
- --disable-werror
56
+ --disable-werror \
57
+ --with-gmp-include=... \
58
+ --with-gmp-lib=... \
59
+ --with-mpfr-include=... \
60
+ --with-mpfr-lib=...
55
61
56
62
make -j8
57
63
sudo make install
58
64
```
59
65
60
- and the cross compiler:
66
+ finally, our cross compiler: :
61
67
62
68
``` 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 \
69
72
--prefix=" $PREFIX " \
70
73
--target=$TARGET \
71
74
--disable-nls \
72
75
--enable-languages=c,c++ \
73
76
--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=...
75
83
76
84
make -j8 all-gcc
77
85
make -j8 all-target-libgcc
0 commit comments