PR119367 is about an overflow related to debug views, if those are not supported directly by the assembler. The problem is that dw2_asm_output_delta yields a 2-byte variable, which isn't sufficient.
However, as the draft patch of comment 14 shows, dw2_asm_output_delta_uleb128 can be used to avoid the range issues. But that depends on support for uleb128, which is detected using HAVE_AS_LEB128. This currently fails for two reasons: (A) llvm-mc does not produce an ELF file - but a text file (rewritten assembler) this can be fixed by using --filetype=obj - and as this is about the amdgcn target, we add --arch=amdgcn for completeness. (B) For cross compiling, this requires that the amdgcn-amdhsa{/bin/,-}objdump is found. Currently, it isn't which implies that the has-the-proper-value-really-been-written test fails. A lot of ELF tools would do, llvm-objdump and Binutil's objdump alike. For simplicity, this patch just adds llvm-objdump to the list shown in install.texi aliashttps://gcc.gnu.org/install/specific.html#amdgcn-x-amdhsa NOTE: While we list a lot of binaries, I think strictly required in the installed compiler is only 'ld' (alias lld) and 'as' (alias llvm-mc); the others are only required for building GCC, albeit they might be handy when building other libraries (ar, ranlib) albeit in some cases the ELF tools nm and objdump might be handy as well. - I have not attempted to disentangle this in the documentation. OK for mainline? Tobias
[gcn] gcc/configure.ac + install.texi - changes to detect HAVE_AS_LEB128 [PR119367] The llvm-mc linker by default assemblies to another assembly file and not to an ELF binary; that usually does not matter – but for the LEB128 check, additionally, the resulting binary is checked. Hence, when using llvm-mc as target linker for amdgcn-*-*, we better add the "--filetype=obj --arch=amdgcn" flags. Additionally, the resulting ELF file is checked, which requires an ELF reader such as objdump. This commit adds llvm-objdump to the build documentation for amdgcn, albeit also, e.g., Binutil's 'objdump' would do - as long as either amdgcn-amdhsa-objdump or amdgcn-amdhsa/bin/objdump is found during the amdgcn cross build. gcc/ChangeLog: PR debug/119367 * configure.ac (check_leb128_asflags): For gcn, use "--filetype=obj --arch=amdgcn", if supported. * configure: Regenerate. * doc/install.texi (amdgcn-*-*): Also add llvm-objdump to the list of to-be-copied files. gcc/configure | 34 ++++++++++++++++++++++++++++++++++ gcc/configure.ac | 8 ++++++++ gcc/doc/install.texi | 1 + 3 files changed, 43 insertions(+) diff --git a/gcc/configure b/gcc/configure index 4a751d969ba..bce54d162e2 100755 --- a/gcc/configure +++ b/gcc/configure @@ -26493,6 +26493,40 @@ if test $gcc_cv_as_mno_relax = yes; then check_leb128_asflags=-mno-relax fi + ;; + amdgcn*-*-*) + check_leb128_asflags= + # llvm-mc requires those flags to produce a proper .o file + # readable by either binutils' objdump or llvm-objdump + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for --filetype=obj --arch=amdgcn" >&5 +$as_echo_n "checking assembler for --filetype=obj --arch=amdgcn... " >&6; } +if ${gcc_cv_as_filetype_arch+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_filetype_arch=no + if test x$gcc_cv_as != x; then + $as_echo '.text' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags --filetype=obj --arch=amdgcn -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_filetype_arch=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_filetype_arch" >&5 +$as_echo "$gcc_cv_as_filetype_arch" >&6; } +if test $gcc_cv_as_filetype_arch = yes; then + check_leb128_asflags="--filetype=obj --arch=amdgcn" +fi + ;; *) check_leb128_asflags= diff --git a/gcc/configure.ac b/gcc/configure.ac index 4532c5c22fe..61203342b9c 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3301,6 +3301,14 @@ case $target in gcc_cv_as_mno_relax,[-mno-relax],[.text],, [check_leb128_asflags=-mno-relax]) ;; + amdgcn*-*-*) + check_leb128_asflags= + # llvm-mc requires those flags to produce a proper .o file + # readable by either binutils' objdump or llvm-objdump + gcc_GAS_CHECK_FEATURE([--filetype=obj --arch=amdgcn], + gcc_cv_as_filetype_arch,[--filetype=obj --arch=amdgcn],[.text],, + [check_leb128_asflags="--filetype=obj --arch=amdgcn"]) + ;; *) check_leb128_asflags= ;; diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 6913035b596..f2a8d0e24ab 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -4065,6 +4065,7 @@ AMD GCN GPU target. Instead of GNU Binutils, you need to install LLVM and copy @file{bin/llvm-mc} to @file{amdgcn-amdhsa/bin/as}, @file{bin/lld} to @file{amdgcn-amdhsa/bin/ld}, +@file{bin/llvm-objdump} to @file{amdgcn-amdhsa/bin/objdump}, @file{bin/llvm-nm} to @file{amdgcn-amdhsa/bin/nm}, and @file{bin/llvm-ar} to both @file{bin/amdgcn-amdhsa-ar} and @file{bin/amdgcn-amdhsa-ranlib}.