mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-18 19:44:00 +00:00
all: support Arduino in the compiler driver
This makes sure the compiler itself can build/link an ELF file that works on an Arduino.
This commit is contained in:
@@ -89,7 +89,8 @@ func Compile(pkgName, runtimePath, outpath, target string, printIR, dumpSSA bool
|
|||||||
|
|
||||||
// Link the object file with the system compiler.
|
// Link the object file with the system compiler.
|
||||||
executable := filepath.Join(dir, "main")
|
executable := filepath.Join(dir, "main")
|
||||||
cmd := exec.Command("cc", "-o", executable, objfile)
|
args := append(spec.PreLinkArgs, "-o", executable, objfile)
|
||||||
|
cmd := exec.Command(spec.Linker, args...)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ import (
|
|||||||
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html
|
// https://doc.rust-lang.org/nightly/nightly-rustc/rustc_target/spec/struct.TargetOptions.html
|
||||||
// https://github.com/shepmaster/rust-arduino-blink-led-no-core-with-cargo/blob/master/blink/arduino.json
|
// https://github.com/shepmaster/rust-arduino-blink-led-no-core-with-cargo/blob/master/blink/arduino.json
|
||||||
type TargetSpec struct {
|
type TargetSpec struct {
|
||||||
Triple string `json:"llvm-target"`
|
Triple string `json:"llvm-target"`
|
||||||
BuildTags []string `json:"build-tags"`
|
BuildTags []string `json:"build-tags"`
|
||||||
|
Linker string `json:"linker"`
|
||||||
|
PreLinkArgs []string `json:"pre-link-args"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load a target specification
|
// Load a target specification
|
||||||
@@ -23,6 +25,7 @@ func LoadTarget(target string) (*TargetSpec, error) {
|
|||||||
spec := &TargetSpec{
|
spec := &TargetSpec{
|
||||||
Triple: target,
|
Triple: target,
|
||||||
BuildTags: []string{runtime.GOOS, runtime.GOARCH},
|
BuildTags: []string{runtime.GOOS, runtime.GOARCH},
|
||||||
|
Linker: "cc",
|
||||||
}
|
}
|
||||||
|
|
||||||
// See whether there is a target specification for this target (e.g.
|
// See whether there is a target specification for this target (e.g.
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
"llvm-target": "avr-atmel-none",
|
"llvm-target": "avr-atmel-none",
|
||||||
"build-tags": ["avr", "avr8", "atmega", "atmega328p", "js", "wasm"]
|
"build-tags": ["avr", "avr8", "atmega", "atmega328p", "js", "wasm"],
|
||||||
|
"linker": "avr-gcc",
|
||||||
|
"pre-link-args": ["-nostdlib", "-T", "avr.ld", "-Wl,--gc-sections", "avr.S"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user