You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PGICompiler (used by NvidiaHPC_CCompiler, NvidiaHPC_FortranCompiler, PGICCompiler, …)
does not implement get_dependency_gen_args(), so it inherits the base class stub:
Meson still emits deps = gcc and a depfile into the ninja rule, and sets DEPFILE
on every build statement — but the compile line never receives -MD/-MF, so no depfile
is ever written. Ninja waits for a file that never appears and records zero
dependencies for every object. A changed header therefore never triggers a rebuild.
This is the same defect as #11969 (CUDA), fixed by #12665, in a different compiler class.
This is not just a stale-build annoyance. Incremental builds silently produce binaries
whose translation units disagree about struct layout. In our project a struct member in
a shared header shifted, only some objects were rebuilt, and two members aliased: the
program printed a nonsense value and hung, with no compile error, no warning and no
crash. It took a long time to attribute to the build system rather than to our own code.
To Reproduce
Any meson project built with CC=nvc:
$ meson setup build && ninja -C build
$ ninja -C build -t deps | grep -cE '^\S+\.o: #deps [1-9]'0 # no object has any recorded dependency
$ find build -name '*.d'| wc -l0 # no depfile was ever produced
$ touch some_header_used_everywhere.h
$ ninja -C build -n | grep -c 'Compiling'0 # nothing rebuilds
The generated rule declares depfile support that the command line never satisfies:
Touching a header rebuilds the objects that include it, as with GCC and Clang.
Fix
nvc supports the GCC-style flags, so this is the same shape of fix as #12665.
Important: -MQ must not be used.nvc accepts -MQ but ignores its argument and
writes the literal string mttarget as the depfile target, which ninja then silently
discards — reintroducing the original bug in a form that looks fixed. Verified on
nvc 26.3:
So PGICompiler needs ['-MD', '-MT', outtarget, '-MF', outfile].
Because -MT does not Make-escape the target, this also needs the escaping that #12665
added for CUDA. That escaping is currently gated on langname == 'cuda' / compiler.get_language() == 'cuda' in ninjabackend.py. Rather than add a second
special case, the attached patch introduces a compiler predicate:
defneeds_escaped_depfile_target(self) ->bool:
"""Whether the depfile target must be Make-escaped by the backend."""returnFalse
returning True for CUDA and PGI, and switches both ninjabackend.py gates to it. The
ninja variable CUDA_ESCAPED_TARGET is renamed ESCAPED_DEPFILE_TARGET since it is no
longer CUDA-specific. No behaviour change for CUDA.
The 13 rebuilt objects are exactly those including that header, across both extension
modules. The project's test suites pass unchanged with the patch applied.
Note for anyone checking this: the fixed build leaves no *.d files on disk — ninja
folds each depfile into .ninja_deps and deletes it. Check ninja -t deps, not the
filesystem.
Open questions for maintainers
Version gating.Add support for dumping dependent headers in nvcc #12665 gated CUDA on >= 10.2. I have only nvc 26.3 available and
do not know the earliest NVHPC/PGI release supporting -MD/-MT. If gating is wanted,
someone with older toolchains should pick the bound.
Classic PGI vs NVHPC.PGICompiler backs both PGICCompiler (pgcc) and NvidiaHPC_*. I verified NVHPC only. If legacy pgcc differs, the override may belong
on the NVHPC classes rather than the shared mixin.
Fortran. The mixin is shared with the Fortran compilers, which I have not tested.
system parameters
Is this a cross build or just a plain native build (for the same computer)? — native
what operating system — Linux (Ubuntu, kernel 7.0.0)
what Python version are you using — 3.14.5
what meson --version — 1.11.1 (bug also present on master at time of writing)
what ninja --version if it's a Ninja build — 1.13.2
Describe the bug
PGICompiler(used byNvidiaHPC_CCompiler,NvidiaHPC_FortranCompiler,PGICCompiler, …)does not implement
get_dependency_gen_args(), so it inherits the base class stub:Meson still emits
deps = gccand adepfileinto the ninja rule, and setsDEPFILEon every build statement — but the compile line never receives
-MD/-MF, so no depfileis ever written. Ninja waits for a file that never appears and records zero
dependencies for every object. A changed header therefore never triggers a rebuild.
This is the same defect as #11969 (CUDA), fixed by #12665, in a different compiler class.
This is not just a stale-build annoyance. Incremental builds silently produce binaries
whose translation units disagree about struct layout. In our project a struct member in
a shared header shifted, only some objects were rebuilt, and two members aliased: the
program printed a nonsense value and hung, with no compile error, no warning and no
crash. It took a long time to attribute to the build system rather than to our own code.
To Reproduce
Any meson project built with
CC=nvc:The generated rule declares depfile support that the command line never satisfies:
Expected behavior
Touching a header rebuilds the objects that include it, as with GCC and Clang.
Fix
nvcsupports the GCC-style flags, so this is the same shape of fix as #12665.Important:
-MQmust not be used.nvcaccepts-MQbut ignores its argument andwrites the literal string
mttargetas the depfile target, which ninja then silentlydiscards — reintroducing the original bug in a form that looks fixed. Verified on
nvc 26.3:
So
PGICompilerneeds['-MD', '-MT', outtarget, '-MF', outfile].Because
-MTdoes not Make-escape the target, this also needs the escaping that #12665added for CUDA. That escaping is currently gated on
langname == 'cuda'/compiler.get_language() == 'cuda'inninjabackend.py. Rather than add a secondspecial case, the attached patch introduces a compiler predicate:
returning
Truefor CUDA and PGI, and switches bothninjabackend.pygates to it. Theninja variable
CUDA_ESCAPED_TARGETis renamedESCAPED_DEPFILE_TARGETsince it is nolonger CUDA-specific. No behaviour change for CUDA.
Diffstat:
Verification
With the patch applied, on a real NVHPC project (~34 objects, C + Cython-generated C,
-mp=gpu):The 13 rebuilt objects are exactly those including that header, across both extension
modules. The project's test suites pass unchanged with the patch applied.
Note for anyone checking this: the fixed build leaves no
*.dfiles on disk — ninjafolds each depfile into
.ninja_depsand deletes it. Checkninja -t deps, not thefilesystem.
Open questions for maintainers
>= 10.2. I have only nvc 26.3 available anddo not know the earliest NVHPC/PGI release supporting
-MD/-MT. If gating is wanted,someone with older toolchains should pick the bound.
PGICompilerbacks bothPGICCompiler(pgcc) andNvidiaHPC_*. I verified NVHPC only. If legacypgccdiffers, the override may belongon the NVHPC classes rather than the shared mixin.
system parameters
meson --version— 1.11.1 (bug also present on master at time of writing)ninja --versionif it's a Ninja build — 1.13.2nvc26.3-0, x86-64,-tp znver5