From e939e243bfa40169612db51509f0a02f45a9434e Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Tue, 8 Jun 2021 14:20:31 +0100 Subject: [PATCH] build: don't pass python override to V8 build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the `configure.py` script is executed by a Python binary that is not the one on the PATH it will create a `python` symlink in `out/tools/bin` and prefix that to the PATH so it is used instead of the one that otherwise would have been found on the PATH. This is done so that gyp scripts shelling out to `python` execute with the same version of Python as used to run the configure script. V8's build uses V8's build toolchain (i.e. not gyp) and currently that is incompatible with Python 3. Prevent prefixing the PATH for the V8 build so that it picks up `python` from the unprefixed PATH. This will allow us to build Node.js with Python 3 but still use Python 2 to build V8 in the CI. PR-URL: https://github.com/nodejs/node/pull/38969 Reviewed-By: James M Snell Reviewed-By: Michaƫl Zasso --- Makefile | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 939bba64575bff..688cb85e774b14 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,11 @@ V8_TEST_OPTIONS = $(V8_EXTRA_TEST_OPTIONS) ifdef DISABLE_V8_I18N V8_BUILD_OPTIONS += i18nsupport=off endif +# V8 build and test toolchains are not currently compatible with Python 3. +# config.mk may have prepended a symlink for `python` to PATH which we need +# to undo before calling V8's tools. +OVERRIDE_BIN_DIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))out/tools/bin +NO_BIN_OVERRIDE_PATH=$(subst $() $(),:,$(filter-out $(OVERRIDE_BIN_DIR),$(subst :, ,$(PATH)))) ifeq ($(OSTYPE), darwin) GCOV = xcrun llvm-cov gcov @@ -274,7 +279,8 @@ endif # Rebuilds deps/v8 as a git tree, pulls its third-party dependencies, and # builds it. v8: - tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS) + export PATH="$(NO_BIN_OVERRIDE_PATH)" && \ + tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS) .PHONY: jstest jstest: build-addons build-js-native-api-tests build-node-api-tests ## Runs addon tests and JS tests @@ -651,19 +657,22 @@ test-with-async-hooks: ifneq ("","$(wildcard deps/v8/tools/run-tests.py)") # Related CI job: node-test-commit-v8-linux test-v8: v8 ## Runs the V8 test suite on deps/v8. - deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) $(V8_TEST_OPTIONS) \ + export PATH="$(NO_BIN_OVERRIDE_PATH)" && \ + deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) $(V8_TEST_OPTIONS) \ mjsunit cctest debugger inspector message preparser \ $(TAP_V8) $(info Testing hash seed) $(MAKE) test-hash-seed test-v8-intl: v8 - deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \ + export PATH="$(NO_BIN_OVERRIDE_PATH)" && \ + deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \ --mode=$(BUILDTYPE_LOWER) intl \ $(TAP_V8_INTL) test-v8-benchmarks: v8 - deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) --mode=$(BUILDTYPE_LOWER) \ + export PATH="$(NO_BIN_OVERRIDE_PATH)" && \ + deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) --mode=$(BUILDTYPE_LOWER) \ benchmarks \ $(TAP_V8_BENCHMARKS)