Clang requires libatomic to be linked via LDFLAGS

Clang requires the libatomic to be linked via LDFLAGS or else the linker
will fail to recognise __atomic macros.

An error as a result of not passing -latomic to the linker can be seen
below:

ld.lld: error: undefined symbol: __atomic_fetch_add_2
>>> referenced by sds.c:185
>>>               lto.tmp:(sdsdupshared)
clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [Makefile:276: keydb-server] Error 1
Former-commit-id: dcd7b684bbb7b4719a0e44d5764b01c48eb619dd
This commit is contained in:
Diab Neiroukh 2020-04-30 18:43:23 +01:00 committed by John Sully
parent cf13892cfa
commit 7ae66c0866

View File

@ -70,6 +70,7 @@ endif
ifeq ($(COMPILER_NAME),clang) ifeq ($(COMPILER_NAME),clang)
CXXFLAGS+= -stdlib=libc++ CXXFLAGS+= -stdlib=libc++
LDFLAGS+= -latomic
endif endif
# To get ARM stack traces if Redis crashes we need a special C flag. # To get ARM stack traces if Redis crashes we need a special C flag.