aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDmitri Goutnik <[email protected]>2019-12-14 07:36:47 -0500
committerRon Evans <[email protected]>2019-12-29 10:48:28 +0100
commit71a380ce8c622480eb4df50f9f43f2e63c00bccc (patch)
tree3cff776cdba95757da2296472e9cef419b6d4194
parent3b2a4b64c5b70803e50eca12e58d66142c4a6182 (diff)
downloadtinygo-71a380ce8c622480eb4df50f9f43f2e63c00bccc.tar.gz
tinygo-71a380ce8c622480eb4df50f9f43f2e63c00bccc.zip
Add initial FreeBSD support
-rw-r--r--Makefile5
-rw-r--r--builder/commands.go6
-rw-r--r--cgo/libclang_config.go2
-rw-r--r--compiler/syscall.go2
-rw-r--r--main.go6
-rw-r--r--src/os/file_unix.go2
-rw-r--r--src/runtime/os_freebsd.go5
-rw-r--r--src/runtime/runtime_unix.go2
8 files changed, 25 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index ff189ca70..ad09d9e49 100644
--- a/Makefile
+++ b/Makefile
@@ -62,6 +62,11 @@ $(LIBCLANG_PATH): $(LIBCLANG_FILES)
else ifeq ($(shell uname -s),Darwin)
MD5SUM = md5
LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a
+else ifeq ($(shell uname -s),FreeBSD)
+ MD5SUM = md5
+ LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a
+ START_GROUP = -Wl,--start-group
+ END_GROUP = -Wl,--end-group
else
LIBCLANG_PATH = $(abspath $(LLVM_BUILDDIR))/lib/libclang.a
START_GROUP = -Wl,--start-group
diff --git a/builder/commands.go b/builder/commands.go
index 2f2b131e5..ab196337d 100644
--- a/builder/commands.go
+++ b/builder/commands.go
@@ -34,6 +34,12 @@ func init() {
commands["ld.lld"] = append(commands["ld.lld"], "lld", "C:\\Program Files\\LLVM\\bin\\lld.exe")
commands["wasm-ld"] = append(commands["wasm-ld"], "C:\\Program Files\\LLVM\\bin\\wasm-ld.exe")
}
+ // Add the path to the llvm90 installed from ports
+ if runtime.GOOS == "freebsd" {
+ commands["clang"] = append(commands["clang"], "/usr/local/llvm90/bin/clang-9")
+ commands["ld.lld"] = append(commands["ld.lld"], "/usr/local/llvm90/bin/ld.lld")
+ commands["wasm-ld"] = append(commands["wasm-ld"], "/usr/local/llvm90/bin/wasm-ld")
+ }
}
func execCommand(cmdNames []string, args ...string) error {
diff --git a/cgo/libclang_config.go b/cgo/libclang_config.go
index 822e05206..908d7d5ba 100644
--- a/cgo/libclang_config.go
+++ b/cgo/libclang_config.go
@@ -5,7 +5,9 @@ package cgo
/*
#cgo linux CFLAGS: -I/usr/lib/llvm-9/include
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@9/include
+#cgo freebsd CFLAGS: -I/usr/local/llvm90/include
#cgo linux LDFLAGS: -L/usr/lib/llvm-9/lib -lclang
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@9/lib -lclang -lffi
+#cgo freebsd LDFLAGS: -L/usr/local/llvm90/lib -lclang
*/
import "C"
diff --git a/compiler/syscall.go b/compiler/syscall.go
index 9799669d9..8dbc81928 100644
--- a/compiler/syscall.go
+++ b/compiler/syscall.go
@@ -152,7 +152,7 @@ func (c *Compiler) emitSyscall(frame *Frame, call *ssa.CallCommon) (llvm.Value,
return llvm.Value{}, c.makeError(call.Pos(), "unknown GOOS/GOARCH for syscall: "+c.GOOS()+"/"+c.GOARCH())
}
switch c.GOOS() {
- case "linux":
+ case "linux", "freebsd":
// Return values: r0, r1 uintptr, err Errno
// Pseudocode:
// var err uintptr
diff --git a/main.go b/main.go
index c954e9741..dea040b5d 100644
--- a/main.go
+++ b/main.go
@@ -452,7 +452,7 @@ func flashUF2UsingMSD(volume, tmppath string) error {
// find standard UF2 info path
var infoPath string
switch runtime.GOOS {
- case "linux":
+ case "linux", "freebsd":
infoPath = "/media/*/" + volume + "/INFO_UF2.TXT"
case "darwin":
infoPath = "/Volumes/" + volume + "/INFO_UF2.TXT"
@@ -479,7 +479,7 @@ func flashHexUsingMSD(volume, tmppath string) error {
// find expected volume path
var destPath string
switch runtime.GOOS {
- case "linux":
+ case "linux", "freebsd":
destPath = "/media/*/" + volume
case "darwin":
destPath = "/Volumes/" + volume
@@ -558,6 +558,8 @@ func getDefaultPort() (port string, err error) {
portPath = "/dev/cu.usb*"
case "linux":
portPath = "/dev/ttyACM*"
+ case "freebsd":
+ portPath = "/dev/cuaU*"
case "windows":
cmd := exec.Command("wmic",
"PATH", "Win32_SerialPort", "WHERE", "Caption LIKE 'USB Serial%'", "GET", "DeviceID")
diff --git a/src/os/file_unix.go b/src/os/file_unix.go
index b4aaa7722..9f2a31e9d 100644
--- a/src/os/file_unix.go
+++ b/src/os/file_unix.go
@@ -1,4 +1,4 @@
-// +build darwin linux,!baremetal
+// +build darwin linux,!baremetal freebsd,!baremetal
package os
diff --git a/src/runtime/os_freebsd.go b/src/runtime/os_freebsd.go
new file mode 100644
index 000000000..1ba301968
--- /dev/null
+++ b/src/runtime/os_freebsd.go
@@ -0,0 +1,5 @@
+// +build freebsd
+
+package runtime
+
+const GOOS = "freebsd"
diff --git a/src/runtime/runtime_unix.go b/src/runtime/runtime_unix.go
index ce07fe65b..63d78917e 100644
--- a/src/runtime/runtime_unix.go
+++ b/src/runtime/runtime_unix.go
@@ -1,4 +1,4 @@
-// +build darwin linux,!baremetal
+// +build darwin linux,!baremetal freebsd,!baremetal
package runtime