Skip to content

compiling multiple cuda files #505

@YoshikawaMasashi

Description

@YoshikawaMasashi

I'm trying to compile multiple Cuda files that have dependencies. and I got an error message.
Is there a way to compile multiple CUDA files using cc-rs?

build.rs

extern crate cc;

fn main() {
    cc::Build::new()
        .cuda(true)
        .flag("-gencode")
        .flag("arch=compute_60,code=sm_60")
        .flag("-gencode")
        .flag("arch=compute_61,code=sm_61")
        .flag("-gencode")
        .flag("arch=compute_62,code=sm_62")
        .file("cuda_src/a.cu")
        .file("cuda_src/b.cu")
        .compile("kernel.o");

    println!("cargo:rustc-link-search=native=/usr/local/cuda/lib64");
    println!("cargo:rustc-link-lib=cudart");
}

a.cu

#include "b.h"

__device__ int a_func(int x) {
    return b_func(x) + 1;
}

b.cu

#include "b.h"

__device__ int b_func(int x) {
    return x + 1;
}

b.h

__device__ int b_func(int x);

error

warning: ptxas fatal   : Unresolved extern function '_Z6b_funci'
error: failed to run custom build command for `cc-rs-test v0.1.0

Activity

alexcrichton

alexcrichton commented on May 26, 2020

@alexcrichton
Member

Sorry I do not know anything about cuda, so I am not able to help you here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alexcrichton@YoshikawaMasashi

        Issue actions

          compiling multiple cuda files · Issue #505 · rust-lang/cc-rs