Skip to content

Commit 8181889

Browse files
Transurgeonclaude
andcommitted
Fix Linux build: define _POSIX_C_SOURCE for clock_gettime
The diff_engine_core uses clock_gettime() and struct timespec for timing, which require _POSIX_C_SOURCE=200809L on Linux when compiling with -std=c99 (which disables GNU extensions). The CMakeLists.txt already had this define, but it wasn't being applied when building through setuptools. Added define_macros to the diffengine Extension for Linux builds. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ee4d329 commit 8181889

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

setup/extensions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ def not_on_windows(s: str) -> str:
7373
if 'dnlp_diff_engine' not in s # Exclude standalone Python package
7474
] + [_diffengine_bindings]
7575

76+
# Define _POSIX_C_SOURCE on Linux for clock_gettime and struct timespec
77+
diffengine_defines = []
78+
if platform.system().lower() == 'linux':
79+
diffengine_defines.append(('_POSIX_C_SOURCE', '200809L'))
80+
7681
diffengine = Extension(
7782
'_diffengine',
7883
sources=diff_engine_sources,
@@ -81,6 +86,7 @@ def not_on_windows(s: str) -> str:
8186
'diff_engine_core/src/',
8287
'diff_engine_core/python/',
8388
],
89+
define_macros=diffengine_defines,
8490
extra_compile_args=[
8591
'-O3',
8692
'-std=c99',

0 commit comments

Comments
 (0)