Skip to content

Commit dad1c0e

Browse files
committed
riscv: add support for compiler-rt
This gets all the tests to compile and many of them to pass. There are some issues left, but those are probably unrelated to compiler-rt.
1 parent 44b3df9 commit dad1c0e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

builder/builtins.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ func CompileBuiltins(target string, callback func(path string) error) error {
236236
// Note: -fdebug-prefix-map is necessary to make the output archive
237237
// reproducible. Otherwise the temporary directory is stored in the
238238
// archive itself, which varies each run.
239-
err := execCommand(commands["clang"], "-c", "-Oz", "-g", "-Werror", "-Wall", "-std=c11", "-fshort-enums", "-nostdlibinc", "-ffunction-sections", "-fdata-sections", "--target="+target, "-fdebug-prefix-map="+dir+"="+remapDir, "-o", objpath, srcpath)
239+
args := []string{"-c", "-Oz", "-g", "-Werror", "-Wall", "-std=c11", "-fshort-enums", "-nostdlibinc", "-ffunction-sections", "-fdata-sections", "--target=" + target, "-fdebug-prefix-map=" + dir + "=" + remapDir}
240+
if strings.HasPrefix(target, "riscv32-") {
241+
args = append(args, "-march=rv32imac", "-mabi=ilp32", "-fforce-enable-int128")
242+
}
243+
err := execCommand(commands["clang"], append(args, "-o", objpath, srcpath)...)
240244
if err != nil {
241245
return &commandError{"failed to build", srcpath, err}
242246
}

targets/riscv.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"gc": "conservative",
77
"compiler": "clang",
88
"linker": "ld.lld",
9+
"rtlib": "compiler-rt",
910
"cflags": [
1011
"--target=riscv32--none",
1112
"-march=rv32imac",

0 commit comments

Comments
 (0)