From 4d4ccddad8ebb1be5246ec889f1ce3a9b9cf9e9e Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 15 Oct 2023 15:46:09 +0200 Subject: [PATCH] nix: support `make wasi-libc` on MacOS --- GNUmakefile | 5 ----- flake.nix | 12 +++++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 7a93a1ef..43335659 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -25,11 +25,6 @@ CLANG ?= $(call findLLVMTool,clang) LLVM_AR ?= $(call findLLVMTool,llvm-ar) LLVM_NM ?= $(call findLLVMTool,llvm-nm) -# Patch up Clang for Nix. -ifneq (, ${CLANG_RESOURCE_DIR}) - CLANG := $(CLANG) -resource-dir ${CLANG_RESOURCE_DIR} -endif - # Go binary and GOROOT to select GO ?= go export GOROOT = $(shell $(GO) env GOROOT) diff --git a/flake.nix b/flake.nix index 60cb579b..30e5cde1 100644 --- a/flake.nix +++ b/flake.nix @@ -64,10 +64,16 @@ #openocd ]; shellHook= '' + # Configure CLANG, LLVM_AR, and LLVM_NM for `make wasi-libc`. + # Without setting these explicitly, Homebrew versions might be used + # or the default `ar` and `nm` tools might be used (which don't + # support wasi). + export CLANG="clang-16 -resource-dir ${llvmPackages_16.clang.cc.lib}/lib/clang/16" + export LLVM_AR=llvm-ar + export LLVM_NM=llvm-nm + # Ugly hack to make the Clang resources directory available. - # Perhaps there is a cleaner way to do it, but this works. - export CLANG_RESOURCE_DIR="${llvmPackages_16.clang.cc.lib}/lib/clang/16" - export GOFLAGS="\"-ldflags=-X github.com/tinygo-org/tinygo/goenv.clangResourceDir=$CLANG_RESOURCE_DIR"\" + export GOFLAGS="\"-ldflags=-X github.com/tinygo-org/tinygo/goenv.clangResourceDir=${llvmPackages_16.clang.cc.lib}/lib/clang/16"\" ''; }; }