diff options
| author | Denys Zariaiev <denys.zariaiev@gmail.com> | 2019-01-29 20:54:23 +0100 |
|---|---|---|
| committer | Denys Zariaiev <denys.zariaiev@gmail.com> | 2019-01-29 20:55:09 +0100 |
| commit | 3f624456e6e284f918d4e189e766e357911b49e2 (patch) | |
| tree | 15a2eb6038a6d57b3d67233d27d7a88e7b602d71 | |
| parent | 899d936dee555ef2ac67e68a5017ccb0d1e9a697 (diff) | |
| download | rust-3f624456e6e284f918d4e189e766e357911b49e2.tar.gz rust-3f624456e6e284f918d4e189e766e357911b49e2.zip | |
Provide PTXLinker with fallback to internal `target-cpu`
| -rw-r--r-- | src/ci/docker/test-various/Dockerfile | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/back/linker.rs | 6 | ||||
| -rw-r--r-- | src/test/run-make/nvptx-binary-crate/Makefile | 7 | ||||
| -rw-r--r-- | src/test/run-make/nvptx-dylib-crate/kernel.rs | 2 |
4 files changed, 13 insertions, 4 deletions
diff --git a/src/ci/docker/test-various/Dockerfile b/src/ci/docker/test-various/Dockerfile index a5ae94262c1..6c419e13c9f 100644 --- a/src/ci/docker/test-various/Dockerfile +++ b/src/ci/docker/test-various/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ xz-utils # FIXME: build the `ptx-linker` instead. -RUN curl -sL https://github.com/denzp/rust-ptx-linker/releases/download/v0.9.0-alpha.1/rust-ptx-linker.linux64.tar.gz | \ +RUN curl -sL https://github.com/denzp/rust-ptx-linker/releases/download/v0.9.0-alpha.2/rust-ptx-linker.linux64.tar.gz | \ tar -xzvC /usr/bin RUN curl -sL https://nodejs.org/dist/v9.2.0/node-v9.2.0-linux-x64.tar.xz | \ diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index 55b02ebe6c4..249715a7b6e 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -1132,6 +1132,12 @@ impl<'a> Linker for PtxLinker<'a> { } fn finalize(&mut self) -> Command { + // Provide the linker with fallback to internal `target-cpu`. + self.cmd.arg("--fallback-arch").arg(match self.sess.opts.cg.target_cpu { + Some(ref s) => s, + None => &self.sess.target.target.options.cpu + }); + ::std::mem::replace(&mut self.cmd, Command::new("")) } diff --git a/src/test/run-make/nvptx-binary-crate/Makefile b/src/test/run-make/nvptx-binary-crate/Makefile index 4c22dae265c..2c211b5c785 100644 --- a/src/test/run-make/nvptx-binary-crate/Makefile +++ b/src/test/run-make/nvptx-binary-crate/Makefile @@ -2,8 +2,11 @@ ifeq ($(TARGET),nvptx64-nvidia-cuda) all: - $(RUSTC) main.rs -Clink-arg=--arch=sm_60 --crate-type="bin" -O --target $(TARGET) - FileCheck main.rs --input-file $(TMPDIR)/main.ptx + $(RUSTC) main.rs --crate-type="bin" --target $(TARGET) -O -C link-arg=--arch=sm_60 -o $(TMPDIR)/main.link_arg.ptx + $(RUSTC) main.rs --crate-type="bin" --target $(TARGET) -O -C target-cpu=sm_60 -o $(TMPDIR)/main.target_cpu.ptx + + FileCheck main.rs --input-file $(TMPDIR)/main.link_arg.ptx + FileCheck main.rs --input-file $(TMPDIR)/main.target_cpu.ptx else all: endif diff --git a/src/test/run-make/nvptx-dylib-crate/kernel.rs b/src/test/run-make/nvptx-dylib-crate/kernel.rs index 5e65cca9140..63fd6b063dd 100644 --- a/src/test/run-make/nvptx-dylib-crate/kernel.rs +++ b/src/test/run-make/nvptx-dylib-crate/kernel.rs @@ -5,7 +5,7 @@ extern crate dep; // Verify the default CUDA arch. -// CHECK: .target sm_20 +// CHECK: .target sm_30 // CHECK: .address_size 64 // Make sure declarations are there. |
