Skip to content

Commit

Permalink
goenv: re-add support for Clang headers on darwin
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
aykevl authored and deadprogram committed Oct 15, 2023
1 parent 2d43076 commit dde9b5a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions goenv/goenv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit dde9b5a

Please sign in to comment.