Skip to content

Commit 6dae709

Browse files
committed
build: don't pass python override to V8 build
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.
1 parent 65a7fd3 commit 6dae709

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Makefile

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ V8_TEST_OPTIONS = $(V8_EXTRA_TEST_OPTIONS)
3636
ifdef DISABLE_V8_I18N
3737
V8_BUILD_OPTIONS += i18nsupport=off
3838
endif
39+
# V8 build and test toolchains are not currently compatible with Python 3.
40+
# config.mk may have prepended a symlink for `python` to PATH which we need
41+
# to undo before calling V8's tools.
42+
OVERRIDE_BIN_DIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))out/tools/bin
43+
NO_BIN_OVERRIDE_PATH=$(subst $() $(),:,$(filter-out $(OVERRIDE_BIN_DIR),$(subst :, ,$(PATH))))
3944

4045
ifeq ($(OSTYPE), darwin)
4146
GCOV = xcrun llvm-cov gcov
@@ -274,7 +279,8 @@ endif
274279
# Rebuilds deps/v8 as a git tree, pulls its third-party dependencies, and
275280
# builds it.
276281
v8:
277-
tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
282+
export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
283+
tools/make-v8.sh $(V8_ARCH).$(BUILDTYPE_LOWER) $(V8_BUILD_OPTIONS)
278284

279285
.PHONY: jstest
280286
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:
651657
ifneq ("","$(wildcard deps/v8/tools/run-tests.py)")
652658
# Related CI job: node-test-commit-v8-linux
653659
test-v8: v8 ## Runs the V8 test suite on deps/v8.
654-
deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) $(V8_TEST_OPTIONS) \
660+
export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
661+
deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) $(V8_TEST_OPTIONS) \
655662
mjsunit cctest debugger inspector message preparser \
656663
$(TAP_V8)
657664
$(info Testing hash seed)
658665
$(MAKE) test-hash-seed
659666

660667
test-v8-intl: v8
661-
deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \
668+
export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
669+
deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) \
662670
--mode=$(BUILDTYPE_LOWER) intl \
663671
$(TAP_V8_INTL)
664672

665673
test-v8-benchmarks: v8
666-
deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) --mode=$(BUILDTYPE_LOWER) \
674+
export PATH="$(NO_BIN_OVERRIDE_PATH)" && \
675+
deps/v8/tools/run-tests.py --gn --arch=$(V8_ARCH) --mode=$(BUILDTYPE_LOWER) \
667676
benchmarks \
668677
$(TAP_V8_BENCHMARKS)
669678

0 commit comments

Comments
 (0)