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

Fails compiling with cuda #641

Closed
elichai opened this issue Nov 27, 2021 · 1 comment · Fixed by #712
Closed

Fails compiling with cuda #641

elichai opened this issue Nov 27, 2021 · 1 comment · Fixed by #712

Comments

@elichai
Copy link

elichai commented Nov 27, 2021

I tried to build cuda code using the following build script:

    cc::Build::new()
        .cuda(true)
        .cudart("static")
        .flag("arch=sm_75")
        .flag("-std=c++17")
        .include("./testing/src")
        .file("testing/src/kernel.cu")
        .compile("libtesting.a");

And got the following error:
cargo:warning=nvcc fatal : Unknown option '--target=x86_64-unknown-linux-gnu'

Apparently nvcc doesn't like this flag.
full error:

  --- stdout
  TARGET = Some("x86_64-unknown-linux-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-unknown-linux-gnu")
  CXX_x86_64-unknown-linux-gnu = None
  CXX_x86_64_unknown_linux_gnu = None
  HOST_CXX = None
  CXX = Some("clang++ -stdlib=libc++")
  NVCC_x86_64-unknown-linux-gnu = None
  NVCC_x86_64_unknown_linux_gnu = None
  HOST_NVCC = None
  NVCC = None
  CXXFLAGS_x86_64-unknown-linux-gnu = None
  CXXFLAGS_x86_64_unknown_linux_gnu = None
  HOST_CXXFLAGS = None
  CXXFLAGS = None
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  running: "nvcc" "-ccbin=clang++" "-Xcompiler" "-O0" "-Xcompiler" "-ffunction-sections" "-Xcompiler" "-fdata-sections" "-Xcompiler" "-fPIC" "-G" "-Xcompiler" "-g" "-Xcompiler" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "-I" "./testing/src" "-Xcompiler" "-Wall" "-Xcompiler" "-Wextra" "arch=sm_75" "-std=c++17" "-o" .../src/kernel.o" "-c" "testing/src/kernel.cu"
  cargo:warning=nvcc fatal   : Unknown option '--target=x86_64-unknown-linux-gnu'
  exit status: 1

  --- stderr


  error occurred: Command "nvcc" "-ccbin=clang++" "-Xcompiler" "-O0" "-Xcompiler" "-ffunction-sections" "-Xcompiler" "-fdata-sections" "-Xcompiler" "-fPIC" "-G" "-Xcompiler" "-g" "-Xcompiler" "-fno-omit-frame-pointer" "--target=x86_64-unknown-linux-gnu" "-I" "./testing/src" "-Xcompiler" "-Wall" "-Xcompiler" "-Wextra" "arch=sm_75" "-std=c++17" "-o" "/.../src/kernel.o" "-c" "testing/src/kernel.cu" with args "nvcc" did not execute successfully (status code exit status: 1).

nvcc version:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_Sep_13_19:13:29_PDT_2021
Cuda compilation tools, release 11.5, V11.5.50
Build cuda_11.5.r11.5/compiler.30411180_0
@alexcrichton
Copy link
Member

I think you'll need to configure .target(..) if because otherwise the TARGET and HOST env vars are being read which makes this look like a different compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants