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

Add an environment variable to skip cross build check in build.rs #20282

Closed
secext2022 opened this issue Aug 25, 2023 · 1 comment
Closed

Add an environment variable to skip cross build check in build.rs #20282

secext2022 opened this issue Aug 25, 2023 · 1 comment

Comments

@secext2022
Copy link
Contributor

Cross build deno is possible with some special method (#1846, #19759).

Currently we have to patch build.rs like this:

diff '--color=auto' -ru -x Cargo.lock workdir-1/deno-1.36.2/build.rs workdir/deno-1.36.2/build.rs
--- workdir-1/deno-1.36.2/build.rs	2023-08-24 19:38:40.831557143 +0800
+++ workdir/deno-1.36.2/build.rs	2023-08-24 19:39:43.532680484 +0800
@@ -400,9 +400,6 @@
   // Host snapshots won't work when cross compiling.
   let target = env::var("TARGET").unwrap();
   let host = env::var("HOST").unwrap();
-  if target != host {
-    panic!("Cross compiling with snapshot is not supported.");
-  }
 
   let symbols_path = std::path::Path::new("napi").join(
     format!("generated_symbol_exports_list_{}.def", env::consts::OS).as_str(),

But if we add an environment variable like this:

diff '--color=auto' -ru -x Cargo.lock workdir-1/deno-1.36.2/build.rs workdir/deno-1.36.2/build.rs
--- workdir-1/deno-1.36.2/build.rs	2023-08-24 19:38:40.831557143 +0800
+++ workdir/deno-1.36.2/build.rs	2023-08-25 14:02:31.747904547 +0800
@@ -400,7 +400,8 @@
   // Host snapshots won't work when cross compiling.
   let target = env::var("TARGET").unwrap();
   let host = env::var("HOST").unwrap();
-  if target != host {
+  let skip_cross_build = env::var("DENO_SKIP_CROSS_BUILD_CHECK").map_or(false, |v| v == "1");
+  if (!skip_cross_build) && (target != host) {
     panic!("Cross compiling with snapshot is not supported.");
   }

Then when do cross build, we can just export DENO_SKIP_CROSS_BUILD_CHECK=1, and no need to patch build.rs.

But when some one do cross build accidentally (not setup special method for cross build), they will still get warned:

  thread 'main' panicked at 'Cross compiling with snapshot is not supported.', build.rs:405:5
@secext2022
Copy link
Contributor Author

sorry, network error

@secext2022 secext2022 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant