diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f82d456..7c52f38b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ project(falco) option(USE_BUNDLED_DEPS "Bundle hard to find dependencies into the Falco binary" OFF) option(BUILD_WARNINGS_AS_ERRORS "Enable building with -Wextra -Werror flags" OFF) option(MINIMAL_BUILD "Build a minimal version of Falco, containing only the engine and basic input/output" OFF) +option(MUSL_OPTIMIZED_BUILD "Enable if you want a musl optimized build" OFF) # Elapsed time # set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CMAKE_COMMAND} -E time") # TODO(fntlnz, leodido): add a flag to enable this @@ -55,7 +56,11 @@ if(MINIMAL_BUILD) set(MINIMAL_BUILD_FLAGS "-DMINIMAL_BUILD") endif() -set(CMAKE_COMMON_FLAGS "-Wall -ggdb ${DRAIOS_FEATURE_FLAGS} ${MINIMAL_BUILD_FLAGS}") +if(MUSL_OPTIMIZED_BUILD) + set(MUSL_FLAGS "-static -Os -D__NEED_struct_timespec -D__NEED_time_t") +endif() + +set(CMAKE_COMMON_FLAGS "-Wall -ggdb ${DRAIOS_FEATURE_FLAGS} ${MINIMAL_BUILD_FLAGS} ${MUSL_FLAGS}") if(BUILD_WARNINGS_AS_ERRORS) set(CMAKE_SUPPRESSED_WARNINGS diff --git a/cmake/modules/sysdig.cmake b/cmake/modules/sysdig.cmake index c06ca541..3f4239a7 100644 --- a/cmake/modules/sysdig.cmake +++ b/cmake/modules/sysdig.cmake @@ -23,10 +23,6 @@ if(USE_BUNDLED_DEPS) set(USE_BUNDLED_JQ ON) endif() -if(MINIMAL_BUILD) - set(MUSL_OPTIMIZED_BUILD ON) -endif() - file(MAKE_DIRECTORY ${SYSDIG_CMAKE_WORKING_DIR}) # The sysdig git reference (branch name, commit hash, or tag) To update sysdig version for the next release, change the @@ -34,7 +30,7 @@ file(MAKE_DIRECTORY ${SYSDIG_CMAKE_WORKING_DIR}) # -DSYSDIG_VERSION=dev ..` if(NOT SYSDIG_VERSION) set(SYSDIG_VERSION "build/stripped") # todo(leogr): set the correct version and checksum before merging - set(SYSDIG_CHECKSUM "SHA256=653a2e665b3a0ac2cafac07debaa779dc65113f9308f4e4e4ff3d5c9582836d3") + set(SYSDIG_CHECKSUM "SHA256=c6df1bf9e9846bd44adbb74861d2479ac5ba59745faf33d650fd9ece24445d27") endif() set(PROBE_VERSION "${SYSDIG_VERSION}") @@ -61,6 +57,9 @@ add_subdirectory("${SYSDIG_SOURCE_DIR}/driver" "${PROJECT_BINARY_DIR}/driver") # Add libscap directory add_definitions(-D_GNU_SOURCE) add_definitions(-DHAS_CAPTURE) +if(MUSL_OPTIMIZED_BUILD) + add_definitions(-DMUSL_OPTIMIZED) +endif() add_subdirectory("${SYSDIG_SOURCE_DIR}/userspace/libscap" "${PROJECT_BINARY_DIR}/userspace/libscap") # Add libsinsp directory