[Driver] Let -fno-integrated-as -gdwarf-5 use -fdwarf-directory-asm
authorFangrui Song <i@maskray.me>
Mon, 12 Jul 2021 22:46:20 +0000 (15:46 -0700)
committerFangrui Song <i@maskray.me>
Mon, 12 Jul 2021 22:46:20 +0000 (15:46 -0700)
commit51fc742ce716a09359f4f87ffe3876cb7ff9479d
tree50407a7d67c648ef75b47b96b9ef73bf6c877287
parentf2832c2295c6076b51a35d0d7b304c08e1b41c29
[Driver] Let -fno-integrated-as -gdwarf-5 use -fdwarf-directory-asm

While GNU as only allows the directory form of the .file directive for DWARF v5,
the integrated assembler prefers the directory form on all DWARF versions
(-fdwarf-directory-asm).

We currently set CC1 -fno-dwarf-directory-asm for -fno-integrated-as -gdwarf-5
which may cause the directory entry 0 and the filename entry 0 to be incorrect
(see D105662 and the example below). This patch makes -fno-integrated-as -gdwarf-5 use
-fdwarf-directory-asm as well.

```
cd /tmp/c

before
% clang -g -gdwarf-5 -fno-integrated-as e/a.c -S -o - | grep '\.file.*0'
        .file   0 "/tmp/c/e/a.c" md5 0x97e31cee64b4e58a4af8787512d735b6
% clang -g -gdwarf-5 -fno-integrated-as e/a.c -c
% llvm-dwarfdump a.o | grep include_directories
include_directories[  0] = "/tmp/c/e"

after
% clang -g -gdwarf-5 -fno-integrated-as e/a.c -S -o - | grep '\.file.*0'
        .file   0 "/tmp/c" "e/a.c" md5 0x97e31cee64b4e58a4af8787512d735b6
% clang -g -gdwarf-5 -fno-integrated-as e/a.c -c
% llvm-dwarfdump a.o | grep include_directories
include_directories[  0] = "/tmp/c"
```

Reviewed By: #debug-info, dblaikie, osandov

Differential Revision: https://reviews.llvm.org/D105835
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options.c