@cryptotaxi247 / netdata-1 / commits / 2c9ade87e

Add check for 64bit builtin atomics (#18565)

Compilers for some architectures e.g. RISCV32 do not have 64bit atomics therefore, its important to deduce that and use it to pass right flags to compiler to use them, e.g. h2o module Fixes nection.c.o): in function `h2o_create_connection': | /usr/src/debug/netdata/1.47.1/src/web/server/h2o/libh2o/include/h2o.h:1917:(.text.create_conn+0x5e): undefined reference to `__sync_add_and_fetch_8' | collect2: error: ld returned 1 exit status

Khem Raj committed Oct 8, 2024 at 05:07 UTC 2c9ade87e88eba46e0eb81fa2f3a50734610ea71
1 file changed +11
CMakeLists.txt
+11
@@ -453,6 +453,15 @@ int main() {
453 }
454 " HAVE_BUILTIN_ATOMICS)
455
456 +check_cxx_source_compiles("
457 +#include <stdint.h>
458 +int main(void) {
459 + uint64_t a;
460 + __sync_add_and_fetch(&a, 1);
461 + return 0;
462 +}
463 +" ARCH_SUPPORTS_64BIT_ATOMICS)
464 +
465 check_c_source_compiles("
466 void my_printf(char const *s, ...) __attribute__((format(gnu_printf, 1, 2)));
467 int main() { return 0; }
@@ -1679,6 +1688,8 @@ if(ENABLE_H2O)
1688
1689 target_compile_options(h2o PUBLIC -DH2O_USE_LIBUV=0)
1690 target_link_libraries(h2o PRIVATE PkgConfig::TLS)
1691 + target_compile_definitions(h2o PRIVATE
1692 + "$<$<NOT:$<BOOL:${ARCH_SUPPORTS_64BIT_ATOMICS}>>:H2O_NO_64BIT_ATOMICS>")
1693 endif()
1694
1695 #