(1)export PATH=/usr/local/gcc-11/bin:$PATH export LD_LIBRARY_PATH=/usr/local/gcc-11/lib:/usr/local/gcc-11/lib64:$LD_LIBRARY_PATH export CXX=g++ export CC=gcc RHEL 8.4 (2)wget http://download.redis.io/redis-stable.tar.gz (3)make OPT=-O3 CFLAGS="-march=znver2" CPPFLAGS="-march=znver2">& log9.txt Build failed:
jemalloc version : 5.1.0-0-g0 library revision : 2
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -march=znver2" LDFLAGS="" lib/libjemalloc.a make[3]: Entering directory '/home/postgres/anil/redis/test-gcc-flags/redis-stable/deps/jemalloc' gcc -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -march=znver2 -c -march=znver2 -o src/jemalloc.sym.o src/jemalloc.c src/jemalloc.c:2:10: fatal error: jemalloc/internal/jemalloc_preamble.h: No such file or directory 2 | #include "jemalloc/internal/jemalloc_preamble.h" | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(2)make CFLAGS="-flto" CPPFLAGS="-flto"
gcc -o lua lua.o liblua.a -lm
/tmp/ccFoBdaF.ltrans0.ltrans.o: In function lstop':
<artificial>:(.text+0xb): undefined reference tolua_sethook'
/tmp/ccFoBdaF.ltrans0.ltrans.o: In function traceback':
<artificial>:(.text+0x5a): undefined reference tolua_isstring'
lua_getfield'
<artificial>:(.text+0x8b): undefined reference tolua_type'
Comment From: yossigo
@anilbommareddy You're overriding CPPFLAGS in a way that causes dependency building to fail. Try to only override CFLAGS (which makes more sense since -march= is really a compiler flag).
Comment From: anilbommareddy
@yossigo yes overriding only CPPFLAGS causing issues and with remaining flags like CONFIGURE_CXXFLAGS not seen dependency(jemalloc) building fail. (2) make CFLAGS="-flto " observed dependency build fails.
Comment From: yossigo
@anilbommareddy Just to be clear, I was proposing to leave CPPFLAGS and override only CFLAGS, i.e.
make OPT=-O3 CFLAGS="-march=znver2". I can confirm that this does work on my test system (Ubuntu 22.04 amd64).
Comment From: anilbommareddy
@yossigo for me also it worked in Ubuntu environment. Is redis supoort(build source code )clang(LLVM-clang) and Intel compiler(ICC) if yes then below hard codes changes need to be modified. redis-stable/tests/modules/Makefile:15: LD = gcc /support for clang/ICC redis-stable/tests/modules/Makefile:16: CC = gcc
Comment From: anilbommareddy
@yossigo ; To build source code has compiler flags like CFLAGS and LDFLAGS then what is use of REDIS_CFLAGS and REDIS_LDFLAGS ,? As I see but understand on this. REDIS_CFLAGS used in hiredis-example(deps/hiredis/Makefile-QT) REDIS_LDFLAGS used helgrind
Comment From: yossigo
These flags only affect Redis itself and not the dependencies, as stated in src/Makefile.
Comment From: anilbommareddy
@yossigo Redis build failed for llvm-clang with -flto option in Ubuntu 20.04.3 LTS" 1.wget https://download.redis.io/redis-stable.tar.gz
2. tar -xvzf redis-stable.tar.zx and cd redis-stable
3.export CC=clang ,export CXX=clang++ and PATH and LD_LIBRARY_PATH of llvm
4.make OPTIMIZATION=-O3 CFLAGS="-march=znver2 -flto build failed:ld.lld: error: undefined symbol: je_malloc
referenced by zmalloc.c:108 lto.tmp:(listCreate) referenced by zmalloc.c:108 lto.tmp:(listAddNodeHead) referenced by zmalloc.c:108 lto.tmp:(listAddNodeTail) referenced 1286 more times
ld.lld: error: undefined symbol: je_malloc_usable_size
referenced by zmalloc.c:112 lto.tmp:(listCreate) referenced by zmalloc.c:312 lto.tmp:(listEmpty) referenced by zmalloc.c:312 lto.tmp:(listRelease) referenced 3197 more times Note : the same working fine for GCC
Comment From: yossigo
@anilbommareddy Looks like jemalloc was not built, try make distclean and rebuild. If it fails, look for errors during jemalloc compilation.
Comment From: anilbommareddy
@yossigo : checked with fresh build but still seen jemalloc compilation issues make V=1 OPTIMIZATION=-O3 CFLAGS="-flto -I/home/llvm-clang/include" LDFLAGS="-L/home/llvm-clang/lib" Compilation issues:c/lib/libjemalloc.a -lm -ldl -pthread -lrt ld.lld: error: undefined symbol: je_get_defrag_hint
referenced by defrag.c:60 lto.tmp:(activeDefragAlloc) referenced by defrag.c:60 lto.tmp:(activeDefragSds) referenced by defrag.c:60 lto.tmp:(activeDefragStringOb) referenced 57 more times clang-13: error: linker command failed with exit code 1 (use -v to see invocation) make[1]: *** [redis-server] Error 1 Makefile:373: recipe for target 'redis-server' failed
And I tried with as
(1) git clone https://github.com/jemalloc/jemalloc.git
(2) cd jemalloc (3)./autogen.sh CC=clang CFLAGS=-flto CXX=clang++ CXXFLAGS=-flto CPPFLAGS=-I/home/llvm-clang/include LDFLAGS=-L/home/llvm-clang/lib (4)make (5) Build successfully
Comment From: yossigo
@anilbommareddy The messages above indicate that jemalloc was indeed not compiled, but you did not include the messages that could indicate why it failed.
Comment From: anilbommareddy
@yossigo I think jemalloc compiled in Redis-llvm-clang environment Exa cd jemalloc && ./configure --with-version=5.2.1-0-g0 --with-lg-quantum=3 --with-jemalloc-prefix=je_ CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -flto -I/home/llvm-clang/include" LDFLAGS="-L/home/llvm-clang/lib" config.status: executing include/jemalloc/jemalloc.h commands
jemalloc version : 5.2.1-0-g0 library revision : 2
cd jemalloc && make CFLAGS="-std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -flto -I/home/llvm-clang/include" LDFLAGS="-L/home/llvm-clang/lib" lib/libjemalloc.a make[3]: Entering directory '/home/amd/hemanth/anil/redis/test-flto-redis/redis-stable/deps/jemalloc' clang -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -flto -I/home/llvm-clang/include -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/jemalloc.sym.o src/jemalloc.c nm -a src/jemalloc.sym.o | gawk -f include/jemalloc/internal/private_symbols.awk > src/jemalloc.sym clang -std=gnu99 -Wall -pipe -g3 -O3 -funroll-loops -flto -I/home/llvm-clang/include -c -D_GNU_SOURCE -D_REENTRANT -Iinclude -Iinclude -DJEMALLOC_NO_PRIVATE_NAMESPACE -o src/arena.sym.o src/arena
I checked llvm-clang, Redis-build without -flto option and the build success. the build was failed only using "-flto" option.
Comment From: wjx951753
You can first compile jemalloc. if you use "-flto", you should use "llvm-nm -a" to get symbols, not “nm -a”. so you can modify deps/jemalloc/Makefile.