Skip to content

Commit 5456721

Browse files
authored
build(profiling): clean up cfg checks for MSRV 1.80+ (#3601)
* build(profiling): clean up cfg checks for MSRV 1.80+ * build: drop rustc_version dependency
1 parent c4d4325 commit 5456721

3 files changed

Lines changed: 8 additions & 46 deletions

File tree

Cargo.lock

Lines changed: 0 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

profiling/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ trigger_time_sample = []
7676
bindgen = { version = "0.69.4" }
7777
cc = { version = "1.0" }
7878

79-
# We can remove this when we're using Rust 1.80+
80-
rustc_version = "0.4"
81-
8279
# profiling release options in root Cargo.toml
8380

8481
[lints.rust]

profiling/build.rs

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use bindgen::callbacks::IntKind;
2-
use rustc_version::version_meta;
32
use std::collections::HashSet;
43
use std::path::Path;
54
use std::path::PathBuf;
@@ -301,18 +300,8 @@ fn generate_bindings(php_config_includes: &str, fibers: bool, zend_error_observe
301300
.expect("bindings to be written successfully");
302301
}
303302

304-
// See https://doc.rust-lang.org/nightly/rustc/check-cfg/cargo-specifics.html
305-
// We can remove this when we're on Rust 1.80+.
306-
fn has_check_cfg() -> bool {
307-
let meta = version_meta().unwrap();
308-
assert_eq!(1, meta.semver.major);
309-
meta.semver.minor >= 80
310-
}
311-
312303
fn cfg_post_startup_cb(vernum: u64) -> bool {
313-
if has_check_cfg() {
314-
println!("cargo::rustc-check-cfg=cfg(php_post_startup_cb)");
315-
}
304+
println!("cargo::rustc-check-cfg=cfg(php_post_startup_cb)");
316305
if vernum >= 70300 {
317306
println!("cargo:rustc-cfg=php_post_startup_cb");
318307
true
@@ -322,9 +311,7 @@ fn cfg_post_startup_cb(vernum: u64) -> bool {
322311
}
323312

324313
fn cfg_preload(vernum: u64) -> bool {
325-
if has_check_cfg() {
326-
println!("cargo::rustc-check-cfg=cfg(php_preload)");
327-
}
314+
println!("cargo::rustc-check-cfg=cfg(php_preload)");
328315
if vernum >= 70400 {
329316
println!("cargo:rustc-cfg=php_preload");
330317
true
@@ -334,9 +321,7 @@ fn cfg_preload(vernum: u64) -> bool {
334321
}
335322

336323
fn cfg_run_time_cache(vernum: u64) -> bool {
337-
if has_check_cfg() {
338-
println!("cargo::rustc-check-cfg=cfg(php_run_time_cache)");
339-
}
324+
println!("cargo::rustc-check-cfg=cfg(php_run_time_cache)");
340325
if vernum >= 80000 {
341326
println!("cargo:rustc-cfg=php_run_time_cache");
342327
true
@@ -350,9 +335,7 @@ fn cfg_trigger_time_sample() -> bool {
350335
}
351336

352337
fn cfg_zend_error_observer(vernum: u64) -> bool {
353-
if has_check_cfg() {
354-
println!("cargo::rustc-check-cfg=cfg(zend_error_observer, zend_error_observer_80)");
355-
}
338+
println!("cargo::rustc-check-cfg=cfg(zend_error_observer, zend_error_observer_80)");
356339
if vernum >= 80000 {
357340
println!("cargo:rustc-cfg=zend_error_observer");
358341
if vernum < 80100 {
@@ -365,9 +348,7 @@ fn cfg_zend_error_observer(vernum: u64) -> bool {
365348
}
366349

367350
fn cfg_php_major_version(vernum: u64) {
368-
if has_check_cfg() {
369-
println!("cargo::rustc-check-cfg=cfg(php7, php8)");
370-
}
351+
println!("cargo::rustc-check-cfg=cfg(php7, php8)");
371352

372353
let major_version = match vernum {
373354
70000..=79999 => 7,
@@ -383,9 +364,7 @@ fn cfg_php_major_version(vernum: u64) {
383364
}
384365

385366
fn cfg_fibers(vernum: u64) -> bool {
386-
if has_check_cfg() {
387-
println!("cargo::rustc-check-cfg=cfg(php_has_fibers)");
388-
}
367+
println!("cargo::rustc-check-cfg=cfg(php_has_fibers)");
389368
if vernum >= 80100 {
390369
println!("cargo:rustc-cfg=php_has_fibers");
391370
true
@@ -395,9 +374,7 @@ fn cfg_fibers(vernum: u64) -> bool {
395374
}
396375

397376
fn cfg_php_feature_flags(vernum: u64) {
398-
if has_check_cfg() {
399-
println!("cargo::rustc-check-cfg=cfg(php_gc_status, php_zend_compile_string_has_position, php_gc_status_extended, php_frameless, php_opcache_restart_hook, php_zend_mm_set_custom_handlers_ex)");
400-
}
377+
println!("cargo::rustc-check-cfg=cfg(php_gc_status, php_zend_compile_string_has_position, php_gc_status_extended, php_frameless, php_opcache_restart_hook, php_zend_mm_set_custom_handlers_ex)");
401378

402379
if vernum >= 70300 {
403380
println!("cargo:rustc-cfg=php_gc_status");
@@ -416,9 +393,7 @@ fn cfg_php_feature_flags(vernum: u64) {
416393
}
417394

418395
fn cfg_zts() {
419-
if has_check_cfg() {
420-
println!("cargo::rustc-check-cfg=cfg(php_zts)");
421-
}
396+
println!("cargo::rustc-check-cfg=cfg(php_zts)");
422397

423398
let output = Command::new("php-config")
424399
.arg("--include-dir")

0 commit comments

Comments
 (0)