public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] ada: Fix musl build on Linux
@ 2023-02-08  9:44 宋冬生
  2023-02-08 11:12 ` Arnaud Charlet
  0 siblings, 1 reply; 2+ messages in thread
From: 宋冬生 @ 2023-02-08  9:44 UTC (permalink / raw)
  To: Eric Botcazou, Marc Poulhiès, gcc-patches

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;
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ada: Fix musl build on Linux
  2023-02-08  9:44 [PATCH] ada: Fix musl build on Linux 宋冬生
@ 2023-02-08 11:12 ` Arnaud Charlet
  0 siblings, 0 replies; 2+ messages in thread
From: Arnaud Charlet @ 2023-02-08 11:12 UTC (permalink / raw)
  To: ?????????; +Cc: Eric Botcazou, Marc Poulhi??s, gcc-patches, Arnaud Charlet

> 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.

OK, thanks,

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-08 11:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08  9:44 [PATCH] ada: Fix musl build on Linux 宋冬生
2023-02-08 11:12 ` Arnaud Charlet

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).