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 libatomic linking on Raspberry Pi OS Bullseye #28041

Merged
merged 1 commit into from
Dec 15, 2021
Merged

Fix libatomic linking on Raspberry Pi OS Bullseye #28041

merged 1 commit into from
Dec 15, 2021

Conversation

Alberto97
Copy link
Contributor

The test c++ code inside check_linker_need_libatomic silently breaks on Raspberry Pi OS Bullseye which leads libatomic not to be linked in the final binary.
I'm not a c/c++ expert by any means but from a quick googling it looks like -latomic needs to be the last parameter of the build command in order to be picked up properly.
Here's the output of the test code on my machine:

pi@raspberrypi:~ $ echo -e '#include <atomic>\nint main() { return std::atomic<int64_t>{}; }' | c++ -x c++ -std=c++11 -latomic -
/usr/bin/ld: /tmp/ccDrXAd4.o: in function `std::__atomic_base<long long>::operator long long() const':
:(.text._ZNKSt13__atomic_baseIxEcvxEv[_ZNKSt13__atomic_baseIxEcvxEv]+0x40): undefined reference to `__atomic_load_8'
collect2: error: ld returned 1 exit status
pi@raspberrypi:~ $ echo -e '#include <atomic>\nint main() { return std::atomic<int64_t>{}; }' | c++ -x c++ -std=c++11 - -latomic
pi@raspberrypi:~ $ 

And this is the ldd output of source built cygrpc.cpython-39-arm-linux-gnueabihf.so before

cygrpc.cpython-39-arm-linux-gnueabihf.so:
	linux-vdso.so.1 (0xbedac000)
	/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb68c7000)
	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb6888000)
	libstdc++.so.6 => /lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6700000)
	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb6691000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb653d000)
	/lib/ld-linux-armhf.so.3 (0xb6edf000)
	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6510000)

and after this patch

cygrpc.cpython-39-arm-linux-gnueabihf.so:
	linux-vdso.so.1 (0xbefb5000)
	/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0xb68f1000)
	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0xb68b2000)
	libatomic.so.1 => /lib/arm-linux-gnueabihf/libatomic.so.1 (0xb6899000)
	libstdc++.so.6 => /lib/arm-linux-gnueabihf/libstdc++.so.6 (0xb6711000)
	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0xb66a2000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb654e000)
	/lib/ld-linux-armhf.so.3 (0xb6f09000)
	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0xb6521000)

This fixes #25720

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Nov 15, 2021

CLA Signed

The committers are authorized under a signed CLA.

@lidizheng lidizheng added area/build lang/Python release notes: yes Indicates if PR needs to be in release notes labels Nov 15, 2021
@lidizheng lidizheng self-requested a review November 15, 2021 18:25
@lidizheng lidizheng self-assigned this Nov 15, 2021
@jtattermusch jtattermusch self-requested a review November 16, 2021 13:45
@Alberto97 Alberto97 changed the title Fix libatomic linking on Rasperry Pi OS Bullseye Fix libatomic linking on Raspberry Pi OS Bullseye Nov 16, 2021
@veblush veblush self-requested a review December 15, 2021 19:02
Copy link
Contributor

@veblush veblush left a comment

Choose a reason for hiding this comment

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

Yeah, this looks right and linker options should be after the source option (-).

@veblush
Copy link
Contributor

veblush commented Dec 15, 2021

Since all test failures are irrelevant to this PR, I'm going to get this merged.

@veblush veblush closed this Dec 15, 2021
@veblush veblush reopened this Dec 15, 2021
@veblush veblush merged commit c1fe2bc into grpc:master Dec 15, 2021
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build bloat/none imported Specifies if the PR has been imported to the internal repository lang/Python perf-change/none release notes: yes Indicates if PR needs to be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

undefined symbol: __atomic_exchange_8 on Raspberry Pi
4 participants