Get full cmake lines and prepocessed source for a GCC bug report

Hi,

for filing a GCC v8.2.0 bug in Debian/buster AMD64 the Debian/GCC
mainatiners want two things...

[ FULL CMAKE LINE ]

How do I configure this in the LLVM/Clang build?
Can I set an option of cmake?

[ PREPROCESSED SOURCE FILES ]

How and where do I get the preprocessed source?
Do I need to set options for this in my build-script?

My build-script is attached.

Thanks in advance.

Regards,
- Sedat -

[0] [llvm-dev] LLVM/Clang version 7.0.0rc2 fails with gcc (Debian 8.2.0-4)
[1] [llvm-dev] LLVM/Clang version 7.0.0rc2 fails with gcc (Debian 8.2.0-4)
[2] Building LLVM with CMake — LLVM 15.0.0git documentation

build_clang-with-ninja.sh (2.23 KB)

/usr/bin/g++-8 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-Ilib/Bitcode/Reader
-I/home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader -Iinclude
-I/home/sdi/src/llvm-toolchain/llvm/include -fPIC
-fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra
-Wno-unused-parameter -Wwrite-strings -Wcast-qual
-Wno-missing-field-initializers -pedantic -Wno-long-long
-Wno-maybe-uninitialized -Wno-class-memaccess
-Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color
-ffunction-sections -fdata-sections -O3 -UNDEBUG -fno-exceptions
-fno-rtti -MD -MT
lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o
-MF lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o.d
-o lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o
-c /home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader/MetadataLoader.cpp

To generate preprocessed source from that, you use the -E flag, so
adding something like this to the end of command-line should work:

-E -o /tmp/preprocessed.ii

To see the internal GCC invocation, you can add the -### option to the
command. The output of that, and the preprocessed source, should be
enough to reproduce the bug.

- Hans

Thanks, Hans.

I kept the build-directory of my build with my selfmade llvm-toolchain
v7.0.0rc2.

So I can run this gcc-line directly?

- sed@ -

Yes, I think that should work.

sdi@iniza:~/src/llvm-toolchain$ ./scripts/gcc-bug.sh

sdi@iniza:~/src/llvm-toolchain$ find build/ -name '*MetadataLoader*'
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o.d

sdi@iniza:~/src/llvm-toolchain$ LC_ALL=C ls -lh
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o.d
-rw-r--r-- 1 sdi sdi 271K Aug 29 12:15
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o
-rw-r--r-- 1 sdi sdi 20K Aug 29 12:15
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o.d

Above seems to generate the files correctly?
No, Error messages.

sdi@iniza:~/src/llvm-toolchain$ LC_ALL=C
./scripts/gcc-bug_preprocessed-source.sh
cc1plus: error: output filename specified twice
cc1plus: error: too many filenames given. Type cc1plus --help for usage
cc1plus: fatal error: /tmp/preprocessed.d: No such file or directory
compilation terminated.

What's wrong with the 2nd run when trying to generate preprocessed.ii?

I tried to replace/move...

- -o lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o
\
+ -E -o /tmp/preprocessed.ii \

Thanks.

- Sedat -

gcc-bug.sh (986 Bytes)

gcc-bug_preprocessed-source.sh (1016 Bytes)

[ 2nd tryout ]

sdi@iniza:~/src/llvm-toolchain$ LANG=C rm -v
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o
build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o.d
removed 'build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o'
removed 'build/lib/Bitcode/Reader/CMakeFiles/LLVMBitReader.dir/MetadataLoader.cpp.o.d'

sdi@iniza:~/src/llvm-toolchain$ ./scripts/gcc-bug_preprocessed.sh
# 1 "/home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader/MetadataLoader.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "/home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader/MetadataLoader.cpp"
# 10 "/home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader/MetadataLoader.cpp"
# 1 "/home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader/MetadataLoader.h" 1
In file included from
/home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader/MetadataLoader.cpp:10:
/home/sdi/src/llvm-toolchain/llvm/lib/Bitcode/Reader/MetadataLoader.h:17:10:
fatal error: llvm/ADT/SmallVector.h: No such file or directory
#include "llvm/ADT/SmallVector.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

New script attached.

- Sedat -

gcc-bug_preprocessed.sh (1.06 KB)

[ I am not subscribed to llvm-dev ML ]

I have answered and attached all required files.

Thanks for all the help.

- Sedat -