From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id D40D13858D33 for ; Wed, 8 Mar 2023 22:54:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D40D13858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4PX70T3DN2z3M9Y; Wed, 8 Mar 2023 22:54:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PX70T2Qc2z4NmW; Wed, 8 Mar 2023 22:54:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678316041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d5/hnePRLqJpV4drmj0psxY6B+BqxS63Kht6EUZ0kz4=; b=DcjjWHF5eFmnqwLV0JnRdAskDoJ1rV6fkR8CR1Wb98pXJ5n0fSJJPSGvDROHphZk27hJx9 jqDMMDDlgdP3enK7plNUyeMsb6gBNUUK5sgs7rwv9Zh0vt8K1kHlDJ+TtuoyHHsmO8n008 ej5zaX53ZZeY0zrt1Ud1/CYCVdD/wTIDfUMs/QncB88TAW71Oc/13vLNCG9v9uwhP10bct vOvdWDbqiXls+BsOr/S9xhyK1eg+qIbdxfsma9K3w3wexnGYSRKba0Rx8McIdR7iHxENhn okfSsCLyBQLcgT+XyIVztgUF0+4ntEHdKI1GXkGaVkzVYXwHH/qWiNdtZrjafg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678316041; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=d5/hnePRLqJpV4drmj0psxY6B+BqxS63Kht6EUZ0kz4=; b=ooU+BnnItARrnwGT2ksfNd59N+zRjCGr1a7ZZTrfC/VvaaxOwGpE5Q5bPyGcz6ejThaNaq UE0O2QNmql+JWuFQqyM8+Bv/KV0Tc9+95zm2qA5RYiglTyeYDC+h6rUEOcn5WQ5GvYy46R +9W7se42pnBax67PhAdfezzqeYx1AmRoVgmU0GiRGimjqlkQcpdpytvPVH3XnvNYcpB+pb Uc8UGrnXhZERgxW8UBJl8BRagx49jw9ywyv5fzrTQTm8jEITbKkyKAr/M2I+ExjpQFG9WR u+0wM7QmQJ1xaX4mfXKmDgulmHAT/1uIj92OtY4+lBlMfsmlx8zlhfPVkw6yJA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678316041; a=rsa-sha256; cv=none; b=iqKlPIZKt5Tzrf6gtvHDfXBdHAiJhkQb5h7KgNJCIixT9mO3hRxMw1/YKdG7fgy2FvkTrN 0lHolvxKLsrTbloRcpSfDSVNRRD2KhGtkDWPCkACSO3bIx/2EIlRqNnB/vJqn2zgjsoNKI D13I5Op1PZ6skUGI2WeUkjLX+3oPgpGVA1UpTzObPJt275y7h7j67EUUlq4knnalWr6nGE 2QAH9LygCGqA7AiVldUInOKJGiAnPijW7/WfNRiPdnATHk9QVdYtBLEkkomrm/JlGvNzNV nPBOextl7r3nm7euLstNCwolubknEXQ0kC/w1maEiYgmfWAOh0AQI6SQUJ29SA== Received: from [IPV6:2601:648:8680:16b0:857b:4c55:ea29:36e3] (unknown [IPv6:2601:648:8680:16b0:857b:4c55:ea29:36e3]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PX70S61myzFP7; Wed, 8 Mar 2023 22:54:00 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <70b50c1d-29bf-2c5c-2dbb-c2ed7dc55ab2@FreeBSD.org> Date: Wed, 8 Mar 2023 14:53:59 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Content-Language: en-US To: Chris Johns , Simon Marchi , gdb@sourceware.org References: From: John Baldwin Subject: Re: GDB 13.1 and clang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,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: On 3/8/23 1:22 PM, Chris Johns wrote: > On 9/3/2023 5:22 am, Simon Marchi wrote: >> On 3/8/23 15:07, Chris Johns wrote: >>> Hi, >>> >>> I have just tried to build the latest RTEMS tools and we now use gdb 13.1. I am >>> seeing a build failure on FreeBSD 13.1 of: >>> >>> In file included from ../../gdb-13.1/gdb/xml-tdesc.c:23: >>> In file included from ../../gdb-13.1/gdb/target.h:42: >>> In file included from ../../gdb-13.1/gdb/infrun.h:21: >>> In file included from ../../gdb-13.1/gdb/gdbthread.h:26: >>> In file included from ../../gdb-13.1/gdb/breakpoint.h:38: >>> ../../gdb-13.1/gdb/target/waitstatus.h:113:1: error: use of undeclared >>> identifier 'DIAGNOSTIC_ERROR_SWITCH' >>> DIAGNOSTIC_ERROR_SWITCH >>> ^ >>> >>> I only have clang installed on the FreeBSD machine. >>> >>> A quick review of include/diagnostics.h seems to show support for >>> DIAGNOSTIC_ERROR_SWITCH only in the gcc area? >> >> Hmm, I see it in the clang section: >> >> # define DIAGNOSTIC_ERROR_SWITCH \ >> DIAGNOSTIC_ERROR ("-Wswitch") >> > > It seems I need to do a better review before posting :) > >> https://sourceware.org/cgit/binutils-gdb/tree/include/diagnostics.h?h=gdb-13.1-release&id=4f3e26ac6ee31f7bc4b04abd8bdb944e7f1fc5d2#n76 >> >> Unless there's a typo I don't see. >> >> diagnostics.h is included at the top of waitstatus.h. Is it possible >> that another unrelated diagnostics.h gets included on FreeBSD? You >> could inspect the preprocessed file to see what the preprocessor >> included for diagnostics.h. > > There is another version installed here: > > $ pkg which /usr/local/include/diagnostics.h > /usr/local/include/diagnostics.h was installed by package binutils-2.37_2,1 > > We have /usr/local/include early in the include list on FreeBSD to pick up some > of the required libraries installed as packages. I will check for a package > update or I revisit the build flags to see how it can be handled. > > Thank you for the prompt and helpful responses. Yes, I manually delete all the headers installed by binutils into /usr/local/include when building GDB from source locally to work around this. :( I'm not sure of the best fix for this. I tracked it down to the change to add zstd as ZSTD_CFLAGS is before BFD_CFLAGS in INTERNAL_CFLAGS_BASE in Makefile.in in this commit: commit 2cac01e3ffff74898c54fa5e6418817f5578adb6 Author: Fangrui Song Date: Mon Sep 26 19:50:13 2022 -0700 binutils, gdb: support zstd compressed debug sections PR29397 PR29563: Add new configure option --with-zstd which defaults to auto. If pkgconfig/libzstd.pc is found, define HAVE_ZSTD and support zstd compressed debug sections for most tools. * bfd: for addr2line, objdump --dwarf, gdb, etc * gas: support --compress-debug-sections=zstd * ld: support ELFCOMPRESS_ZSTD input and --compress-debug-sections=zstd * objcopy: support ELFCOMPRESS_ZSTD input for --decompress-debug-sections and --compress-debug-sections=zstd * gdb: support ELFCOMPRESS_ZSTD input. The bfd change references zstd symbols, so gdb has to link against -lzstd in this patch. If zstd is not supported, ELFCOMPRESS_ZSTD input triggers an error. We can avoid HAVE_ZSTD if binutils-gdb imports zstd/ like zlib/, but this is too heavyweight, so don't do it for now. ``` % ld/ld-new a.o ld/ld-new: a.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... % ld/ld-new a.o --compress-debug-sections=zstd ld/ld-new: --compress-debug-sections=zstd: ld is not built with zstd support % binutils/objcopy --compress-debug-sections=zstd a.o b.o binutils/objcopy: --compress-debug-sections=zstd: binutils is not built with zstd support % binutils/objcopy b.o --decompress-debug-sections binutils/objcopy: zstd.o: section .debug_abbrev is compressed with zstd, but BFD is not built with zstd support ... ``` I have not tried moving ZSTD_CFLAGS after BFD_CFLAGS, but if it worked I think the right solution is to ensure all the "local" includes for things in git come first before any includes that pull from the installed system. I think this would mean moving READLINE_CFLAGS (for systems that use a system readline), ZLIBINC, and ZSTD_CFLAGS after INCLUDE_CFLAGS. I just tried this and it worked for me locally: diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 6e39383eb93..40497541880 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -629,8 +629,8 @@ INTERNAL_CPPFLAGS = $(CPPFLAGS) @GUILE_CPPFLAGS@ @PYTHON_CPPFLAGS@ \ # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. INTERNAL_CFLAGS_BASE = \ $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \ - $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \ - $(ZSTD_CFLAGS) $(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ + $(GDB_CFLAGS) $(OPCODES_CFLAGS) $(BFD_CFLAGS) $(INCLUDE_CFLAGS) \ + $(READLINE_CFLAGS) $(ZLIBINC) $(ZSTD_CFLAGS) $(LIBDECNUMBER_CFLAGS) \ $(INTL_CFLAGS) $(INCGNU) $(INCSUPPORT) $(LIBBACKTRACE_INC) \ $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS) $(SRCHIGH_CFLAGS) \ $(TOP_CFLAGS) $(PTHREAD_CFLAGS) $(DEBUGINFOD_CFLAGS) $(GMPINC) \ -- John Baldwin