Convenient `build.rs` helper for NVPTX crates
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src remove tool_lints feature Nov 9, 2018
tests Fix Windows tests Oct 11, 2018
.gitignore Initial commit Jan 30, 2018
.travis.yml remove tool_lints feature Nov 9, 2018
Cargo.toml New crates release Nov 10, 2018
LICENSE Readme Feb 8, 2018
README.md Fix docs link Oct 11, 2018
appveyor.yml Fix AppVeyor tests on Windows Aug 29, 2018

README.md

Rust PTX Builder

Build Status Build status Current Version Docs

New Release: 0.5 🎉

Say goodbye to proxy crate approach

This allows us to use single-source CUDA in binary-only crates (ones without lib.rs). New approach might seem a bit hacky with overriding Cargo behavior and enforcing --crate-type dylib, but in the end, development workflow became much more convinient.

Development breaking changes

The crate does not provide a default panic_handler anymore. From now on, it either up to a user, or other crates (e.g. coming soon ptx-support crate).

Next workaround should work in common cases, although it doesn't provide any panic details in runtime:

#![feature(core_intrinsics)]

#[panic_handler]
unsafe fn breakpoint_panic_handler(_: &::core::panic::PanicInfo) -> ! {
    core::intrinsics::breakpoint();
    core::hint::unreachable_unchecked();
}

API Breaking Changes - less boilerplate code

build.rs script was never so compact and clear before:

use ptx_builder::error::Result;
use ptx_builder::prelude::*;

fn main() -> Result<()> {
    CargoAdapter::with_env_var("KERNEL_PTX_PATH").build(Builder::new(".")?);
}

Documentation improvements

This release comes with a significant documentation improvement! Check it out :)

Purpose

The library should facilitate CUDA development with Rust. It can be used in a cargo build script of a host crate, and take responsibility for building device crates.

Features

  1. Obviously, device crates building.
  2. Announcing device crates sources to cargo, so it can automatically rebuild after changes.
  3. Reporting about missing tools, for example:
[PTX] Unable to get target details
[PTX]
[PTX] caused by:
[PTX]   Command not found in PATH: 'ptx-linker'. You can install it with: 'cargo install ptx-linker'.

Prerequirements

The library depends on ptx-linker and xargo. Both can be installed from crates.io:

cargo install xargo
cargo install ptx-linker

Windows users!

Unfortunately, due to rustc-llvm-proxy#1 MSVS targets are not supported yet.

You might face similar errors:

Unable to find symbol 'LLVMContextCreate' in the LLVM shared lib

For now the only solution is to use GNU targets.

Usage

First, you need to specify a build script in host crate's Cargo.toml and declare the library as a build-dependency:

[build-dependencies]
ptx-builder = "0.5"

Then, typical build.rs might look like:

use ptx_builder::error::Result;
use ptx_builder::prelude::*;

fn main() -> Result<()> {
    CargoAdapter::with_env_var("KERNEL_PTX_PATH").build(Builder::new(".")?);
}