Fix assembler error when -g and -gdwarf-* is passed with
-fno-integrated-as.
D136309 and D136707 are 2 differentials that pass -g and -gdwarf-* to
assembler when -fno-integrated-as is used. Due to this we started seeing
below assembler error with GNU binutils version 2.34 and below. This
error is not shown by binutils version 2.36 and later.
Error: file number 1 already allocated"
This is because the debug info generated at the source code level is conflicting
with the debug info generated by assembler as mentioned in the gcc bug report -
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35925
This patch solves the above failure by passing -g and -gdwarf-* flags to
assembler only when the source code is assembly, otherwise just generate the
debug info at the source code level.
The above error can be reproduced through below testcase-
(clang from main, Ubuntu 16.04).
$ cat test.cpp int foo() { int i=6; do --i; while (!(i%3)); do {} while (!(i%5)); return 0; } $ clang++ test.cpp --target=arm-linux-gnueabi -c -fno-integrated-as -gdwarf-4 -O2 -fno-finite-loops --gcc-toolchain=<path/to/GNU/assembler/for/arm> /tmp/C06127-9298ce.s: Assembler messages: /tmp/C06127-9298ce.s:56: Error: file number 1 already allocated clang++: error: assembler command failed with exit code 1 (use -v to see invocation)
The following input causes clang to crash:
Please fix that and add a test case for /dev/null (i.e. inputs for which no extension exists).