the bigger picture is, ahm, bigger:
We have a workflow of source-to-source instrumentation, which is roughly:
- pre-process source
- modify source, which includes adding #include and #define statements and use macros in #pragma omp statements
- compile source with preprocessing on (i.e., its not a .i file)
When using ‘pgcc -E’ as the preprocessor, we get double the -preinclude _c_macros.h file, which results in errors because of redefinition of struct __va_list_tag.
I was looking into the -Mcpp option than.
If I use ‘pgcc -Mcpp’ for step one, than I get errors, because of a wrongly included gcc header:
$ pgcc --version
pgcc 18.4-0 64-bit target on x86-64 Linux -tp haswell
PGI Compilers and Tools
Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
$ cat >empty.c <<EOF
$ pgcc -mp -Mcpp=nocomment,line empty.c
PREPRO-I-0222-Redundant definition for symbol __extension__ (/usr/include/x86_64-linux-gnu/sys/cdefs.h: 367)
$ pgcc -mp -c empty.i
PGC-S-0040-Illegal use of symbol, __INT_LEAST8_TYPE__ (/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint-gcc.h: 60)
PGC-W-0156-Type not specified, 'int' assumed (/usr/lib/gcc/x86_64-linux-gnu/7/include/stdint-gcc.h: 60)
The stdint-gcc.h header is not included, when preprocessed with -E though.
Note also, that ‘-Mcpp -mp’ does not #define _OPENMP.
Next I tried to use -Mcpp for the preprocessing in step 3, i.e., splitting this step into 2.
3a. pre-process with -Mcpp into an .i file
3b. compile .i file, which disables pre-processing
And here the pre-processing with -Mcpp does not resolve the macros in the #pragma statements.
I thought, it maybe simpler to try to get this second approach working, but maybe it is also possible to prevent the -preinclude of _c_macros.h somehow?