Hi Compiler Team,
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.
When you mean ‘didn’t find a way to match this behavior’, I hope you meant you couldn’t reproduce the gcc/g++ output to the nvc/nvc++ output.
Also, please update once engineering has a solution.
Meaning that we don’t have a method to change the directory where the dependency file gets outputed.
I’ll post a notification if/when either of these requests are available in a release.
Thanks, do let me know once it is available.
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:
g++ -E -MMD -MP -MF $(OBJDIR)$(*F).d -MT $(OBJDIR)$(*F).o $(INCDIRS) $< >/dev/null 2>&1
Everything else is the same. Not the most elegant solution, but it works!
- Cannot use ‘cpp’ (C preprocessor) as it has similar behaviour to nvc/nvc++.
- ‘>/dev/null 2>&1’ is to suppress the output from the preprocessor. There might be a better way for this.
@MatColgrove, please add suggestions/corrections as required.