allinurl / goaccess

GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
https://goaccess.io
MIT License
17.78k stars 1.09k forks source link

__sync_add_and_fetch() breaks cross-compilation #2635

Open ryzhovau opened 4 months ago

ryzhovau commented 4 months ago

https://github.com/allinurl/goaccess/commit/4b140aaf03c1e82402636bab73814af53170a797#diff-b4dbf33d511bc4aaeb20a4539e694cf4575e9dfe0b9aed1881d58f20e95e6c53R613 and https://github.com/allinurl/goaccess/commit/728fd7d481297db5498b6af938f24cf6c00e3167#diff-3045e316fef9708ebd7095e9a191c711c5dd24e58cdb91c0961961463fabacccR1863 makes goaccess unportable to some ARM/MIPS(el)/PowerPC platforms:

mipsel-openwrt-linux-gnu-gcc -O2 -DSYSCONFDIR=\"/opt/etc\" -Wall -Wextra -Wnested-externs -Wformat=2 -g -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare -Wbad-function-cast -Wcast-align -Wdeclaration-after-statement -Wshadow -Wold-style-definition -O2 -pipe -mno-branch-likely -mips32r2 -mtune=mips32r2 -fno-caller-saves -fhonour-copts -msoft-float -mips16 -minterlink-mips16  -pthread -rdynamic -Wl,--dynamic-linker=/opt/lib/ld.so.1 -Wl,-rpath=/opt/lib -L/home/me/E/staging_dir/toolchain-mipsel_mips32r2_gcc-8.4.0_glibc-2.27/usr/lib -L/home/me/E/staging_dir/toolchain-mipsel_mips32r2_gcc-8.4.0_glibc-2.27/lib -fuse-ld=bfd -latomic  -o goaccess src/base64.o src/browsers.o src/color.o src/commons.o src/csv.o src/error.o src/gdashboard.o src/gdns.o src/gholder.o src/gkhash.o src/gkmhash.o src/gmenu.o src/goaccess.o src/gslist.o src/gstorage.o src/gwsocket.o src/json.o src/opesys.o src/options.o src/output.o src/parser.o src/persistence.o src/pdjson.o src/settings.o src/sort.o src/tpl.o src/ui.o src/util.o src/websocket.o src/xmalloc.o src/sha1.o     -lnsl -lncursesw -lpthread 
/home/me/E/staging_dir/toolchain-mipsel_mips32r2_gcc-8.4.0_glibc-2.27/lib/gcc/mipsel-openwrt-linux-gnu/8.4.0/../../../../mipsel-openwrt-linux-gnu/bin/ld.bfd: src/gstorage.o: in function `count_process':
/home/me/E/build_dir/target-mipsel_mips32r2_glibc-2.27/goaccess-1.9/src/gstorage.c:613: undefined reference to `__sync_add_and_fetch_8'
/home/me/E/staging_dir/toolchain-mipsel_mips32r2_gcc-8.4.0_glibc-2.27/lib/gcc/mipsel-openwrt-linux-gnu/8.4.0/../../../../mipsel-openwrt-linux-gnu/bin/ld.bfd: src/parser.o: in function `atomic_lpts_update':
/home/me/E/build_dir/target-mipsel_mips32r2_glibc-2.27/goaccess-1.9/src/parser.c:1863: undefined reference to `__sync_bool_compare_and_swap_8'
collect2: error: ld returned 1 exit status

It's similar to https://github.com/rakshasa/rtorrent/issues/156

Is there a way to make __sync_add_and_fetch() usage optional?

allinurl commented 4 months ago

Thanks for bringing this up. I'm interested to know about ARM since I've had smooth builds on armhf and arm64. Could you specify which ARM platform you tried this on? Also, any idea if those platforms include the C11 <stdatomic.h> header? Otherwise, we might have to resort to using mutex locks.

0bi-w6n-K3nobi commented 2 months ago

Hi @allinurl

Maybe the new __atomic functions be the solution... See here for more details.