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

Fix #23903, compile on pi4, debian bookworm due to missing '_atomic_*' functions. #23904

Merged
merged 7 commits into from
Jan 21, 2025

Conversation

bsekisser
Copy link
Contributor

./configure && make fails reporting missing 'atomic*' functions
during link of r2pm.

compiled on pi4, uname -a:
Linux raspberrypi 6.6.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25) aarch64 GNU/Linux

with gcc: version 12.2.0 (Raspbian 12.2.0-14+rpi1)

modified:   mk/gcc.mk
  • Mark this if you consider it ready to merge
  • I've added tests (optional)
  • I wrote some lines in the book (optional)

Description

mk/gcc.mk Outdated
@@ -8,6 +8,7 @@ AR?=ar
CC_AR=${AR} q ${LIBAR}
CFLAGS+=-MD
CFLAGS_INCLUDE=-I
LDFLAGS+=-latomic
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check should detect if its needed at compile time, because this library is not necessary or available in other targets. another option is to check if the output from uname is arm32 (is your pi4 running in arm64 mode?)

CHECK_ATOMIC = $(shell echo "int main() { __atomic_fetch_add(0, 0, 0); return 0; }" | \
	$(CC) -x c -o /dev/null - $(CFLAGS) $(LDFLAGS) >/dev/null 2>&1 || echo "-latomic")
DFLAGS += $(CHECK_ATOMIC)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bit fuggered up on the commits (doing a github sync put me down a rabbit hole), but here is where it stands...

amended commit... your suggested revision mostly worked.... two minor changes were needed. as it were, test would always fail and make stops with circular loop. also, __atomic_fetch_add by itself is fine except when referencing large values, _atomic_fetch*_8 nails the problem.

stock bookworm install... aarch64 kernel, 32bit user-land.

uname -m reports aarch64... but binaries are 32bit.

so, uname is missleading but, file $(command -v file) shows 32 bit. that was the one suggested test I found when digging in response to your question.

@bsekisser bsekisser force-pushed the fix_atomic branch 2 times, most recently from e140ee5 to c93ad10 Compare January 16, 2025 21:13
@trufae
Copy link
Collaborator

trufae commented Jan 18, 2025

Another option would be to check for libatomic in configure and meson like u did for r2dec

@bsekisser
Copy link
Contributor Author

yes, that was my thought... while it works for me, seems like there ought to be a better place to do it during configuration... started looking... seen the meson build files, believe i tried putting in qjs like i did with quickjs but didnt work/help. will keep digging, hope to get back to you with something in a few days.

./configure && make fails reporting missing '_atomic_*' functions
	during link of r2pm.

compiled on pi4, uname -a:
Linux raspberrypi 6.6.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25) aarch64 GNU/Linux

with gcc: version 12.2.0 (Raspbian 12.2.0-14+rpi1)

	modified:   mk/gcc.mk
	modified:   mk/gcc.mk
	modified:   binr/r2pm/meson.build
This reverts commit 6745d17cdf681ecec38ea08c3d7ea92d84306e8b.
This reverts commit 8ed619b42d040ad2a23888fa0eb5c4749df2883c.
This reverts commit e4605f77e1ee4c2d48dae167230ab712e5318d4b.
./configure && make fails reporting missing '_atomic_*' functions
	during link of r2pm.

compiled on pi4, uname -a:
	Linux raspberrypi 6.6.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.6.62-1+rpt1 (2024-11-25) aarch64 GNU/Linux

with gcc: version 12.2.0 (Raspbian 12.2.0-14+rpi1)

	modified:   config-user.mk.acr
	modified:   configure
	modified:   configure.acr
	modified:   libr/lang/Makefile
@trufae
Copy link
Collaborator

trufae commented Jan 21, 2025

lgtm now!

@trufae
Copy link
Collaborator

trufae commented Jan 21, 2025

ok to remove the draft bit?

@trufae trufae marked this pull request as ready for review January 21, 2025 18:08
@trufae trufae merged commit 60befec into radareorg:master Jan 21, 2025
45 checks passed
@bsekisser
Copy link
Contributor Author

Ready enough... Weren't going to take it out of draft until the tests passed and got confirmation that the forced pushes were not going to create a problem (or got further instructions to fix it).

Pleasantly surprised, thanks.

@bsekisser bsekisser deleted the fix_atomic branch January 21, 2025 19:15
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

Successfully merging this pull request may close these issues.

2 participants