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

add nvptx_target_feature #138689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jedbrown
Copy link
Contributor

Tracking issue: #44839 (catch-all arches)
The feature gate is #![feature(nvptx_target_feature)]

This exposes the target features sm_20 through sm_120a as defined by LLVM.

Cc: @gonzalobg
@rustbot label +O-NVPTX +A-target-feature

@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2025

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. O-NVPTX Target: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.html labels Mar 19, 2025
@jedbrown
Copy link
Contributor Author

Do I need to create a dedicated tracking issue or can I reuse #44839?

I have an associated patch for rust-lang/stdarch that provides a fix for #137086. Can I submit that while this PR is still in review?

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-18 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#19 exporting to docker image format
#19 sending tarball 19.9s done
#19 DONE 26.6s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-18]
[CI_JOB_NAME=x86_64-gnu-llvm-18]
debug: `DISABLE_CI_RUSTC_IF_INCOMPATIBLE` configured.
---
sccache: Listening on address 127.0.0.1:4226
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-18', '--enable-llvm-link-shared', '--set', 'rust.randomize-layout=true', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'build.print-step-timings', '--enable-verbose-tests', '--set', 'build.metrics', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'rust.lld=false', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: build.build          := x86_64-unknown-linux-gnu
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-18/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.randomize-layout := True
configure: rust.thin-lto-import-instr-limit := 10
---
  Number of decisions:   4447
  longest path:          1159 (code:    152)
  longest backtrack:       66 (code:    428)
Shared 86733 out of 152951 states by creating 14756 new states, saving 71977
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc: In function ‘rtx_def* extract_bit_field_1(rtx, poly_uint64, poly_uint64, int, rtx, machine_mode, machine_mode, bool, bool, rtx_def**)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc:1864:45: warning: ‘*(unsigned int*)((char*)&imode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ may be used uninitialized [-Wmaybe-uninitialized]
 1864 |       rtx sub = extract_bit_field_as_subreg (mode1, op0, imode,
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
 1865 |                                              bitsize, bitnum);
      |                                              ~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/expmed.cc:1824:19: note: ‘*(unsigned int*)((char*)&imode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))’ was declared here
 1824 |   scalar_int_mode imode;
      |                   ^~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gimple-range-gori.cc: In member function ‘void range_def_chain::dump(FILE*, basic_block, const char*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gimple-range-gori.cc:319:19: warning: format not a string literal and no format arguments [-Wformat-security]
  319 |           fprintf (f, prefix);
      |           ~~~~~~~~^~~~~~~~~~~
---
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc:7930:9: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 7930 |   write (fd, "\n\n", 2);
      |   ~~~~~~^~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc: In member function ‘void driver::final_actions() const’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/gcc.cc:9307:13: warning: ignoring return value of ‘int truncate(const char*, __off_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 9307 |     truncate(totruncate_file, 0);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto-wrapper.cc: In function ‘bool find_and_merge_options(int, off_t, const char*, vec<cl_decoded_option>, bool, vec<cl_decoded_option>*, const char*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto-wrapper.cc:1165:8: warning: ignoring return value of ‘ssize_t read(int, void*, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 1165 |   read (fd, data, length);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc: In function ‘void lto_resolution_read(splay_tree, FILE*, lto_file*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2091:10: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2091 |   fscanf (resolution, " ");   /* Read white space.  */
      |   ~~~~~~~^~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2093:9: warning: ignoring return value of ‘size_t fread(void*, size_t, size_t, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2093 |   fread (obj_name, sizeof (char), name_len, resolution);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/lto/lto-common.cc:2113:10: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
 2113 |   fscanf (resolution, "%u", &num_symbols);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/gcc/jit/jit-recording.cc:32:
---
Applying io_quotes_use            to linux/blkzoned.h
Applying io_quotes_use            to linux/ipmi.h
Applying io_quotes_use            to linux/psp-dbc.h
Applying io_quotes_use            to linux/bt-bmc.h
Applying io_quotes_use            to linux/tps6594_pfsm.h
Applying io_quotes_use            to linux/cxl_mem.h
Applying io_quotes_use            to linux/wmi.h
Applying io_quotes_use            to linux/auto_fs.h
Applying io_quotes_use            to linux/mmtimer.h
Applying io_quotes_use            to linux/f2fs.h
Applying io_quotes_use            to linux/vhost.h
---
Applying machine_name             to x86_64-linux-gnu/bits/unistd_ext.h
Applying io_quotes_use            to x86_64-linux-gnu/asm/mtrr.h
Applying io_quotes_use            to x86_64-linux-gnu/asm/amd_hsmp.h
Applying machine_name             to openssl/e_os2.h
Applying io_quotes_use            to drm/xe_drm.h
Applying io_quotes_use            to drm/radeon_drm.h
Applying io_quotes_use            to drm/panfrost_drm.h
Applying io_quotes_use            to drm/etnaviv_drm.h
Applying io_quotes_use            to drm/lima_drm.h
Applying io_quotes_use            to drm/qaic_accel.h
Applying io_quotes_use            to drm/vc4_drm.h
Applying io_quotes_use            to drm/i915_drm.h
Applying io_quotes_use            to drm/omap_drm.h
Applying io_quotes_use            to drm/pvr_drm.h
Applying io_quotes_use            to drm/amdgpu_drm.h
Applying io_quotes_use            to drm/vgem_drm.h
Applying io_quotes_use            to drm/msm_drm.h
Applying io_quotes_use            to drm/v3d_drm.h
Applying io_quotes_use            to drm/exynos_drm.h
Applying io_quotes_use            to drm/nouveau_drm.h
Applying io_quotes_use            to drm/drm.h
Applying io_quotes_use            to drm/habanalabs_accel.h
Applying io_quotes_use            to drm/tegra_drm.h
Applying io_quotes_use            to rdma/rdma_user_ioctl.h
cc1: note: self-tests are not enabled in this build
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/c++tools/server.cc: In function ‘void server(bool, int, module_resolver*)’:
/checkout/obj/build/x86_64-unknown-linux-gnu/gcc/src/c++tools/server.cc:620:10: warning: ignoring return value of ‘int pipe(int*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
---
test [ui] tests/ui/transmutability/primitives/numbers.rs#next ... ok

failures:

---- [ui] tests/ui/abi/compatibility.rs#nvptx64 stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/compatibility.nvptx64/compatibility.nvptx64.stderr"
normalized stderr:
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)



The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args abi/compatibility.rs`

error in revision `nvptx64`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/abi/compatibility.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--cfg" "nvptx64" "--check-cfg" "cfg(test,FALSE,host,i686,x86_64,x86_64_win,arm,aarch64,s390x,mips,mips64,sparc,sparc64,powerpc64,riscv,loongarch64,wasip1,bpf,m68k,csky,nvptx64)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/compatibility.nvptx64" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target" "nvptx64-nvidia-cuda" "-Cpanic=abort" "--extern" "minicore=/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/abi/compatibility.nvptx64/libminicore.rlib"
stdout: none
--- stderr -------------------------------
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
------------------------------------------


---- [ui] tests/ui/check-cfg/target_feature.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/check-cfg/target_feature/target_feature.stderr"
---
To only update this specific test, also pass `--test-args check-cfg/target_feature.rs`

error: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/check-cfg/target_feature.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/check-cfg/target_feature" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--check-cfg=cfg()" "-Zcheck-cfg-all-expected"
stdout: none
--- stderr -------------------------------
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
##[warning]  --> /checkout/tests/ui/check-cfg/target_feature.rs:16:10
   |
LL |     cfg!(target_feature = "_UNEXPECTED_VALUE");
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `amx-bf16`, `amx-complex`, `amx-fp16`, `amx-int8`, `amx-tile`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `avxifma`, `avxneconvert`, `avxvnni`, `avxvnniint16`, `avxvnniint8`, `backchain`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `cssc`, `d`, `d32`, `deflate-conversion`, `dit`, `div32`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `ecv`, `edsp`, `elrw`, `enhanced-sort`, `ermsb`, `exception-handling`, `extended-const`, `f`, `f16c`, `f32mm`, `f64mm`, `faminmax`, `fcma`, `fdivdu`, `fhm`, `flagm`, `flagm2`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fp8`, `fp8dot2`, `fp8dot4`, `fp8fma`, `fpregs`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frecipe`, `frintts`, `fxsr`, `gfni`, `guarded-storage`, `hard-float`, `hard-float-abi`, `hard-tp`, `hbc`, `high-registers`, `high-word`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `isa-68000`, `isa-68010`, `isa-68020`, `isa-68030`, `isa-68040`, `isa-68060`, `isa-68881`, `isa-68882`, `jsconv`, `kl`, `lahfsahf`, `lam-bh`, `lamcas`, `lasx`, `lbt`, `ld-seq-sa`, `leoncasa`, `lor`, `lse`, `lse128`, `lse2`, `lsx`, `lut`, `lvz`, `lzcnt`, `m`, `mclass`, `mops`, `movbe`, `mp`, `mp1e2`, `msa`, `msync`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nnp-assist`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `partword-atomics`, `pauth-lr`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-crypto`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `quadword-atomics`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rcpc3`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `reserve-x18`, `rtm`, `sb`, `scq`, `sha`, `sha2`, `sha3`, `sha512`, `sign-ext`, `simd128`, `sm3`, `sm4`, `sm_100`, `sm_100a`, `sm_101`, `sm_101a`, `sm_120`, `sm_120a`, `sm_20`, `sm_21`, `sm_30`, `sm_32`, `sm_35`, `sm_37`, `sm_50`, `sm_52`, `sm_53`, `sm_60`, `sm_61`, `sm_62`, `sm_70`, `sm_72`, `sm_75`, `sm_80`, `sm_86`, `sm_87`, `sm_90`, `sm_90a`, `sme`, `sme-b16b16`, `sme-f16f16`, `sme-f64f64`, `sme-f8f16`, `sme-f8f32`, `sme-fa64`, `sme-i16i64`, `sme-lutv2`, `sme2`, `sme2p1`, `soft-float`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `ssve-fp8dot2`, `ssve-fp8dot4`, `ssve-fp8fma`, `sve`, `sve-b16b16`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `sve2p1`, `tail-call`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `transactional-execution`, `trust`, `trustzone`, `ual`, `unaligned-scalar-mem`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `v8.8a`, `v8.9a`, `v8plus`, `v9`, `v9.1a`, `v9.2a`, `v9.3a`, `v9.4a`, `v9.5a`, `v9a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vector`, `vector-enhancements-1`, `vector-enhancements-2`, `vector-packed-decimal`, `vector-packed-decimal-enhancement`, `vector-packed-decimal-enhancement-2`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `wfxt`, `wide-arithmetic`, `widekl`, `x87`, `xop`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `za128rs`, `za64rs`, `zaamo`, `zabha`, `zacas`, `zalrsc`, `zama16b`, `zawrs`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, and `zkt`
   = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
   = note: `#[warn(unexpected_cfgs)]` on by default

warning: 1 warning emitted
------------------------------------------


---- [ui] tests/ui/feature-gates/feature-gate-abi_ptx.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-abi_ptx/feature-gate-abi_ptx.stderr"
diff of stderr:

+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
1 error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
2   --> $DIR/feature-gate-abi_ptx.rs:10:8
3    |


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args feature-gates/feature-gate-abi_ptx.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-abi_ptx" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target=nvptx64-nvidia-cuda" "--crate-type=rlib" "-Cpanic=abort" "--extern" "minicore=/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/feature-gates/feature-gate-abi_ptx/libminicore.rlib"
stdout: none
--- stderr -------------------------------
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs:10:8
   |
LL | extern "ptx-kernel" fn fu() {} //~ ERROR extern "ptx-kernel" ABI is experimental
   |        ^^^^^^^^^^^^
   |
   = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information
   = help: add `#![feature(abi_ptx)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs:13:12
   |
LL |     extern "ptx-kernel" fn mu(); //~ ERROR extern "ptx-kernel" ABI is experimental
   |            ^^^^^^^^^^^^
   |
   = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information
   = help: add `#![feature(abi_ptx)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs:14:12
   |
LL |     extern "ptx-kernel" fn dmu() {} //~ ERROR extern "ptx-kernel" ABI is experimental
   |            ^^^^^^^^^^^^
   |
   = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information
   = help: add `#![feature(abi_ptx)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs:19:12
   |
LL |     extern "ptx-kernel" fn mu() {} //~ ERROR extern "ptx-kernel" ABI is experimental
   |            ^^^^^^^^^^^^
   |
   = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information
   = help: add `#![feature(abi_ptx)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs:23:12
   |
LL |     extern "ptx-kernel" fn imu() {} //~ ERROR extern "ptx-kernel" ABI is experimental
   |            ^^^^^^^^^^^^
   |
   = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information
   = help: add `#![feature(abi_ptx)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs:26:19
   |
LL | type TAU = extern "ptx-kernel" fn(); //~ ERROR extern "ptx-kernel" ABI is experimental
   |                   ^^^^^^^^^^^^
   |
   = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information
   = help: add `#![feature(abi_ptx)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the extern "ptx-kernel" ABI is experimental and subject to change
##[error]  --> /checkout/tests/ui/feature-gates/feature-gate-abi_ptx.rs:28:8
   |
LL | extern "ptx-kernel" {} //~ ERROR extern "ptx-kernel" ABI is experimental
   |        ^^^^^^^^^^^^
   |
   = note: see issue #38788 <https://github.com/rust-lang/rust/issues/38788> for more information
   = help: add `#![feature(abi_ptx)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0658`.
------------------------------------------


---- [ui] tests/ui/stack-protector/warn-stack-protector-unsupported.rs#strong stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/stack-protector/warn-stack-protector-unsupported.strong/warn-stack-protector-unsupported.strong.stderr"
diff of stderr:

1 warning: `-Z stack-protector=strong` is not supported for target nvptx64-nvidia-cuda and will be ignored
2 
+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
3 warning: 1 warning emitted
4 
5 


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args stack-protector/warn-stack-protector-unsupported.rs`

error in revision `strong`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/stack-protector/warn-stack-protector-unsupported.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--cfg" "strong" "--check-cfg" "cfg(test,FALSE,all,strong,basic)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/stack-protector/warn-stack-protector-unsupported.strong" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target" "nvptx64-nvidia-cuda" "-Z" "stack-protector=strong"
stdout: none
--- stderr -------------------------------
warning: `-Z stack-protector=strong` is not supported for target nvptx64-nvidia-cuda and will be ignored

'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
warning: 1 warning emitted
------------------------------------------


---- [ui] tests/ui/stack-protector/warn-stack-protector-unsupported.rs#basic stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/stack-protector/warn-stack-protector-unsupported.basic/warn-stack-protector-unsupported.basic.stderr"
diff of stderr:

1 warning: `-Z stack-protector=basic` is not supported for target nvptx64-nvidia-cuda and will be ignored
2 
+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
3 warning: 1 warning emitted
4 
5 


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args stack-protector/warn-stack-protector-unsupported.rs`

error in revision `basic`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/stack-protector/warn-stack-protector-unsupported.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--cfg" "basic" "--check-cfg" "cfg(test,FALSE,all,strong,basic)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/stack-protector/warn-stack-protector-unsupported.basic" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target" "nvptx64-nvidia-cuda" "-Z" "stack-protector=basic"
stdout: none
--- stderr -------------------------------
warning: `-Z stack-protector=basic` is not supported for target nvptx64-nvidia-cuda and will be ignored

'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
warning: 1 warning emitted
------------------------------------------


---- [ui] tests/ui/stack-protector/warn-stack-protector-unsupported.rs#all stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/stack-protector/warn-stack-protector-unsupported.all/warn-stack-protector-unsupported.all.stderr"
diff of stderr:

1 warning: `-Z stack-protector=all` is not supported for target nvptx64-nvidia-cuda and will be ignored
2 
+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_100a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_101a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
+ '+sm_120a' is not a recognized feature for this target (ignoring feature)
3 warning: 1 warning emitted
4 
5 


The actual stderr differed from the expected stderr.
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args stack-protector/warn-stack-protector-unsupported.rs`

error in revision `all`: 1 errors occurred comparing output.
status: exit status: 0
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/stack-protector/warn-stack-protector-unsupported.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--cfg" "all" "--check-cfg" "cfg(test,FALSE,all,strong,basic)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/stack-protector/warn-stack-protector-unsupported.all" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target" "nvptx64-nvidia-cuda" "-Z" "stack-protector=all"
stdout: none
--- stderr -------------------------------
warning: `-Z stack-protector=all` is not supported for target nvptx64-nvidia-cuda and will be ignored

'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_100a' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_101a' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
'+sm_120a' is not a recognized feature for this target (ignoring feature)
warning: 1 warning emitted
------------------------------------------


---- [ui] tests/ui/target-feature/gate.rs stdout ----
Saved the actual stderr to "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/target-feature/gate/gate.stderr"
diff of stderr:

1 error[E0658]: the target feature `avx512bw` is currently unstable
-   --> $DIR/gate.rs:30:18
+   --> $DIR/gate.rs:31:18
3    |
4 LL | #[target_feature(enable = "avx512bw")]
5    |                  ^^^^^^^^^^^^^^^^^^^

Note: some mismatched output was normalized before being compared
-   --> /checkout/tests/ui/target-feature/gate.rs:31:18
+   --> $DIR/gate.rs:31:18
---
To only update this specific test, also pass `--test-args target-feature/gate.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: env -u RUSTC_LOG_COLOR RUSTC_ICE="0" RUST_BACKTRACE="short" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/target-feature/gate.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--check-cfg" "cfg(test,FALSE)" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zwrite-long-types-to-disk=no" "-Cstrip=debuginfo" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/target-feature/gate" "-A" "unused" "-A" "internal_features" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers"
stdout: none
--- stderr -------------------------------
error[E0658]: the target feature `avx512bw` is currently unstable
##[error]  --> /checkout/tests/ui/target-feature/gate.rs:31:18
   |
LL | #[target_feature(enable = "avx512bw")]
   |                  ^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #44839 <https://github.com/rust-lang/rust/issues/44839> for more information
   = help: add `#![feature(avx512_target_feature)]` to the crate attributes to enable
   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0658`.
------------------------------------------

@jedbrown
Copy link
Contributor Author

It looks like the failing build environment is using LLVM-18 (sm_100 onward were added recently llvm/llvm-project#124155). I could remove those entirely (such hardware isn't available yet) or guard them based on LLVM version (how?).

@gonzalobg
Copy link

This exposes the target features sm_20 through sm_120a as defined by LLVM.

IIUC LLVM exposes these as target CPUs (Proc) above, not target features, but I think it is fine to expose these as target features in Rust.

Comment on lines +509 to +514
("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90a"]),
("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100a"]),
("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101a"]),
("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to comment these out until rust supports the required LLVM version.

Suggested change
("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90a"]),
("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100a"]),
("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101a"]),
("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),
// TODO: requires LLVM 21+
// ("sm_100", Unstable(sym::nvptx_target_feature), &["sm_90a"]),
// ("sm_100a", Unstable(sym::nvptx_target_feature), &["sm_100"]),
// ("sm_101", Unstable(sym::nvptx_target_feature), &["sm_100a"]),
// ("sm_101a", Unstable(sym::nvptx_target_feature), &["sm_101"]),
// ("sm_120", Unstable(sym::nvptx_target_feature), &["sm_101a"]),
// ("sm_120a", Unstable(sym::nvptx_target_feature), &["sm_120"]),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are in LLVM-20, which is what Rust's src/llvm-project submodule uses (and thus I think all the official builds). The failing CI build environment is using LLVM-18, but I don't know what the convention is for such backward compatibility. I'm fine just commenting these out for now.

@gonzalobg Is it correct for these features to represent a total order, or is there a more general DAG?

Copy link

@gonzalobg gonzalobg Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For SM Compute Capabilities:

  • The non _a capabilities extend each other: sm_90 is a subset of sm_100.
  • The _a capability of some SM:
    • Extends the capability of only that one SM: sm_90 is a subset of sm_90a (and therefore sm_80 is a subset of sm_90a).
    • Contains some unique functionality: sm_90a is not a sub-set of sm_100a (and by extension sm_100).
  • An SM Compute Capability implies PTX ISA version >= some_version (e.g. sm_90 implies ptx>=78, or said differently, sm_90 can't be used if ptx < 78).

Each PTX feature (e.g. using a particular instruction) requires a certain SM capability and certain PTX ISA version.

Approximately, the SM capability is a HW constraint, and PTX ISA is a Driver constraint; to use a feature both constraints must be satisfied. This table relates PTX ISA versions, sm capabilities, and driver versions. Each instruction documents which SM capability and PTX ISA version it requires.

@gonzalobg
Copy link

I think it'd be good to have more testing (could be punted into an issue and done later):

  1. A basic fail test that tries to compile for sm_xx but uses an op that is only available in sm_yy.
    • A pass version of this test that guards the op correctly using cfg!
  2. A test that compiles for sm_yy, uses an op that is supported for sm_xx but not in sm_yy even though yy > xx, and therefore fails to compile. That is guarding the op on sm_yy does not suffice, it needs to be precisely guarded on sm_xx.
  3. A test that compiles for sm_xx, uses an op that is supported for sm_xx, but the PTX ISA version used does not support this op.
    • I think the proposed solution is not sufficient to guard these ops. The proposed scheme may need to be extended, e.g., to be able to also guard on PTX ISA versions and treating "ptx82" as a target feature), or maybe we need a different solution (exposing target-features describing functionality and do the SM+PTX math in rustc; or expose ptx ISA version and then build in stdarch, etc.).

I think it'd also be good to have more docs:

@taiki-e
Copy link
Member

taiki-e commented Mar 19, 2025

@jedbrown

It looks like the failing build environment is using LLVM-18 (sm_100 onward were added recently llvm/llvm-project#124155). I could remove those entirely (such hardware isn't available yet) or guard them based on LLVM version (how?).

You can address this issue by modifying to_llvm_features function in rustc_codegen_llvm/src/llvm_util.rs like some riscv features do:

// Filter out features that are not supported by the current LLVM version
("riscv32" | "riscv64", "zaamo") if get_version().0 < 19 => None,
("riscv32" | "riscv64", "zabha") if get_version().0 < 19 => None,
("riscv32" | "riscv64", "zalrsc") if get_version().0 < 19 => None,
("riscv32" | "riscv64", "zama16b") if get_version().0 < 19 => None,
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,


@gonzalobg

This exposes the target features sm_20 through sm_120a as defined by LLVM.

IIUC LLVM exposes these as target CPUs (Proc) above, not target features, but I think it is fine to expose these as target features in Rust.

LLVM actually supports sm_* on both the features and CPUs. (However, their behavior differs as from the sm_* CPUs both sm_* and ptx* features are enabled, but from the sm_* features only sm_* features are enabled.)

Outputs of both --print target-cpus and --print target-features also show them
$ rustc --target nvptx64-nvidia-cuda --print target-cpus
Available CPUs for this target:
    sm_100
    sm_100a
    sm_101
    sm_101a
    sm_120
    sm_120a
    sm_20
    sm_21
    sm_30   - This is the default target CPU for the current build target (currently nvptx64-nvidia-cuda).
    sm_32
    sm_35
    sm_37
    sm_50
    sm_52
    sm_53
    sm_60
    sm_61
    sm_62
    sm_70
    sm_72
    sm_75
    sm_80
    sm_86
    sm_87
    sm_89
    sm_90
    sm_90a

$ rustc --target nvptx64-nvidia-cuda --print target-features
Features supported by rustc for this target:
    crt-static - Enables C Run-time Libraries to be statically linked.

Code-generation features supported by LLVM for this target:
    ptx32      - Use PTX version 32.
    ptx40      - Use PTX version 40.
    ptx41      - Use PTX version 41.
    ptx42      - Use PTX version 42.
    ptx43      - Use PTX version 43.
    ptx50      - Use PTX version 50.
    ptx60      - Use PTX version 60.
    ptx61      - Use PTX version 61.
    ptx62      - Use PTX version 62.
    ptx63      - Use PTX version 63.
    ptx64      - Use PTX version 64.
    ptx65      - Use PTX version 65.
    ptx70      - Use PTX version 70.
    ptx71      - Use PTX version 71.
    ptx72      - Use PTX version 72.
    ptx73      - Use PTX version 73.
    ptx74      - Use PTX version 74.
    ptx75      - Use PTX version 75.
    ptx76      - Use PTX version 76.
    ptx77      - Use PTX version 77.
    ptx78      - Use PTX version 78.
    ptx80      - Use PTX version 80.
    ptx81      - Use PTX version 81.
    ptx82      - Use PTX version 82.
    ptx83      - Use PTX version 83.
    ptx84      - Use PTX version 84.
    ptx85      - Use PTX version 85.
    ptx86      - Use PTX version 86.
    ptx87      - Use PTX version 87.
    sm_100     - Target SM 100.
    sm_100a    - Target SM 100a.
    sm_101     - Target SM 101.
    sm_101a    - Target SM 101a.
    sm_120     - Target SM 120.
    sm_120a    - Target SM 120a.
    sm_20      - Target SM 20.
    sm_21      - Target SM 21.
    sm_30      - Target SM 30.
    sm_32      - Target SM 32.
    sm_35      - Target SM 35.
    sm_37      - Target SM 37.
    sm_50      - Target SM 50.
    sm_52      - Target SM 52.
    sm_53      - Target SM 53.
    sm_60      - Target SM 60.
    sm_61      - Target SM 61.
    sm_62      - Target SM 62.
    sm_70      - Target SM 70.
    sm_72      - Target SM 72.
    sm_75      - Target SM 75.
    sm_80      - Target SM 80.
    sm_86      - Target SM 86.
    sm_87      - Target SM 87.
    sm_89      - Target SM 89.
    sm_90      - Target SM 90.
    sm_90a     - Target SM 90a.

Use +feature to enable a feature, or -feature to disable it.
For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2

Code-generation features cannot be used in cfg or #[target_feature],
and may be renamed or removed in a future version of LLVM or rustc.

@taiki-e
Copy link
Member

taiki-e commented Mar 19, 2025

Btw, is it intentional that the ptx* target features are not added? My understanding is that we need to check both sm_* and ptx* to use some of the functionality, like LLVM does here.

@jedbrown
Copy link
Contributor Author

Thanks @taiki-e. I'll update accordingly. I'm seeing PTX 7.8 being written in an otherwise-default configuration with target sm_89. Do you know where such defaults are set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-target-feature Area: Enabling/disabling target features like AVX, Neon, etc. O-NVPTX Target: the NVPTX LLVM backend for running rust on GPUs, https://llvm.org/docs/NVPTXUsage.html S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants