From patchwork Wed Jan 29 12:53:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 1230877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-518487-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=Q6m1+ogN; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4873Ly16Ttz9sPK for ; Wed, 29 Jan 2020 23:53:28 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=vw1zDngqvBX7z60h6lp7TNjopcNZrJhGrDdNDbLGtr1YBIOhLw sIKrseW1Mer9bi6LVXQfktkrK27OrSGwG9WyupYrLK1C9xIOr4NxA/TY7R8eEs9t 6wTTxTKCrkZlHUb4cUe2yIWS3VwmFys9LaDSMRFQPoOr5POPTxPSLqiBw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=0T4gTD0aaDIgXhbp8IEF5iEo53g=; b=Q6m1+ogNGSyy60tEIvi6 UPWzyNJeyqJEE2NRgWziLKhbMwMas9OIlIrgmN5J+TXwJIn/+EW7/DjgJhaFacpF 1NUQtk9eRFx+hrdvhxnVNC3IdBuMKJYUksbyeFAZmaFrCrxC93zKzPTydnlEMJwo 0ta/yXvcffWSREM0EoB/As0= Received: (qmail 17915 invoked by alias); 29 Jan 2020 12:53:20 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 17907 invoked by uid 89); 29 Jan 2020 12:53:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.6 required=5.0 tests=AWL, BAYES_00, GARBLED_SUBJECT, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT autolearn=ham version=3.3.1 spammy= X-HELO: esa4.mentor.iphmx.com Received: from esa4.mentor.iphmx.com (HELO esa4.mentor.iphmx.com) (68.232.137.252) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Jan 2020 12:53:17 +0000 IronPort-SDR: eL6vaI00TzyXN0mAjG3R0MzfNRaQbMLj68RSW9PRhtIHQb4WyevyODhoVluf2EdLsAFZgRHBm6 1vpFisEqI4l/hlmj51/ayBW/NLiLQt8jJye+NQ4SnlEpj3+/st8z7LQqIszqgQV/VDZsNHEkSk opaZytie5uEX175pkd2q5fdxP4ga329P73bGmFwb7DoMXrqOugmBl9FgeIhPgab9Q41MRPKSTn HUrAonIAoUHTRhfzZF4vhhZimn/ZMcrWXsHf5AlXorD0CXAg6JxiJm5dpqtCcMnpHS/q8aq8ov sZ4= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 29 Jan 2020 04:53:15 -0800 IronPort-SDR: 66cL6j7PkAaZZsE8exrHQ+LRRDfOMYsmUyYWCxSlj92/rJprHFwG/MO7gg3/uk5rcalXwazmcD U/StgxyeXsUA== To: gcc-patches , Andrew Stubbs , Matthias Klose From: Tobias Burnus Subject: =?utf-8?q?=5BPatch=5D_GCN_=E2=80=93_call_assembler_with_-mattr?= =?utf-8?q?=3D-code-object-v3_=28PR93409=29?= Message-ID: <5a2d66cd-5206-fb0a-21f9-c7a6f281282d@codesourcery.com> Date: Wed, 29 Jan 2020 13:53:09 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 X-IsSubscribed: yes Cf. PR93409 comments 4 and later. The comments 1–3 of the PR are covered by patch https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01663.html (skip building libgomp's HSA/GCN plugin with -mx32). For AMDGCN, the LLVM assembler is used. While for LLVM 7+8, GCC generates code which is the same as LLVM, for LLVM 9 (and later), the LLVM switched from Code Object V2 to V3. With LLVM 9, the old variant is only accepted when also passing "-mattr=-code-object-v3" to the compiler; that's a"-" after the "=" to disable V3. (Cf. also https://sources.debian.org/src/gcc-10/10-20200117-2/debian/patches/gcc-amdgcn-fix.diff/). My initial idea was to add a configure check – which I also include as attachment. However, it turned out that at last the assembler of LLVM version 7.0.1 already supports this flag. Hence, we can go for the simpler solution and use the assembler flag unconditionally. OK for the trunk? Tobias * IGNORE * THIS PATCH IS NOT NEEDED AS LLVM 7's ASSEMBLER ALREADY SUPPORTS THAT OPTION. ONLY THE DEFAULT CHANGED WITH LLVM 9 * gcc/configure.ac: Add -mattr=-code-object-v3 check. * gcc/config/gcn/gcn-hsa.h (ASM_SPEC): use it gcc/config.in | 12 +++++++ gcc/config/gcn/gcn-hsa.h | 7 ++++ gcc/configure | 91 +++++++++++++++++++++++++++++++++++++++++++----- gcc/configure.ac | 33 ++++++++++++++++++ 4 files changed, 135 insertions(+), 8 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index ec5c46abdb5..05dc9499f22 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -546,6 +546,12 @@ #endif +/* Define if your assembler supports -mattr=-code-object-v3. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_MATTR_CODE_OBJECT_V3 +#endif + + /* Define if your assembler supports mfcr field. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_MFCRF @@ -2185,6 +2191,12 @@ #endif +/* Define if your target C Library properly handles PT_GNU_STACK */ +#ifndef USED_FOR_TARGET +#undef TARGET_LIBC_GNUSTACK +#endif + + /* Define if your target C Library provides the AT_HWCAP value in the TCB */ #ifndef USED_FOR_TARGET #undef TARGET_LIBC_PROVIDES_HWCAP_IN_TCB diff --git a/gcc/config/gcn/gcn-hsa.h b/gcc/config/gcn/gcn-hsa.h index cefe67217e7..9ba2b543519 100644 --- a/gcc/config/gcn/gcn-hsa.h +++ b/gcc/config/gcn/gcn-hsa.h @@ -76,9 +76,16 @@ extern unsigned int gcn_local_sym_hash (const char *name); #define GOMP_SELF_SPECS "" /* Use LLVM assembler and linker options. */ +#if HAVE_AS_MATTR_CODE_OBJECT_V3 +#define ASM_SPEC "-triple=amdgcn--amdhsa -mattr=-code-object-v3 " \ + "%:last_arg(%{march=*:-mcpu=%*}) " \ + "-filetype=obj" +#else #define ASM_SPEC "-triple=amdgcn--amdhsa " \ "%:last_arg(%{march=*:-mcpu=%*}) " \ "-filetype=obj" +#endif + /* Add -mlocal-symbol-id= unless the user (or mkoffload) passes the option explicitly on the command line. The option also causes several dump-matching tests to fail in the testsuite, so the option is not diff --git a/gcc/configure b/gcc/configure index 490fe6ac8e8..0b6a8cb23a4 100755 --- a/gcc/configure +++ b/gcc/configure @@ -974,6 +974,7 @@ with_zstd_include with_zstd_lib enable_rpath with_libiconv_prefix +with_libiconv_type enable_sjlj_exceptions with_gcc_major_version_only enable_secureplt @@ -1811,6 +1812,7 @@ Optional Packages: --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir + --with-libiconv-type=TYPE type of library to search for (auto/static/shared) --with-gcc-major-version-only use only GCC major number in filesystem paths --with-pic try to use only PIC/non-PIC objects [default=use @@ -10730,6 +10732,16 @@ if test "${with_libiconv_prefix+set}" = set; then : fi + +# Check whether --with-libiconv-type was given. +if test "${with_libiconv_type+set}" = set; then : + withval=$with_libiconv_type; with_libiconv_type=$withval +else + with_libiconv_type=auto +fi + + lib_type=`eval echo \$with_libiconv_type` + LIBICONV= LTLIBICONV= INCICONV= @@ -10767,13 +10779,13 @@ fi found_so= found_a= if test $use_additional = yes; then - if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then + if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext" && test x$lib_type != xstatic; then found_dir="$additional_libdir" found_so="$additional_libdir/lib$name.$shlibext" if test -f "$additional_libdir/lib$name.la"; then found_la="$additional_libdir/lib$name.la" fi - else + elif test x$lib_type != xshared; then if test -f "$additional_libdir/lib$name.$libext"; then found_dir="$additional_libdir" found_a="$additional_libdir/lib$name.$libext" @@ -10797,13 +10809,13 @@ fi case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` - if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then + if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext" && test x$lib_type != xstatic; then found_dir="$dir" found_so="$dir/lib$name.$shlibext" if test -f "$dir/lib$name.la"; then found_la="$dir/lib$name.la" fi - else + elif test x$lib_type != xshared; then if test -f "$dir/lib$name.$libext"; then found_dir="$dir" found_a="$dir/lib$name.$libext" @@ -11031,8 +11043,13 @@ fi done fi else - LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" - LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" + if x$lib_type = xauto || x$lib_type = xshared; then + LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" + else + LIBICONV="${LIBICONV}${LIBICONV:+ }-l:lib$name.$libext" + LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l:lib$name.$libext" + fi fi fi fi @@ -18957,7 +18974,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18960 "configure" +#line 18977 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -19063,7 +19080,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 19066 "configure" +#line 19083 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -28158,6 +28175,47 @@ case "$target" in ;; esac +# AMGCGN: Check whether the assembler supports -mattr=-code-object-v3 +case "$target" in + amdgcn-* | gcn-*) + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler support for -mattr=-code-object-v3" >&5 +$as_echo_n "checking assembler support for -mattr=-code-object-v3... " >&6; } + gcc_cv_as_mattr_code_object_v3=no + if test x$gcc_cv_as != x; then + cat > conftest.s <&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_mattr_code_object_v3=yes + fi + rm -f conftest.s conftest.o conftest + fi + if test x$gcc_cv_as_mattr_code_object_v3 = xyes; then + +$as_echo "#define HAVE_AS_MATTR_CODE_OBJECT_V3 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_mattr_code_object_v3" >&5 +$as_echo "$gcc_cv_as_mattr_code_object_v3" >&6; } + ;; +esac + # ??? Not all targets support dwarf2 debug_line, even within a version # of gas. Moreover, we need to emit a valid instruction to trigger any # info to the output file. So, as supported targets are added to gas 2.11, @@ -29800,6 +29858,23 @@ $as_echo "#define TARGET_LIBC_PROVIDES_HWCAP_IN_TCB 1" >>confdefs.h fi +# Check if the target LIBC handles PT_GNU_STACK. +gcc_cv_libc_gnustack=unknown +case "$target" in + mips*-*-linux*) + +if test $glibc_version_major -gt 2 \ + || ( test $glibc_version_major -eq 2 && test $glibc_version_minor -ge 31 ); then : + gcc_cv_libc_gnustack=yes +fi + ;; +esac +if test x$gcc_cv_libc_gnustack = xyes; then + +$as_echo "#define TARGET_LIBC_GNUSTACK 1" >>confdefs.h + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking dl_iterate_phdr in target C library" >&5 $as_echo_n "checking dl_iterate_phdr in target C library... " >&6; } gcc_cv_target_dl_iterate_phdr=unknown diff --git a/gcc/configure.ac b/gcc/configure.ac index a7521ee9943..22357ff1aac 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5084,6 +5084,39 @@ case "$target" in ;; esac +# AMGCGN: Check whether the assembler supports -mattr=-code-object-v3 +case "$target" in + amdgcn-* | gcn-*) + AC_MSG_CHECKING(assembler support for -mattr=-code-object-v3) + gcc_cv_as_mattr_code_object_v3=no + if test x$gcc_cv_as != x; then + cat > conftest.s <