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

LLVM ERROR: Module has aliases, which NVPTX does not support. #13

Closed
ahendriksen opened this issue Dec 6, 2018 · 12 comments
Closed

LLVM ERROR: Module has aliases, which NVPTX does not support. #13

ahendriksen opened this issue Dec 6, 2018 · 12 comments

Comments

@ahendriksen
Copy link

Hi,

Thanks for creating this great package! I have tried to get rust-ptx-builder to work, but I have not yet succeeded. I get the error 'LLVM ERROR: Module has aliases, which NVPTX does not support.'. To make sure that I was not an error on my part, I have tried to build one of the example projects in rust-ptx-support.

This is what I get:

$ cargo build
   Compiling cuda-println v0.1.0 (/export/scratch1/hendriks/projects/rustacuda_example/rust-ptx-support/examples/cuda-println)
error: failed to run custom build command for `cuda-println v0.1.0 (/export/scratch1/hendriks/projects/rustacuda_example/rust-ptx-support/examples/cuda-println)`
process didn't exit successfully: `/export/scratch1/hendriks/projects/rustacuda_example/rust-ptx-support/target/debug/build/cuda-println-0022aa50cae5c930/build-script-build` (exit code: 1)
--- stderr
[PTX] Unable to build a PTX crate!
[PTX]    Compiling cuda-println v0.1.0 (/export/scratch1/hendriks/projects/rustacuda_example/rust-ptx-support/examples/cuda-println)
[PTX] error: linking with `ptx-linker` failed: exit code: 1
[PTX]   |
[PTX]   = note: "ptx-linker" "-L" "/ufs/hendriks/.xargo/lib/rustlib/nvptx64-nvidia-cuda/lib" "/tmp/ptx-builder-0.5/cuda_println/d623bafb1eb4deca/nvptx64-nvidia-cuda/release/deps/cuda_println-01803fec47121bc1.cuda_println.2jagi3my-cgu.0.rcgu.o" "/tmp/ptx-builder-0.5/cuda_println/d623bafb1eb4deca/nvptx64-nvidia-cuda/release/deps/cuda_println-01803fec47121bc1.cuda_println.2jagi3my-cgu.1.rcgu.o" "-o" "/tmp/ptx-builder-0.5/cuda_println/d623bafb1eb4deca/nvptx64-nvidia-cuda/release/deps/cuda_println-01803fec47121bc1.ptx" "/tmp/ptx-builder-0.5/cuda_println/d623bafb1eb4deca/nvptx64-nvidia-cuda/release/deps/cuda_println-01803fec47121bc1.1w5kxn6gnyc7w18l.rcgu.o" "-O1" "-L" "/tmp/ptx-builder-0.5/cuda_println/d623bafb1eb4deca/nvptx64-nvidia-cuda/release/deps" "-L" "/tmp/ptx-builder-0.5/cuda_println/d623bafb1eb4deca/release/deps" "-L" "/ufs/hendriks/.xargo/lib/rustlib/nvptx64-nvidia-cuda/lib" "--start-group" "-Bstatic" "--whole-archive" "/tmp/rustchm5YG8/libptx_support-bac6370d784080de.rlib" "--no-whole-archive" "--whole-archive" "/tmp/rustchm5YG8/libcore-5040dc495f9f5fc0.rlib" "--no-whole-archive" "--end-group" "/tmp/rustchm5YG8/libcompiler_builtins-44064ef211638321.rlib" "-shared" "-Bdynamic"
[PTX]   = note:  [INFO] Going to link 3 bitcode modules and 3 rlibs...
[PTX]                   
[PTX]            [INFO] Linking with Link Time Optimisation
[PTX]           LLVM ERROR: Module has aliases, which NVPTX does not support.
[PTX]           
[PTX] 
[PTX] error: aborting due to previous error
[PTX] 
[PTX] error: Could not compile `cuda-println`.
[PTX] 

Unfortunately, I cannot seem to get more verbose output than this. I have installed xargo and ptx-linker. I have CUDA_LIBRARY_PATH set correctly. I do not have LLVM installed locally.

I tried with the following versions of rustc:

  • rustc 1.32.0-nightly (14997d56a 2018-12-05) failed: same reason
  • rustc 1.32.0-nightly (b3af09205 2018-12-04) failed: same reason
  • rustc 1.32.0-nightly (5aff30734 2018-11-19) failed: different reason - "note: Unable to find LLVM shared lib in possible locations:"
  • rustc 1.32.0-nightly (653da4fd0 2018-11-08) failed: different reason - "note: Unable to find LLVM shared lib in possible locations:"
  • rustc 1.32.0-nightly (36a50c29f 2018-11-09) failed: different reason - "note: Unable to find LLVM shared lib in possible locations:"
  • rustc 1.31.0-nightly (de9666f12 2018-10-31) failed: different reason - "note: Unable to find LLVM shared lib in possible locations:"

I am not sure which of these errors occurs earlier in the compilation process, the module alias error, or the LLVM shared lib error.

If there is anything I can do to make this issue more specific, please let me know!

@Frequenzmodulation
Copy link

Hi,

I'm getting the same error, even for a minimal example like

#![feature(core_intrinsics)]

#![no_std]
fn foo() {}

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

When I do RUST_TARGET_PATH=$(pwd) xargo rustc --target nvptx64-nvidia-cuda -- --emit=asm I don't get errors, it just hangs.

I ran out of ideas what to try for now, so any suggestions what to do next are greatly appreciated. Thanks!

@denzp
Copy link
Owner

denzp commented Jan 9, 2019

Sorry for a late response. The problem was reported in rust-lang/rust#57356 and you can track its progress in rust-lang/rust#57268. As soon as the PR will be merged, there will be a chance to disable an optimisation pass that causes the issue.

@denzp
Copy link
Owner

denzp commented Jan 20, 2019

Could you please try the updated ptx-linker? Version 0.8.3 contains a modified target specification json with the disabled optimisation pass.

rm -rf /tmp/ptx-builder-targets-0.5
cargo install -f ptx-linker
ptx-linker -V

@Frequenzmodulation
Copy link

Thank you for this suggestion.
After following your steps and cargo clean I get

$ ptx-linker -V
ptx-linker 0.8.3
$ cargo build
...
[PTX]            [INFO] Linking without optimisations
[PTX]           LLVM ERROR: Module has aliases, which NVPTX does not support.
...
[PTX] error: aborting due to previous error

Are the troubling optimisations done before linking time?

@denzp
Copy link
Owner

denzp commented Jan 21, 2019

Sorry, forgot to mention: it also has to be a recent Rust nightly (7bac68a5d 2019-01-21 works for me).

@Frequenzmodulation
Copy link

This looks like progress. Still not quite.

$ rustup install nightly-2019-01-21
...
$ rustup default nightly-2019-01-21
...
$ cargo build
...
error: unrecognized platform-specific intrinsic function: `nvptx_block_dim_x`
 --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:5:5
  |
5 |     pub fn nvptx_block_dim_x() -> i32;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_block_dim_y`
 --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:8:5
  |
8 |     pub fn nvptx_block_dim_y() -> i32;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_block_dim_z`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:11:5
   |
11 |     pub fn nvptx_block_dim_z() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_block_idx_x`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:14:5
   |
14 |     pub fn nvptx_block_idx_x() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_block_idx_y`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:17:5
   |
17 |     pub fn nvptx_block_idx_y() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_block_idx_z`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:20:5
   |
20 |     pub fn nvptx_block_idx_z() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_grid_dim_x`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:23:5
   |
23 |     pub fn nvptx_grid_dim_x() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_grid_dim_y`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:26:5
   |
26 |     pub fn nvptx_grid_dim_y() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_grid_dim_z`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:29:5
   |
29 |     pub fn nvptx_grid_dim_z() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_syncthreads`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:32:5
   |
32 |     pub fn nvptx_syncthreads() -> ();
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_thread_idx_x`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:35:5
   |
35 |     pub fn nvptx_thread_idx_x() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_thread_idx_y`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:38:5
   |
38 |     pub fn nvptx_thread_idx_y() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: unrecognized platform-specific intrinsic function: `nvptx_thread_idx_z`
  --> ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/nvptx-builtins-0.1.0/src/intrinsics.rs:41:5
   |
41 |     pub fn nvptx_thread_idx_z() -> i32;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 13 previous errors

error: Could not compile `nvptx-builtins`.

@denzp
Copy link
Owner

denzp commented Jan 21, 2019

Yes, unfortunately, nvptx-builtins is deprecated.

I applied the following trivial fix to a test crate at ptx-linker:
denzp/rust-ptx-linker@92f8f0f#diff-7a043822a4ef5ff6e6e78275cb97f70f

Functions in core::arch::nvptx are similar to those exported from nvptx-builtins, just prefixed with underscore.

@Frequenzmodulation
Copy link

I'm trying to compile your ptx-linker intrinsics example.
First I got:

error: linker `legacy-ptx-linker` not found
  |
  = note: No such file or directory (os error 2)

After this hack: export PATH=$PATH:../../target/release/ I get:

$ xargo build --target nvptx64-nvidia-cuda --release
   Compiling example v0.1.0 (${HOME}/rust-ptx-linker/examples/intrinsics)
error: linking with `legacy-ptx-linker` failed: signal: 4
  |
  = note: "legacy-ptx-linker" "-L" "${HOME}/.xargo/lib/rustlib/nvptx64-nvidia-cuda/lib" "${HOME}/rust-ptx-linker/examples/intrinsics/target/nvptx64-nvidia-cuda/release/deps/example.example.9zaa1d02-cgu.0.rcgu.o" "${HOME}/rust-ptx-linker/examples/intrinsics/target/nvptx64-nvidia-cuda/release/deps/example.example.9zaa1d02-cgu.1.rcgu.o" "-o" "${HOME}/rust-ptx-linker/examples/intrinsics/target/nvptx64-nvidia-cuda/release/deps/example.ptx" "${HOME}/rust-ptx-linker/examples/intrinsics/target/nvptx64-nvidia-cuda/release/deps/example.57v44vf34hrady31.rcgu.o" "-O1" "-L" "${HOME}/rust-ptx-linker/examples/intrinsics/target/nvptx64-nvidia-cuda/release/deps" "-L" "${HOME}/rust-ptx-linker/examples/intrinsics/target/release/deps" "-L" "${HOME}/.xargo/lib/rustlib/nvptx64-nvidia-cuda/lib" "-Bstatic" "--whole-archive" "/tmp/rustc3Vk5Cr/librustc_std_workspace_core-7aab447a2eaf1c96.rlib" "--no-whole-archive" "--whole-archive" "/tmp/rustc3Vk5Cr/libcore-5f9f04db0e313fa5.rlib" "--no-whole-archive" "/tmp/rustc3Vk5Cr/libcompiler_builtins-7defd96cc8eb2126.rlib" "-shared" "-Bdynamic"
  = note: Unable to find LLVM shared lib in possible locations:
          - ${HOME}/.xargo/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends
          - ${HOME}/.cargo/codegen-backends
          - ${HOME}/.cargo/codegen-backends
          - ${HOME}/.cabal/codegen-backends
          - ${HOME}/.cargo/codegen-backends
          - ${HOME}/codegen-backends
          - ${HOME}/.cabal/codegen-backends
          - /usr/local/codegen-backends
          - /usr/local/codegen-backends
          - /usr/codegen-backends
          - /usr/codegen-backends
          - /codegen-backends
          - /codegen-backends
          - /usr/codegen-backends
          - /usr/local/codegen-backends
          - /snap/codegen-backends
          - ${HOME}/codegen-backends
          - ${HOME}/.local/codegen-backends
          - /usr/local/cuda-8.0/codegen-backends
          - ${HOME}/codegen-backends
          - ${HOME}/.local/codegen-backends
          - /usr/local/cuda-8.0/codegen-backends
          - ../../target/codegen-backends
          - ${HOME}/.rustup/toolchains/nightly-2019-01-21-x86_64-unknown-linux-gnu/lib/rustlib/2019-01-21-x86_64-unknown-linux-gnu/codegen-backends
          - ${HOME}/.rustup/toolchains/nightly-2019-01-21-x86_64-unknown-linux-gnu/lib/rustlib/2019-01-21-x86_64-unknown-linux-gnu/codegen-backends
          - ${HOME}/rust-ptx-linker/examples/intrinsics/target/release/lib/rustlib/codegen-backends
          - ${HOME}/.rustup/toolchains/nightly-2019-01-21-x86_64-unknown-linux-gnu/lib/rustlib/2019-01-21-x86_64-unknown-linux-gnu/codegen-backends
          - ${HOME}/.rustup/toolchains/nightly-2019-01-21-x86_64-unknown-linux-gnu/lib/rustlib/2019-01-21-x86_64-unknown-linux-gnu/codegen-backends
          - ${HOME}/.rustup/toolchains/nightly-2019-01-21-x86_64-unknown-linux-gnu/lib/rustlib/2019-01-21-x86_64-unknown-linux-gnu/codegen-backends
          - ${HOME}/.rustup/toolchains/nightly-2019-01-21-x86_64-unknown-linux-gnu/lib/rustlib/2019-01-21-x86_64-unknown-linux-gnu/codegen-backends
          thread 'main' panicked at 'explicit panic', ${HOME}/.cargo/registry/src/github.aaakk.us.kg-1ecc6299db9ec823/rustc-llvm-proxy-0.1.7/src/lib.rs:58:17
          note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
          

error: aborting due to previous error

error: Could not compile `example`.

I'm somewhat new to Rust, thanks for all your help!

@denzp
Copy link
Owner

denzp commented Jan 21, 2019

That's a nice catch, thanks. I can reproduce your problem!
Seems like, the linker cannot find the LLVM library when using a specific Rust version (nightly-2019-01-21 instead of nightly).

I'll post here when the issue will be fixed.

@denzp
Copy link
Owner

denzp commented Jan 21, 2019

@Frequenzmodulation can you please pull the latest ptx-linker and try to compile the example again?

I've added a code to handle the case: denzp/rustc-llvm-proxy@20815b5

@Frequenzmodulation
Copy link

@denzp Thank you, seems it did the trick! I produces target/nvptx64-nvidia-cuda/release/example.ptx.

@ahendriksen
Copy link
Author

Great! that fixes my issue :)

Sorry for the long delay!

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

No branches or pull requests

3 participants