mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
Compare commits
3 Commits
mips
...
avr-compiler-rt
| Author | SHA1 | Date | |
|---|---|---|---|
| ce0abac5a3 | |||
| 43d7f48de4 | |||
| f7f2082979 |
+8
-2
@@ -16,8 +16,10 @@ var genericBuiltins = []string{
|
|||||||
"addvsi3.c",
|
"addvsi3.c",
|
||||||
"addvti3.c",
|
"addvti3.c",
|
||||||
"apple_versioning.c",
|
"apple_versioning.c",
|
||||||
|
"ashlsi3.c",
|
||||||
"ashldi3.c",
|
"ashldi3.c",
|
||||||
"ashlti3.c",
|
"ashlti3.c",
|
||||||
|
"ashrsi3.c",
|
||||||
"ashrdi3.c",
|
"ashrdi3.c",
|
||||||
"ashrti3.c",
|
"ashrti3.c",
|
||||||
"bswapdi2.c",
|
"bswapdi2.c",
|
||||||
@@ -72,7 +74,9 @@ var genericBuiltins = []string{
|
|||||||
"floatunsisf.c",
|
"floatunsisf.c",
|
||||||
"floatuntidf.c",
|
"floatuntidf.c",
|
||||||
"floatuntisf.c",
|
"floatuntisf.c",
|
||||||
//"int_util.c",
|
"fp_mode.c",
|
||||||
|
"int_util.c",
|
||||||
|
"lshrsi3.c",
|
||||||
"lshrdi3.c",
|
"lshrdi3.c",
|
||||||
"lshrti3.c",
|
"lshrti3.c",
|
||||||
"moddi3.c",
|
"moddi3.c",
|
||||||
@@ -86,6 +90,7 @@ var genericBuiltins = []string{
|
|||||||
"muloti4.c",
|
"muloti4.c",
|
||||||
"mulsc3.c",
|
"mulsc3.c",
|
||||||
"mulsf3.c",
|
"mulsf3.c",
|
||||||
|
"mulsi3.c",
|
||||||
"multi3.c",
|
"multi3.c",
|
||||||
"multf3.c",
|
"multf3.c",
|
||||||
"mulvdi3.c",
|
"mulvdi3.c",
|
||||||
@@ -108,6 +113,7 @@ var genericBuiltins = []string{
|
|||||||
"powidf2.c",
|
"powidf2.c",
|
||||||
"powisf2.c",
|
"powisf2.c",
|
||||||
"powitf2.c",
|
"powitf2.c",
|
||||||
|
"powixf2.c",
|
||||||
"subdf3.c",
|
"subdf3.c",
|
||||||
"subsf3.c",
|
"subsf3.c",
|
||||||
"subvdi3.c",
|
"subvdi3.c",
|
||||||
@@ -159,7 +165,7 @@ var aeabiBuiltins = []string{
|
|||||||
var CompilerRT = Library{
|
var CompilerRT = Library{
|
||||||
name: "compiler-rt",
|
name: "compiler-rt",
|
||||||
cflags: func() []string { return []string{"-Werror", "-Wall", "-std=c11", "-nostdlibinc"} },
|
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 {
|
sources: func(target string) []string {
|
||||||
builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins
|
builtins := append([]string{}, genericBuiltins...) // copy genericBuiltins
|
||||||
if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
|
if strings.HasPrefix(target, "arm") || strings.HasPrefix(target, "thumb") {
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ func (l *Library) Load(target string) (path string, err error) {
|
|||||||
if strings.HasPrefix(target, "riscv32-") {
|
if strings.HasPrefix(target, "riscv32-") {
|
||||||
args = append(args, "-march=rv32imac", "-mabi=ilp32", "-fforce-enable-int128")
|
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.
|
// Compile all sources.
|
||||||
var objs []string
|
var objs []string
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// +build !byollvm
|
// +build !byollvm
|
||||||
// +build !llvm9
|
// +build !llvm9,!llvm11
|
||||||
|
|
||||||
package cgo
|
package cgo
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// +build !byollvm
|
||||||
|
// +build llvm11
|
||||||
|
|
||||||
|
package cgo
|
||||||
|
|
||||||
|
/*
|
||||||
|
#cgo linux CFLAGS: -I/usr/lib/llvm-11/include
|
||||||
|
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@11/include
|
||||||
|
#cgo freebsd CFLAGS: -I/usr/local/llvm11/include
|
||||||
|
#cgo linux LDFLAGS: -L/usr/lib/llvm-11/lib -lclang
|
||||||
|
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@11/lib -lclang -lffi
|
||||||
|
#cgo freebsd LDFLAGS: -L/usr/local/llvm11/lib -lclang
|
||||||
|
*/
|
||||||
|
import "C"
|
||||||
@@ -10,5 +10,5 @@ require (
|
|||||||
github.com/marcinbor85/gohex v0.0.0-20200531091804-343a4b548892
|
github.com/marcinbor85/gohex v0.0.0-20200531091804-343a4b548892
|
||||||
go.bug.st/serial v1.0.0
|
go.bug.st/serial v1.0.0
|
||||||
golang.org/x/tools v0.0.0-20200216192241-b320d3a0f5a2
|
golang.org/x/tools v0.0.0-20200216192241-b320d3a0f5a2
|
||||||
tinygo.org/x/go-llvm v0.0.0-20200503225853-345b2947b59d
|
tinygo.org/x/go-llvm v0.0.0-20200503224449-70c558526021
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -46,5 +46,5 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbO
|
|||||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
tinygo.org/x/go-llvm v0.0.0-20200503225853-345b2947b59d h1:hcX7vpB067GWM/EH4sGGOti0PMgIx+0bbZwUXctOIvE=
|
tinygo.org/x/go-llvm v0.0.0-20200503224449-70c558526021 h1:d8T98WXGjrTgDmMXgxa6nb9EAYXGXwnzXygnJl6d+ac=
|
||||||
tinygo.org/x/go-llvm v0.0.0-20200503225853-345b2947b59d/go.mod h1:fv1F0BSNpxMfCL0zF3M4OPFbgYHnhtB6ST0HvUtu/LE=
|
tinygo.org/x/go-llvm v0.0.0-20200503224449-70c558526021/go.mod h1:fv1F0BSNpxMfCL0zF3M4OPFbgYHnhtB6ST0HvUtu/LE=
|
||||||
|
|||||||
@@ -310,10 +310,12 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
|
|||||||
switch gdbInterface {
|
switch gdbInterface {
|
||||||
case "msd", "command", "":
|
case "msd", "command", "":
|
||||||
if len(config.Target.Emulator) != 0 {
|
if len(config.Target.Emulator) != 0 {
|
||||||
// Assume QEMU as an emulator.
|
|
||||||
if config.Target.Emulator[0] == "mgba" {
|
if config.Target.Emulator[0] == "mgba" {
|
||||||
gdbInterface = "mgba"
|
gdbInterface = "mgba"
|
||||||
|
} else if config.Target.Emulator[0] == "simavr" {
|
||||||
|
gdbInterface = "simavr"
|
||||||
} else {
|
} else {
|
||||||
|
// Assume QEMU as an emulator.
|
||||||
gdbInterface = "qemu"
|
gdbInterface = "qemu"
|
||||||
}
|
}
|
||||||
} else if openocdInterface != "" && config.Target.OpenOCDTarget != "" {
|
} else if openocdInterface != "" && config.Target.OpenOCDTarget != "" {
|
||||||
@@ -379,6 +381,14 @@ func FlashGDB(pkgName string, ocdOutput bool, options *compileopts.Options) erro
|
|||||||
daemon = exec.Command(config.Target.Emulator[0], args...)
|
daemon = exec.Command(config.Target.Emulator[0], args...)
|
||||||
daemon.Stdout = os.Stdout
|
daemon.Stdout = os.Stdout
|
||||||
daemon.Stderr = os.Stderr
|
daemon.Stderr = os.Stderr
|
||||||
|
case "simavr":
|
||||||
|
gdbCommands = append(gdbCommands, "target remote :1234")
|
||||||
|
|
||||||
|
// Run in an emulator.
|
||||||
|
args := append(config.Target.Emulator[1:], "-g", tmppath)
|
||||||
|
daemon = exec.Command(config.Target.Emulator[0], args...)
|
||||||
|
daemon.Stdout = os.Stdout
|
||||||
|
daemon.Stderr = os.Stderr
|
||||||
case "msd":
|
case "msd":
|
||||||
return errors.New("gdb is not supported for drag-and-drop programmable devices")
|
return errors.New("gdb is not supported for drag-and-drop programmable devices")
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ package task
|
|||||||
|
|
||||||
import "unsafe"
|
import "unsafe"
|
||||||
|
|
||||||
const stackSize = 256
|
const stackSize = 1024
|
||||||
|
|
||||||
// calleeSavedRegs is the list of registers that must be saved and restored when
|
// 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
|
// switching between tasks. Also see scheduler_avr.S that relies on the
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
"inherits": ["atmega328p"],
|
"inherits": ["atmega328p"],
|
||||||
"build-tags": ["arduino"],
|
"build-tags": ["arduino"],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"-Wl,--defsym=_bootloader_size=512",
|
"--defsym=_bootloader_size=512",
|
||||||
"-Wl,--defsym=_stack_size=512"
|
"--defsym=_stack_size=512"
|
||||||
],
|
],
|
||||||
"flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i"
|
"flash-command": "avrdude -c arduino -p atmega328p -P {port} -U flash:w:{hex}:i"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,9 +7,8 @@
|
|||||||
"-mmcu=atmega1284p"
|
"-mmcu=atmega1284p"
|
||||||
],
|
],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"-mmcu=avr51",
|
"--defsym=_bootloader_size=0",
|
||||||
"-Wl,--defsym=_bootloader_size=0",
|
"--defsym=_stack_size=512"
|
||||||
"-Wl,--defsym=_stack_size=512"
|
|
||||||
],
|
],
|
||||||
"linkerscript": "src/device/avr/atmega1284p.ld",
|
"linkerscript": "src/device/avr/atmega1284p.ld",
|
||||||
"extra-files": [
|
"extra-files": [
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"-mmcu=atmega328p"
|
"-mmcu=atmega328p"
|
||||||
],
|
],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"-mmcu=avr5"
|
"-mavr5"
|
||||||
],
|
],
|
||||||
"linkerscript": "src/device/avr/atmega328p.ld",
|
"linkerscript": "src/device/avr/atmega328p.ld",
|
||||||
"extra-files": [
|
"extra-files": [
|
||||||
|
|||||||
@@ -2,6 +2,30 @@
|
|||||||
; in Go.
|
; in Go.
|
||||||
; The reset vector is device-specific and is generated by tools/gen-device-avr.py.
|
; 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
|
; Startup code
|
||||||
.section .text.__vector_RESET
|
.section .text.__vector_RESET
|
||||||
.global __vector_RESET
|
.global __vector_RESET
|
||||||
|
|||||||
+13
-4
@@ -2,15 +2,24 @@
|
|||||||
"build-tags": ["avr", "baremetal", "linux", "arm"],
|
"build-tags": ["avr", "baremetal", "linux", "arm"],
|
||||||
"goos": "linux",
|
"goos": "linux",
|
||||||
"goarch": "arm",
|
"goarch": "arm",
|
||||||
"compiler": "avr-gcc",
|
"compiler": "clang",
|
||||||
"gc": "conservative",
|
"gc": "conservative",
|
||||||
"linker": "avr-gcc",
|
"linker": "llvm-build.master/bin/ld.lld",
|
||||||
"scheduler": "none",
|
"scheduler": "none",
|
||||||
|
"rtlib": "compiler-rt",
|
||||||
|
"libc": "picolibc",
|
||||||
|
"cflags": [
|
||||||
|
"--target=avr-atmel-none",
|
||||||
|
"-g",
|
||||||
|
"-Werror",
|
||||||
|
"-Qunused-arguments"
|
||||||
|
],
|
||||||
"ldflags": [
|
"ldflags": [
|
||||||
"-T", "targets/avr.ld",
|
"-T", "targets/avr.ld",
|
||||||
"-Wl,--gc-sections"
|
"--gc-sections"
|
||||||
],
|
],
|
||||||
"extra-files": [
|
"extra-files": [
|
||||||
"src/runtime/scheduler_avr.S"
|
"src/runtime/scheduler_avr.S"
|
||||||
]
|
],
|
||||||
|
"gdb": "avr-gdb"
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -5,17 +5,22 @@ MEMORY
|
|||||||
RAM (xrw) : ORIGIN = 0x800000 + __ram_start, LENGTH = __ram_size
|
RAM (xrw) : ORIGIN = 0x800000 + __ram_start, LENGTH = __ram_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ENTRY(main)
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
.text :
|
.text : ALIGN(2)
|
||||||
{
|
{
|
||||||
KEEP(*(.vectors))
|
KEEP(*(.vectors))
|
||||||
KEEP(*(.text.__vector_RESET))
|
KEEP(*(.text.__vector_RESET))
|
||||||
KEEP(*(.text.main)) /* main must follow the reset handler */
|
KEEP(*(.text.main)) /* main must follow the reset handler */
|
||||||
|
*(.text)
|
||||||
*(.text.*)
|
*(.text.*)
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
*(.rodata.*)
|
*(.rodata.*)
|
||||||
}
|
*(.progmem.data)
|
||||||
|
. = ALIGN(16); /* required because of lld (not sure why) */
|
||||||
|
} > FLASH_TEXT
|
||||||
|
|
||||||
.stack (NOLOAD) :
|
.stack (NOLOAD) :
|
||||||
{
|
{
|
||||||
@@ -29,7 +34,7 @@ SECTIONS
|
|||||||
{
|
{
|
||||||
_sdata = .; /* used by startup code */
|
_sdata = .; /* used by startup code */
|
||||||
*(.data)
|
*(.data)
|
||||||
*(.data*)
|
*(.data.*)
|
||||||
_edata = .; /* used by startup code */
|
_edata = .; /* used by startup code */
|
||||||
} >RAM AT>FLASH_TEXT
|
} >RAM AT>FLASH_TEXT
|
||||||
|
|
||||||
@@ -37,7 +42,7 @@ SECTIONS
|
|||||||
{
|
{
|
||||||
_sbss = .; /* used by startup code */
|
_sbss = .; /* used by startup code */
|
||||||
*(.bss)
|
*(.bss)
|
||||||
*(.bss*)
|
*(.bss.*)
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
_ebss = .; /* used by startup code */
|
_ebss = .; /* used by startup code */
|
||||||
} >RAM
|
} >RAM
|
||||||
|
|||||||
@@ -407,7 +407,7 @@ __vector_default:
|
|||||||
.endm
|
.endm
|
||||||
|
|
||||||
; The interrupt vector of this device. Must be placed at address 0 by the linker.
|
; The interrupt vector of this device. Must be placed at address 0 by the linker.
|
||||||
.section .vectors
|
.section .vectors, "a", %progbits
|
||||||
.global __vectors
|
.global __vectors
|
||||||
`))
|
`))
|
||||||
err = t.Execute(out, device.metadata)
|
err = t.Execute(out, device.metadata)
|
||||||
|
|||||||
Reference in New Issue
Block a user