Skip to content

Commit 45edd18

Browse files
feat: add pointer-compression-enabled build for x86_64 linux (#1687)
Co-authored-by: Bert Belder <[email protected]>
1 parent 021e701 commit 45edd18

File tree

3 files changed

+58
-23
lines changed

3 files changed

+58
-23
lines changed

.github/workflows/ci.yml

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions: write-all
1212

1313
jobs:
1414
build:
15-
name: ${{ matrix.config.variant }} ${{ matrix.config.target }}
15+
name: ${{ matrix.config.variant }} ${{ matrix.config.target }} ${{ matrix.config.v8_enable_pointer_compression && 'ptrcomp' || '' }}
1616
runs-on: ${{ matrix.config.os }}
1717
timeout-minutes: 180
1818
strategy:
@@ -30,58 +30,82 @@ jobs:
3030
- os: macos-13
3131
target: x86_64-apple-darwin
3232
variant: debug
33+
v8_enable_pointer_compression: false
3334
cargo: cargo
3435

3536
- os: macos-13
3637
target: x86_64-apple-darwin
3738
variant: release
39+
v8_enable_pointer_compression: false
3840
cargo: cargo
3941

4042
- os: macos-14
4143
target: aarch64-apple-darwin
4244
variant: asan
45+
v8_enable_pointer_compression: false
4346
cargo: cargo
4447

4548
- os: macos-14
4649
target: aarch64-apple-darwin
4750
variant: debug
51+
v8_enable_pointer_compression: false
4852
cargo: cargo
4953

5054
- os: macos-14
5155
target: aarch64-apple-darwin
5256
variant: release
57+
v8_enable_pointer_compression: false
5358
cargo: cargo
5459

5560
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
5661
target: x86_64-unknown-linux-gnu
5762
variant: debug
63+
v8_enable_pointer_compression: false
5864
cargo: cargo
5965

6066
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
6167
target: x86_64-unknown-linux-gnu
6268
variant: release
69+
v8_enable_pointer_compression: false
70+
cargo: cargo
71+
72+
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
73+
target: x86_64-unknown-linux-gnu
74+
variant: debug
75+
v8_enable_pointer_compression: true
76+
cargo: cargo
77+
78+
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
79+
target: x86_64-unknown-linux-gnu
80+
variant: release
81+
v8_enable_pointer_compression: true
6382
cargo: cargo
6483

6584
- os: ${{ github.repository == 'denoland/rusty_v8' && 'windows-2022-xxl' || 'windows-2022' }}
6685
target: x86_64-pc-windows-msvc
6786
variant: release # Note: we do not support windows debug builds.
87+
v8_enable_pointer_compression: false
6888
cargo: cargo
6989

7090
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
7191
target: aarch64-unknown-linux-gnu
7292
variant: debug
93+
v8_enable_pointer_compression: false
7394
cargo: cargo
7495

7596
- os: ${{ github.repository == 'denoland/rusty_v8' && 'ubuntu-22.04-xl' || 'ubuntu-22.04' }}
7697
target: aarch64-unknown-linux-gnu
7798
variant: release
99+
v8_enable_pointer_compression: false
78100
cargo: cargo
79101

80102
env:
81103
V8_FROM_SOURCE: true
82104
CARGO_VARIANT_FLAG: ${{ matrix.config.variant == 'release' && '--release' || '' }}
105+
CARGO_FEATURE_FLAGS: ${{ matrix.config.v8_enable_pointer_compression && '--features v8_enable_pointer_compression' || '' }}
83106
LIB_NAME: ${{ contains(matrix.config.target, 'windows') && 'rusty_v8' || 'librusty_v8' }}
84107
LIB_EXT: ${{ contains(matrix.config.target, 'windows') && 'lib' || 'a' }}
108+
FEATURES_SUFFIX: ${{ matrix.config.v8_enable_pointer_compression && '_ptrcomp' || '' }}
85109
RUSTFLAGS: -D warnings
86110

87111
steps:
@@ -143,10 +167,8 @@ jobs:
143167
target/*/.*
144168
target/*/build
145169
target/*/deps
146-
key:
147-
cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-${{ hashFiles('Cargo.lock', 'build.rs', 'git_submodule_status.txt') }}
148-
restore-keys:
149-
cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-
170+
key: cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-{{ matrix.config.v8_enable_pointer_compression }}-${{ hashFiles('Cargo.lock', 'build.rs', 'git_submodule_status.txt') }}
171+
restore-keys: cargo-${{ matrix.config.target }}-${{ matrix.config.variant }}-{{ matrix.config.v8_enable_pointer_compression }}-
150172

151173
- name: Install and start sccache
152174
shell: pwsh
@@ -207,21 +229,19 @@ jobs:
207229
env:
208230
SCCACHE_IDLE_TIMEOUT: 0
209231
if: matrix.config.variant == 'debug' || matrix.config.variant == 'release'
210-
run:
211-
${{ matrix.config.cargo }} nextest run -v --cargo-verbose --cargo-verbose --all-targets --locked --target ${{ matrix.config.target }} ${{ env.CARGO_VARIANT_FLAG }}
232+
run: ${{ matrix.config.cargo }} nextest run -v --cargo-verbose --cargo-verbose --all-targets --locked --target ${{ matrix.config.target }} ${{ env.CARGO_VARIANT_FLAG }} ${{ env.CARGO_FEATURE_FLAGS }}
212233

213234
- name: Clippy
214-
run:
215-
${{ matrix.config.cargo }} clippy --all-targets --locked ${{ env.CARGO_VARIANT_FLAG }} --target ${{ matrix.config.target }} -- -D clippy::all
235+
run: ${{ matrix.config.cargo }} clippy --all-targets --locked --target ${{ matrix.config.target }} ${{ env.CARGO_VARIANT_FLAG }} ${{ env.CARGO_FEATURE_FLAGS }} -- -D clippy::all
216236

217237
- name: Prepare binary publish
218238
if: matrix.config.variant == 'debug' || matrix.config.variant == 'release'
219239
run: |
220-
gzip -9c target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/obj/${{ env.LIB_NAME }}.${{ env.LIB_EXT }} > target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
221-
ls -l target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
240+
gzip -9c target/${{ matrix.config.target }}/${{ matrix.config.variant }}/gn_out/obj/${{ env.LIB_NAME }}.${{ env.LIB_EXT }} > target/${{ env.LIB_NAME }}${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
241+
ls -l target/${{ env.LIB_NAME }}${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
222242
223-
cp target/${{ matrix.config.target }}/${{ matrix.config.variant}}/gn_out/src_binding.rs target/src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
224-
ls -l target/src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
243+
cp target/${{ matrix.config.target }}/${{ matrix.config.variant}}/gn_out/src_binding.rs target/src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
244+
ls -l target/src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
225245
226246
- name: Binary publish
227247
uses: softprops/[email protected]
@@ -233,14 +253,14 @@ jobs:
233253
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
234254
with:
235255
files: |
236-
target/${{ env.LIB_NAME }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
237-
target/src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
256+
target/${{ env.LIB_NAME }}${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.${{ env.LIB_EXT }}.gz
257+
target/src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
238258
239259
- name: Upload CI artifacts
240260
uses: actions/upload-artifact@v4
241261
with:
242-
name: src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
243-
path: target/src_binding_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
262+
name: src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
263+
path: target/src_binding${{ env.FEATURES_SUFFIX }}_${{ matrix.config.variant }}_${{ matrix.config.target }}.rs
244264

245265
publish:
246266
needs: build

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ opt-level = 1
9797
[features]
9898
default = ["use_custom_libcxx"]
9999
use_custom_libcxx = []
100+
v8_enable_pointer_compression = []
100101

101102
[dependencies]
102103
bitflags = "2.5"

build.rs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,14 @@ fn build_v8(is_asan: bool) {
195195
if is_asan {
196196
gn_args.push("is_asan=true".to_string());
197197
}
198-
if env::var("CARGO_FEATURE_USE_CUSTOM_LIBCXX").is_err() {
199-
gn_args.push("use_custom_libcxx=false".to_string());
200-
}
201-
198+
gn_args.push(format!(
199+
"use_custom_libcxx={}",
200+
env::var("CARGO_FEATURE_USE_CUSTOM_LIBCXX").is_ok()
201+
));
202+
gn_args.push(format!(
203+
"v8_enable_pointer_compression={}",
204+
env::var("CARGO_FEATURE_V8_ENABLE_POINTER_COMPRESSION").is_ok()
205+
));
202206
// Fix GN's host_cpu detection when using x86_64 bins on Apple Silicon
203207
if cfg!(target_os = "macos") && cfg!(target_arch = "aarch64") {
204208
gn_args.push("host_cpu=\"arm64\"".to_string())
@@ -399,6 +403,14 @@ fn prebuilt_profile() -> &'static str {
399403
}
400404
}
401405

406+
fn prebuilt_features_suffix() -> String {
407+
let mut features = String::new();
408+
if env::var("CARGO_FEATURE_V8_ENABLE_POINTER_COMPRESSION").is_ok() {
409+
features.push_str("_ptrcomp");
410+
}
411+
features
412+
}
413+
402414
fn static_lib_name(suffix: &str) -> String {
403415
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
404416
if target_os == "windows" {
@@ -418,11 +430,12 @@ fn static_lib_url() -> String {
418430
let version = env::var("CARGO_PKG_VERSION").unwrap();
419431
let target = env::var("TARGET").unwrap();
420432
let profile = prebuilt_profile();
433+
let features = prebuilt_features_suffix();
421434
format!(
422435
"{}/v{}/{}.gz",
423436
base,
424437
version,
425-
static_lib_name(&format!("_{}_{}", profile, target)),
438+
static_lib_name(&format!("{}_{}_{}", features, profile, target)),
426439
)
427440
}
428441

@@ -691,7 +704,8 @@ fn print_prebuilt_src_binding_path() {
691704

692705
let target = env::var("TARGET").unwrap();
693706
let profile = prebuilt_profile();
694-
let name = format!("src_binding_{}_{}.rs", profile, target);
707+
let features = prebuilt_features_suffix();
708+
let name = format!("src_binding{}_{}_{}.rs", features, profile, target);
695709

696710
let src_binding_path = get_dirs().root.join("gen").join(name.clone());
697711

0 commit comments

Comments
 (0)