Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Raspberry Pi] 5.0.4 Build fail : undefined reference to __atomic_fetch_add_8' #6275

Closed
AngusP opened this issue Jul 26, 2019 · 20 comments
Closed
Milestone

Comments

@AngusP
Copy link
Contributor

AngusP commented Jul 26, 2019

On a Raspberry Pi 3 v1.2, and also on I think a Zero W v1.1, but probably all RPis running Raspbian 10 'Buster', the build fails to link atomic -- undefined reference to __atomic_fetch_add_8'

uname: Linux raspberrypi 4.19.57-v7+ #1244 SMP Thu Jul 4 18:45:25 BST 2019 armv7l GNU/Linux`
gcc --version: gcc (Raspbian 8.3.0-6+rpi1) 8.3.0

This is easily fixed by 'hacking' a -latomic in to the build flags, though I'm not too familiar with the Makefile and where best to add such a link without breaking stuff, so haven't PR'd

Redis 5.0.4
    ...
    CC t_stream.o
    CC localtime.o
    CC lolwut.o
    CC lolwut5.o
    LINK redis-server
/usr/bin/ld: networking.o: in function `createClient':
/home/pi/Downloads/redis-5.0.4/src/networking.c:108: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:219: redis-server] Error 1
make[1]: Leaving directory '/home/pi/Downloads/redis-5.0.4/src'
make: *** [Makefile:9: install] Error 2

This seems similar to #5550

@LucidSkyWalker
Copy link

Adding "-latomic" as library is correct.
I just modified the Makefile (under the "src" directory) and it works.
Change:
FINAL_LIBS=-lm
To:
FINAL_LIBS=-lm -latomic

I hope it helps

@qpernil
Copy link

qpernil commented Nov 7, 2019

Any progress on this one ? It still doesn't build...

@AngusP
Copy link
Contributor Author

AngusP commented Nov 7, 2019

@qpernil unfortunately I've not had time to see how best to propose a fix that won't also potentially break other Redis builds...

However, if you edit src/Makefile and add -latomic to line 77, so that it looks like this:

 72   |  # Override default settings if possible
 73   |  -include .make-settings
 74   |  
 75   |  FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
 76   |  FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
*77*  |  FINAL_LIBS=-lm -latomic
 78   |  DEBUG=-g -ggdb
 79   |  
 80   |  ifeq ($(uname_S),SunOS)

and then run make again, it should work for you.

@qpernil
Copy link

qpernil commented Nov 7, 2019

OK, Thanks @AngusP

@mibere
Copy link

mibere commented Nov 26, 2019

Had the same issue. But I can confirm that the compilation of Redis 5.0.7 on Raspbian 10 (Buster) is successful after changing

FINAL_LIBS=-lm

to

FINAL_LIBS=-lm -latomic

in src/Makefile

@qpernil
Copy link

qpernil commented Nov 27, 2019

Yes, I can also confirm it works.

@antirez
Copy link
Contributor

antirez commented Nov 27, 2019

Please @qpernil could you try if instead of using -latomic directly there, it works with the following patch?

diff --git a/src/Makefile b/src/Makefile
index 9fc230f9..e6773198 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -77,6 +77,15 @@ FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
 FINAL_LIBS=-lm
 DEBUG=-g -ggdb
 
+# Linux ARM needs -latomic at linking time
+ifneq (,$(filter aarch64 armv,$(uname_M)))
+        FINAL_LIBS+=-latomic
+else
+ifneq (,$(findstring armv,$(uname_M)))
+        FINAL_LIBS+=-latomic
+endif
+endif
+
 ifeq ($(uname_S),SunOS)
        # SunOS
         ifneq ($(@@),32bit)

Thank you

@antirez antirez added this to the Redis 6 milestone Nov 27, 2019
@antirez
Copy link
Contributor

antirez commented Nov 28, 2019

ping @LucidSkyWalker to see if it's possible to get the patch tested. The problem is that I don't want it to break other builds. Right now my Pi3 looks dead unfortunately, I'll have to resurrect it.

@AngusP
Copy link
Contributor Author

AngusP commented Nov 28, 2019

@antirez I’ve also got a handful of Pis, just not found time to test it yet, will try and do so soon if I don’t get beaten to it

@antirez
Copy link
Contributor

antirez commented Nov 28, 2019

Thanks a lot @AngusP :-) I'll try to resurrect mine at the same time to have a larger test base, especially since I believe I've a version of the distribution that does not need -latomic, to check if it may create problems in that case.

@itamarhaber
Copy link
Member

+@rafie may be able to help too.

@AngusP
Copy link
Contributor Author

AngusP commented Nov 28, 2019

So, build succeeds and tests pass on all the Pis I have access to 🍾 (well, except some tests time out sometimes)

All running Raspbian 10, building the 5.0.7 release with the above Makefile patch given by @antirez.

on a Pi 4 Model B (BCM2835 rev. c03111quad core, 4GB RAM)
uname -a = Linux raspberrypi 4.19.50-v7l+ #895 SMP Thu Jun 20 16:03:42 BST 2019 armv7l GNU/Linux

on a Pi ZeroW v1.1 (BCM2835 rev. 9000c1 single core) (this took a while!)
uname -a = Linux raspberrypi 4.19.57+ #1244 Thu Jul 4 18:42:50 BST 2019 armv6l GNU/Linux

on a Pi 3 Model B v1.2 (BCM2835 rev. a22082 quad core)
uname -a = Linux raspberrypi 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux

@antirez
Copy link
Contributor

antirez commented Nov 29, 2019

Thanks @AngusP! Fix pushed.

@qpernil
Copy link

qpernil commented Dec 2, 2019

Sorry for not finding time to help with this... Next time..

@antirez
Copy link
Contributor

antirez commented Dec 2, 2019

Sorry for not finding time to help with this... Next time..

Thanks anyway!

@qpernil
Copy link

qpernil commented Dec 5, 2019 via email

JackieXie168 pushed a commit to JackieXie168/redis that referenced this issue Dec 24, 2019
@jibp
Copy link

jibp commented Jan 9, 2020

不幸的是,@ qpernil我还没来得及看看如何最好地提出一个修补程序,该修补程序也不会破坏其他Redis版本...

但是,如果您编辑src/Makefile并添加-latomic到第77行,则它看起来像这样:

 72   |  # Override default settings if possible
 73   |  -include .make-settings
 74   |  
 75   |  FINAL_CFLAGS=$(STD) $(WARN) $(OPT) $(DEBUG) $(CFLAGS) $(REDIS_CFLAGS)
 76   |  FINAL_LDFLAGS=$(LDFLAGS) $(REDIS_LDFLAGS) $(DEBUG)
*77*  |  FINAL_LIBS=-lm -latomic
 78   |  DEBUG=-g -ggdb
 79   |  
 80   |  ifeq ($(uname_S),SunOS)

然后make再次运行,它将为您工作。

只要修改src/Makefile 中的 FINAL_LIBS=-lm -latomic 就能运行了 亲测有用

@qpernil
Copy link

qpernil commented Feb 23, 2020

Is this merged into any other branch than unstable ?
/Per

@dustinmm80
Copy link

Is this merged into any other branch than unstable ?
/Per

It doesn't look like it this has been merged into 5.0 branch.

GitLab is mirroring this repository, the gitlab-omnibus installer uses this mirror as a dependency. We are seeing this sameundefined reference to __atomic_fetch_add_8 issue building redis 5 on Raspbian 10 Buster on ARM.

@AngusP do you intend to backport this fix to 5.0 branch? If that is your intention, but you're short on time I am happy to create the PR. Maybe we should reopen this issue.

@AngusP
Copy link
Contributor Author

AngusP commented Mar 10, 2020

@dustinmm80 as far as I can see it'd be fine to backport to any maintained version as it's just a Makefile fix (e9564dc); go ahead if you'd like it, I am a little short on time unfortunately

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants