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

Arch Migrator #11

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .azure-pipelines/azure-pipelines-linux.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .ci_support/linux_aarch64_.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
BUILD:
- aarch64-conda_cos7-linux-gnu
c_compiler:
- gcc
c_compiler_version:
- '10'
cdt_arch:
- aarch64
cdt_name:
- cos7
channel_sources:
- conda-forge
channel_targets:
- conda-forge main
docker_image:
- quay.io/condaforge/linux-anvil-cos7-x86_64
rust_compiler:
- rust
target_platform:
- linux-aarch64
7 changes: 7 additions & 0 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions conda-forge.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
build_platform:
osx_arm64: osx_64
linux_aarch64: linux_64
conda_forge_output_validation: true
github:
branch_name: main
tooling_branch_name: main
provider:
linux_aarch64: default
linux_ppc64le: default
test: native_and_emulated
116 changes: 116 additions & 0 deletions recipe/0001-use-autotools-rs-for-building-tinycc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
From a2274b56938ce2eb460533ece60573b2b16b49b8 Mon Sep 17 00:00:00 2001
From: Michael Sarahan <[email protected]>
Date: Tue, 6 Sep 2022 16:17:33 -0500
Subject: [PATCH 1/3] use autotools-rs for building tinycc

---
Cargo.lock | 10 ++++++++++
ext/ffi/Cargo.toml | 3 +++
ext/ffi/build.rs | 34 +++++++++++-----------------------
3 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 447fea548..4db9913ad 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -233,6 +233,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"

+[[package]]
+name = "autotools"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c8138adefca3e5d2e73bfba83bd6eeaf904b26a7ac1b4a19892cfe16cc7e1701"
+dependencies = [
+ "cc",
+]
+
[[package]]
name = "base16ct"
version = "0.1.1"
@@ -1033,6 +1042,7 @@ dependencies = [
name = "deno_ffi"
version = "0.53.0"
dependencies = [
+ "autotools",
"deno_core",
"dlopen",
"libffi",
diff --git a/ext/ffi/Cargo.toml b/ext/ffi/Cargo.toml
index b233a5747..05d417ad2 100644
--- a/ext/ffi/Cargo.toml
+++ b/ext/ffi/Cargo.toml
@@ -13,6 +13,9 @@ description = "Dynamic library ffi for deno"
[lib]
path = "lib.rs"

+[build-dependencies]
+autotools = "0.2"
+
[dependencies]
deno_core = { version = "0.148.0", path = "../../core" }
dlopen = "0.1.8"
diff --git a/ext/ffi/build.rs b/ext/ffi/build.rs
index 1debd6b9c..fbdcbe58d 100644
--- a/ext/ffi/build.rs
+++ b/ext/ffi/build.rs
@@ -1,8 +1,10 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.

+
#[cfg(not(target_os = "windows"))]
fn build_tcc() {
use std::env;
+ use autotools::Config;

{
// TODO(@littledivy): Windows support for fast call.
@@ -21,35 +23,21 @@ fn build_tcc() {
#[cfg(not(target_os = "windows"))]
{
use std::path::PathBuf;
- use std::process::exit;
- use std::process::Command;

let root = PathBuf::from(concat!(env!("CARGO_MANIFEST_DIR")));
let tcc_src = root.join("tinycc");
dbg!(&tcc_src);
- let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
- let mut configure = Command::new(tcc_src.join("configure"));
- configure.current_dir(&out_dir);
- configure.args(&["--enable-static", "--extra-cflags=-fPIC -O3 -g -static"]);
- let status = configure.status().unwrap();
- if !status.success() {
- eprintln!("Fail to configure: {:?}", status);
- exit(1);
- }

- let mut make = Command::new("make");
- make.current_dir(&out_dir).arg(format!(
- "-j{}",
- env::var("NUM_JOBS").unwrap_or_else(|_| String::from("1"))
- ));
- make.args(&["libtcc.a"]);
- let status = make.status().unwrap();
+ let dst = Config::new("tinycc")
+ .enable("static", None)
+ .cflag("-fPIC")
+ .cflag("-O3")
+ .cflag("-g")
+ .cflag("-static")
+ .make_target("libtcc.a")
+ .build();

- if !status.success() {
- eprintln!("Fail to make: {:?}", status);
- exit(1);
- }
- println!("cargo:rustc-link-search=native={}", out_dir.display());
+ println!("cargo:rustc-link-search=native={}", dst.join("build").display());
println!("cargo:rerun-if-changed={}", tcc_src.display());
}
}
--
2.34.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
From 7e205d19ffdf149e1744f89e544129b6d5132ecd Mon Sep 17 00:00:00 2001
From: Michael Sarahan <[email protected]>
Date: Tue, 6 Sep 2022 21:13:06 -0500
Subject: [PATCH 2/3] explicitly add libffi system dep for cross compiling

---
ext/ffi/Cargo.toml | 2 +-
ext/ffi/build.rs | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/ext/ffi/Cargo.toml b/ext/ffi/Cargo.toml
index 05d417ad2..7763d2d83 100644
--- a/ext/ffi/Cargo.toml
+++ b/ext/ffi/Cargo.toml
@@ -19,7 +19,7 @@ autotools = "0.2"
[dependencies]
deno_core = { version = "0.148.0", path = "../../core" }
dlopen = "0.1.8"
-libffi = "3.0.0"
+libffi = { version="3.0.1", features=["system"] }
serde = { version = "1.0.129", features = ["derive"] }
tokio = { version = "1.17", features = ["full"] }

diff --git a/ext/ffi/build.rs b/ext/ffi/build.rs
index fbdcbe58d..ddd8eeca6 100644
--- a/ext/ffi/build.rs
+++ b/ext/ffi/build.rs
@@ -55,4 +55,5 @@ fn main() {
build_tcc();
}
println!("cargo:rustc-link-lib=static=tcc");
+ println!("cargo:rustc-link-lib=ffi");
}
--
2.34.1

72 changes: 72 additions & 0 deletions recipe/0003-allow-cross.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
From 470aaf847f24ad68b576c574e7e134894b4c5e2a Mon Sep 17 00:00:00 2001
From: Michael Sarahan <[email protected]>
Date: Wed, 7 Sep 2022 10:09:20 -0500
Subject: [PATCH 3/3] allow cross

---
Cargo.lock | 11 ++---------
cli/build.rs | 6 ------
ext/ffi/build.rs | 1 -
3 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 4db9913ad..5f78eda64 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -12,12 +12,6 @@ dependencies = [
"regex",
]

-[[package]]
-name = "abort_on_panic"
-version = "2.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "955f37ac58af2416bac687c8ab66a4ccba282229bd7422a28d2281a5e66a6116"
-
[[package]]
name = "adler"
version = "1.0.2"
@@ -2521,11 +2515,10 @@ checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"

[[package]]
name = "libffi"
-version = "3.0.0"
+version = "3.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0e08093a2ddeee94bd0c830a53d895ff91f1f3bb0f9b3c8c6b00739cdf76bc1d"
+checksum = "1e454b3efb16fba3b17810ae5e41df02b649e564ab3c5a34b3b93ed07ad287e6"
dependencies = [
- "abort_on_panic",
"libc",
"libffi-sys",
]
diff --git a/cli/build.rs b/cli/build.rs
index 1a4eaa425..668864b19 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -324,12 +324,6 @@ fn main() {
return;
}

- // 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.");
- }
// To debug snapshot issues uncomment:
// op_fetch_asset::trace_serializer();

diff --git a/ext/ffi/build.rs b/ext/ffi/build.rs
index ddd8eeca6..fbdcbe58d 100644
--- a/ext/ffi/build.rs
+++ b/ext/ffi/build.rs
@@ -55,5 +55,4 @@ fn main() {
build_tcc();
}
println!("cargo:rustc-link-lib=static=tcc");
- println!("cargo:rustc-link-lib=ffi");
}
--
2.34.1

29 changes: 10 additions & 19 deletions recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
#!/usr/bin/env sh

mkdir -p $PREFIX/bin
if [ "$SUBDIR" = "osx-arm64" ]; then
mv deno $PREFIX/bin
else
unset CARGO_BUILD_RUSTFLAGS
declare -x "CFLAGS_${CONDA_RUST_HOST}_RUSTFLAGS"="-Wl,-rpath,${BUILD_PREFIX}/lib -L${BUILD_PREFIX}/lib"
declare -x "CFLAGS_${CONDA_RUST_TARGET}_RUSTFLAGS"="-Wl,-rpath,${PREFIX}/lib octave-feedstock/pull/81/files-L${PREFIX}/lib"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here? bad copy-paste?


cargo bundle-licenses --format yaml --output DENO_THIRDPARTY_LICENSES.yml
if [[ "$SUBDIR" =~ ^osx.* ]]; then
if [ "$SUBDIR" = "osx-x64" ]; then
export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=$CC
# cargo build --target x86_64-apple-darwin --release
else
export CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=$CC
# cargo build --target aarch64-apple-darwin --release
fi
fi
export "CFLAGS_${CONDA_RUST_HOST}_RUSTFLAGS"
export "CFLAGS_${CONDA_RUST_TARGET}_RUSTFLAGS"

cargo build --release
cargo bundle-licenses --format yaml --output DENO_THIRDPARTY_LICENSES.yml
cargo build --release

mkdir -p $PREFIX/bin
OUTPUT_EXE=$(find target -name deno | tail -n 1)
mv $OUTPUT_EXE $PREFIX/bin/deno
fi
mkdir -p $PREFIX/bin
OUTPUT_EXE=$(find target -name deno | tail -n 1)
mv $OUTPUT_EXE $PREFIX/bin/deno

mkdir -p $PREFIX/etc/conda/activate.d
echo "export DENO_INSTALL_ROOT=$PREFIX" > "${PREFIX}/etc/conda/activate.d/deno.sh"
Expand Down
44 changes: 27 additions & 17 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@ package:
version: {{ version }}

source:
- url: https://github.com/denoland/deno/releases/download/v{{ version }}/deno_src.tar.gz # [not osx or not arm64]
sha256: a00fc3723377ed13a7b3eb3cc8e6564fc6604e50f7493c50d8189a8c6d457a8c # [not osx or not arm64]
- url: https://github.com/denoland/deno/releases/download/v{{ version }}/deno-aarch64-apple-darwin.zip # [osx and arm64]
sha256: 8b69218d94baa216f58d2a1334c4e226e59c7cf303e5abf82abf695e6c747ac5 # [osx and arm64]
url: https://github.com/denoland/deno/releases/download/v{{ version }}/deno_src.tar.gz
sha256: a00fc3723377ed13a7b3eb3cc8e6564fc6604e50f7493c50d8189a8c6d457a8c
patches:
- 0001-use-autotools-rs-for-building-tinycc.patch
- 0002-explicitly-add-libffi-system-dep-for-cross-compiling.patch
- 0003-allow-cross.patch

build:
number: 0
number: 1
# ppc64le is currently not supported by deno-ffi
# error: failed to run custom build command for `deno_ffi v0.51.0 (/home/conda/feedstock_root/build_artifacts/deno_1659987483450/work/ext/ffi)`
# Caused by:
# process didn't exit successfully: `/home/conda/feedstock_root/build_artifacts/deno_1659987483450/work/target/release/build/deno_ffi-7c581e1c41e8d6c6/build-script-build` (exit status: 1)
# --- stdout
# Unsupported CPU
skip: True # [ppc64le]

requirements: # [not osx or not arm64]
build: # [not osx or not arm64]
- {{ compiler("rust") }} # [not osx or not arm64]
requirements:
build:
- {{ compiler("rust") }}
# needs c compiler for run_exports
- {{ compiler("c") }} # [not osx or not arm64]
- {{ compiler("c") }}
- libffi # [build_platform != target_platform]
# for some reason, test_ffi pkg needs lld on osx-arm64
# - lld # [osx and arm64]
- cargo-bundle-licenses # [not osx or not arm64]
- make # [unix and not arm64]
run: # [osx and x86_64]
- __osx >={{ MACOSX_DEPLOYMENT_TARGET }} # [osx and x86_64]
- lld # [osx and arm64]
- cargo-bundle-licenses
- make
host:
- libffi
run: # [osx]
- __osx >={{ MACOSX_DEPLOYMENT_TARGET }} # [osx]

test:
commands:
Expand All @@ -37,10 +49,8 @@ about:
license: MIT
license_family: MIT
license_file:
- LICENSE.md # [not osx or not arm64]
- LICENSE.md
- DENO_THIRDPARTY_LICENSES.yml # [not osx or not arm64]
# the binary doesn't ship with a license. This is one taken from the github repo.
- LICENSE # [osx and arm64]
summary: A simple, modern and secure runtime for JavaScript and TypeScript that uses V8 and is built in Rust
doc_url: https://deno.land/manual
dev_url: https://github.com/denoland/deno
Expand Down