mirror of
https://github.com/denoland/deno.git
synced 2025-01-12 00:54:02 -05:00
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.
This commit is contained in:
parent
e4e7d957e8
commit
f7c298e297
11 changed files with 9 additions and 103 deletions
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
|
@ -224,7 +224,6 @@ jobs:
|
|||
run: |
|
||||
cd target/release
|
||||
zip -r deno-x86_64-unknown-linux-gnu.zip deno
|
||||
zip -r denort-x86_64-unknown-linux-gnu.zip denort
|
||||
./deno types > lib.deno.d.ts
|
||||
|
||||
- name: Pre-release (mac)
|
||||
|
@ -235,7 +234,6 @@ jobs:
|
|||
run: |
|
||||
cd target/release
|
||||
zip -r deno-x86_64-apple-darwin.zip deno
|
||||
zip -r denort-x86_64-apple-darwin.zip denort
|
||||
|
||||
- name: Pre-release (windows)
|
||||
if: |
|
||||
|
@ -244,7 +242,6 @@ jobs:
|
|||
matrix.profile == 'release'
|
||||
run: |
|
||||
Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-x86_64-pc-windows-msvc.zip
|
||||
Compress-Archive -CompressionLevel Optimal -Force -Path target/release/denort.exe -DestinationPath target/release/denort-x86_64-pc-windows-msvc.zip
|
||||
|
||||
- name: Upload canary to dl.deno.land (unix)
|
||||
if: |
|
||||
|
@ -376,7 +373,7 @@ jobs:
|
|||
- name: Clean before cache
|
||||
shell: bash
|
||||
run: |
|
||||
rm -f target/*/deno target/*/denort target/*/test_server
|
||||
rm -f target/*/deno target/*/test_server
|
||||
rm -rf target/*/examples/
|
||||
rm -rf target/*/gn_out/
|
||||
rm -rf target/*/*.zip
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
15
cli/flags.rs
15
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,
|
||||
|
|
11
cli/main.rs
11
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,
|
||||
|
|
|
@ -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))
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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?;
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -108,15 +108,6 @@ pub fn deno_exe_path() -> PathBuf {
|
|||
p
|
||||
}
|
||||
|
||||
pub fn denort_exe_path() -> PathBuf {
|
||||
// Something like /Users/rld/src/deno/target/debug/deps/denort
|
||||
let mut p = target_dir().join("denort");
|
||||
if cfg!(windows) {
|
||||
p.set_extension("exe");
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
pub fn prebuilt_tool_path(tool: &str) -> PathBuf {
|
||||
let mut exe = tool.to_string();
|
||||
exe.push_str(if cfg!(windows) { ".exe" } else { "" });
|
||||
|
|
Loading…
Reference in a new issue