avr: use compiler-rt

This commit is contained in:
Ayke van Laethem
2020-04-14 17:55:07 +02:00
parent 43d7f48de4
commit ce0abac5a3
10 changed files with 60 additions and 18 deletions
+8 -2
View File
@@ -16,8 +16,10 @@ var genericBuiltins = []string{
"addvsi3.c",
"addvti3.c",
"apple_versioning.c",
"ashlsi3.c",
"ashldi3.c",
"ashlti3.c",
"ashrsi3.c",
"ashrdi3.c",
"ashrti3.c",
"bswapdi2.c",
@@ -72,7 +74,9 @@ var genericBuiltins = []string{
"floatunsisf.c",
"floatuntidf.c",
"floatuntisf.c",
//"int_util.c",
"fp_mode.c",
"int_util.c",
"lshrsi3.c",
"lshrdi3.c",
"lshrti3.c",
"moddi3.c",
@@ -86,6 +90,7 @@ var genericBuiltins = []string{
"muloti4.c",
"mulsc3.c",
"mulsf3.c",
"mulsi3.c",
"multi3.c",
"multf3.c",
"mulvdi3.c",
@@ -108,6 +113,7 @@ var genericBuiltins = []string{
"powidf2.c",
"powisf2.c",
"powitf2.c",
"powixf2.c",
"subdf3.c",
"subsf3.c",
"subvdi3.c",
@@ -159,7 +165,7 @@ var aeabiBuiltins = []string{
var CompilerRT = Library{
name: "compiler-rt",
cflags: func() []string { return []string{"-Werror", "-Wall", "-std=c11", "-nostdlibinc"} },
sourceDir: "lib/compiler-rt/lib/builtins",
sourceDir: "llvm-project.master/compiler-rt/lib/builtins",
sources: func(target string) []string {
builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins
if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
+3
View File
@@ -74,6 +74,9 @@ func (l *Library) Load(target string) (path string, err error) {
if strings.HasPrefix(target, "riscv32-") {
args = append(args, "-march=rv32imac", "-mabi=ilp32", "-fforce-enable-int128")
}
if strings.HasPrefix(target, "avr-") {
args = append(args, "-mdouble=64", "-mmcu=atmega1284p")
}
// Compile all sources.
var objs []string
+1 -1
View File
@@ -4,7 +4,7 @@ package task
import "unsafe"
const stackSize = 256
const stackSize = 1024
// calleeSavedRegs is the list of registers that must be saved and restored when
// switching between tasks. Also see scheduler_avr.S that relies on the
+2 -2
View File
@@ -2,8 +2,8 @@
"inherits": ["atmega328p"],
"build-tags": ["arduino"],
"ldflags": [
"-Wl,--defsym=_bootloader_size=512",
"-Wl,--defsym=_stack_size=512"
"--defsym=_bootloader_size=512",
"--defsym=_stack_size=512"
],
"flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i"
}
+2 -3
View File
@@ -7,9 +7,8 @@
"-mmcu=atmega1284p"
],
"ldflags": [
"-mmcu=avr51",
"-Wl,--defsym=_bootloader_size=0",
"-Wl,--defsym=_stack_size=512"
"--defsym=_bootloader_size=0",
"--defsym=_stack_size=512"
],
"linkerscript": "src/device/avr/atmega1284p.ld",
"extra-files": [
+1 -1
View File
@@ -7,7 +7,7 @@
"-mmcu=atmega328p"
],
"ldflags": [
"-mmcu=avr5"
"-mavr5"
],
"linkerscript": "src/device/avr/atmega328p.ld",
"extra-files": [
+24
View File
@@ -2,6 +2,30 @@
; in Go.
; The reset vector is device-specific and is generated by tools/gen-device-avr.py.
#ifndef xl
#define xl r26
#endif
#ifndef xh
#define xh r27
#endif
#ifndef yl
#define yl r28
#endif
#ifndef yh
#define yh r29
#endif
#ifndef zl
#define zl r30
#endif
#ifndef zh
#define zh r31
#endif
; Startup code
.section .text.__vector_RESET
.global __vector_RESET
+9 -4
View File
@@ -2,16 +2,21 @@
"build-tags": ["avr", "baremetal", "linux", "arm"],
"goos": "linux",
"goarch": "arm",
"compiler": "avr-gcc",
"compiler": "clang",
"gc": "conservative",
"linker": "avr-gcc",
"linker": "llvm-build.master/bin/ld.lld",
"scheduler": "none",
"rtlib": "compiler-rt",
"libc": "picolibc",
"cflags": [
"-gdwarf-4"
"--target=avr-atmel-none",
"-g",
"-Werror",
"-Qunused-arguments"
],
"ldflags": [
"-T", "targets/avr.ld",
"-Wl,--gc-sections"
"--gc-sections"
],
"extra-files": [
"src/runtime/scheduler_avr.S"
+9 -4
View File
@@ -5,17 +5,22 @@ MEMORY
RAM (xrw) : ORIGIN = 0x800000 + __ram_start, LENGTH = __ram_size
}
ENTRY(main)
SECTIONS
{
.text :
.text : ALIGN(2)
{
KEEP(*(.vectors))
KEEP(*(.text.__vector_RESET))
KEEP(*(.text.main)) /* main must follow the reset handler */
*(.text)
*(.text.*)
*(.rodata)
*(.rodata.*)
}
*(.progmem.data)
. = ALIGN(16); /* required because of lld (not sure why) */
} > FLASH_TEXT
.stack (NOLOAD) :
{
@@ -29,7 +34,7 @@ SECTIONS
{
_sdata = .; /* used by startup code */
*(.data)
*(.data*)
*(.data.*)
_edata = .; /* used by startup code */
} >RAM AT>FLASH_TEXT
@@ -37,7 +42,7 @@ SECTIONS
{
_sbss = .; /* used by startup code */
*(.bss)
*(.bss*)
*(.bss.*)
*(COMMON)
_ebss = .; /* used by startup code */
} >RAM
+1 -1
View File
@@ -407,7 +407,7 @@ __vector_default:
.endm
; The interrupt vector of this device. Must be placed at address 0 by the linker.
.section .vectors
.section .vectors, "a", %progbits
.global __vectors
`))
err = t.Execute(out, device.metadata)