public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: 宋冬生 <dongsheng.song@gmail.com>
To: "Eric Botcazou" <ebotcazou@adacore.com>,
	"Marc Poulhiès" <poulhies@adacore.com>,
	gcc-patches@gcc.gnu.org
Subject: [PATCH] ada: Fix musl build on Linux
Date: Wed, 8 Feb 2023 17:44:10 +0800	[thread overview]
Message-ID: <Y+Nu6les4SuFnrsB@guest.guest> (raw)

The commit "ada: Add PIE support to backtraces on Linux" [1] use
_r_debug under Linux unconditionally. It is incorrect since musl[2]
libc not defined _r_debug like glibc [3]:

extern struct r_debug _r_debug;

As far as I know, only glibc and uClibc [4] define the global variable
_r_debug. 


[1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=f2b30a724e6bf7ff8e591b176967d596cee7648e;hp=83e8d37fe39d7c1afce19b61bbc2dd828fa37c6f
[2] https://git.musl-libc.org/cgit/musl/tree/include/link.h#n39
[3] https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/link.h;h=3b5954d9818e8ea9f35638c55961f861f6ae6057;hb=HEAD#l66
[4] https://git.uclibc.org/uClibc/tree/include/link.h#n71

OK? Bootstrapped and tested on aarch64-linux-(gnu|musl),
riscv64-linux-(gnu|musl) and x86_64-linux-(gnu|musl) with no regressions.


gcc/ada/

* adaint.c [Linux]: Include <features.h>.
(__gnat_get_executable_load_address) [Linux]: Enable only for glibc & uClibc
on Linux.


 gcc/ada/adaint.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 1c23d1584..852209416 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -3526,6 +3526,7 @@ __gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set)
 #if defined (__APPLE__)
 #include <mach-o/dyld.h>
 #elif defined (__linux__)
+#include <features.h>
 #include <link.h>
 #endif
 
@@ -3535,7 +3536,7 @@ __gnat_get_executable_load_address (void)
 #if defined (__APPLE__)
   return _dyld_get_image_header (0);
 
-#elif defined (__linux__)
+#elif defined (__linux__) && (defined (__GLIBC__) || defined (__UCLIBC__))
   struct link_map *map = _r_debug.r_map;
   return (const void *)map->l_addr;
 

             reply	other threads:[~2023-02-08  9:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08  9:44 宋冬生 [this message]
2023-02-08 11:12 ` Arnaud Charlet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y+Nu6les4SuFnrsB@guest.guest \
    --to=dongsheng.song@gmail.com \
    --cc=ebotcazou@adacore.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=poulhies@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).