Skip to content

Commit

Permalink
build: Cleanups and fixes for a newer clang toolchain (osquery#8412)
Browse files Browse the repository at this point in the history
- Force the use of the DWARF debug symbols version 4,
  since only very recent versions of gdb support any version higher than
  that and on newer clang versions, 5 is the default.

- Correct the secure_getenv check; GLIBC 2.17 is the first version
  that adds supports for it, so it should be included

- Move the selection of the standard library implementation and
  corollary library on Linux to be a toolchain specific setting,
  making it slightly easier to build with a different toolchain.
  • Loading branch information
Smjert authored Sep 9, 2024
1 parent 5dc8429 commit c8ae65d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 0 additions & 3 deletions cmake/flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ function(setupBuildFlags)
-Woverloaded-virtual
-Wnon-virtual-dtor
-Weffc++
-stdlib=libc++
)

set(posix_cxx_link_options
-stdlib=libc++
-ldl
)

Expand Down Expand Up @@ -179,7 +177,6 @@ function(setupBuildFlags)
)

set(linux_cxx_link_libraries
c++abi.a
rt
dl
)
Expand Down
3 changes: 3 additions & 0 deletions cmake/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if(OSQUERY_TOOLCHAIN_SYSROOT)
overwrite_cache_variable("CMAKE_CXX_LINK_PIE_SUPPORTED" "INTERNAL" "TRUE")
overwrite_cache_variable("CMAKE_C_LINK_NO_PIE_SUPPORTED" "INTERNAL" "TRUE")
overwrite_cache_variable("CMAKE_C_LINK_PIE_SUPPORTED" "INTERNAL" "TRUE")
overwrite_cache_variable("CMAKE_CXX_FLAGS_INIT" "STRING" "-stdlib=libc++ -gdwarf-4")
overwrite_cache_variable("CMAKE_C_FLAGS_INIT" "STRING" "-gdwarf-4")
overwrite_cache_variable("CMAKE_EXE_LINKER_FLAGS" "STRING" "-stdlib=libc++ -lc++abi")
else()
option(OSQUERY_STATIC_BUILD "Whether to prefer linking static libraries or not")

Expand Down
2 changes: 1 addition & 1 deletion osquery/tables/system/linux/rpm_packages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <osquery/worker/logging/glog/glog_logger.h>

// librpm may be configured and compiled with glibc < 2.17.
#if defined(__GLIBC__) && __GLIBC_MINOR__ > 17
#if defined(__GLIBC__) && __GLIBC_MINOR__ >= 17
extern "C" char* __secure_getenv(const char* _s) __attribute__((weak));
extern "C" char* __secure_getenv(const char* _s) {
return secure_getenv(_s);
Expand Down

0 comments on commit c8ae65d

Please sign in to comment.