From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Ybf5DC9tpmlg1BEAWB0awg (envelope-from ) for ; Tue, 03 Mar 2026 00:10:07 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=qNCPfDEx; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 310B91E09A; Tue, 03 Mar 2026 00:10:07 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id BD7C81E09A for ; Tue, 03 Mar 2026 00:10:04 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id CC8014BA2E18 for ; Tue, 3 Mar 2026 05:10:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC8014BA2E18 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=qNCPfDEx Received: from mail-dy1-x1335.google.com (mail-dy1-x1335.google.com [IPv6:2607:f8b0:4864:20::1335]) by sourceware.org (Postfix) with ESMTPS id AD3374BA2E12 for ; Tue, 3 Mar 2026 05:07:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD3374BA2E12 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AD3374BA2E12 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1335 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772514420; cv=none; b=KYhbUHMtenJ2w10dz7ecrA2I6y7hsTNC3/aW3wKSuOIDIc8CZqMlfLhLoRWoRlyjqHlcARWxxcEWeI2KiQlqLPPWc9DnKYF3buTBTiRqHxql7txlqD3SxJAN87zccqU+NUndrYAR76kSARWSW4LTuRqdCkpWZ7fyM/LX62xFd+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1772514420; c=relaxed/simple; bh=BEJO+ciOcsMZ4dIt8xeIRkIWOG9O338s35RNgEXYeXs=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=FRgU6aZbLVEDHWspd6ru47roXjQkC5KohxkgS7yFQCkJ5hYpqBm9208cwXWlQ1nmWoqFR08ZX1Vx95awDsk4XfS7jGBbUJqC0QxAIi8vtM0eMOWT2sNQIJhU65XOACEFBf+HFnTlAcXGveOeKiZZGljV9veNc2AgRAjhQfyoOuQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD3374BA2E12 Received: by mail-dy1-x1335.google.com with SMTP id 5a478bee46e88-2bd9a485bd6so406517eec.1 for ; Mon, 02 Mar 2026 21:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1772514420; x=1773119220; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m98BJdhzk4aG6aWEQtf7otSubU+d8tGBIh61gBjm6EQ=; b=qNCPfDExzt/fj1SNtjiUuGEO9orWsFG5KpQYHWPJWHbcn1DMGPsvCdZMJjmFaJSSOM ZdEsv616YICHcBztu2Em8rfUOn1Nh85hQ3NQ5CC5tY7anCInFeua984MLIOvKNonoUPa IPnxHNBOv9mwdKM/qJfc6+JUPmDpHGNLsxrGHBzS5rH9jOrwI5UftrdiPnNMOubK24er P97d/54t6ugM9932nFgxoXRfoCzBFkbhoQo9AeGnsxw9XfNP9ui9R/dPaKOWsSyA2Ozt TfqHb0GT6d0tluueLnY/ZZhVzCgNuaZ2ZqtcKkL/Q1PiVyF4EEurWD0qCMm5I2Ja73co rS0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772514420; x=1773119220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=m98BJdhzk4aG6aWEQtf7otSubU+d8tGBIh61gBjm6EQ=; b=OCYELm0cSZy7IjIFQt4B7s6QMNHpC4AUBkthw5/kyo2VlMe+N5T+dAHsNnmCcFV5kM gwmarV6mlXllt/nAs4+2YzqMWXVX3cVkU/krroV2cSlsTNkWfvtJgbXsGVfC5ggSJd8E wTXxmQTTRJwaF2Md8JkCe3ljN5GM6CAEPOUY8byqy1Iyweaqukp28pQNkEv9ghI//CuZ NpOL8IFBjOD1f0Prl5fAQaNRjIsZ78Lr8p9Bw93wkLkKH2lUDwjXQCKbBNzJaR9l9JNQ S482LEskm8J/phRPlPkcW/2yHZPuQy0q8ksJMmsbuEUpm1d6njQNnWtMifyaFelL+iXA pT1w== X-Gm-Message-State: AOJu0Ywr0/ZQukuqDxIm2OdcATJeBZSh3MpeB6woeK7cbULE3h3CpnO2 CRZn5ihhwVW8Z4MIs0Qd1yT0Li2IbWdOZ3yOSLrVH3uvPM+csCknH4Pu+D+NzX+b8pieY9EmTCR /uWlDd24= X-Gm-Gg: ATEYQzwnxVkK2cXpE6cwIJFhgRkzvP1bwxwBRBk7bNBzGzI7aqPIyKES0leXu78lu2G XrFo9gzMF0+gKqMsGGJEDEPUYFSLtWgKBBTaVSBbPIfry0Y4ph9HK7qfvEe9TkulUYugvoeUSNv En6VxjIgFQIjf1Lb+AVFtNeL3l8F6zWyASyY6FEBDZY/kQZleYZ+d7hdQrz9CwrLkOF/bk4/4Mh 5mMOTva7BisMOKcGNQwBtIgA9r0EpgkDv4gQlNwzoHEy/tdKM3vjrW4ig+SoQe/3Uv01SbVCiqJ tvunxz2ot9/n5Kb6QCqgBc47meZguUnEZx2weawtqiVKv3tHGPpcZ/65vHR5QQHgAd+dlOmTgzo BnMVCb3v6Wb7dhWnKQh0MeDFel+NW/exxFT+UYI2FvvvadKwR8XvfqpUmBI7di7TdN84C8XS6Me PVo7MqJUo4MQ8Zpg+NTNtwYOOc4Jp+d5sG7+NXClQ5dSHI X-Received: by 2002:a05:7300:8cac:b0:2ba:a098:ae64 with SMTP id 5a478bee46e88-2bde1d49f8emr5798410eec.34.1772514419399; Mon, 02 Mar 2026 21:06:59 -0800 (PST) Received: from localhost ([2804:14d:7e39:8083:f04c:42e3:5943:38f6]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2bdd1f7e955sm12368709eec.32.2026.03.02.21.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Mar 2026 21:06:59 -0800 (PST) From: Thiago Jung Bauermann To: gdb-patches@sourceware.org Cc: Chris Packham , Luis , Tom Tromey , Simon Marchi , sunilkumar.dora@windriver.com Subject: [PATCH v4 6/6] GDB: aarch64-linux: Fix build failure on musl systems Date: Tue, 3 Mar 2026 02:06:41 -0300 Message-ID: <20260303050641.198127-7-thiago.bauermann@linaro.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303050641.198127-1-thiago.bauermann@linaro.org> References: <20260303050641.198127-1-thiago.bauermann@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org When building against musl (e.g. on Alpine Linux), the following error happens: CXX linux-aarch64-low.o In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:48: /home/bauermann/src/binutils-gdb/gdbserver/../gdb/nat/aarch64-gcs-linux.h:36:8: error: redefinition of 'struct user_gcs' 36 | struct user_gcs | ^~~~~~~~ In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:36: /usr/include/asm/ptrace.h:329:8: note: previous definition of 'struct user_gcs' 329 | struct user_gcs { | ^~~~~~~~ make[2]: *** [Makefile:565: linux-aarch64-low.o] Error 1 aarch64-linux-tdep.c fails to build in the same way. This happens because aarch64-gcs-linux-ptrace.h uses GCS_MAGIC to see whether the system headers have GCS-related definitions. The problem is that GCS_MAGIC is defined in while struct gcs_user is defined in . It's fine on glibc systems because in the set of system headers that linux-aarch64-low.cc and aarch64-linux-tdep.c include, ends up being included implicitly as well. This doesn't happen when using musl's headers though. There isn't a macro in whose presence is correlated with the presence of the struct user_gcs definition, so a configure check is needed to detect it and conditionally define the struct. Note that there's another build issue with musl, described in PR gdb/33747 affecting compilation of gdb/ser-unix.c. In order to be able to test this patch, I applied the patch in comment 11 there. Tested with a native build on an Alpine Linux aarch64 system, and also verified that all gdb.arch/aarch64-gcs*.exp tests pass on it. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33926 Co-authored-by: Chris Packham --- As I mentioned in the cover letter, if the series is approved I will propose a version of this patch for the GDB 17 branch which doesn't depend on the previous patches. Changes since v3: - Renamed gdb/nat/aarch64-gcs-linux-ptrace.h to gdb/nat/aarch64-gcs-linux.h. Changes since v2: - It's the same patch except that the header changed is gdb/nat/aarch64-gcs-linux-ptrace.h rather than gdb/nat/aarch64-linux.h, which doesn't exist in this version of the patch series. gdb/nat/aarch64-gcs-linux.h | 5 ++--- gdbsupport/config.in | 3 +++ gdbsupport/configure | 36 ++++++++++++++++++++++++++++++++++++ gdbsupport/configure.ac | 19 +++++++++++++++++++ 4 files changed, 60 insertions(+), 3 deletions(-) diff --git a/gdb/nat/aarch64-gcs-linux.h b/gdb/nat/aarch64-gcs-linux.h index ddf8342a4284..3ce7b6486785 100644 --- a/gdb/nat/aarch64-gcs-linux.h +++ b/gdb/nat/aarch64-gcs-linux.h @@ -28,8 +28,7 @@ #define HWCAP_GCS (1ULL << 32) #endif -/* Make sure we only define these if the kernel header doesn't. */ -#ifndef GCS_MAGIC +#ifndef HAVE_STRUCT_USER_GCS /* GCS state (NT_ARM_GCS). */ @@ -40,6 +39,6 @@ struct user_gcs uint64_t gcspr_el0; }; -#endif /* GCS_MAGIC */ +#endif /* HAVE_STRUCT_USER_GCS */ #endif /* GDB_NAT_AARCH64_GCS_LINUX_H */ diff --git a/gdbsupport/config.in b/gdbsupport/config.in index 0beacf22c057..2957ee0f0301 100644 --- a/gdbsupport/config.in +++ b/gdbsupport/config.in @@ -271,6 +271,9 @@ /* Define to 1 if `st_blocks' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_BLOCKS +/* Define to 1 if your system has struct user_gcs. */ +#undef HAVE_STRUCT_USER_GCS + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H diff --git a/gdbsupport/configure b/gdbsupport/configure index 05ad00f48c4f..584a80ef8255 100755 --- a/gdbsupport/configure +++ b/gdbsupport/configure @@ -14307,6 +14307,42 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu +# Check for `struct user_gcs` +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct user_gcs" >&5 +$as_echo_n "checking for struct user_gcs... " >&6; } +if ${gdb_cv_struct_user_gcs+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include +int +main () +{ +struct user_gcs u; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + gdb_cv_struct_user_gcs=yes +else + gdb_cv_struct_user_gcs=no + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gdb_cv_struct_user_gcs" >&5 +$as_echo "$gdb_cv_struct_user_gcs" >&6; } +if test "$gdb_cv_struct_user_gcs" = yes; then + +$as_echo "#define HAVE_STRUCT_USER_GCS 1" >>confdefs.h + +fi + # Set the 'development' global. . $srcdir/../bfd/development.sh diff --git a/gdbsupport/configure.ac b/gdbsupport/configure.ac index 5491b8f3f10a..6c06832f0913 100644 --- a/gdbsupport/configure.ac +++ b/gdbsupport/configure.ac @@ -68,6 +68,25 @@ GDB_AC_PTRACE AM_GDB_COMPILER_TYPE AM_GDB_WARNINGS +# Check for `struct user_gcs` +AC_CACHE_CHECK( + [for struct user_gcs], + [gdb_cv_struct_user_gcs], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [#include + #include ], + [struct user_gcs u;] + )], + [gdb_cv_struct_user_gcs=yes], + [gdb_cv_struct_user_gcs=no] + )] +) +if test "$gdb_cv_struct_user_gcs" = yes; then + AC_DEFINE(HAVE_STRUCT_USER_GCS, 1, + [Define to 1 if your system has struct user_gcs.]) +fi + # Set the 'development' global. . $srcdir/../bfd/development.sh