$ clang -c -o - -x c++ -g - <<<"struct S {}; extern S *s; void f() {s = new S(); }" | llvm-dwarfdump - | grep DW_TAG_structure_type
$ clang -c -o - -x c++ -g - <<<"struct S {}; S *s; void f() {s = new S(); }" | llvm-dwarfdump - | grep DW_TAG_structure_type
0x00000033: DW_TAG_structure_type
I believe the first command should also produce debug info for struct S. We cannot rely on the type information to be emitted in the compilation unit defining s as it may not even have access to the definition (it could be treating it opaquely as a forward-declaration). Interestingly, not even -fstandalone-debug causes the type to be emitted.