From 5e348d976fe02f632daa26951927c141008b882e Mon Sep 17 00:00:00 2001 From: Ash Cripps Date: Mon, 22 Mar 2021 12:18:48 +0000 Subject: [PATCH 1/3] build: update Makefile to support fat binary build a binary that is both x86_64 and arm64 on macos --- Makefile | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d103773a616e1f..c9d9c778198d07 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ TEST_CI_ARGS ?= STAGINGSERVER ?= node-www LOGLEVEL ?= silent OSTYPE := $(shell uname -s | tr '[:upper:]' '[:lower:]') +ARCHTYPE := $(shell uname -m | tr '[:upper:]' '[:lower:]') COVTESTS ?= test-cov COV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js GTEST_FILTER ?= "*" @@ -962,6 +963,14 @@ release-only: check-xz fi $(PKG): release-only +ifneq ($(OSTYPE),darwin) + $(warning Invalid OSTYPE) + $(error OSTYPE should be `darwin` currently is $(OSTYPE)) +endif +ifneq ($(ARCHTYPE),arm64) + $(warning Invalid ARCHTYPE) + $(error ARCHTYPE should be `arm64` currently is $(ARCHTYPE)) +endif $(RM) -r $(MACOSOUTDIR) mkdir -p $(MACOSOUTDIR)/installer/productbuild cat tools/macos-installer/productbuild/distribution.xml.tmpl \ @@ -982,14 +991,28 @@ $(PKG): release-only | sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \ >$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \ done + CC_host="cc -arch x86_64" CXX_host="c++ -arch x86_64" \ + CC_target="cc -arch x86_64" CXX_target="c++ -arch x86_64" \ + CC="cc -arch x86_64" CXX="c++ -arch x86_64" $(PYTHON) ./configure \ + --dest-cpu=x86_64 \ + --tag=$(TAG) \ + --release-urlbase=$(RELEASE_URLBASE) \ + $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS) + arch -x86_64 $(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/x64/node + SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/x64/node/usr/local" sh \ + tools/osx-codesign.sh $(PYTHON) ./configure \ - --dest-cpu=x64 \ + --dest-cpu=arm64 \ --tag=$(TAG) \ --release-urlbase=$(RELEASE_URLBASE) \ $(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS) $(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" sh \ tools/osx-codesign.sh + lipo $(MACOSOUTDIR)/dist/x64/node/usr/local/bin/node \ + $(MACOSOUTDIR)/dist/node/usr/local/bin/node \ + -output $(MACOSOUTDIR)/dist/node/usr/local/bin/node \ + -create mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules mkdir -p $(MACOSOUTDIR)/pkgs mv $(MACOSOUTDIR)/dist/node/usr/local/lib/node_modules/npm \ From ee254a1539e17f1b5ccaf9fe2fdbee7763792fdb Mon Sep 17 00:00:00 2001 From: Ash Cripps Date: Wed, 7 Apr 2021 11:09:17 +0100 Subject: [PATCH 2/3] fixup! build: update Makefile to support fat binary --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index c9d9c778198d07..28260df0737200 100644 --- a/Makefile +++ b/Makefile @@ -963,6 +963,8 @@ release-only: check-xz fi $(PKG): release-only +# pkg buiding is currently only supported on a ARM64 macOS host for +# ease of compiling fat-binaries for both macOS architectures. ifneq ($(OSTYPE),darwin) $(warning Invalid OSTYPE) $(error OSTYPE should be `darwin` currently is $(OSTYPE)) From 788a0fccb722277e6f4212432c6b5eb74fb36a9d Mon Sep 17 00:00:00 2001 From: Ash Cripps Date: Thu, 8 Apr 2021 14:34:12 +0100 Subject: [PATCH 3/3] fixup! fixup! build: update Makefile to support fat binary --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 28260df0737200..b0a2e67f76e0ac 100644 --- a/Makefile +++ b/Makefile @@ -963,7 +963,7 @@ release-only: check-xz fi $(PKG): release-only -# pkg buiding is currently only supported on a ARM64 macOS host for +# pkg building is currently only supported on an ARM64 macOS host for # ease of compiling fat-binaries for both macOS architectures. ifneq ($(OSTYPE),darwin) $(warning Invalid OSTYPE)