Skip to content

Commit 3826019

Browse files
Earlopainnobu
authored andcommitted
Fix a build failure with musl
``` compiling gc.c In file included from gc.c:80: /usr/include/sys/prctl.h:88:8: error: redefinition of 'struct prctl_mm_map' 88 | struct prctl_mm_map { | ^~~~~~~~~~~~ In file included from gc.c:79: /usr/include/linux/prctl.h:134:8: note: originally defined here 134 | struct prctl_mm_map { | ^~~~~~~~~~~~ ``` The first include is not needed and is what causes this issue. Two other places in ruby exclusively use the sys import. See seccomp/libseccomp#19 for a similar problem.
1 parent a8c2d5e commit 3826019

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

gc.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@
7575
#endif
7676

7777
/* For ruby_annotate_mmap */
78-
#ifdef __linux__
79-
#include <linux/prctl.h>
78+
#ifdef HAVE_SYS_PRCTL_H
8079
#include <sys/prctl.h>
8180
#endif
8281

@@ -4516,7 +4515,7 @@ Init_GC(void)
45164515
void
45174516
ruby_annotate_mmap(const void *addr, unsigned long size, const char *name)
45184517
{
4519-
#if defined(__linux__) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
4518+
#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
45204519
// The name length cannot exceed 80 (including the '\0').
45214520
RUBY_ASSERT(strlen(name) < 80);
45224521
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, (unsigned long)addr, size, name);

gc/default.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#ifndef _WIN32
66
# include <sys/mman.h>
77
# include <unistd.h>
8-
# ifdef __linux__
9-
# include <linux/prctl.h>
8+
# ifdef HAVE_SYS_PRCTL_H
109
# include <sys/prctl.h>
1110
# endif
1211
#endif
@@ -1875,7 +1874,7 @@ heap_page_body_allocate(void)
18751874
// `default.c` as a shared library, we will not have access to private
18761875
// symbols, and we have to either call prctl directly or make our own
18771876
// wrapper.
1878-
#if defined(__linux__) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
1877+
#if defined(HAVE_SYS_PRCTL_H) && defined(PR_SET_VMA) && defined(PR_SET_VMA_ANON_NAME)
18791878
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, mmap_size, "Ruby:GC:default:heap_page_body_allocate");
18801879
errno = 0;
18811880
#endif

0 commit comments

Comments
 (0)