From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 36E393858284; Fri, 26 Jan 2024 10:03:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 36E393858284 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706263394; bh=1EXprcQXNZf9XpmNiattM4FVZGAQcDeVQa3her7w11E=; h=From:To:Subject:Date:From; b=s4psbguLjK8t0s9fWMSVRVRC1590nKpgJHyoQSde/9ScGmIQMgDS7NHOCBH8LbL32 OParz9l9EH+V54T6ww+GvzaugVZrXkyfXPcvz8Zsi8jiU8QW5bQStbLeDLh3RVm3fP CAE3xZJfGsvUUTpp8nmxneTwCcNYHscKz2zLZ0jY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8449] gcn/gcn-hsa.h: Always pass --amdhsa-code-object-version= in ASM_SPEC X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/master X-Git-Oldrev: bf23a62ee08fdc114a517dc4af148f15fa5d6545 X-Git-Newrev: 4b5650acb3107239867830dc1214b31bdbe3cacd Message-Id: <20240126100314.36E393858284@sourceware.org> Date: Fri, 26 Jan 2024 10:03:14 +0000 (GMT) List-Id: https://gcc.gnu.org/g:4b5650acb3107239867830dc1214b31bdbe3cacd commit r14-8449-g4b5650acb3107239867830dc1214b31bdbe3cacd Author: Tobias Burnus Date: Fri Jan 26 10:14:09 2024 +0100 gcn/gcn-hsa.h: Always pass --amdhsa-code-object-version= in ASM_SPEC Since LLVM commit 082f87c9d418 (Pull Req. #79038; will become LLVM 18) "[AMDGPU] Change default AMDHSA Code Object version to 5" the default - when no --amdhsa-code-object-version= is used - was bumped. Using --amdhsa-code-object-version=5 is supported (with unknown limitations) since LLVM 14. GCC required for proper support at least LLVM 13.0.1 such that explicitly using COV5 is not possible. Unfortunately, the COV number matters for debugging ("-g") as mkoffload.cc extracts debugging data from the host's object file and writes into an an AMD GPU object file it creates. And all object files linked together must have the same ABI version. gcc/ChangeLog: * config/gcn/gcn-hsa.h (ABI_VERSION_SPEC): New; creates the "--amdhsa-code-object-version=" argument. (ASM_SPEC): Use it; replace previous version of it. Signed-off-by: Tobias Burnus Diff: --- gcc/config/gcn/gcn-hsa.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gcc/config/gcn/gcn-hsa.h b/gcc/config/gcn/gcn-hsa.h index f5de0d2969f1..e5b93f7d9e54 100644 --- a/gcc/config/gcn/gcn-hsa.h +++ b/gcc/config/gcn/gcn-hsa.h @@ -75,6 +75,21 @@ extern unsigned int gcn_local_sym_hash (const char *name); supported for gcn. */ #define GOMP_SELF_SPECS "" +/* Explicitly set the ABI version; in principle, we could use just the + default; however, when debugging symbols are turned on, mkoffload.cc + writes a new AMD GPU object file and the ABI version needs to be the + same. - LLVM <= 17 defaults to 4 while LLVM >= 18 defaults to 5. + GCC supports LLVM >= 13.0.1 and only LLVM >= 14 supports version 5. + Note that Fiji is only suppored with LLVM <= 17 as version 3 i no longer + supported in LLVM >= 18. */ +#define ABI_VERSION_SPEC "march=fiji:--amdhsa-code-object-version=3;" \ + "!march=*|march=*:--amdhsa-code-object-version=4" + +/* Note that the XNACK and SRAM-ECC settings must match those in mkoffload.cc + as the latter creates new ELF object file when debugging is enabled and + the ELF flags (e_flags) of that generated file must be identical to those + generated by the compiler. */ + #define NO_XNACK "march=fiji:;march=gfx1030:;march=gfx1100:;" \ /* These match the defaults set in gcn.cc. */ \ "!mxnack*|mxnack=default:%{march=gfx900|march=gfx906|march=gfx908:-mattr=-xnack};" @@ -88,7 +103,7 @@ extern unsigned int gcn_local_sym_hash (const char *name); /* Use LLVM assembler and linker options. */ #define ASM_SPEC "-triple=amdgcn--amdhsa " \ "%{march=*:-mcpu=%*} " \ - "%{!march=*|march=fiji:--amdhsa-code-object-version=3} " \ + "%{" ABI_VERSION_SPEC "} " \ "%{" NO_XNACK XNACKOPT "} " \ "%{" NO_SRAM_ECC SRAMOPT "} " \ "%{march=gfx1030|march=gfx1100:-mattr=+wavefrontsize64} " \