diff options
author | Ayke van Laethem <[email protected]> | 2023-10-15 00:08:26 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-10-15 10:51:06 +0200 |
commit | dde9b5ad3aacf2b5fc59aabb0b891876813c145a (patch) | |
tree | f357c9166cadb64b3b8072dde6049ee256a0ed8c /goenv/goenv.go | |
parent | 2d4307647e98f9abf05618b90a3f9658cee29d85 (diff) | |
download | tinygo-dde9b5ad3aacf2b5fc59aabb0b891876813c145a.tar.gz tinygo-dde9b5ad3aacf2b5fc59aabb0b891876813c145a.zip |
goenv: re-add support for Clang headers on darwin
When TinyGo is installed using `go install` or `go build`, it uses the
Clang resource directory from the host. This works for Linux, but
doesn't work anymore on macOS with a recent change I made.
This re-adds support for Darwin in that case (with much, much simpler
code than there used to be).
Diffstat (limited to 'goenv/goenv.go')
-rw-r--r-- | goenv/goenv.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/goenv/goenv.go b/goenv/goenv.go index 4715b8769..439d4bf1e 100644 --- a/goenv/goenv.go +++ b/goenv/goenv.go @@ -366,6 +366,22 @@ func findSystemClangResources(TINYGOROOT string) string { if err == nil { return path } + case "darwin": + // This assumes a Homebrew installation, like in builder/commands.go. + var prefix string + switch runtime.GOARCH { + case "amd64": + prefix = "/usr/local/opt/llvm@" + llvmMajor + case "arm64": + prefix = "/opt/homebrew/opt/llvm@" + llvmMajor + default: + return "" // very unlikely for now + } + path := fmt.Sprintf("%s/lib/clang/%s", prefix, llvmMajor) + _, err := os.Stat(path + "/include/stdint.h") + if err == nil { + return path + } } // Could not find it. |