feat: support build on darwin arm64 (#2439)
main: support build on darwin arm64
Этот коммит содержится в:
родитель
ef77b645b9
коммит
93e0636c03
5 изменённых файлов: 38 добавлений и 21 удалений
1
Makefile
1
Makefile
|
@ -9,6 +9,7 @@ CLANG_SRC ?= $(LLVM_PROJECTDIR)/clang
|
||||||
LLD_SRC ?= $(LLVM_PROJECTDIR)/lld
|
LLD_SRC ?= $(LLVM_PROJECTDIR)/lld
|
||||||
|
|
||||||
# Try to autodetect LLVM build tools.
|
# Try to autodetect LLVM build tools.
|
||||||
|
# FIXME(#2438): This doesn't work on darwin now. Homebrew installed llvm is key-only.
|
||||||
detect = $(shell command -v $(1) 2> /dev/null && echo $(1))
|
detect = $(shell command -v $(1) 2> /dev/null && echo $(1))
|
||||||
CLANG ?= $(word 1,$(abspath $(call detect,llvm-build/bin/clang))$(call detect,clang-13)$(call detect,clang-12)$(call detect,clang-11)$(call detect,clang))
|
CLANG ?= $(word 1,$(abspath $(call detect,llvm-build/bin/clang))$(call detect,clang-13)$(call detect,clang-12)$(call detect,clang-11)$(call detect,clang))
|
||||||
LLVM_AR ?= $(word 1,$(abspath $(call detect,llvm-build/bin/llvm-ar))$(call detect,llvm-ar-13)$(call detect,llvm-ar-12)$(call detect,llvm-ar-11)$(call detect,llvm-ar))
|
LLVM_AR ?= $(word 1,$(abspath $(call detect,llvm-build/bin/llvm-ar))$(call detect,llvm-ar-13)$(call detect,llvm-ar-12)$(call detect,llvm-ar-11)$(call detect,llvm-ar))
|
||||||
|
|
|
@ -2,6 +2,7 @@ package builder
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -25,7 +26,16 @@ func init() {
|
||||||
// Add the path to a Homebrew-installed LLVM for ease of use (no need to
|
// Add the path to a Homebrew-installed LLVM for ease of use (no need to
|
||||||
// manually set $PATH).
|
// manually set $PATH).
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
prefix := "/usr/local/opt/llvm@" + llvmMajor + "/bin/"
|
var prefix string
|
||||||
|
switch runtime.GOARCH {
|
||||||
|
case "amd64":
|
||||||
|
prefix = "/usr/local/opt/llvm@" + llvmMajor + "/bin/"
|
||||||
|
case "arm64":
|
||||||
|
prefix = "/opt/homebrew/opt/llvm@" + llvmMajor + "/bin/"
|
||||||
|
default:
|
||||||
|
// unknown GOARCH
|
||||||
|
panic(fmt.Sprintf("unknown GOARCH: %s on darwin", runtime.GOARCH))
|
||||||
|
}
|
||||||
commands["clang"] = append(commands["clang"], prefix+"clang-"+llvmMajor)
|
commands["clang"] = append(commands["clang"], prefix+"clang-"+llvmMajor)
|
||||||
commands["ld.lld"] = append(commands["ld.lld"], prefix+"ld.lld")
|
commands["ld.lld"] = append(commands["ld.lld"], prefix+"ld.lld")
|
||||||
commands["wasm-ld"] = append(commands["wasm-ld"], prefix+"wasm-ld")
|
commands["wasm-ld"] = append(commands["wasm-ld"], prefix+"wasm-ld")
|
||||||
|
|
|
@ -5,10 +5,12 @@ package cgo
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo linux CFLAGS: -I/usr/lib/llvm-11/include
|
#cgo linux CFLAGS: -I/usr/lib/llvm-11/include
|
||||||
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@11/include
|
#cgo darwin amd64 CFLAGS: -I/usr/local/opt/llvm@11/include
|
||||||
|
#cgo darwin arm64 CFLAGS: -I/opt/homebrew/opt/llvm@11/include
|
||||||
#cgo freebsd CFLAGS: -I/usr/local/llvm11/include
|
#cgo freebsd CFLAGS: -I/usr/local/llvm11/include
|
||||||
#cgo linux LDFLAGS: -L/usr/lib/llvm-11/lib -lclang
|
#cgo linux LDFLAGS: -L/usr/lib/llvm-11/lib -lclang
|
||||||
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@11/lib -lclang -lffi
|
#cgo darwin amd64 LDFLAGS: -L/usr/local/opt/llvm@11/lib -lclang -lffi
|
||||||
|
#cgo darwin arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@11/lib -lclang -lffi
|
||||||
#cgo freebsd LDFLAGS: -L/usr/local/llvm11/lib -lclang
|
#cgo freebsd LDFLAGS: -L/usr/local/llvm11/lib -lclang
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
// +build !byollvm
|
//go:build !byollvm && llvm12
|
||||||
// +build llvm12
|
// +build !byollvm,llvm12
|
||||||
|
|
||||||
package cgo
|
package cgo
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo linux CFLAGS: -I/usr/lib/llvm-12/include
|
#cgo linux CFLAGS: -I/usr/lib/llvm-12/include
|
||||||
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@12/include
|
#cgo darwin amd64 CFLAGS: -I/usr/local/opt/llvm@12/include
|
||||||
|
#cgo darwin arm64 CFLAGS: -I/opt/homebrew/opt/llvm@12/include
|
||||||
#cgo freebsd CFLAGS: -I/usr/local/llvm12/include
|
#cgo freebsd CFLAGS: -I/usr/local/llvm12/include
|
||||||
#cgo linux LDFLAGS: -L/usr/lib/llvm-12/lib -lclang
|
#cgo linux LDFLAGS: -L/usr/lib/llvm-12/lib -lclang
|
||||||
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@12/lib -lclang -lffi
|
#cgo darwin amd64 LDFLAGS: -L/usr/local/opt/llvm@12/lib -lclang -lffi
|
||||||
|
#cgo darwin arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@12/lib -lclang -lffi
|
||||||
#cgo freebsd LDFLAGS: -L/usr/local/llvm12/lib -lclang
|
#cgo freebsd LDFLAGS: -L/usr/local/llvm12/lib -lclang
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
|
@ -5,10 +5,12 @@ package cgo
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#cgo linux CFLAGS: -I/usr/lib/llvm-13/include
|
#cgo linux CFLAGS: -I/usr/lib/llvm-13/include
|
||||||
#cgo darwin CFLAGS: -I/usr/local/opt/llvm@13/include
|
#cgo darwin amd64 CFLAGS: -I/usr/local/opt/llvm@13/include
|
||||||
|
#cgo darwin arm64 CFLAGS: -I/opt/homebrew/opt/llvm@13/include
|
||||||
#cgo freebsd CFLAGS: -I/usr/local/llvm13/include
|
#cgo freebsd CFLAGS: -I/usr/local/llvm13/include
|
||||||
#cgo linux LDFLAGS: -L/usr/lib/llvm-13/lib -lclang
|
#cgo linux LDFLAGS: -L/usr/lib/llvm-13/lib -lclang
|
||||||
#cgo darwin LDFLAGS: -L/usr/local/opt/llvm@13/lib -lclang -lffi
|
#cgo darwin amd64 LDFLAGS: -L/usr/local/opt/llvm@13/lib -lclang -lffi
|
||||||
|
#cgo darwin arm64 LDFLAGS: -L/opt/homebrew/opt/llvm@13/lib -lclang -lffi
|
||||||
#cgo freebsd LDFLAGS: -L/usr/local/llvm13/lib -lclang
|
#cgo freebsd LDFLAGS: -L/usr/local/llvm13/lib -lclang
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче