From 9b89479e649299b316165754bc7a98f322e4da54 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Wed, 25 Apr 2018 12:08:24 -0700 Subject: [PATCH] Pass -latomic to linker when using clang Summary: clang compilation is failing due to a4fb1f8c049ee9d61a9da8cf23b64d2c7d36a33f. In that commit I added a call to `std::atomic::is_lock_free` which was evidently relying on a compiler builtin only present in gcc. Drawbacks to this fix are: - users may need to install libatomic - there might be cases where clang is used even though USE_CLANG is unset (e.g., when clang is the only available compiler). I didn't figure out how to add -latomic in those cases... An alternative fix mentioned in http://lists.llvm.org/pipermail/llvm-bugs/2017-August/057263.html is using -stdlib=libc++ with clang. Closes https://github.com/facebook/rocksdb/pull/3769 Differential Revision: D7756261 Pulled By: ajkr fbshipit-source-id: 26888300683fa9970ab5950239d1aa217e8efd49 --- build_tools/build_detect_platform | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 480e7a962..c9c3aa6e2 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -144,6 +144,8 @@ case "$TARGET_OS" in COMMON_FLAGS="$COMMON_FLAGS -DOS_LINUX" if [ -z "$USE_CLANG" ]; then COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp" + else + PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic" fi PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt" # PORT_FILES=port/linux/linux_specific.cc @@ -196,6 +198,8 @@ case "$TARGET_OS" in COMMON_FLAGS="$COMMON_FLAGS -DCYGWIN" if [ -z "$USE_CLANG" ]; then COMMON_FLAGS="$COMMON_FLAGS -fno-builtin-memcmp" + else + PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -latomic" fi PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS -lpthread -lrt" # PORT_FILES=port/linux/linux_specific.cc