Skip to content

Commit 07917f2

Browse files
committed
Define _GNU_SOURCE at compiler invocation
1 parent 186f966 commit 07917f2

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

graalpython/com.oracle.graal.python.cext/posix/fork_exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
*
44
* Licensed under the PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
55
*/
6-
#ifdef __gnu_linux__
7-
#define _GNU_SOURCE
6+
#if defined(__gnu_linux__) && !defined(_GNU_SOURCE)
7+
#define _GNU_SOURCE 1
88
#endif
99

1010
#include <unistd.h>

graalpython/com.oracle.graal.python.cext/posix/posix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444

4545
// This file uses GNU extensions. Functions that require non-GNU versions (e.g. strerror_r)
4646
// need to go to posix_no_gnu.c
47-
#ifdef __gnu_linux__
48-
#define _GNU_SOURCE
47+
#if defined(__gnu_linux__) && !defined(_GNU_SOURCE)
48+
#define _GNU_SOURCE 1
4949
#endif
5050

5151
#include <arpa/inet.h>

graalpython/com.oracle.graal.python.cext/setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ def build_nativelibsupport(capi_home, subdir, libname, deps=[], **kwargs):
473473
def build_libposix(capi_home):
474474
src_dir = os.path.join(__dir__, "posix")
475475
files = [os.path.abspath(os.path.join(src_dir, f)) for f in os.listdir(src_dir) if f.endswith(".c")]
476+
no_gnu_source = get_config_var("USE_GNU_SOURCE")
477+
if no_gnu_source:
478+
get_config_vars()["CFLAGS"] = get_config_var("CFLAGS_DEFAULT")
476479
module = Extension(libposix_name,
477480
sources=files,
478481
libraries=['crypt'] if not darwin_native else [],
@@ -486,6 +489,8 @@ def build_libposix(capi_home):
486489
description="Graal Python's Native support for the POSIX library",
487490
ext_modules=[module],
488491
)
492+
if no_gnu_source:
493+
get_config_vars()["CFLAGS"] = get_config_var("CFLAGS_DEFAULT") + " " + get_config_var("USE_GNU_SOURCE")
489494

490495

491496
def build_builtin_exts(capi_home):

graalpython/lib-graalpython/_sysconfig.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ def _get_posix_vars():
8484
g['OPT'] = "-stdlib=libc++ -DNDEBUG"
8585
g['CONFINCLUDEPY'] = get_python_inc()
8686
g['CPPFLAGS'] = '-I. -I' + get_python_inc()
87-
g['CFLAGS'] = "-Wno-unused-command-line-argument -stdlib=libc++ -DNDEBUG -DGRAALVM_PYTHON_LLVM"
87+
gnu_source = "-D_GNU_SOURCE=1"
88+
g['USE_GNU_SOURCE'] = gnu_source
89+
cflags_default = "-Wno-unused-command-line-argument -stdlib=libc++ -DNDEBUG -DGRAALVM_PYTHON_LLVM"
90+
g['CFLAGS_DEFAULT'] = cflags_default
91+
g['CFLAGS'] = cflags_default + " " + gnu_source
8892
g['LDFLAGS'] = ""
8993
g['CCSHARED'] = "-fPIC"
9094
g['LDSHARED_LINUX'] = "%s -shared -fPIC" % __graalpython__.get_toolchain_tool_path('CC')

0 commit comments

Comments
 (0)