Skip to content

Commit

Permalink
avr: use Clang for compiling C and assembly files
Browse files Browse the repository at this point in the history
This is one step towards an avr-gcc free TinyGo toolchain, something
that will make it easier to use AVR targets in TinyGo.
  • Loading branch information
aykevl authored and deadprogram committed Feb 12, 2021
1 parent 9c8ef5c commit 801bd2a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 3 additions & 1 deletion targets/attiny85.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"cpu": "attiny85",
"build-tags": ["attiny85", "attiny", "avr2", "avr25"],
"cflags": [
"-mmcu=attiny85"
"-mmcu=attiny85",
"-D__AVR_ARCH__=25",
"-Qunused-arguments"
],
"ldflags": [
"-mmcu=avr25"
Expand Down
9 changes: 9 additions & 0 deletions targets/avr.S
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
; in Go.
; The reset vector is device-specific and is generated by tools/gen-device-avr.py.

; These definitions are necessary because LLVM does not yet know these register
; aliases. See: https://reviews.llvm.org/D96492
#define xl r26
#define xh r27
#define yl r28
#define yh r29
#define zl r30
#define zh r31

; Startup code
.section .text.__vector_RESET
.global __vector_RESET
Expand Down
5 changes: 4 additions & 1 deletion targets/avr.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
"build-tags": ["avr", "baremetal", "linux", "arm"],
"goos": "linux",
"goarch": "arm",
"compiler": "avr-gcc",
"compiler": "clang",
"gc": "conservative",
"linker": "avr-gcc",
"scheduler": "none",
"default-stack-size": 256,
"cflags": [
"--target=avr-unknown-unknown"
],
"ldflags": [
"-T", "targets/avr.ld",
"-Wl,--gc-sections"
Expand Down

0 comments on commit 801bd2a

Please sign in to comment.