Skip to content

Commit 3f62445

Browse files
committed
Provide PTXLinker with fallback to internal target-cpu
1 parent 899d936 commit 3f62445

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/ci/docker/test-various/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1414
xz-utils
1515

1616
# FIXME: build the `ptx-linker` instead.
17-
RUN curl -sL https://github.com/denzp/rust-ptx-linker/releases/download/v0.9.0-alpha.1/rust-ptx-linker.linux64.tar.gz | \
17+
RUN curl -sL https://github.com/denzp/rust-ptx-linker/releases/download/v0.9.0-alpha.2/rust-ptx-linker.linux64.tar.gz | \
1818
tar -xzvC /usr/bin
1919

2020
RUN curl -sL https://nodejs.org/dist/v9.2.0/node-v9.2.0-linux-x64.tar.xz | \

src/librustc_codegen_ssa/back/linker.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,12 @@ impl<'a> Linker for PtxLinker<'a> {
11321132
}
11331133

11341134
fn finalize(&mut self) -> Command {
1135+
// Provide the linker with fallback to internal `target-cpu`.
1136+
self.cmd.arg("--fallback-arch").arg(match self.sess.opts.cg.target_cpu {
1137+
Some(ref s) => s,
1138+
None => &self.sess.target.target.options.cpu
1139+
});
1140+
11351141
::std::mem::replace(&mut self.cmd, Command::new(""))
11361142
}
11371143

src/test/run-make/nvptx-binary-crate/Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
ifeq ($(TARGET),nvptx64-nvidia-cuda)
44
all:
5-
$(RUSTC) main.rs -Clink-arg=--arch=sm_60 --crate-type="bin" -O --target $(TARGET)
6-
FileCheck main.rs --input-file $(TMPDIR)/main.ptx
5+
$(RUSTC) main.rs --crate-type="bin" --target $(TARGET) -O -C link-arg=--arch=sm_60 -o $(TMPDIR)/main.link_arg.ptx
6+
$(RUSTC) main.rs --crate-type="bin" --target $(TARGET) -O -C target-cpu=sm_60 -o $(TMPDIR)/main.target_cpu.ptx
7+
8+
FileCheck main.rs --input-file $(TMPDIR)/main.link_arg.ptx
9+
FileCheck main.rs --input-file $(TMPDIR)/main.target_cpu.ptx
710
else
811
all:
912
endif

src/test/run-make/nvptx-dylib-crate/kernel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
extern crate dep;
66

77
// Verify the default CUDA arch.
8-
// CHECK: .target sm_20
8+
// CHECK: .target sm_30
99
// CHECK: .address_size 64
1010

1111
// Make sure declarations are there.

0 commit comments

Comments
 (0)