diff --git a/.circleci/config.yml b/.circleci/config.yml index ca09e4aa..d0d2e40e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7dd5fbbf..114959b0 100644 --- a/.github/workflows/linux.yml +++ b/.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 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 0ee5aebf..896bdb77 100644 --- a/.github/workflows/windows.yml +++ b/.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 diff --git a/builder/builtins.go b/builder/builtins.go index 479b541d..121398fa 100644 --- a/builder/builtins.go +++ b/builder/builtins.go @@ -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. diff --git a/builder/library.go b/builder/library.go index 01c5ebd1..1a2ed61c 100644 --- a/builder/library.go +++ b/builder/library.go @@ -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") } diff --git a/main_test.go b/main_test.go index 6139b74b..0e6bdfbd 100644 --- a/main_test.go +++ b/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/": diff --git a/targets/avr.json b/targets/avr.json index fbf43064..0915370c 100644 --- a/targets/avr.json +++ b/targets/avr.json @@ -6,6 +6,7 @@ "gc": "conservative", "linker": "avr-gcc", "scheduler": "none", + "rtlib": "compiler-rt", "default-stack-size": 256, "cflags": [ "-Werror"