avr: use compiler-rt
This change adds support for compiler-rt, which supports float64 (unlike libgcc for AVR). This gets a number of tests to pass that require float64 support. We're still using libgcc with this change, but libgcc will probably be removed eventually once AVR support in compiler-rt is a bit more mature. I've also pushed a fix for a small regression in our xtensa_release_14.0.0-patched LLVM branch that has also been merged upstream. Without it, a floating point comparison against zero always returns true which is certainly a bug. It is necessary to correctly print floating point values.
Этот коммит содержится в:
родитель
a94e03eff2
коммит
109b5298c4
7 изменённых файлов: 26 добавлений и 23 удалений
|
@ -22,12 +22,12 @@ commands:
|
|||
steps:
|
||||
- restore_cache:
|
||||
keys:
|
||||
- llvm-source-14-v1
|
||||
- llvm-source-14-v2
|
||||
- run:
|
||||
name: "Fetch LLVM source"
|
||||
command: make llvm-source
|
||||
- save_cache:
|
||||
key: llvm-source-14-v1
|
||||
key: llvm-source-14-v2
|
||||
paths:
|
||||
- llvm-project/clang/lib/Headers
|
||||
- llvm-project/clang/include
|
||||
|
|
6
.github/workflows/linux.yml
предоставленный
6
.github/workflows/linux.yml
предоставленный
|
@ -38,7 +38,7 @@ jobs:
|
|||
uses: actions/cache@v2
|
||||
id: cache-llvm-source
|
||||
with:
|
||||
key: llvm-source-14-linux-v1
|
||||
key: llvm-source-14-linux-v2
|
||||
path: |
|
||||
llvm-project/clang/lib/Headers
|
||||
llvm-project/clang/include
|
||||
|
@ -179,7 +179,7 @@ jobs:
|
|||
uses: actions/cache@v2
|
||||
id: cache-llvm-source
|
||||
with:
|
||||
key: llvm-source-14-linux-asserts-v1
|
||||
key: llvm-source-14-linux-asserts-v2
|
||||
path: |
|
||||
llvm-project/clang/lib/Headers
|
||||
llvm-project/clang/include
|
||||
|
@ -276,7 +276,7 @@ jobs:
|
|||
uses: actions/cache@v2
|
||||
id: cache-llvm-source
|
||||
with:
|
||||
key: llvm-source-14-linux-v1
|
||||
key: llvm-source-14-linux-v2
|
||||
path: |
|
||||
llvm-project/clang/lib/Headers
|
||||
llvm-project/clang/include
|
||||
|
|
2
.github/workflows/windows.yml
предоставленный
2
.github/workflows/windows.yml
предоставленный
|
@ -37,7 +37,7 @@ jobs:
|
|||
uses: actions/cache@v2
|
||||
id: cache-llvm-source
|
||||
with:
|
||||
key: llvm-source-14-windows-v1
|
||||
key: llvm-source-14-windows-v2
|
||||
path: |
|
||||
llvm-project/clang/lib/Headers
|
||||
llvm-project/clang/include
|
||||
|
|
|
@ -40,7 +40,6 @@ var genericBuiltins = []string{
|
|||
"divdf3.c",
|
||||
"divdi3.c",
|
||||
"divmoddi4.c",
|
||||
"divmodsi4.c",
|
||||
"divsc3.c",
|
||||
"divsf3.c",
|
||||
"divsi3.c",
|
||||
|
@ -127,7 +126,6 @@ var genericBuiltins = []string{
|
|||
"ucmpti2.c",
|
||||
"udivdi3.c",
|
||||
"udivmoddi4.c",
|
||||
"udivmodsi4.c",
|
||||
"udivmodti4.c",
|
||||
"udivsi3.c",
|
||||
"udivti3.c",
|
||||
|
@ -154,6 +152,14 @@ var aeabiBuiltins = []string{
|
|||
"arm/aeabi_memset.S",
|
||||
"arm/aeabi_uidivmod.S",
|
||||
"arm/aeabi_uldivmod.S",
|
||||
|
||||
// These two are not technically EABI builtins but are used by them and only
|
||||
// seem to be used on ARM. LLVM seems to use __divsi3 and __modsi3 on most
|
||||
// other architectures.
|
||||
// Most importantly, they have a different calling convention on AVR so
|
||||
// should not be used on AVR.
|
||||
"divmodsi4.c",
|
||||
"udivmodsi4.c",
|
||||
}
|
||||
|
||||
// CompilerRT is a library with symbols required by programs compiled with LLVM.
|
||||
|
|
|
@ -148,6 +148,8 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ
|
|||
// However, ARM has not done this.
|
||||
if strings.HasPrefix(target, "i386") || strings.HasPrefix(target, "x86_64") {
|
||||
args = append(args, "-march="+cpu)
|
||||
} else if strings.HasPrefix(target, "avr") {
|
||||
args = append(args, "-mmcu="+cpu)
|
||||
} else {
|
||||
args = append(args, "-mcpu="+cpu)
|
||||
}
|
||||
|
@ -155,6 +157,13 @@ func (l *Library) load(config *compileopts.Config, tmpdir string) (job *compileJ
|
|||
if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
|
||||
args = append(args, "-fshort-enums", "-fomit-frame-pointer", "-mfloat-abi=soft", "-fno-unwind-tables", "-fno-asynchronous-unwind-tables")
|
||||
}
|
||||
if strings.HasPrefix(target, "avr") {
|
||||
// AVR defaults to C float and double both being 32-bit. This deviates
|
||||
// from what most code (and certainly compiler-rt) expects. So we need
|
||||
// to force the compiler to use 64-bit floating point numbers for
|
||||
// double.
|
||||
args = append(args, "-mdouble=64")
|
||||
}
|
||||
if strings.HasPrefix(target, "riscv32-") {
|
||||
args = append(args, "-march=rv32imac", "-mabi=ilp32", "-fforce-enable-int128")
|
||||
}
|
||||
|
|
17
main_test.go
17
main_test.go
|
@ -182,11 +182,6 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) {
|
|||
// Not all tests are currently supported on AVR.
|
||||
// Skip the ones that aren't.
|
||||
switch name {
|
||||
case "atomic.go":
|
||||
// Requires GCC 11.2.0 or above for interface comparison.
|
||||
// https://github.com/gcc-mirror/gcc/commit/f30dd607669212de135dec1f1d8a93b8954c327c
|
||||
continue
|
||||
|
||||
case "reflect.go":
|
||||
// Reflect tests do not work due to type code issues.
|
||||
continue
|
||||
|
@ -203,20 +198,12 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) {
|
|||
// Reflect size calculation crashes.
|
||||
continue
|
||||
|
||||
case "binop.go":
|
||||
// Interface comparison results are inverted.
|
||||
continue
|
||||
|
||||
case "channel.go":
|
||||
// Freezes after recv from closed channel.
|
||||
continue
|
||||
|
||||
case "float.go", "math.go", "print.go":
|
||||
// Stuck in runtime.printfloat64.
|
||||
continue
|
||||
|
||||
case "interface.go":
|
||||
// Several comparison tests fail.
|
||||
case "math.go":
|
||||
// Stuck somewhere, not sure what's happening.
|
||||
continue
|
||||
|
||||
case "cgo/":
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
"gc": "conservative",
|
||||
"linker": "avr-gcc",
|
||||
"scheduler": "none",
|
||||
"rtlib": "compiler-rt",
|
||||
"default-stack-size": 256,
|
||||
"cflags": [
|
||||
"-Werror"
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче