From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 10ACE3858401 for ; Fri, 18 Aug 2023 08:39:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10ACE3858401 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 074E71F893 for ; Fri, 18 Aug 2023 08:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692347964; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ni5wCpi8OFTBvMN7XyZtmLGRjjfl1SXun/sjt3CaP/U=; b=pvsRVCu5P3SYCmLvBWBIL9EfBevl/CmsW4h0vZ+6q2kpQI2G5HvpBMIp+Txc258zAPfDYR fO8oBGHVjeMLshA3qI+vx+e4iQTRlFxUyParvEuikNeF0lDOY8qEaps5lq/qHEWjzRbPEQ /lXoeQ74KCSvZUo/L9vZ9J01VTX9xFY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692347964; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ni5wCpi8OFTBvMN7XyZtmLGRjjfl1SXun/sjt3CaP/U=; b=9W+L55ErFwpY+tTbFBl7x90tG50q1ZaI8OhAyuYY13RHWP3mmjBvozpv5I+H6tKyCcM1wk KWzRKme8t+qzEnCg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E7DD3138F0 for ; Fri, 18 Aug 2023 08:39:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iDx+Nzsu32QmEAAAMHmgww (envelope-from ) for ; Fri, 18 Aug 2023 08:39:23 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/build] Work around cgen odr violations Date: Fri, 18 Aug 2023 10:38:57 +0200 Message-Id: <20230818083857.15960-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: When building gdb with -flto -O2, I run into: ... opcodes/mep-desc.h:250:14: warning: type 'cgen_operand_type' violates the \ C++ One Definition Rule [-Wodr] typedef enum cgen_operand_type { ^ opcodes/or1k-desc.h:624:14: note: an enum with different value name is \ defined in another translation unit typedef enum cgen_operand_type { ^ opcodes/mep-desc.h:212:14: warning: type 'cgen_hw_type' violates the C++ One \ Definition Rule [-Wodr] typedef enum cgen_hw_type { ^ opcodes/or1k-desc.h:433:14: note: an enum with different value name is \ defined in another translation unit typedef enum cgen_hw_type { ^ ... Fix this by making the conflicting type names unique, adding a target-specific prefix using a define before the include: ... #define cgen_operand_type _cgen_operand_type #define cgen_hw_type _cgen_hw_type #include "opcodes/-desc.h" ... Likewise for targets frv and lm32, the two other targets that include opcodes/-desc.h. A PR has been filed to take care of this in the opcodes dir instead (PR30758). Tested on x86_64-linux. PR build/30757 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30757 --- gdb/frv-tdep.c | 6 +++++- gdb/lm32-tdep.c | 6 +++++- gdb/mep-tdep.c | 5 ++++- gdb/or1k-tdep.h | 3 +++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c index 6c6050a919a..a32071f0395 100644 --- a/gdb/frv-tdep.c +++ b/gdb/frv-tdep.c @@ -29,7 +29,6 @@ #include "dis-asm.h" #include "sim-regno.h" #include "sim/sim-frv.h" -#include "opcodes/frv-desc.h" /* for the H_SPR_... enums */ #include "symtab.h" #include "elf-bfd.h" #include "elf/frv.h" @@ -40,6 +39,11 @@ #include "objfiles.h" #include "gdbarch.h" +/* Make cgen names unique to prevent ODR conflicts with other targets. */ +#define cgen_operand_type frv_cgen_operand_type +#define cgen_hw_type frv_cgen_hw_type +#include "opcodes/frv-desc.h" /* for the H_SPR_... enums */ + struct frv_unwind_cache /* was struct frame_extra_info */ { /* The previous frame's inner-most stack address. Used as this diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c index 23998f85dd8..6ab57fde1df 100644 --- a/gdb/lm32-tdep.c +++ b/gdb/lm32-tdep.c @@ -32,10 +32,14 @@ #include "regcache.h" #include "trad-frame.h" #include "reggroups.h" -#include "opcodes/lm32-desc.h" #include #include "gdbarch.h" +/* Make cgen names unique to prevent ODR conflicts with other targets. */ +#define cgen_operand_type lm32_cgen_operand_type +#define cgen_hw_type lm32_cgen_hw_type +#include "opcodes/lm32-desc.h" + /* Macros to extract fields from an instruction. */ #define LM32_OPCODE(insn) ((insn >> 26) & 0x3f) #define LM32_REG0(insn) ((insn >> 21) & 0x1f) diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c index fc786f09e44..3484b9bbe0a 100644 --- a/gdb/mep-tdep.c +++ b/gdb/mep-tdep.c @@ -47,7 +47,10 @@ #include "gdbarch.h" /* Get the user's customized MeP coprocessor register names from - libopcodes. */ + libopcodes. Make cgen names unique to prevent ODR conflicts with other + targets. */ +#define cgen_operand_type mep_cgen_operand_type +#define cgen_hw_type mep_cgen_hw_type #include "opcodes/mep-desc.h" #include "opcodes/mep-opc.h" diff --git a/gdb/or1k-tdep.h b/gdb/or1k-tdep.h index a11950584d7..c1efbc4c3de 100644 --- a/gdb/or1k-tdep.h +++ b/gdb/or1k-tdep.h @@ -23,6 +23,9 @@ #define TARGET_OR1K #endif +/* Make cgen names unique to prevent ODR conflicts with other targets. */ +#define cgen_operand_type or1k_cgen_operand_type +#define cgen_hw_type or1k_cgen_hw_type #include "opcodes/or1k-desc.h" #include "opcodes/or1k-opc.h" base-commit: 0c9546b152f6b01756475ce259c895d3fa446774 -- 2.35.3