diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2021-04-26 13:28:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 13:28:38 -0400 |
commit | f7c298e2972e6a1eb8f9329272ed8e8c9549266c (patch) | |
tree | ed17f90092481db6e5692cff7b3066889541e01e /cli | |
parent | e4e7d957e8cde899d48878c83f2099b0028dfdef (diff) |
Remove denort optimization (#10350)
denort is an optimization to "deno compile" to produce slightly smaller
output. It's a decent idea, but causes a lot of negative side-effects:
- Deno's link time is a source of constant agony both locally and in CI,
denort doubles link time.
- The release process is a long and arduous undertaking with many manual
steps. denort necessitates an additional manual zip + upload from M1
apple computers.
- The "deno compile" interface is complicated with the "--lite" option.
This is confusing for uses ("why wouldn't you want lite?").
The benefits of this feature do not outweigh the negatives. We must find
a different approach to optimizing "deno compile" output.
Diffstat (limited to 'cli')
-rw-r--r-- | cli/Cargo.toml | 4 | ||||
-rw-r--r-- | cli/bench/main.rs | 6 | ||||
-rw-r--r-- | cli/colors.rs | 12 | ||||
-rw-r--r-- | cli/flags.rs | 15 | ||||
-rw-r--r-- | cli/main.rs | 11 | ||||
-rw-r--r-- | cli/main_runtime.rs | 29 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 11 | ||||
-rw-r--r-- | cli/tools/standalone.rs | 8 | ||||
-rw-r--r-- | cli/version.rs | 2 |
9 files changed, 8 insertions, 90 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml index a2b90b916..97b698f42 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -14,10 +14,6 @@ default-run = "deno" name = "deno" path = "main.rs" -[[bin]] -name = "denort" -path = "main_runtime.rs" - [[bench]] name = "deno_bench" harness = false diff --git a/cli/bench/main.rs b/cli/bench/main.rs index 8890ec79c..f2ade54d8 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -228,12 +228,6 @@ fn get_binary_sizes(target_dir: &Path) -> Result<HashMap<String, u64>> { test_util::deno_exe_path().metadata()?.len(), ); - // add up size for denort - sizes.insert( - "denort".to_string(), - test_util::denort_exe_path().metadata()?.len(), - ); - // add up size for everything in target/release/deps/libswc* let swc_size = rlib_size(&target_dir, "libswc"); println!("swc {} bytes", swc_size); diff --git a/cli/colors.rs b/cli/colors.rs index 5eafef4d4..ce0af172d 100644 --- a/cli/colors.rs +++ b/cli/colors.rs @@ -1,8 +1,5 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -// allow(dead_code) because denort does not use this. -#![allow(dead_code)] - use regex::Regex; use std::fmt; use std::io::Write; @@ -128,15 +125,6 @@ pub fn gray<S: AsRef<str>>(s: S) -> impl fmt::Display { style(s, style_spec) } -pub fn italic_bold_gray<S: AsRef<str>>(s: S) -> impl fmt::Display { - let mut style_spec = ColorSpec::new(); - style_spec - .set_fg(Some(Ansi256(8))) - .set_bold(true) - .set_italic(true); - style(s, style_spec) -} - pub fn intense_blue<S: AsRef<str>>(s: S) -> impl fmt::Display { let mut style_spec = ColorSpec::new(); style_spec.set_fg(Some(Blue)).set_intense(true); diff --git a/cli/flags.rs b/cli/flags.rs index 3f5e77ff6..0a1ae5ee8 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -45,7 +45,6 @@ pub enum DenoSubcommand { output: Option<PathBuf>, args: Vec<String>, target: Option<String>, - lite: bool, }, Completions { buf: Box<[u8]>, @@ -483,18 +482,12 @@ fn compile_subcommand<'a, 'b>() -> App<'a, 'b> { .takes_value(true) .possible_values(&["x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc", "x86_64-apple-darwin", "aarch64-apple-darwin"]) ) - .arg( - Arg::with_name("lite") - .long("lite") - .help("Use lite runtime") - ) .about("Compile the script into a self contained executable") .long_about( "Compiles the given script into a self contained executable. deno compile --unstable -A https://deno.land/std/http/file_server.ts deno compile --unstable --output /usr/local/bin/color_util https://deno.land/std/examples/colors.ts - deno compile --unstable --lite --target x86_64-unknown-linux-gnu -A https://deno.land/std/http/file_server.ts Any flags passed which affect runtime behavior, such as '--unstable', '--allow-*', '--v8-flags', etc. are encoded into the output executable and used @@ -511,9 +504,6 @@ The executable name is inferred by default: This commands supports cross-compiling to different target architectures using `--target` flag. On the first invocation with deno will download proper binary and cache it in $DENO_DIR. The aarch64-apple-darwin target is not supported in canary. - -It is possible to use \"lite\" binaries when compiling by passing `--lite` flag; these are stripped down versions -of the deno binary that do not contain built-in tooling (eg. formatter, linter). This feature is experimental. ", ) } @@ -1444,14 +1434,12 @@ fn compile_parse(flags: &mut Flags, matches: &clap::ArgMatches) { let args = script.split_off(1); let source_file = script[0].to_string(); let output = matches.value_of("output").map(PathBuf::from); - let lite = matches.is_present("lite"); let target = matches.value_of("target").map(String::from); flags.subcommand = DenoSubcommand::Compile { source_file, output, args, - lite, target, }; } @@ -3600,7 +3588,6 @@ mod tests { let r = flags_from_vec(svec![ "deno", "compile", - "--lite", "https://deno.land/std/examples/colors.ts" ]); assert_eq!( @@ -3611,7 +3598,6 @@ mod tests { output: None, args: vec![], target: None, - lite: true, }, ..Flags::default() } @@ -3630,7 +3616,6 @@ mod tests { output: Some(PathBuf::from("colors")), args: svec!["foo", "bar"], target: None, - lite: false, }, import_map_path: Some("import_map.json".to_string()), no_remote: true, diff --git a/cli/main.rs b/cli/main.rs index 319811460..f33bdd3a9 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -319,7 +319,6 @@ async fn compile_command( output: Option<PathBuf>, args: Vec<String>, target: Option<String>, - lite: bool, ) -> Result<(), AnyError> { if !flags.unstable { exit_unstable("compile"); @@ -360,9 +359,9 @@ async fn compile_command( module_specifier.to_string() ); - // Select base binary based on `target` and `lite` arguments + // Select base binary based on target let original_binary = - tools::standalone::get_base_binary(deno_dir, target.clone(), lite).await?; + tools::standalone::get_base_binary(deno_dir, target.clone()).await?; let final_bin = tools::standalone::create_standalone_binary( original_binary, @@ -1096,10 +1095,10 @@ fn get_subcommand( source_file, output, args, - lite, target, - } => compile_command(flags, source_file, output, args, target, lite) - .boxed_local(), + } => { + compile_command(flags, source_file, output, args, target).boxed_local() + } DenoSubcommand::Coverage { files, ignore, diff --git a/cli/main_runtime.rs b/cli/main_runtime.rs deleted file mode 100644 index 83c74ceaa..000000000 --- a/cli/main_runtime.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. - -mod colors; -mod standalone; -mod tokio_util; -mod unix_util; -mod version; - -use deno_core::error::anyhow; -use deno_core::error::AnyError; -use std::env; - -pub fn main() { - #[cfg(windows)] - colors::enable_ansi(); // For Windows 10 - unix_util::raise_fd_limit(); - - let args: Vec<String> = env::args().collect(); - if let Err(err) = run(args) { - eprintln!("{}: {}", colors::red_bold("error"), err.to_string()); - std::process::exit(1); - } -} - -fn run(args: Vec<String>) -> Result<(), AnyError> { - let (metadata, bundle) = standalone::extract_standalone(args)? - .ok_or_else(|| anyhow!("This executable is used internally by 'deno compile', it is not meant to be invoked directly."))?; - tokio_util::run_basic(standalone::run(bundle, metadata)) -} diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 92deb9416..bb99cf49b 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -5637,17 +5637,6 @@ console.log("finish"); .contains("PermissionDenied: Requires write access")); } - #[test] - fn denort_direct_use_error() { - let status = Command::new(util::denort_exe_path()) - .current_dir(util::root_path()) - .spawn() - .unwrap() - .wait() - .unwrap(); - assert!(!status.success()); - } - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn test_resolve_dns() { use std::collections::BTreeMap; diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index 593d99931..37f464914 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -23,16 +23,14 @@ use crate::standalone::MAGIC_TRAILER; pub async fn get_base_binary( deno_dir: &DenoDir, target: Option<String>, - lite: bool, ) -> Result<Vec<u8>, AnyError> { - if target.is_none() && !lite { + if target.is_none() { let path = std::env::current_exe()?; return Ok(tokio::fs::read(path).await?); } let target = target.unwrap_or_else(|| env!("TARGET").to_string()); - let exe_name = if lite { "denort" } else { "deno" }; - let binary_name = format!("{}-{}.zip", exe_name, target); + let binary_name = format!("deno-{}.zip", target); let binary_path_suffix = if crate::version::is_canary() { format!("canary/{}/{}", crate::version::GIT_COMMIT_HASH, binary_name) @@ -50,7 +48,7 @@ pub async fn get_base_binary( let archive_data = tokio::fs::read(binary_path).await?; let base_binary_path = crate::tools::upgrade::unpack( archive_data, - exe_name, + "deno", target.contains("windows"), )?; let base_binary = tokio::fs::read(base_binary_path).await?; diff --git a/cli/version.rs b/cli/version.rs index 6fe7da070..8d82f5130 100644 --- a/cli/version.rs +++ b/cli/version.rs @@ -10,8 +10,6 @@ pub fn deno() -> String { }) } -// allow(dead_code) because denort does not use this. -#[allow(dead_code)] pub fn is_canary() -> bool { option_env!("DENO_CANARY").is_some() } |