From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uejAB96jmWmbCQQAWB0awg (envelope-from ) for ; Sat, 21 Feb 2026 07:23:58 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=hQ3suGhT; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 15C991E0BA; Sat, 21 Feb 2026 07:23:58 -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,FREEMAIL_FROM,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 05E751E089 for ; Sat, 21 Feb 2026 07:23:57 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 794304B9DB7B for ; Sat, 21 Feb 2026 12:23:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 794304B9DB7B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=hQ3suGhT Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 3CF4E4BA2E3D for ; Sat, 21 Feb 2026 12:23:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3CF4E4BA2E3D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3CF4E4BA2E3D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::42a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771676609; cv=none; b=CxEc7E4MgfMnRMPUqgYCRgJBwPAU4NCfD2h2PgfrjFSJdcEHbR+6a2Ifehl02m03E9+1cmEcmJ42pAyGcuvGKtti8Q6kPcGpwA0tNkdHhaKkTbdyrxR7X5nv5wcT5gCD6RMfm0xEjVcHy4sFNXQn6GkhNS3SCHZtRgs8Tg9aG64= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1771676609; c=relaxed/simple; bh=CHRYz4UbEEe0BiumSt5ATAeKRZPiHIvIHtIH1G9NHDM=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=nNmyI/FQL5KuUYlr5Nq/OuSO192N8x/QzOaHD3kN6WJ6TuNS9FFLjLb/Wa5bHjGAPejt5+R9/SZjbfIb64ubQJJRYZYzv52hS/NUEM8Ln6fQ1/AR+hbOpoYAJqqvJn8DAg7IsGNecDdmEh73bM68r0jJT1Y6FKI2rV9TukXYPV4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3CF4E4BA2E3D Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-4376c0bffc1so2201803f8f.0 for ; Sat, 21 Feb 2026 04:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771676608; x=1772281408; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=nyiJUvvfb2qz+dyEQ/gkLFrvjK9XtZU+XEdJoF5oDyI=; b=hQ3suGhTIbPaq/mFC97nIEWLQ9FyjGozgK2ueuJHwEOLQfTihicy6AqgImJcFtq2x2 o/XUeTU1Y4klSILVSYc1MBLELzHrya096syfdnLR7mYYYB2lJukaclCIYYfix4KW7KTY OZUi1aY4jb7QslUHaquIJ/4Xz/6wapsFDpVAyTpUvH87YrbtzKL/xAFNQj3du5n5XTnv Qwz69AgcH+dQTY2E/l/UZdn/sdnibNM7fAmbG7KGNk40HzGLdFjmizPEpcOQusPTu+wd tybDMpmafzO1DnRi3U1JgpP6p6IUBrQi6GLixUVoB3jY8la1qVMeztR1prP+qWlnDbhX 0xtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771676608; x=1772281408; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nyiJUvvfb2qz+dyEQ/gkLFrvjK9XtZU+XEdJoF5oDyI=; b=TYVHwJJGqvYUIlZJDcJgHK85il8VqLAnmK6tUuIouXYjYdHjCPhi4bXFIvdrJBquT2 bpaAVL3lB4zFQKhSEaQ9juoW3neg+adcGnr+k7G9/UpUd9fetDTn0zmeA1wfREqiR1Us M+b7FIncE14J9CES4hifqVRBnFwolv9YIUI9c/BFu5klOniR+NEmuNoukhG6GGW0udMa GMjG9+1RROpyNFt4rvgWPJ4O6A1mStpIi9HS2WE5uCqBwEbDXFfSLM2EglQeuWH1vQUU W0cqyc3wclRdvZocWFgrORfMRN3s+nDSeVyUWkqyTJR55uGS4vJo/8URXYnoaeW1FHm0 Rxlw== X-Forwarded-Encrypted: i=1; AJvYcCWvljld4ryxUOJwur8FOLQ5QMrDipBNes9+eEYzrrNaAveCNRD0CWLO/wvpIt8qTkaR6cQdtlVs9D/Qig==@sourceware.org X-Gm-Message-State: AOJu0YzKYhQhl7qryh/n9Oknbi0r4G6xRwQOSKlyCgszgec6H30sbOLc ep51G6qQECpM74aWgh9Gb5khEAZpvsFzZHNp48fGc0Q2AjTC1ApkN+0kXEzr5Q== X-Gm-Gg: AZuq6aLMfW2Ug0eGErZpvlzg16g4jM4FBVmj2HMd6fCC6vZwxmzwNzVJybfEdFR/cGk n4+/0SRj3QlOFIra6NYuchZVYlxIj3CQk9cO6k5+QpQ23XYsS7auAaqewG9CO26be+Dq2SDS892 0/fUNZndwBIFyqke3qIv9kYnuAM+fJ14n11y5+g9YSDYOMXLbi5WOW4KkLfDEOiaZ6rF/W4LlPK RAa/Mr2ZSPDhC9Jabqy7l9CWprWCSBma0vDPVNVjES6nJ2PoUE6AsmoIbQpAO6fDdIOfvpDsY+k JW/a70aZr3NHtqbk7row6p12zjt7NzcRUBgFZe3Cz/aflxUKtQf4heMuDu77f7tqvBWEamyx9We nI9Y2KQj7fEy+2gtIEgKWz2M6xB1SDTE48glROwnGq3mZHobYl1cJKWhuFixEP70gjm3mJNTZRM ewwsuJho0bIBIERIz40L4S7TPbobFAqIY7+pz+ X-Received: by 2002:a05:6000:615:b0:432:8504:8d5b with SMTP id ffacd0b85a97d-4396f194345mr5309883f8f.50.1771676607838; Sat, 21 Feb 2026 04:23:27 -0800 (PST) Received: from [192.168.0.38] ([86.12.216.189]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970bfa015sm5139000f8f.8.2026.02.21.04.23.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 21 Feb 2026 04:23:27 -0800 (PST) Message-ID: Date: Sat, 21 Feb 2026 12:23:26 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 4/4] GDB: aarch64-linux: Fix build failure on musl systems Content-Language: en-US To: Thiago Jung Bauermann , gdb-patches@sourceware.org Cc: Chris Packham , Tom Tromey , Simon Marchi References: <20260217060106.1906312-1-thiago.bauermann@linaro.org> <20260217060106.1906312-5-thiago.bauermann@linaro.org> From: Luis In-Reply-To: <20260217060106.1906312-5-thiago.bauermann@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 17/02/2026 06:01, Thiago Jung Bauermann wrote: > 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-ptrace.h:31:8: error: redefinition of 'struct user_gcs' > 31 | struct user_gcs > | ^~~~~~~~ > In file included from /home/bauermann/src/binutils-gdb/gdbserver/linux-aarch64-low.cc:35: > /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-linux.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. > > Co-authored-by: Chris Packham > --- > 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-ptrace.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-ptrace.h b/gdb/nat/aarch64-gcs-linux-ptrace.h > index f45a1059cd0a..f3dda08a1d27 100644 > --- a/gdb/nat/aarch64-gcs-linux-ptrace.h > +++ b/gdb/nat/aarch64-gcs-linux-ptrace.h > @@ -23,8 +23,7 @@ > #include > #include > > -/* 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). */ > > @@ -35,6 +34,6 @@ struct user_gcs > uint64_t gcspr_el0; > }; > > -#endif /* GCS_MAGIC */ > +#endif /* HAVE_STRUCT_USER_GCS */ > > #endif /* GDB_NAT_AARCH64_GCS_LINUX_PTRACE_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 > Thanks. Still looks OK to me. I'd like a second approval from Tom or Simon. Approved-By: Luis Machado