Skip to content

Commit b03b1d1

Browse files
committed
truffle.nfi.native: detect musl in header file instead in suite definition
1 parent b49fa84 commit b03b1d1

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

truffle/mx.truffle/suite.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,12 +1034,6 @@
10341034
"ldlibs" : ["-ldl"],
10351035
},
10361036
},
1037-
"linux-musl" : {
1038-
"<others>" : {
1039-
"cflags" : ["-g", "-O3", "-Wall", "-Werror", "-fvisibility=hidden"],
1040-
"ldlibs" : ["-ldl"],
1041-
},
1042-
},
10431037
"<others>" : {
10441038
"<others>" : {
10451039
"cflags" : ["-g", "-O3", "-Wall", "-Werror", "-fvisibility=hidden"],

truffle/src/com.oracle.truffle.nfi.native/src/internal.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,28 @@
4141
#ifndef __TRUFFLE_INTERNAL_H
4242
#define __TRUFFLE_INTERNAL_H
4343

44-
#if defined(__linux__) && defined(_GNU_SOURCE)
44+
#if defined(__linux__)
45+
46+
#if !defined(_GNU_SOURCE)
47+
#error "expected to be set via CLFAGS. required for detection below"
48+
#endif
49+
50+
/* musl does not set __USE_GNU in features.h
51+
* source: https://stackoverflow.com/a/70211227
52+
*/
53+
#include <features.h>
54+
55+
#ifdef __USE_GNU
56+
/* glibc */
4557
#define ENABLE_ISOLATED_NAMESPACE
4658
#define ISOLATED_NAMESPACE 0x10000
4759
#include <dlfcn.h>
48-
#endif
60+
61+
#else // !__USE_GNU
62+
/* musl. dlmopen not available */
63+
#endif // !__USE_GNU
64+
65+
#endif // __linux__
4966

5067
#include "native.h"
5168
#include "trufflenfi.h"

0 commit comments

Comments
 (0)