I frequently use the nvc/nvc++ compiler for OpenACC. Recently I started generating dependency files to make the build process incremental.
In gcc/g++ I use the ‘-MMD -MP’ flags while compiling object files. gcc by default generates the .d files in the same directory as the .o files when compiled. I realise that it is different with nvc/nvc++:
-MP does not work with it.
.d files are generated in the directory where the command (nvc/nvc++) is run from.
I want the dependency files to be generated in the same directory as the object files as it reduces clutter. To achieve this I tried using the C preprocessor (cpp) to generate the .d files and then compiling using nvc/nvc++ in the same make rule. But nvc/nvc++ does not detect changes in header files if done that way.
Is there any way to achieve my requirement in the NVIDIA HPC SDK (21.9) I am using? Why does nvc/nvc++ not generate the .d files in the same directory as the object files? Any plan to add this in future?
I double checked, but didn’t find a way to match this behavior, nor do we support the “-MP” option. Hence I added RFEs for both, TPR #32156 for -MMD, and TPR #32157 for -MP.
Not sure we’ll be able to do this, but I’ll let engineering see what can be done.
I kept on the issue and have temporary fix. For anyone else requiring the same behaviour, put this command before the nvc/nvc++ command in the make rule for building objects:
We’ve updated the -MMD behavior to match GCC’s, i.e. the dependency file will be placed in the same directory as the object file. Though they haven’t yet added support for -MP.
% nvc -V23.3 -MMD dir/test.c -c -o dir/test.o
% ls test.d
test.d
% rm test.d
% nvc -V23.5 -MMD dir/test.c -c -o dir/test.o
% ls test.d
ls: cannot access 'test.d': No such file or directory
% ls dir/test.d
dir/test.d