From 35067a60ff38bc34f54d50e5ad4e1253ccb4ab8a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 16 May 2025 19:33:30 +0530 Subject: [PATCH] Also build launcher with -std=c11 Fixes #8642 --- kitty/launcher/cmdline.c | 1 + kitty/launcher/utils.h | 1 + setup.py | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kitty/launcher/cmdline.c b/kitty/launcher/cmdline.c index d6c217b57..b584a85fc 100644 --- a/kitty/launcher/cmdline.c +++ b/kitty/launcher/cmdline.c @@ -5,6 +5,7 @@ * Distributed under terms of the GPL3 license. */ +#define _POSIX_C_SOURCE 200809L #include "shlex.h" #include "utils.h" #include "launcher.h" diff --git a/kitty/launcher/utils.h b/kitty/launcher/utils.h index e1c52a34a..7cc426632 100644 --- a/kitty/launcher/utils.h +++ b/kitty/launcher/utils.h @@ -17,6 +17,7 @@ #include #include #include +#include static const char* home = NULL; diff --git a/setup.py b/setup.py index 043cb32d7..7b02afd2d 100755 --- a/setup.py +++ b/setup.py @@ -67,6 +67,7 @@ is_netbsd = 'netbsd' in _plat is_dragonflybsd = 'dragonfly' in _plat is_bsd = is_freebsd or is_netbsd or is_dragonflybsd or is_openbsd is_arm = platform.processor() == 'arm' or platform.machine() in ('arm64', 'aarch64') +c_std = '' if is_openbsd else '-std=c11' Env = glfw.Env env = Env() PKGCONFIG = os.environ.get('PKGCONFIG_EXE', 'pkg-config') @@ -498,7 +499,6 @@ def init_env( cppflags.append('-DDEBUG_{}'.format(el.upper().replace('-', '_'))) has_copy_file_range = test_compile(cc, src='#define _GNU_SOURCE 1\n#include \nint main() { copy_file_range(1, NULL, 2, NULL, 0, 0); return 0; }') werror = '' if ignore_compiler_warnings else '-pedantic-errors -Werror' - std = '' if is_openbsd else '-std=c11' sanitize_flag = ' '.join(sanitize_args) env_cflags = shlex.split(os.environ.get('CFLAGS', '')) env_cppflags = shlex.split(os.environ.get('CPPFLAGS', '')) @@ -508,7 +508,7 @@ def init_env( cflags_ = os.environ.get( 'OVERRIDE_CFLAGS', ( - f'-Wextra {float_conversion} -Wno-missing-field-initializers -Wall -Wstrict-prototypes {std}' + f'-Wextra {float_conversion} -Wno-missing-field-initializers -Wall -Wstrict-prototypes {c_std}' f' {werror} {optimize} {sanitize_flag} -fwrapv {stack_protector} {missing_braces}' f' -pipe -fvisibility=hidden {no_plt}' ) @@ -1297,7 +1297,7 @@ def read_bool_options(path: str = 'kitty/cli.py') -> Tuple[str, ...]: def build_launcher(args: Options, launcher_dir: str = '.', bundle_type: str = 'source') -> str: werror = '' if args.ignore_compiler_warnings else '-pedantic-errors -Werror' - cflags = f'-Wall {werror} -fpie'.split() + cflags = f'-Wall {werror} -fpie {c_std}'.strip().split() cppflags = [define(f'WRAPPED_KITTENS=" {wrapped_kittens()} "')] ldflags = shlex.split(os.environ.get('LDFLAGS', '')) xxhash = xxhash_flags()