-
Notifications
You must be signed in to change notification settings - Fork 10
/
riscv_rules.hancho
46 lines (41 loc) · 1.27 KB
/
riscv_rules.hancho
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
# FIXME could merge these with base_rules.hancho
riscv64_toolchain = hancho.Config(
arch="riscv64",
compiler="riscv64-unknown-elf-g++",
linker="riscv64-unknown-elf-g++",
)
rv_config = hancho.Config(
rv_toolchain = "riscv64-unknown-elf",
rv_flags_c = [
"{rv_opt_mode}",
"-std=gnu++2a",
"-mabi=ilp32",
"-march=rv32i_zicsr", # _zicsr needed with newer GCC?
"-mstrict-align",
"-g",
"-MMD"
],
rv_opt_mode = "-O0",
warnings = None,
defines = None,
includes = None,
joined_warnings = "{join_prefix('-W', warnings)}",
joined_defines = "{join_prefix('-D', defines)}",
joined_includes = "{join_prefix('-I', includes)}",
)
rv_compile = hancho.Config(
rv_config,
command = "{rv_toolchain}-g++ {rv_flags_c} {joined_warnings} {joined_defines} {joined_includes} -c {in_src} -o {out_obj}",
out_obj = "{swap_ext(in_src, '.o')}",
in_depfile = "{swap_ext(out_obj, '.d')}",
)
rv_link = hancho.Config(
rv_config,
command = "{rv_toolchain}-gcc {rv_flags_c} {in_objs} -o {out_bin} -lgcc",
rv_flags_c = rv_config.rv_flags_c + [
"-nostdlib",
"-nostartfiles",
"-Wl,-T {linkerscript}",
],
linkerscript = "{repo_dir}/pinwheel/tools/pinwheel.ld",
)