Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 736d3fb

Browse files
committed
Update for llvm-bitcode-linker
1 parent 0e4b1f8 commit 736d3fb

File tree

26 files changed

+193
-373
lines changed

26 files changed

+193
-373
lines changed

.github/workflows/ci.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- '*'
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
14+
jobs:
15+
check:
16+
name: Check
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest]
21+
rust: [nightly]
22+
23+
- name: Checkout the Repository
24+
uses: actions/checkout@v2
25+
26+
- name: Install the Rust toolchain
27+
uses: actions-rs/toolchain@v1
28+
with:
29+
toolchain: ${{ matrix.rust }}
30+
profile: minimal
31+
target: nvptx64-nvidia-cuda
32+
components: llvm-bitcode-linker, llvm-tools
33+
override: true
34+
35+
- name: Check all workspace targets
36+
run: cargo check --workspace --all-targets
37+
38+
test:
39+
name: Test Suite
40+
runs-on: ${{ matrix.os }}
41+
strategy:
42+
matrix:
43+
os: [ubuntu-latest]
44+
rust: [nightly]
45+
46+
steps:
47+
- name: Checkout the Repository
48+
uses: actions/checkout@v2
49+
50+
- name: Install the Rust toolchain
51+
uses: actions-rs/toolchain@v1
52+
with:
53+
toolchain: ${{ matrix.rust }}
54+
profile: minimal
55+
target: nvptx64-nvidia-cuda
56+
components: llvm-bitcode-linker, llvm-tools
57+
override: true
58+
59+
- name: Run the test-suite
60+
run: cargo test --workspace --no-fail-fast
61+
62+
fmt:
63+
name: Rustfmt
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Checkout the Repository
68+
uses: actions/checkout@v2
69+
70+
- name: Install the Rust toolchain
71+
uses: actions-rs/toolchain@v1
72+
with:
73+
toolchain: nightly
74+
profile: minimal
75+
components: rustfmt
76+
override: true
77+
78+
- name: Check the code formatting
79+
run: cargo fmt --all -- --check
80+
81+
clippy:
82+
name: Clippy
83+
runs-on: ${{ matrix.os }}
84+
strategy:
85+
matrix:
86+
os: [ubuntu-latest]
87+
rust: [nightly]
88+
89+
steps:
90+
- name: Checkout the Repository
91+
uses: actions/checkout@v2
92+
93+
- name: Install the Rust toolchain
94+
uses: actions-rs/toolchain@v1
95+
with:
96+
toolchain: ${{ matrix.rust }}
97+
profile: minimal
98+
components: clippy
99+
components: llvm-bitcode-linker, llvm-tools
100+
override: true
101+
102+
- name: Check all workspace targets
103+
run: cargo clippy --workspace --all-targets -- -D warnings

.github/workflows/rustdoc.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: rustdoc to gh-pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
env:
9+
CARGO_TERM_COLOR: always
10+
11+
jobs:
12+
release:
13+
name: GitHub Pages
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout the Repository
18+
uses: actions/checkout@v2
19+
20+
- name: Install the Rust toolchain
21+
uses: actions-rs/toolchain@v1
22+
with:
23+
toolchain: nightly
24+
profile: minimal
25+
override: true
26+
27+
- name: Build the Documentation
28+
run: |
29+
RUSTDOCFLAGS="\
30+
--enable-index-page \
31+
-Zunstable-options \
32+
" cargo doc --no-deps
33+
34+
- name: Deploy the Documentation
35+
uses: peaceiris/actions-gh-pages@v3
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
publish_branch: gh-pages
39+
publish_dir: ./target/doc

.travis.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

Cargo.toml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
[package]
22
name = "ptx-builder"
3-
version = "0.5.3"
4-
authors = ["Denys Zariaiev <denys.zariaiev@gmail.com>"]
3+
version = "0.6.0"
4+
authors = ["Denys Zariaiev <denys.zariaiev@gmail.com>", "Juniper Tyree <juniper.tyree@helsinki.fi>"]
55
license = "MIT"
6-
edition = "2018"
6+
edition = "2021"
7+
rust-version = "1.79" # nightly
78

89
readme = "README.md"
910
description = "NVPTX build helper"
@@ -28,8 +29,3 @@ libc = "0.2"
2829

2930
[dev-dependencies]
3031
antidote = "1.0"
31-
32-
[badges]
33-
appveyor = { repository = "denzp/rust-ptx-builder", branch = "master", service = "github" }
34-
travis-ci = { repository = "denzp/rust-ptx-builder", branch = "master" }
35-
maintenance = { status = "passively-maintained" }

LICENSE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
MIT License
22

3-
Copyright (c) 2018 Denys Zariaiev
3+
Copyright (c) 2018-2020 Denys Zariaiev
4+
Copyright (c) 2021- Juniper Tyree
45

56
Permission is hereby granted, free of charge, to any person obtaining a copy
67
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 9 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,14 @@
1-
# Rust PTX Builder
2-
[![Build Status](https://travis-ci.org/denzp/rust-ptx-builder.svg?branch=master)](https://travis-ci.org/denzp/rust-ptx-builder)
3-
[![Current Version](https://img.shields.io/crates/v/ptx-builder.svg)](https://crates.io/crates/ptx-builder)
4-
[![Docs](https://docs.rs/ptx-builder/badge.svg)](https://docs.rs/ptx-builder)
1+
# ptx-builder &emsp; [![CI Status]][workflow] [![MSRV]][repo] [![Rust Doc]][docs]
52

6-
## New Release: 0.5 🎉
7-
### Say goodbye to proxy crate approach
8-
This allows us to use single-source CUDA in **binary**-only crates (ones without `lib.rs`).
3+
[CI Status]: https://img.shields.io/github/actions/workflow/status/juntyr/rust-ptx-builder/ci.yml?branch=main
4+
[workflow]: https://github.com/juntyr/rust-ptx-builder/actions/workflows/ci.yml?query=branch%3Amain
95

10-
### Development breaking changes
11-
The crate does not provide a default `panic_handler` anymore.
12-
From now on, it either up to a user, or other crates (e.g. coming soon [`ptx-support` crate](https://github.com/denzp/rust-ptx-support)).
6+
[MSRV]: https://img.shields.io/badge/MSRV-1.79.0--nightly-orange
7+
[repo]: https://github.com/juntyr/rust-ptx-builder
138

14-
Next workaround should work in common cases,
15-
although it doesn't provide any panic details in runtime:
16-
``` rust
17-
#![feature(core_intrinsics)]
9+
[Rust Doc]: https://img.shields.io/badge/docs-main-blue
10+
[docs]: https://juntyr.github.io/rust-ptx-builder/
1811

19-
#[panic_handler]
20-
unsafe fn breakpoint_panic_handler(_: &::core::panic::PanicInfo) -> ! {
21-
core::intrinsics::breakpoint();
22-
core::hint::unreachable_unchecked();
23-
}
24-
```
12+
## License
2513

26-
### API Breaking Changes - less boilerplate code
27-
`build.rs` script was never so compact and clear before:
28-
``` rust
29-
use ptx_builder::error::Result;
30-
use ptx_builder::prelude::*;
31-
32-
fn main() -> Result<()> {
33-
let builder = Builder::new(".")?;
34-
CargoAdapter::with_env_var("KERNEL_PTX_PATH").build(builder);
35-
}
36-
```
37-
38-
### Documentation improvements
39-
This release comes with a significant documentation improvement! [Check it out](https://docs.rs/ptx-builder) :)
40-
41-
## Purpose
42-
The library should facilitate CUDA development with Rust.
43-
It can be used in a [cargo build script](http://doc.crates.io/build-script.html) of a host crate, and take responsibility for building device crates.
44-
45-
## Features
46-
1. Obviously, device crates building.
47-
2. Announcing device crates sources to cargo, so it can automatically rebuild after changes.
48-
3. Reporting about missing tools, for example:
49-
```
50-
[PTX] Unable to get target details
51-
[PTX]
52-
[PTX] caused by:
53-
[PTX] Command not found in PATH: 'rust-ptx-linker'. You can install it with: 'cargo install ptx-linker'.
54-
```
55-
56-
## Prerequirements
57-
The library depends on a fresh Nightly and [ptx-linker](https://crates.io/crates/ptx-linker).
58-
The latter can be installed from crates.io:
59-
```
60-
cargo install ptx-linker
61-
```
62-
63-
## Usage
64-
First, you need to specify a build script in host crate's `Cargo.toml` and declare the library as a *build-dependency*:
65-
``` toml
66-
[build-dependencies]
67-
ptx-builder = "0.5"
68-
```
69-
70-
Then, typical `build.rs` might look like:
71-
``` rust
72-
use ptx_builder::error::Result;
73-
use ptx_builder::prelude::*;
74-
75-
fn main() -> Result<()> {
76-
let builder = Builder::new(".")?;
77-
CargoAdapter::with_env_var("KERNEL_PTX_PATH").build(builder);
78-
}
79-
```
14+
Licensed under the MIT license ([LICENSE](LICENSE) or http://opensource.org/licenses/MIT).

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[toolchain]
22
channel = "nightly"
3-
components = [ "rustfmt", "clippy" ]
3+
components = [ "rustfmt", "clippy", "llvm-bitcode-linker", "llvm-tools" ]
44
targets = [ "x86_64-unknown-linux-gnu", "nvptx64-nvidia-cuda" ]

src/builder.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use regex::Regex;
1010

1111
use crate::{
1212
error::{BuildErrorKind, Error, Result, ResultExt},
13-
executable::{Cargo, ExecutableRunner, Linker},
13+
executable::{Cargo, ExecutableRunner},
1414
source::Crate,
1515
};
1616

@@ -249,9 +249,6 @@ impl Builder {
249249
return Ok(BuildStatus::NotNeeded);
250250
}
251251

252-
// Verify `ptx-linker` version.
253-
ExecutableRunner::new(Linker).with_args(vec!["-V"]).run()?;
254-
255252
let mut cargo = ExecutableRunner::new(Cargo);
256253
let mut args = vec!["rustc"];
257254

@@ -372,8 +369,8 @@ impl Builder {
372369
.trim_matches('\n')
373370
.split('\n')
374371
.find(|line| {
375-
line.contains(&format!("--crate-name {}", crate_name))
376-
&& line.contains(&format!("--crate-type {}", crate_type))
372+
line.contains(&format!("--crate-name {crate_name}"))
373+
&& line.contains(&format!("--crate-type {crate_type}"))
377374
})
378375
.map(|line| BuildCommand::Realtime(line.to_string()))
379376
.or_else(|| Self::load_cached_build_command(&output_path, &self.prefix))
@@ -419,15 +416,15 @@ impl Builder {
419416
}
420417

421418
fn load_cached_build_command(output_path: &Path, prefix: &str) -> Option<BuildCommand> {
422-
match read_to_string(output_path.join(format!("{}.{}", LAST_BUILD_CMD, prefix))) {
419+
match read_to_string(output_path.join(format!("{LAST_BUILD_CMD}.{prefix}"))) {
423420
Ok(contents) => Some(BuildCommand::Cached(contents)),
424421
Err(_) => None,
425422
}
426423
}
427424

428425
fn store_cached_build_command(output_path: &Path, prefix: &str, command: &str) -> Result<()> {
429426
write(
430-
output_path.join(format!("{}.{}", LAST_BUILD_CMD, prefix)),
427+
output_path.join(format!("{LAST_BUILD_CMD}.{prefix}")),
431428
command.as_bytes(),
432429
)
433430
.context(BuildErrorKind::OtherError)?;
@@ -535,7 +532,7 @@ impl<'a> BuildOutput<'a> {
535532
.trim()
536533
.split(' ')
537534
.map(|item| PathBuf::from(item.trim()))
538-
.chain(cargo_deps.into_iter())
535+
.chain(cargo_deps)
539536
.collect())
540537
}
541538

src/executable/mod.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ pub trait Executable {
3333
/// `cargo` command.
3434
pub struct Cargo;
3535

36-
/// `ptx-linker` command.
37-
pub struct Linker;
38-
3936
impl Executable for Cargo {
4037
fn get_name(&self) -> String {
4138
String::from("cargo")
@@ -63,21 +60,3 @@ impl Executable for Cargo {
6360
})
6461
}
6562
}
66-
67-
impl Executable for Linker {
68-
fn get_name(&self) -> String {
69-
String::from("rust-ptx-linker")
70-
}
71-
72-
fn get_verification_hint(&self) -> String {
73-
String::from("You can install it with: 'cargo install ptx-linker'")
74-
}
75-
76-
fn get_version_hint(&self) -> String {
77-
String::from("You can update it with: 'cargo install -f ptx-linker'")
78-
}
79-
80-
fn get_required_version(&self) -> Option<VersionReq> {
81-
Some(VersionReq::parse(">= 0.9.0").unwrap())
82-
}
83-
}

0 commit comments

Comments
 (0)