denzp / rust-ptx-builder

Convenient `build.rs` helper for NVPTX crates
MIT License
53 stars 9 forks source link

Compile in release mode only when build is in release mode #6

Closed dbeckwith closed 6 years ago

dbeckwith commented 6 years ago

Fixes #5 I feel like the intent is right, but I'm getting a bad-looking error from xargo when it tries to compile without the --release flag:

   Compiling sample-ptx_crate v0.1.0 (file://$HOME/Dropbox/Programming/rust/rust-ptx-builder/tests/fixtures/sample-crate)
   Compiling proxy v0.0.0 (file:///tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa)
error: linking with `ptx-linker` failed: exit code: 1
  |
  = note: "ptx-linker" "-L" "$HOME/.xargo/lib/rustlib/nvptx64-nvidia-cuda/lib" "/tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa/target/nvptx64-nvidia-cuda/debug/deps/proxy.3rg6oty3sxxix4x5.rcgu.o" "-o" "/tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa/target/nvptx64-nvidia-cuda/debug/deps/proxy.ptx" "/tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa/target/nvptx64-nvidia-cuda/debug/deps/proxy.crate.metadata.rcgu.o" "-L" "/tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa/target/nvptx64-nvidia-cuda/debug/deps" "-L" "/tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa/target/debug/deps" "-L" "$HOME/.xargo/lib/rustlib/nvptx64-nvidia-cuda/lib" "-Bstatic" "--whole-archive" "/tmp/rustc.9Iv8OM6g45O1/libsample_ptx_crate-832f87e79ce5cf64.rlib" "--no-whole-archive" "--whole-archive" "/tmp/rustc.9Iv8OM6g45O1/libcore-d30d934963d2f831.rlib" "--no-whole-archive" "/tmp/rustc.9Iv8OM6g45O1/libcompiler_builtins-75beea7828105c3b.rlib" "-shared" "-Bdynamic"
  = note:  [INFO] Going to link 2 bitcode modules and 3 rlibs...

          [DEBUG] Linking bitcode: "/tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa/target/nvptx64-nvidia-cuda/debug/deps/proxy.3rg6oty3sxxix4x5.rcgu.o"
          error: Invalid record

error: aborting due to previous error

error: Could not compile `proxy`.

To learn more, run the command again with --verbose.

Any idea how to solve that?

denzp commented 6 years ago

Interesting, it doesn't crash on my side, albeit I have same versions as Travis, where it fails... Will try to investigate more details. So far, it looks like a ptx-linker issue.

BTW, I think it still might try to use release assembly, because the path is also specified at: https://github.com/denzp/rust-ptx-builder/pull/6/files#diff-058d40ebe40b5d40f6ffb05cf3d82dd8R126

dbeckwith commented 6 years ago

Yeah I guess ptx-linker can't handle debug symbols or something?

denzp commented 6 years ago

Can you please provide an output of llvm-config --version and, if it's possible, please send me /tmp/ptx-builder/sample_ptx_crate/2173c7eb610022fa/target/nvptx64-nvidia-cuda/debug/deps/proxy.3rg6oty3sxxix4x5.rcgu.o.

I suspect Rust generates 6.0 bitcode that can't be processed by ptx-linker since it depends on LLVM 5.0 on Travis.

dbeckwith commented 6 years ago

Yep, I'm using llvm 5.0.0 as required by the llvm-sys 50 crate that's required by ptx-linker. GitHub won't let me upload that file type, so I just put it in my Dropbox.

denzp commented 6 years ago

Thanks for details!

The file seems fine, it's indeed an LLVM bitcode. Which proves assumption about LLVM version issues... I'll add more strict version requirements for ptx-linker soon.

denzp commented 6 years ago

Sorry for the delay, I'm afraid it's blocked by the denzp/rust-ptx-linker#11 because debug mode is de-facto default mode during development. I think it's important to get the linker updated and published first.

dbeckwith commented 6 years ago

No problem! Thanks for helping!

denzp commented 6 years ago

Thanks for the PR!

I updated ptx-linker version requirements in a685c5bf9bc7ad503ce46b1a9809e740cc73fa42 and published 0.3.4.