Fix compilation on OpenBSD

Fixes #2935
This commit is contained in:
Kovid Goyal 2020-08-24 12:05:39 +05:30
parent f65914599b
commit 11942ed6dc
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 3 deletions

View File

@ -10,6 +10,7 @@ from typing import Callable, Dict, List, Optional, Tuple
_plat = sys.platform.lower() _plat = sys.platform.lower()
is_linux = 'linux' in _plat is_linux = 'linux' in _plat
is_openbsd = 'openbsd' in _plat
base = os.path.dirname(os.path.abspath(__file__)) 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'): if module in ('x11', 'wayland'):
ans.cflags.append('-pthread') ans.cflags.append('-pthread')
ans.ldpaths.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) at_least_version('xkbcommon', 0, 5)
if module == 'x11': if module == 'x11':

View File

@ -263,10 +263,11 @@ def init_env(
cppflags.append('-DDEBUG_{}'.format(el.upper().replace('-', '_'))) cppflags.append('-DDEBUG_{}'.format(el.upper().replace('-', '_')))
cflags_ = os.environ.get( cflags_ = os.environ.get(
'OVERRIDE_CFLAGS', ( '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 {}' ' -pedantic-errors -Werror {} {} -fwrapv {} {} -pipe {} -fvisibility=hidden {}'
).format( ).format(
float_conversion, float_conversion,
'' if is_openbsd else '-std=c11',
optimize, optimize,
' '.join(sanitize_args), ' '.join(sanitize_args),
stack_protector, stack_protector,
@ -287,7 +288,7 @@ def init_env(
cppflags += shlex.split(os.environ.get('CPPFLAGS', '')) cppflags += shlex.split(os.environ.get('CPPFLAGS', ''))
cflags += shlex.split(os.environ.get('CFLAGS', '')) cflags += shlex.split(os.environ.get('CFLAGS', ''))
ldflags += shlex.split(os.environ.get('LDFLAGS', '')) 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 # See https://github.com/google/sanitizers/issues/647
cflags.append('-flto') cflags.append('-flto')
ldflags.append('-flto') ldflags.append('-flto')