diff options
author | Ayke van Laethem <[email protected]> | 2021-02-12 01:34:22 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2022-05-18 15:20:09 +0200 |
commit | 109b5298c4b2e068a00de5376d9552ace4a5cda4 (patch) | |
tree | 224d2f72ec5c0cfae7cc0a88f7082dd11f5f9006 /builder/library.go | |
parent | a94e03eff26792effe80ec3accb8c251d165681e (diff) | |
download | tinygo-109b5298c4b2e068a00de5376d9552ace4a5cda4.tar.gz tinygo-109b5298c4b2e068a00de5376d9552ace4a5cda4.zip |
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.
Diffstat (limited to 'builder/library.go')
-rw-r--r-- | builder/library.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/builder/library.go b/builder/library.go index 01c5ebd14..1a2ed61c2 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") } |