-
Notifications
You must be signed in to change notification settings - Fork 9
/
bootstrap_compiler
executable file
·38 lines (19 loc) · 1.77 KB
/
bootstrap_compiler
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
#!/usr/bin/env bash
# Use the bootstrapping compiler to compile the compiler written in L2 and replace the self-hosting and test compilers with the result
set -e
mkdir -p bin
echo "* Compiling assembly support routines ..."
gcc -nostdlib -static -g -c -o bin/x86_64_linux_interface.o bootstrap/x86_64_linux_interface.s
echo "* Compiling the bootstrap compiler ..."
gcc -nostdlib -static -g -o bin/l2compile0 bootstrap/compile.c bin/x86_64_linux_interface.o
echo "* Compiling the instruction wrappers that provide x86-64 functionality ..."
gcc --static -g -c -o bin/x86_64.o bootstrap/x86_64.s
objcopy --redefine-syms=bootstrap/x86_64_sym_pairs bin/x86_64.o
cd ./src
echo "* Compiling L2 source code into object files ..."
../bin/l2compile0 core-meta.l2 text-meta.l2 flow-meta.l2 elf-meta.l2 x86-64-linux-interface.l2 lexer.l2 x86-64-object.l2 expressions.l2 x86-64-assembler.l2 analysis.l2 x86-64-generator.l2 compile.l2 list.l2 64-numbers.l2 hash-table.l2 x86-64-arithmetic-intrinsics.l2 - - ../bin/x86_64.o
echo "* Linking the produced object files together and replacing l2compile ..."
gold --section-start .text=0x400000 --entry 0x400000 --unresolved-symbols ignore-in-object-files x86-64-linux-interface.o lexer.o x86-64-object.o expressions.o x86-64-assembler.o analysis.o x86-64-generator.o x86-64-arithmetic-intrinsics.o list.o 64-numbers.o hash-table.o elf-meta.o text-meta.o compile.o flow-meta.o ../bin/x86_64.o -o ../bin/l2compile
cp ../bin/l2compile ../bin/l2compilet
echo "* Removing the intermediate files ..."
rm "hash-table.o" "x86-64-linux-interface.o" "lexer.o" "x86-64-object.o" "expressions.o" "x86-64-assembler.o" "analysis.o" "x86-64-generator.o" "x86-64-arithmetic-intrinsics.o" "compile.o" "list.o" "64-numbers.o" "elf-meta.o" "flow-meta.o" "text-meta.o" "core-meta.o"