Skip to content

nvcc: handle dry runs without PATH assignments - #3012

Open
drahnr wants to merge 5 commits into
mainfrom
bs-nvcc-path-lu
Open

drahnr wants to merge 5 commits into
mainfrom
bs-nvcc-path-lu

Conversation

@drahnr

@drahnr drahnr commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

Fall back to the environment passed to NVCC when dry-run output omits PATH, while preserving explicit dry-run overrides. Return executable lookup errors instead of panicking when PATH is absent.

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2026 NVIDIA Corporation
Built on Mon_Aug_03_13:24:11_PDT_2026
Cuda compilation tools, release 13.4, V13.4.59
Build cuda_13.4.r13.4/compiler.38657139_0
/usr/bin/nvcc --dryrun --keep -c tests/test_a.cu -o /tmp/sccache-nvcc-path-repro.o
#$ _NVVM_BRANCH_=nvvm
#$ _SPACE_=
#$ _CUDART_=cudart
#$ CUDA_ROOT=/usr
#$ _HERE_=/usr/bin
#$ _THERE_=/usr/bin
#$ _TARGET_SIZE_=
#$ _TARGET_DIR_=
#$ _TARGET_SIZE_=64
#$ CICC_PATH=/usr/bin
#$ NVVMIR_LIBRARY_DIR=/usr/nvvm/libdevice
#$ INCLUDES="-I/usr/include/cccl"
#$ LIBRARIES="-L/usr/lib64"
#$ CUDAFE_FLAGS=
#$ PTXAS_FLAGS=
#$ g++-15 -D__CUDA_ARCH_LIST__=750 -E -x c++ -D__CUDACC__ -D__NVCC__  "-I/usr/include/cccl"  -D__CUDACC_VER_MAJOR__=13 -D__CUDACC_VER_MINOR__=4 -D__CUDACC_VER_BUILD__=59 -D__CUDA_API_VER_MAJOR__=13 -D__CUDA_API_VER_MINOR__=4 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -D__CUDACC_DEVICE_ATOMIC_BUILTINS__=1 -include "cuda_runtime.h" -m64 "tests/test_a.cu" -o "test_a.cpp4.ii"
#$ cudafe++ --c++17 --static-host-stub --device-hidden-visibility --gnu_version=150301 --display_error_number --orig_src_file_name "tests/test_a.cu" --orig_src_path_name "/media/humpback/projects/worktrees/sccache/zephyr-stone/sccache/tests/test_a.cu" --allow_managed  --m64 --parse_templates --gen_c_file_name "test_a.cudafe1.cpp" --stub_file_name "test_a.cudafe1.stub.c" --gen_module_id_file --module_id_file_name "test_a.module_id" --simt-only "test_a.cpp4.ii"
#$ g++-15 -D__CUDA_ARCH__=750 -D__CUDA_ARCH_LIST__=750 -E -x c++  -DCUDA_DOUBLE_MATH_FUNCTIONS -D__CUDACC__ -D__NVCC__  "-I/usr/include/cccl"  -D__CUDACC_VER_MAJOR__=13 -D__CUDACC_VER_MINOR__=4 -D__CUDACC_VER_BUILD__=59 -D__CUDA_API_VER_MAJOR__=13 -D__CUDA_API_VER_MINOR__=4 -D__NVCC_DIAG_PRAGMA_SUPPORT__=1 -D__CUDACC_DEVICE_ATOMIC_BUILTINS__=1 -include "cuda_runtime.h" -m64 "tests/test_a.cu" -o "test_a.cpp1.ii"
#$ "$CICC_PATH/cicc" --c++17 --static-host-stub --device-hidden-visibility --gnu_version=150301 --display_error_number --orig_src_file_name "tests/test_a.cu" --orig_src_path_name "/media/humpback/projects/worktrees/sccache/zephyr-stone/sccache/tests/test_a.cu" --allow_managed   -arch compute_75 -m64 --no-version-ident -ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1 --include_file_name "test_a.fatbin.c"  -tused --module_id_file_name "test_a.module_id" --gen_c_file_name "test_a.cudafe1.c" --stub_file_name "test_a.cudafe1.stub.c" --gen_device_file_name "test_a.cudafe1.gpu"  "test_a.cpp1.ii" --simt-only -o "test_a.ptx"
#$ ptxas -arch=sm_75 -m64  "test_a.ptx"  -o "test_a.sm_75.cubin"
#$ fatbinary --create="test_a.fatbin" -64 --cicc-cmdline="-ftz=0 -prec_div=1 -prec_sqrt=1 -fmad=1 " "--image3=kind=elf,sm=75,file=test_a.sm_75.cubin" "--image3=kind=ptx,sm=75,file=test_a.ptx" --embedded-fatbin="test_a.fatbin.c"
#$ g++-15 -D__CUDA_ARCH__=750 -D__CUDA_ARCH_LIST__=750 -c -x c++  -DCUDA_DOUBLE_MATH_FUNCTIONS -Wno-psabi "-I/usr/include/cccl" -m64 "test_a.cudafe1.cpp" -o "/tmp/sccache-nvcc-path-repro.o"

So the core issue is the missing $# PATH which is not present in all distributions, hence we also use the inherited_env_vars we (the sccache wrapper process) pass to the nvcc binary and also search that.

Fall back to the environment passed to NVCC when dry-run output omits PATH, while preserving explicit dry-run overrides. Return executable lookup errors instead of panicking when PATH is absent.
@codecov-commenter

codecov-commenter commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.84%. Comparing base (33d12fb) to head (0b3eadf).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3012      +/-   ##
==========================================
+ Coverage   78.81%   78.84%   +0.03%     
==========================================
  Files          75       75              
  Lines       45354    45433      +79     
==========================================
+ Hits        35745    35823      +78     
- Misses       9609     9610       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@drahnr
drahnr marked this pull request as ready for review November 9, 2026 10:04
Copilot AI balanced review requested due to automatic review settings November 9, 2026 10:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The case-sensitive PATH lookup ignores inherited Path on Windows, causing bare compiler names to remain unresolved when the dry run omits PATH.

1 open issue
What changed in this PR

Updates NVCC dry-run parsing to support distributions that omit PATH assignments, using the environment passed to NVCC for executable lookup.

Changes:

  • Falls back to inherited PATH while preserving explicit dry-run overrides.
  • Returns executable lookup errors instead of panicking when PATH is absent.
  • Adds tests for PATH fallback, override precedence, absolute executable paths, and missing-PATH errors.
File Description
src/​compiler/​nvcc.rs Updates subcommand executable lookup and adds regression tests.

Review effort: Balanced

Comment thread src/compiler/nvcc.rs Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@drahnr
drahnr requested a review from sylvestre November 9, 2026 17:09
Comment thread src/compiler/nvcc.rs Resolved
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

Successfully merging this pull request may close these issues.

4 participants