Skip to content

Commit

Permalink
feat: add mold for linux (#1033)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hofer-Julian authored Nov 10, 2024
1 parent 8e3ef72 commit 26309bb
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 225 deletions.
13 changes: 5 additions & 8 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ concurrency:
env:
RUST_LOG: info
RUST_BACKTRACE: 1
RUSTFLAGS: "-D warnings"
CARGO_TERM_COLOR: always
RATTLER_BUILD_ENABLE_GITHUB_INTEGRATION: "true"

Expand All @@ -39,16 +38,14 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: "1.75.0"
workspaces: ". -> target-pixi"
key: ${{ hashFiles('pixi.lock') }}
- uses: prefix-dev/[email protected]
- if: runner.os == 'macOS'
run: pixi global install patchelf
# build in release mode so that it's reasonably fast to run the tests
- run: cargo build --release
- run: cargo test --release -p rust-tests -- --test-threads 1
- run: pixi run end_to_end_test -s -v
- run: pixi run build-release
- run: pixi run test-ci
- run: pixi run test-end-to-end -s -v
env:
PREFIX_DEV_READ_ONLY_TOKEN: ${{ secrets.PREFIX_DEV_READ_ONLY_TOKEN }}
ANACONDA_ORG_TEST_TOKEN: ${{ secrets.ANACONDA_ORG_TEST_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ site

# pixi environments
.pixi
target-pixi
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ default-run = "rattler-build"
rust-version = "1.80.0"

[features]
default = ['native-tls', 'recipe-generation']
default = ['rustls-tls', 'recipe-generation']
native-tls = [
'reqwest/native-tls',
'rattler/native-tls',
Expand Down
576 changes: 371 additions & 205 deletions pixi.lock

Large diffs are not rendered by default.

31 changes: 27 additions & 4 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ channels = ["conda-forge"]
platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"]

[tasks]
build = "cargo build --release"
build-release = "cargo build --release"
install = "cargo install --path . --locked"
end_to_end_test = "pytest test/end-to-end --snapshot-warn-unused --snapshot-details"
test-end-to-end = { cmd = "pytest test/end-to-end --snapshot-warn-unused --snapshot-details", depends-on = [
"build-release",
] }
test = "cargo test"
test-ci = "cargo test --release -p rust-tests -- --test-threads 1"
lint = "pre-commit run --all"
generate-cli-docs = "cargo add clap-markdown --git https://github.com/ruben-arts/clap-markdown --branch main && cargo run --bin generate-cli-docs --features generate-cli-docs > docs/reference/cli.md && cargo rm clap-markdown"
update-snapshots = "pytest test/end-to-end --snapshot-update"
Expand All @@ -36,6 +39,24 @@ conda-package-handling = "2.2.0.*"
requests = ">=2.32.2,<2.33"
syrupy = "4.6.*"

[target.linux-64.dependencies]
clang = ">=18.1.8,<19.0"
mold = ">=2.33.0,<3.0"
patchelf = ">=0.17.2,<0.18"

[target.osx-64.dependencies]
patchelf = ">=0.18.0,<0.19"

[target.osx-arm64.dependencies]
patchelf = ">=0.18.0,<0.19"

[target.linux-64.activation]
scripts = ["scripts/activate.sh"]
[target.osx-arm64.activation]
scripts = ["scripts/activate.sh"]
[target.win-64.activation]
scripts = ["scripts/activate.bat"]

[feature.docs.dependencies]
mkdocs = "1.5.3.*"
mkdocs-material = ">=9.5.16,<9.7"
Expand All @@ -45,5 +66,7 @@ mike = "2.0.0.*"

[environments]
# Using same solve group to keep the environment consistent in versions used and improving cache hits
default = {solve-group = "default"}
docs = {features = ["docs"], no-default-feature = true, solve-group = "default"}
default = { solve-group = "default" }
docs = { features = [
"docs",
], no-default-feature = true, solve-group = "default" }
4 changes: 2 additions & 2 deletions rust-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ mod tests {
assert!(pkg.join("info/index.json").exists());
let index_json: HashMap<String, serde_json::Value> =
serde_json::from_slice(&std::fs::read(pkg.join("info/index.json")).unwrap()).unwrap();
assert!(index_json.get("depends").is_none());
assert!(!index_json.contains_key("depends"));
}

#[test]
Expand All @@ -253,7 +253,7 @@ mod tests {
assert!(pkg.join("info/index.json").exists());
let index_json: HashMap<String, serde_json::Value> =
serde_json::from_slice(&std::fs::read(pkg.join("info/index.json")).unwrap()).unwrap();
assert!(index_json.get("depends").is_none());
assert!(!index_json.contains_key("depends"));
}

fn get_package(folder: impl AsRef<Path>, mut glob_str: String) -> PathBuf {
Expand Down
3 changes: 3 additions & 0 deletions scripts/activate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
set CARGO_TARGET_DIR=target-pixi
set RATTLER_BUILD_PATH="%PIXI_PROJECT_ROOT%\target-pixi\release\rattler-build.exe"
12 changes: 12 additions & 0 deletions scripts/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -Eeuo pipefail
export CARGO_TARGET_DIR="target-pixi"
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER="clang"
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=-fuse-ld=$CONDA_PREFIX/bin/mold"

# on macOS we need to set these rust flags
export CARGO_TARGET_X86_64_APPLE_DARWIN_RUSTFLAGS="-C link-arg=-Wl,-rpath,$CONDA_PREFIX/lib"
export CARGO_TARGET_AARCH64_APPLE_DARWIN_RUSTFLAGS="-C link-arg=-Wl,-rpath,$CONDA_PREFIX/lib"

export RATTLER_BUILD_PATH="$PIXI_PROJECT_ROOT/target-pixi/release/rattler-build"

2 changes: 1 addition & 1 deletion src/console_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ pub fn init_logging(
Ok(log_handler)
}

/// check if we are on Github CI nad if the user has enabled the integration
/// check if we are on Github CI and if the user has enabled the integration
pub fn github_integration_enabled() -> bool {
std::env::var("GITHUB_ACTIONS").is_ok()
&& std::env::var("RATTLER_BUILD_ENABLE_GITHUB_INTEGRATION") == Ok("true".to_string())
Expand Down
5 changes: 1 addition & 4 deletions src/recipe/jinja.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,10 +1120,7 @@ mod tests {
);

assert_eq!(
jinja
.eval(&format!("(var | split('.'))[2]"))
.unwrap()
.to_string(),
jinja.eval("(var | split('.'))[2]").unwrap().to_string(),
"3"
);
}
Expand Down

0 comments on commit 26309bb

Please sign in to comment.