lol

fluent-bit: fix build on darwin

- Update fix-luajit-darwin.patch to apply to the current version.

- Add a patch to fix compilation of cmetrics on darwin.

- Use default stdenv instead of gccStdenv. The only requirement for GCC
was the bundled luajit having 'DEFAULT_CC = gcc' hardcoded, but it has
been fixed with the updated fix-luajit-darwin.patch by adding
DEFAULT_CC=cc to the arguments.

authored by

Sebastián Mancilla and committed by
tomberek
09a54b14 46c3452a

+52 -13
+5 -2
pkgs/tools/misc/fluent-bit/default.nix
··· 11 11 sha256 = "sha256-b+MZuZQB/sl0HcioU1KCxH3TNiXYSPBfC9dBKqCVeXk="; 12 12 }; 13 13 14 + patches = lib.optionals stdenv.isDarwin [ 15 + ./fix-cmetrics-darwin.patch 16 + ./fix-luajit-darwin.patch 17 + ]; 18 + 14 19 nativeBuildInputs = [ cmake flex bison ]; 15 20 16 21 buildInputs = lib.optionals stdenv.isLinux [ systemd ]; 17 22 18 23 cmakeFlags = [ "-DFLB_METRICS=ON" "-DFLB_HTTP_SERVER=ON" ]; 19 - 20 - patches = lib.optionals stdenv.isDarwin [ ./fix-luajit-darwin.patch ]; 21 24 22 25 # _FORTIFY_SOURCE requires compiling with optimization (-O) 23 26 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-O";
+23
pkgs/tools/misc/fluent-bit/fix-cmetrics-darwin.patch
··· 1 + diff --git i/lib/cmetrics/src/cmt_time.c w/lib/cmetrics/src/cmt_time.c 2 + --- i/lib/cmetrics/src/cmt_time.c 3 + +++ w/lib/cmetrics/src/cmt_time.c 4 + @@ -20,7 +20,7 @@ 5 + #include <cmetrics/cmt_info.h> 6 + 7 + /* MacOS */ 8 + -#ifdef FLB_HAVE_CLOCK_GET_TIME 9 + +#ifdef CMT_HAVE_CLOCK_GET_TIME 10 + #include <mach/clock.h> 11 + #include <mach/mach.h> 12 + #endif 13 + @@ -41,8 +41,8 @@ 14 + mach_timespec_t mts; 15 + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); 16 + clock_get_time(cclock, &mts); 17 + - tm->tv_sec = mts.tv_sec; 18 + - tm->tv_nsec = mts.tv_nsec; 19 + + tm.tv_sec = mts.tv_sec; 20 + + tm.tv_nsec = mts.tv_nsec; 21 + mach_port_deallocate(mach_task_self(), cclock); 22 + #else /* __STDC_VERSION__ */ 23 + clock_gettime(CLOCK_REALTIME, &tm);
+23 -8
pkgs/tools/misc/fluent-bit/fix-luajit-darwin.patch
··· 1 1 diff -Naur fluent-bit.old/cmake/luajit.cmake fluent-bit.new/cmake/luajit.cmake 2 2 --- fluent-bit.old/cmake/luajit.cmake 3 3 +++ fluent-bit.new/cmake/luajit.cmake 4 - @@ -11,10 +11,6 @@ 5 - set(LUAJIT_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${FLB_PATH_LIB_LUAJIT}) 4 + @@ -12,15 +12,7 @@ 6 5 set(LUAJIT_DEST ${CMAKE_CURRENT_BINARY_DIR}) 7 6 8 - -if (CMAKE_SYSTEM_NAME MATCHES "Darwin") 9 - - set(CFLAGS "${CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT}") 10 - -endif() 11 - - 7 + if (CMAKE_SYSTEM_NAME MATCHES "Darwin") 8 + - set(CFLAGS "${CFLAGS} -isysroot ${CMAKE_OSX_SYSROOT} -fno-stack-check") 9 + - if (CMAKE_HOST_SYSTEM_VERSION VERSION_GREATER_EQUAL 20 10 + - AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS 21) 11 + - set(DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=11.0") 12 + - else() 13 + - set(DEPLOYMENT_TARGET "MACOSX_DEPLOYMENT_TARGET=10.15") 14 + - endif() 15 + -else() 16 + - set(DEPLOYMENT_TARGET "") 17 + + set(CFLAGS "${CFLAGS} -fno-stack-check") 18 + endif() 19 + 12 20 # luajit (UNIX) 13 - # ============= 14 - ExternalProject_Add(luajit 21 + @@ -30,7 +22,7 @@ 22 + EXCLUDE_FROM_ALL TRUE 23 + SOURCE_DIR ${LUAJIT_SRC} 24 + CONFIGURE_COMMAND ./configure 25 + - BUILD_COMMAND $(MAKE) CROSS=${CROSS_PREFIX} CFLAGS=${CFLAGS} BUILD_MODE=static "XCFLAGS=-fPIC" ${DEPLOYMENT_TARGET} 26 + + BUILD_COMMAND $(MAKE) DEFAULT_CC=cc CROSS=${CROSS_PREFIX} CFLAGS=${CFLAGS} BUILD_MODE=static "XCFLAGS=-fPIC" 27 + INSTALL_COMMAND cp src/libluajit.a "${LUAJIT_DEST}/lib/libluajit.a") 28 + 29 + # luajit (Windows)
+1 -3
pkgs/top-level/all-packages.nix
··· 5159 5159 icu = icu63; 5160 5160 }; 5161 5161 5162 - fluent-bit = callPackage ../tools/misc/fluent-bit { 5163 - stdenv = gccStdenv; 5164 - }; 5162 + fluent-bit = callPackage ../tools/misc/fluent-bit { }; 5165 5163 5166 5164 flux = callPackage ../development/compilers/flux { }; 5167 5165