Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: build release/CI on non-Windows with code cache #22934

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,18 @@ CODE_CACHE_FILE ?= $(CODE_CACHE_DIR)/node_code_cache.cc
ifeq ($(BUILDTYPE),Debug)
CONFIG_FLAGS += --debug
endif

.PHONY: generate-code-cache
generate-code-cache: all
mkdir -p $(CODE_CACHE_DIR)
out/$(BUILDTYPE)/$(NODE_EXE) --expose-internals tools/generate_code_cache.js $(CODE_CACHE_FILE)

.PHONY: with-code-cache
with-code-cache:
@echo $(CONFIG_FLAGS)
$(PYTHON) ./configure $(CONFIG_FLAGS)
$(MAKE)
mkdir -p $(CODE_CACHE_DIR)
out/$(BUILDTYPE)/$(NODE_EXE) --expose-internals tools/generate_code_cache.js $(CODE_CACHE_FILE)
$(PYTHON) ./configure --code-cache-path $(CODE_CACHE_FILE) $(CONFIG_FLAGS)
$(MAKE) generate-code-cache
$(PYTHON) ./configure $(CONFIG_FLAGS) --code-cache-path $(CODE_CACHE_FILE)
$(MAKE)

.PHONY: test-code-cache
Expand Down Expand Up @@ -475,9 +479,7 @@ test-ci: | clear-stalled build-addons build-addons-napi doc-only
.PHONY: build-ci
# Prepare the build for running the tests.
# Related CI jobs: most CI tests, excluding node-test-commit-arm-fanned
build-ci:
$(PYTHON) ./configure $(CONFIG_FLAGS)
$(MAKE)
build-ci: with-code-cache

.PHONY: run-ci
# Run by CI tests, exceptions:
Expand Down Expand Up @@ -870,12 +872,23 @@ $(PKG): release-only
| sed -E "s/\\{npmversion\\}/$(NPMVERSION)/g" \
>$(MACOSOUTDIR)/installer/productbuild/Resources/$$lang/conclusion.html ; \
done

# Pass 1: build the binary without empty code cache to generate code cache
$(PYTHON) ./configure \
--dest-cpu=x64 \
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
$(MAKE) generate-code-cache
# Pass 2: build the binary with the code cache
$(PYTHON) ./configure \
--dest-cpu=x64 \
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS) \
--code-cache-path $(CODE_CACHE_FILE)
$(MAKE) install V=$(V) DESTDIR=$(MACOSOUTDIR)/dist/node

SIGN="$(CODESIGN_CERT)" PKGDIR="$(MACOSOUTDIR)/dist/node/usr/local" bash \
tools/osx-codesign.sh
mkdir -p $(MACOSOUTDIR)/dist/npm/usr/local/lib/node_modules
Expand Down Expand Up @@ -1005,13 +1018,25 @@ endif
$(BINARYTAR): release-only
$(RM) -r $(BINARYNAME)
$(RM) -r out/deps out/Release

# Pass 1: build the binary without empty code cache to generate code cache
$(PYTHON) ./configure \
--prefix=/ \
--dest-cpu=$(DESTCPU) \
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS)
$(MAKE) generate-code-cache
# Pass 2: build the binary with the code cache
$(PYTHON) ./configure \
--prefix=/ \
--dest-cpu=$(DESTCPU) \
--tag=$(TAG) \
--release-urlbase=$(RELEASE_URLBASE) \
$(CONFIG_FLAGS) $(BUILD_RELEASE_FLAGS) \
--code-cache-path $(CODE_CACHE_FILE)
$(MAKE) install DESTDIR=$(BINARYNAME) V=$(V) PORTABLE=1

cp README.md $(BINARYNAME)
cp LICENSE $(BINARYNAME)
cp CHANGELOG.md $(BINARYNAME)
Expand Down
6 changes: 5 additions & 1 deletion test/code-cache/test-code-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// This test verifies that the binary is compiled with code cache and the
// cache is used when built in modules are compiled.

require('../common');
const common = require('../common');
const assert = require('assert');
const {
types: {
Expand All @@ -18,6 +18,10 @@ const {
compiledWithoutCache
} = require('internal/bootstrap/cache');

if (process.config.variables.node_code_cache_path === undefined) {
common.skip('Not configured with --code-cache-path');
}

assert.strictEqual(
typeof process.config.variables.node_code_cache_path,
'string'
Expand Down