From 11942ed6dc394f4efc890f5624df198bb57738f8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 24 Aug 2020 12:05:39 +0530 Subject: [PATCH] Fix compilation on OpenBSD Fixes #2935 --- glfw/glfw.py | 5 ++++- setup.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/glfw/glfw.py b/glfw/glfw.py index 79954eda7..1153610ae 100755 --- a/glfw/glfw.py +++ b/glfw/glfw.py @@ -10,6 +10,7 @@ from typing import Callable, Dict, List, Optional, Tuple _plat = sys.platform.lower() is_linux = 'linux' in _plat +is_openbsd = 'openbsd' in _plat base = os.path.dirname(os.path.abspath(__file__)) @@ -73,7 +74,9 @@ def init_env(env: Env, pkg_config: Callable, at_least_version: Callable, test_co if module in ('x11', 'wayland'): ans.cflags.append('-pthread') ans.ldpaths.append('-pthread') - ans.ldpaths.extend('-lrt -lm -ldl'.split()) + ans.ldpaths.append('-lm') + if not is_openbsd: + ans.ldpaths.extend('-lrt -ldl'.split()) at_least_version('xkbcommon', 0, 5) if module == 'x11': diff --git a/setup.py b/setup.py index 667bcf0b0..eccefc867 100755 --- a/setup.py +++ b/setup.py @@ -263,10 +263,11 @@ def init_env( cppflags.append('-DDEBUG_{}'.format(el.upper().replace('-', '_'))) cflags_ = os.environ.get( 'OVERRIDE_CFLAGS', ( - '-Wextra {} -Wno-missing-field-initializers -Wall -Wstrict-prototypes -std=c11' + '-Wextra {} -Wno-missing-field-initializers -Wall -Wstrict-prototypes {}' ' -pedantic-errors -Werror {} {} -fwrapv {} {} -pipe {} -fvisibility=hidden {}' ).format( float_conversion, + '' if is_openbsd else '-std=c11', optimize, ' '.join(sanitize_args), stack_protector, @@ -287,7 +288,7 @@ def init_env( cppflags += shlex.split(os.environ.get('CPPFLAGS', '')) cflags += shlex.split(os.environ.get('CFLAGS', '')) ldflags += shlex.split(os.environ.get('LDFLAGS', '')) - if not debug and not sanitize: + if not debug and not sanitize and not is_openbsd: # See https://github.com/google/sanitizers/issues/647 cflags.append('-flto') ldflags.append('-flto')