diff --git a/.github/workflows/codeql_runner.yml b/.github/workflows/codeql_runner.yml index 657f7f976de..ceade25b291 100644 --- a/.github/workflows/codeql_runner.yml +++ b/.github/workflows/codeql_runner.yml @@ -209,20 +209,6 @@ jobs: run: | git submodule sync --recursive - # NOTE: We will only use an already existing cache, and will not save it later, - # just to prevent trashing of cache. Also the cache is only partially updated, - # since we only build third party libraries with the cache on. - - name: Update the cache (sccache) - uses: actions/cache/restore@v3 - with: - path: ${{ steps.build_paths.outputs.SCCACHE }} - - key: | - sccache_${{ matrix.os }}_64_Release_${{ steps.determine_compiler_version.outputs.COMPILER_VERSION }}_${{ github.sha }} - - restore-keys: | - sccache_${{ matrix.os }}_64_Release_${{ steps.determine_compiler_version.outputs.COMPILER_VERSION }} - - name: Initialize the Python 3 installation uses: actions/setup-python@v2 with: @@ -283,8 +269,6 @@ jobs: echo "${{ steps.build_paths.outputs.INSTALL }}\sccache" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - ls -l ${{ steps.build_paths.outputs.SCCACHE }} - - name: Prepare sccache wrapper working-directory: ${{ steps.build_paths.outputs.SOURCE }} shell: cmd @@ -323,8 +307,8 @@ jobs: -DCMAKE_CXX_COMPILER=cl.exe ^ -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ^ -DOSQUERY_BUILD_TESTS=OFF ^ - -DCMAKE_C_COMPILER_LAUNCHER="${{ steps.build_paths.outputs.INSTALL }}\sccache\sccache_wrapper.exe" ^ - -DCMAKE_CXX_COMPILER_LAUNCHER="${{ steps.build_paths.outputs.INSTALL }}\sccache\sccache_wrapper.exe" ^ + -DCMAKE_C_COMPILER_LAUNCHER="${{ steps.build_paths.outputs.INSTALL }}\sccache\sccache.exe" ^ + -DCMAKE_CXX_COMPILER_LAUNCHER="${{ steps.build_paths.outputs.INSTALL }}\sccache\sccache.exe" ^ -DPython3_ROOT_DIR=${{ steps.python_root_directory.outputs.VALUE }} ^ ${{ steps.build_paths.outputs.SOURCE }} @@ -365,6 +349,20 @@ jobs: echo "COMPILER_VERSION=$version" >> $env:GITHUB_OUTPUT + # NOTE: We will only use an already existing cache, and will not save it later, + # just to prevent trashing of cache. Also the cache is only partially updated, + # since we only build third party libraries with the cache on. + - name: Update the cache (sccache) + uses: actions/cache/restore@v3 + with: + path: ${{ steps.build_paths.outputs.SCCACHE }} + + key: | + sccache_${{ matrix.os }}_64_Release_${{ steps.determine_compiler_version.outputs.COMPILER_VERSION }}_${{ github.sha }} + + restore-keys: | + sccache_${{ matrix.os }}_64_Release_${{ steps.determine_compiler_version.outputs.COMPILER_VERSION }} + - name: Build third party libraries shell: cmd working-directory: ${{ steps.build_paths.outputs.BINARY }} @@ -397,10 +395,15 @@ jobs: working-directory: ${{ steps.build_paths.outputs.BINARY }} shell: cmd + env: + SCCACHE_DIR: ${{ steps.build_paths.outputs.SCCACHE }} + SCCACHE_CACHE_SIZE: "5G" + run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64 @echo on + rmdir "${{ steps.build_paths.outputs.SCCACHE }}" /S /Q type nul > "${{ steps.build_paths.outputs.INSTALL }}\sccache\disable_sccache" cmake --build . -j 3 --target osqueryd diff --git a/cmake/flags.cmake b/cmake/flags.cmake index e0896f72b90..5eff95c65b1 100644 --- a/cmake/flags.cmake +++ b/cmake/flags.cmake @@ -2,8 +2,9 @@ if(DEFINED PLATFORM_POSIX) include(CheckPIESupported) check_pie_supported() + if(NOT CMAKE_C_LINK_PIE_SUPPORTED OR NOT CMAKE_CXX_LINK_PIE_SUPPORTED) - message(FATAL_ERROR "The linker for the current compiler does not support -fPIE or -pie") + message(FATAL_ERROR "The linker for the current compiler does not support -fPIE or -pie") endif() set(CMAKE_POSITION_INDEPENDENT_CODE ON) @@ -35,7 +36,6 @@ function(setupBuildFlags) endif() if(DEFINED PLATFORM_POSIX) - set(posix_common_compile_options -Qunused-arguments -Wno-shadow-field @@ -161,8 +161,8 @@ function(setupBuildFlags) set(osquery_linux_common_defines LINUX=1 OSQUERY_LINUX=1 - OSQUERY_BUILD_DISTRO="centos7" - OSQUERY_BUILD_PLATFORM="linux" + OSQUERY_BUILD_DISTRO=centos7 + OSQUERY_BUILD_PLATFORM=linux ) set(osquery_linux_common_link_options @@ -259,8 +259,8 @@ function(setupBuildFlags) DARWIN=1 BSD=1 OSQUERY_DARWIN=1 - OSQUERY_BUILD_PLATFORM="darwin" - OSQUERY_BUILD_DISTRO="10.14" + OSQUERY_BUILD_PLATFORM=darwin + OSQUERY_BUILD_DISTRO=10.14 ) target_compile_options(cxx_settings INTERFACE @@ -280,12 +280,11 @@ function(setupBuildFlags) if(OSQUERY_NO_DEBUG_SYMBOLS AND ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug" OR - "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")) + "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")) target_compile_options(cxx_settings INTERFACE -g0) target_compile_options(c_settings INTERFACE -g0) endif() elseif(DEFINED PLATFORM_WINDOWS) - set(windows_common_compile_options "$<$,$>:/Gs;/GS>" "$<$:/Od;/UNDEBUG>$<$>:/Ot>" @@ -344,8 +343,8 @@ function(setupBuildFlags) WINDOWS=1 WIN32_LEAN_AND_MEAN OSQUERY_WINDOWS=1 - OSQUERY_BUILD_PLATFORM="windows" - OSQUERY_BUILD_DISTRO="10" + OSQUERY_BUILD_PLATFORM=windows + OSQUERY_BUILD_DISTRO=10 BOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE=1 UNICODE _UNICODE @@ -444,7 +443,6 @@ function(setupBuildFlags) ${osquery_defines} ) - add_library(osquery_c_settings INTERFACE) target_link_libraries(osquery_c_settings INTERFACE c_settings @@ -457,7 +455,6 @@ function(setupBuildFlags) target_compile_definitions(osquery_c_settings INTERFACE ${osquery_defines} ) - endfunction() setupBuildFlags() diff --git a/osquery/tables/utility/osquery.cpp b/osquery/tables/utility/osquery.cpp index e137b13df9b..df6b08115e0 100644 --- a/osquery/tables/utility/osquery.cpp +++ b/osquery/tables/utility/osquery.cpp @@ -211,8 +211,8 @@ QueryData genOsqueryInfo(QueryContext& context) { r["config_valid"] = Config::get().isValid() ? INTEGER(1) : INTEGER(0); r["extensions"] = (pingExtension(FLAGS_extensions_socket).ok()) ? "active" : "inactive"; - r["build_platform"] = OSQUERY_BUILD_PLATFORM; - r["build_distro"] = OSQUERY_BUILD_DISTRO; + r["build_platform"] = STR(OSQUERY_BUILD_PLATFORM); + r["build_distro"] = STR(OSQUERY_BUILD_DISTRO); r["start_time"] = INTEGER(getStartTime()); if (Initializer::isWorker()) { r["watcher"] = INTEGER(PlatformProcess::getLauncherProcess()->pid()); diff --git a/osquery/utils/info/platform_type.h b/osquery/utils/info/platform_type.h index 682901a1008..cafc6aadd62 100644 --- a/osquery/utils/info/platform_type.h +++ b/osquery/utils/info/platform_type.h @@ -35,7 +35,8 @@ enum class PlatformType { }; /// The build-defined set of platform types. -constexpr PlatformType kPlatformType = static_cast(0u +constexpr PlatformType kPlatformType = static_cast( + 0u #ifdef POSIX | static_cast(PlatformType::TYPE_POSIX) #endif @@ -82,7 +83,7 @@ PlatformType operator|(PlatformType a, PlatformType b); #error The build must define OSQUERY_BUILD_DISTRO. #endif -#define OSQUERY_PLATFORM OSQUERY_BUILD_PLATFORM +#define OSQUERY_PLATFORM STR(OSQUERY_BUILD_PLATFORM) /// Identifies the build platform of either the core extension. extern const std::string kSDKPlatform;