From 316aa777ef5635aaef31323b47176de49e6c0cf1 Mon Sep 17 00:00:00 2001 From: Axel Ibarrondo Date: Tue, 18 Aug 2026 21:15:00 -0300 Subject: [PATCH 1/2] fix: drop _XOPEN_SOURCE from pty.c to keep the BSD tty API visible CMake already builds with gnu11 (CMAKE_C_EXTENSIONS ON), so posix_openpt is visible without _XOPEN_SOURCE. Defining it hides the BSD extensions the tty path needs (cfmakeraw, TIOCSCTTY, struct winsize) and breaks the macOS build as soon as the tty code lands. Also documents in sandbox_darwin.c that sandbox_init() is deprecated since macOS 10.8 and trips -Werror: wrap that single call in a scoped clang pragma instead of turning OMICRON_WERROR off. --- src/pty.c | 5 +++-- src/sandbox_darwin.c | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pty.c b/src/pty.c index a872093..b791304 100644 --- a/src/pty.c +++ b/src/pty.c @@ -1,7 +1,8 @@ /* Dueño: LevtCode. Portable: usar posix_openpt, no openpty (evita #ifdef). */ -/* Macro del compilador para poder usar posix_openpt. (Debe declararse casi al principio del código) */ -#define _XOPEN_SOURCE 600 +/* Sin _XOPEN_SOURCE: CMake ya compila en gnu11 (CMAKE_C_EXTENSIONS ON), que deja + * visible posix_openpt. Definirlo esconde las extensiones BSD que necesita el tty + * (cfmakeraw, TIOCSCTTY, struct winsize) y rompe el build en macOS. */ #include "omicron/pty.h" #include "omicron/sandbox.h" diff --git a/src/sandbox_darwin.c b/src/sandbox_darwin.c index d0f3688..69f0fca 100644 --- a/src/sandbox_darwin.c +++ b/src/sandbox_darwin.c @@ -17,6 +17,14 @@ om_sandbox *om_sandbox_prepare(const om_policy *p) return NULL; } +/* Ojo al implementar: sandbox_init() está marcada deprecada desde macOS 10.8 y + * con -Werror el build falla por -Wdeprecated-declarations. Sigue siendo la API + * viva de Seatbelt, así que NO apagar OMICRON_WERROR: envolver solo la llamada. + * #pragma clang diagnostic push + * #pragma clang diagnostic ignored "-Wdeprecated-declarations" + * rc = sandbox_init(s->profile, 0, &err); + * #pragma clang diagnostic pop + */ int om_sandbox_apply(const om_sandbox *s) { (void)s; From 1da187dbab926d986f2b463ddf9e3c14f2f316cd Mon Sep 17 00:00:00 2001 From: levtcode Date: Thu, 20 Aug 2026 05:21:47 +0200 Subject: [PATCH 2/2] fix: added the POSIX _XOPEN_SOURCE global macro to fix the lastest-ubuntu crash --- CMakeLists.txt | 6 ++++++ src/pty.c | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90924a3..fd32293 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,12 @@ set(CMAKE_C_STANDARD_REQUIRED ON) set(CMAKE_C_EXTENSIONS ON) # gnu11: hace falta para POSIX/BSD (termios, ioctl) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +# No funciona solo con CMAKE_C_EXTENSIONS, hay que definirlo explicitamente, aunque CMAKE_EXTENSIONS +# expone símbolos clave de libc y glibc, para que funcione en Linux hay que añadir la macro +# POSIX del compilador. Se debe definir antes que cualquier otro archivo o cabecera +add_compile_definitions(_XOPEN_SOURCE=700) # Usamos la versión 2008 POSIX +add_compile_definitions(_DEFAULT_SOURCE) + if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) endif() diff --git a/src/pty.c b/src/pty.c index b791304..acbdc49 100644 --- a/src/pty.c +++ b/src/pty.c @@ -1,9 +1,5 @@ /* Dueño: LevtCode. Portable: usar posix_openpt, no openpty (evita #ifdef). */ -/* Sin _XOPEN_SOURCE: CMake ya compila en gnu11 (CMAKE_C_EXTENSIONS ON), que deja - * visible posix_openpt. Definirlo esconde las extensiones BSD que necesita el tty - * (cfmakeraw, TIOCSCTTY, struct winsize) y rompe el build en macOS. */ - #include "omicron/pty.h" #include "omicron/sandbox.h"