Skip to content

Commit

Permalink
disable autocfg probe and move config options to gn for num_bigint
Browse files Browse the repository at this point in the history
  • Loading branch information
bridiver authored and cdesouza-chromium committed Sep 6, 2023
1 parent ff53434 commit 29fc07e
Show file tree
Hide file tree
Showing 22 changed files with 231 additions and 44 deletions.
6 changes: 0 additions & 6 deletions build/commands/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,12 +562,6 @@ Config.prototype.buildArgs = function () {
// We want it to be enabled for all configurations
args.disable_android_lint = false

if (this.targetArch === 'arm64') {
// TODO: Ideally we should properly compile our rust libraries in order to
// be able to use default 'standard' flow integrity. For now just revert
// it to 'pac'.
args.arm_control_flow_integrity = 'pac'
}
args.android_aab_to_apk = this.androidAabToApk

// These do not exist on android
Expand Down
20 changes: 0 additions & 20 deletions patches/build-rust-run_build_script.py.patch

This file was deleted.

9 changes: 4 additions & 5 deletions patches/build-rust-rust_target.gni.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
diff --git a/build/rust/rust_target.gni b/build/rust/rust_target.gni
index 1fdad6338f3aeb5cf2d1811891bd26173e981525..37332a6483218c3084507ef55689710b60da4f31 100644
index 1fdad6338f3aeb5cf2d1811891bd26173e981525..a0a56a47e95d5fea755f40a63ab0007532f2d858 100644
--- a/build/rust/rust_target.gni
+++ b/build/rust/rust_target.gni
@@ -172,8 +172,7 @@ template("rust_target") {
"outside the Chromium build.")
@@ -173,7 +173,7 @@ template("rust_target") {
_cxx_bindings = invoker.cxx_bindings
}
- _rustenv = [ "OUT_DIR=" +
_rustenv = [ "OUT_DIR=" +
- rebase_path(_env_out_dir, get_path_info(_crate_root, "dir")) ]
+ _rustenv = [ "OUT_DIR=" + rebase_path(_env_out_dir) ]
+ rebase_path(_env_out_dir) ]
if (defined(invoker.rustenv)) {
_rustenv += invoker.rustenv
}
13 changes: 0 additions & 13 deletions patches/build-rust-std-rules-BUILD.gn.patch

This file was deleted.

22 changes: 22 additions & 0 deletions third_party/rust/lock_api/v0_4/0001-remove-autocfg-probe.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From 4217a857d39dded221b63239893c200251ceaffe Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Wed, 23 Aug 2023 07:34:18 -0700
Subject: [PATCH] patch build.rs

---
third_party/rust/lock_api/v0_4/crate/build.rs | 1 +
1 file changed, 1 insertion(+)

diff --git a/third_party/rust/lock_api/v0_4/crate/build.rs b/third_party/rust/lock_api/v0_4/crate/build.rs
index 886a3454c3..f52f18e7b3 100644
--- a/third_party/rust/lock_api/v0_4/crate/build.rs
+++ b/third_party/rust/lock_api/v0_4/crate/build.rs
@@ -1,4 +1,5 @@
fn main() {
+ return; #[allow(unused)]
let cfg = autocfg::new();

if cfg.probe_rustc_version(1, 61) {
--
2.34.1

4 changes: 4 additions & 0 deletions third_party/rust/lock_api/v0_4/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ cargo_crate("lib") {
build_deps = [ "//third_party/rust/autocfg/v1:buildrs_support" ]
build_root = "crate/build.rs"
build_sources = [ "crate/build.rs" ]
rustflags = [
"--cfg",
"has_const_fn_trait_bound",
]
}
1 change: 1 addition & 0 deletions third_party/rust/lock_api/v0_4/crate/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fn main() {
return; #[allow(unused)]
let cfg = autocfg::new();

if cfg.probe_rustc_version(1, 61) {
Expand Down
4 changes: 4 additions & 0 deletions third_party/rust/num_bigint/v0_2/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,8 @@ cargo_crate("lib") {
features = [ "std" ]
build_root = "crate/build.rs"
build_sources = [ "crate/build.rs" ]
rustflags = [
"--cfg",
"has_i128",
]
}
1 change: 1 addition & 0 deletions third_party/rust/num_bigint/v0_2/crate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extern crate autocfg;
use std::env;

fn main() {
return; #[allow(unused)]
let ac = autocfg::new();
if ac.probe_type("i128") {
println!("cargo:rustc-cfg=has_i128");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From da7bfb9cee19deccc0dc6dbf0823bbd438d0fa67 Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Wed, 23 Aug 2023 09:23:16 -0700
Subject: [PATCH] remove autocfg probe_type

---
third_party/rust/num_bigint/v0_2/crate/build.rs | 1 +
1 file changed, 1 insertion(+)

diff --git a/third_party/rust/num_bigint/v0_2/crate/build.rs b/third_party/rust/num_bigint/v0_2/crate/build.rs
index e483c15fd7..3ea385c1c4 100644
--- a/third_party/rust/num_bigint/v0_2/crate/build.rs
+++ b/third_party/rust/num_bigint/v0_2/crate/build.rs
@@ -3,6 +3,7 @@ extern crate autocfg;
use std::env;

fn main() {
+ return; #[allow(unused)]
let ac = autocfg::new();
if ac.probe_type("i128") {
println!("cargo:rustc-cfg=has_i128");
--
2.34.1

10 changes: 10 additions & 0 deletions third_party/rust/num_bigint/v0_3/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,14 @@ cargo_crate("lib") {
build_root = "crate/build.rs"
build_sources = [ "crate/build.rs" ]
build_script_outputs = [ "radix_bases.rs" ]
rustflags = [
"--cfg",
"has_try_from",
]
if (current_cpu == "arm64" || current_cpu == "x64") {
rustflags += [
"--cfg",
"u64_digit",
]
}
}
2 changes: 2 additions & 0 deletions third_party/rust/num_bigint/v0_3/crate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::io::Write;
use std::path::Path;

fn main() {
/*
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH");
let u64_digit = pointer_width.as_ref().map(String::as_str) == Ok("64");
if u64_digit {
Expand Down Expand Up @@ -32,6 +33,7 @@ fn main() {
}
autocfg::rerun_path("build.rs");
*/

write_radix_bases().unwrap();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 45c741b53bb268f78636c9501db06530b72cc69e Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Tue, 22 Aug 2023 16:00:43 -0700
Subject: [PATCH] temp

---
third_party/rust/num_bigint/v0_3/crate/build.rs | 2 --
1 file changed, 2 deletions(-)

diff --git a/third_party/rust/num_bigint/v0_3/crate/build.rs b/third_party/rust/num_bigint/v0_3/crate/build.rs
index 3405cff8e5..3daed5e8d3 100644
--- a/third_party/rust/num_bigint/v0_3/crate/build.rs
+++ b/third_party/rust/num_bigint/v0_3/crate/build.rs
@@ -5,7 +5,6 @@ use std::io::Write;
use std::path::Path;

fn main() {
- /*
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH");
let u64_digit = pointer_width.as_ref().map(String::as_str) == Ok("64");
if u64_digit {
@@ -33,7 +32,6 @@ fn main() {
}

autocfg::rerun_path("build.rs");
-*/

write_radix_bases().unwrap();
}
--
2.34.1

10 changes: 10 additions & 0 deletions third_party/rust/num_bigint/v0_4/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ cargo_crate("lib") {
build_root = "crate/build.rs"
build_sources = [ "crate/build.rs" ]
build_script_outputs = [ "radix_bases.rs" ]
rustflags = [
"--cfg",
"has_try_from",
]
if (current_cpu == "arm64" || current_cpu == "x64") {
rustflags += [
"--cfg",
"u64_digit",
]
}
}
2 changes: 2 additions & 0 deletions third_party/rust/num_bigint/v0_4/crate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::io::Write;
use std::path::Path;

fn main() {
/*
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH");
let u64_digit = pointer_width.as_ref().map(String::as_str) == Ok("64");
if u64_digit {
Expand Down Expand Up @@ -32,6 +33,7 @@ fn main() {
}
autocfg::rerun_path("build.rs");
*/

write_radix_bases().unwrap();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 5913c99a92cc3e77033010b346bf8328465a42f1 Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Tue, 22 Aug 2023 16:06:53 -0700
Subject: [PATCH] temp2

---
third_party/rust/num_bigint/v0_4/crate/build.rs | 2 --
1 file changed, 2 deletions(-)

diff --git a/third_party/rust/num_bigint/v0_4/crate/build.rs b/third_party/rust/num_bigint/v0_4/crate/build.rs
index 284c22fe1a..3daed5e8d3 100644
--- a/third_party/rust/num_bigint/v0_4/crate/build.rs
+++ b/third_party/rust/num_bigint/v0_4/crate/build.rs
@@ -5,7 +5,6 @@ use std::io::Write;
use std::path::Path;

fn main() {
- /*
let pointer_width = env::var("CARGO_CFG_TARGET_POINTER_WIDTH");
let u64_digit = pointer_width.as_ref().map(String::as_str) == Ok("64");
if u64_digit {
@@ -33,7 +32,6 @@ fn main() {
}

autocfg::rerun_path("build.rs");
- */

write_radix_bases().unwrap();
}
--
2.34.1

16 changes: 16 additions & 0 deletions third_party/rust/num_traits/v0_2/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,20 @@ cargo_crate("lib") {
]
build_root = "crate/build.rs"
build_sources = [ "crate/build.rs" ]
rustflags = [
"--cfg",
"has_i128",
"--cfg",
"has_to_int_unchecked",
"--cfg",
"has_reverse_bits",
"--cfg",
"has_leading_trailing_ones",
"--cfg",
"has_int_assignop_ref",
"--cfg",
"has_div_euclid",
"--cfg",
"has_copysign",
]
}
1 change: 1 addition & 0 deletions third_party/rust/num_traits/v0_2/crate/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extern crate autocfg;
use std::env;

fn main() {
return; #[allow(unused)]
let ac = autocfg::new();

// If the "i128" feature is explicity requested, don't bother probing for it.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 4e24c13a8ddc7599c2c164b2c7d9eaa2d83e2d80 Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Wed, 23 Aug 2023 13:14:39 -0700
Subject: [PATCH] autocfg

---
third_party/rust/num_traits/v0_2/crate/build.rs | 1 +
1 file changed, 1 insertion(+)

diff --git a/third_party/rust/num_traits/v0_2/crate/build.rs b/third_party/rust/num_traits/v0_2/crate/build.rs
index c7bf364f1c..21558be654 100644
--- a/third_party/rust/num_traits/v0_2/crate/build.rs
+++ b/third_party/rust/num_traits/v0_2/crate/build.rs
@@ -3,6 +3,7 @@ extern crate autocfg;
use std::env;

fn main() {
+ return; #[allow(unused)]
let ac = autocfg::new();

// If the "i128" feature is explicity requested, don't bother probing for it.
--
2.34.1

1 change: 1 addition & 0 deletions third_party/rust/slab/v0_4/crate/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fn main() {
return; #[allow(unused)]
let cfg = match autocfg::AutoCfg::new() {
Ok(cfg) => cfg,
Err(e) => {
Expand Down
22 changes: 22 additions & 0 deletions third_party/rust/slab/v0_4/patches/0001-remove-autocfg-probe.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From 5178e6a72e04675d32b19c5dfbe185388550143e Mon Sep 17 00:00:00 2001
From: bridiver <34129+bridiver@users.noreply.github.com>
Date: Wed, 23 Aug 2023 09:22:12 -0700
Subject: [PATCH] skip autocfg probe_type

---
third_party/rust/slab/v0_4/crate/build.rs | 1 +
1 file changed, 1 insertion(+)

diff --git a/third_party/rust/slab/v0_4/crate/build.rs b/third_party/rust/slab/v0_4/crate/build.rs
index b60351aaf2..6a56d34911 100644
--- a/third_party/rust/slab/v0_4/crate/build.rs
+++ b/third_party/rust/slab/v0_4/crate/build.rs
@@ -1,4 +1,5 @@
fn main() {
+ return; #[allow(unused)]
let cfg = match autocfg::AutoCfg::new() {
Ok(cfg) => cfg,
Err(e) => {
--
2.34.1

19 changes: 19 additions & 0 deletions third_party/rust/third_party.toml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,16 @@ cargo_manifest_dir =
rustenv = [ "CARGO_MANIFEST_DIR=$cargo_manifest_dir" ]
'''

[dependencies.lock_api]
version = "0.4.9"
allow-first-party-usage = false
gn-variables-lib = '''
rustflags = [
"--cfg",
"has_const_fn_trait_bound",
]
'''

[dependencies.typenum]
version = "1"
allow-first-party-usage = false
Expand All @@ -289,6 +299,15 @@ rustenv = [
version = "0.4"
allow-first-party-usage = false
build-script-outputs = [ "radix_bases.rs" ]
gn-variables-lib = '''
rustflags = [
"--cfg",
"has_try_from",
]
if (current_cpu == "arm64" || current_cpu == "x64") {
rustflags += [ "--cfg", "u64_digit" ]
}
'''

[dependencies.selectors]
version = "0.23"
Expand Down

0 comments on commit 29fc07e

Please sign in to comment.