Bug 101987 - gcc 10.3.1 fails to generate debugging information for aarch64 .S files
Summary: gcc 10.3.1 fails to generate debugging information for aarch64 .S files
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 10.3.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-19 20:57 UTC by Dietmar May
Modified: 2021-08-20 00:25 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2021-08-19 00:00:00


Attachments
simple makefile project (1.98 KB, application/zip)
2021-08-19 20:57 UTC, Dietmar May
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dietmar May 2021-08-19 20:57:03 UTC
Created attachment 51325 [details]
simple makefile project

Using the ARM / linaro aarch64-none-elf build of gcc 10.3.1, building a bare metal bootloader, (at least) the boot.S entry code is missing all debugging information. As such, gdb fails to step or honor breakpoints in the startup code.

linaro's 10.2.1 version generates debugging information as expected; and the same file compiled with the Ubuntu 20.04 gcc-10.3.0 aarch64 cross compiler matches exactly (except for AS version number), when viewed using objdump -W.

The problem is trivially reproduced using the attached project, which builds with missing debug info in target/boot.o using linaro's 10.3.1 cross compiler.
Comment 1 Andrew Pinski 2021-08-19 21:04:32 UTC
GCC seems to be involving as correctly with -g on the trunk:
 ./as --gdwarf2 -v -EL -mabi=lp64 -o /tmp/ccu6moah.o /tmp/ccOieH6c.s


Can you provide the output of "aarch64-none-elf-gcc -v -g boot.S -c"
Comment 2 Dietmar May 2021-08-19 21:08:18 UTC
$ /opt/linaro/10.3.1/bin/aarch64-none-elf-gcc -v -g src/boot.S -c
Using built-in specs.
COLLECT_GCC=/opt/linaro/10.3.1/bin/aarch64-none-elf-gcc
Target: aarch64-none-elf
Configured with: /data/jenkins/workspace/GNU-toolchain/arm-10/src/gcc/configure --target=aarch64-none-elf --prefix=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-elf/install// --with-gmp=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-elf/host-tools --with-mpfr=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-elf/host-tools --with-mpc=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-elf/host-tools --with-isl=/data/jenkins/workspace/GNU-toolchain/arm-10/build-aarch64-none-elf/host-tools --disable-shared --disable-nls --disable-threads --disable-tls --enable-checking=release --enable-languages=c,c++,fortran --with-newlib --with-pkgversion='GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)' --with-bugurl=https://bugs.linaro.org/
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.3.1 20210621 (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29)) 
COLLECT_GCC_OPTIONS='-v' '-g' '-c' '-mlittle-endian' '-mabi=lp64'
 /opt/linaro/10.3.1/bin/../libexec/gcc/aarch64-none-elf/10.3.1/cc1 -E -lang-asm -quiet -v -iprefix /opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/ src/boot.S -mlittle-endian -mabi=lp64 -g -fworking-directory -fno-directives-only -o /tmp/ccjOmWwv.s
ignoring nonexistent directory "/opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/sys-include"
ignoring duplicate directory "/opt/linaro/10.3.1/bin/../lib/gcc/../../lib/gcc/aarch64-none-elf/10.3.1/include"
ignoring duplicate directory "/opt/linaro/10.3.1/bin/../lib/gcc/../../lib/gcc/aarch64-none-elf/10.3.1/include-fixed"
ignoring nonexistent directory "/opt/linaro/10.3.1/bin/../lib/gcc/../../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/sys-include"
ignoring duplicate directory "/opt/linaro/10.3.1/bin/../lib/gcc/../../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/include
 /opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/include-fixed
 /opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-g' '-c' '-mlittle-endian' '-mabi=lp64'
 /opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/bin/as --gdwarf2 -EL -mabi=lp64 -o boot.o /tmp/ccjOmWwv.s
COMPILER_PATH=/opt/linaro/10.3.1/bin/../libexec/gcc/aarch64-none-elf/10.3.1/:/opt/linaro/10.3.1/bin/../libexec/gcc/:/opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/bin/
LIBRARY_PATH=/opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/:/opt/linaro/10.3.1/bin/../lib/gcc/:/opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/lib/
COLLECT_GCC_OPTIONS='-v' '-g' '-c' '-mlittle-endian' '-mabi=lp64'
Comment 3 Andrew Pinski 2021-08-19 21:11:19 UTC
> /opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/../../../../aarch64-none-elf/bin/as --gdwarf2 -EL -mabi=lp64 -o boot.o /tmp/ccjOmWwv.s

So GCC is doing the right thing; that is passing --gdwarf2 which enables emitting debug info for the assembly file.  It is either a binutils issue or it is a bug in your makefile.

You should report this to the Linaro folks anyways since they are the release of the toolchain.
Comment 4 Dietmar May 2021-08-19 21:26:48 UTC
You're correct.


$ /opt/linaro/10.3.1/bin/../libexec/gcc/aarch64-none-elf/10.3.1/cc1 -E -lang-asm -quiet -v -iprefix /opt/linaro/10.3.1/bin/../lib/gcc/aarch64-none-elf/10.3.1/ src/boot.S -mlittle-endian -mabi=lp64 -g -fworking-directory -fno-directives-only -o tmp.s

preprocesses the .S -> .s for as


$ /opt/linaro/10.2.1/bin/aarch64-none-elf-as --gdwarf2 -EL -mabi=lp64 -o boot.o tmp.s

yields a .o file with debug info


$ /opt/linaro/10.3.1/bin/aarch64-none-elf-as --gdwarf2 -EL -mabi=lp64 -o boot.o tmp.s

yields a .o file missing debug info


ergo it's not a gcc issue.

Thanks for helping to diagnose this so quickly.
Comment 5 Dietmar May 2021-08-20 00:25:33 UTC
I've confirmed that the issue is present in binutils 2.36.1, but not 2.35.1

ARM / Linaro's aarch64 10.2.1 toolchain uses binutils 2.35.1
Their 10.3.1 toolchain uses binutils 2.36.1

By copying the 'as' binary from 10.2.1 to the 10.3.1 toolchain, I've confirmed that the boot.o file contains debugging information, and this problem does not appear.

In other words, running with gcc 10.3.1, but with the binutils 2.35.1 as assembler, there is no problem.

I've also confirmed this by assembling using my own mingw build of binutils 2.36.1