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

client_test build issue with Boost atomic library #4657

Closed
jamesr42 opened this issue May 17, 2020 · 15 comments
Closed

client_test build issue with Boost atomic library #4657

jamesr42 opened this issue May 17, 2020 · 15 comments
Labels

Comments

@jamesr42
Copy link

libtorrent version (or branch): 1.2.6
platform/architecture: Raspberry Pi 3 ARM
compiler and compiler version: gcc 8.3.0
Boost: 1.73, fresh build of b2

Awesome product, btw ... refreshing my coding and design skills using it. Python bindings make it possible to interactively do torrenting stuff as a learning/technical experience. A+!

libtorrent library shared and static build ok, but client_test does not, seems to be a problem with the Boost atomic library. Odd (in Boost) that it compiled, but could not find functions in library.

b2 release runtime-link=shared link=shared -j 2 client_test
../Jamroot.jam:1: syntax error at EOF
CXXFLAGS =
LDFLAGS =
OS = LINUX
building boost from source directory:  /home/pi/boost_1_73_0
Performing configuration checks

    - default address-model    : 32-bit (cached)
    - default architecture     : arm (cached)
...patience...
...patience...
...patience...
...found 3215 targets...
...updating 1 target...
gcc.link bin/gcc-8/release/threading-multi/client_test
/usr/bin/ld: ../bin/gcc-8/release/threading-multi/libtorrent.so.1.2.6: undefined reference to '__atomic_compare_exchange_8'
/usr/bin/ld: ../bin/gcc-8/release/threading-multi/libtorrent.so.1.2.6: undefined reference to '__atomic_load_8'
/usr/bin/ld: ../bin/gcc-8/release/threading-multi/libtorrent.so.1.2.6: undefined reference to '__atomic_store_8'
/usr/bin/ld: ../bin/gcc-8/release/threading-multi/libtorrent.so.1.2.6: undefined reference to '__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status

    "g++"  -Wl,-rpath -Wl,"/home/pi/boost_1_73_0/bin.v2/libs/system/build/gcc-8/release/threading-multi/visibility-hidden" -Wl,-rpath -Wl,"/home/pi/libtorrent-rasterbar-1.2.6/bin/gcc-8/release/threading-multi" -Wl,-rpath-link -Wl,"/home/pi/boost_1_73_0/bin.v2/libs/system/build/gcc-8/release/threading-multi/visibility-hidden" -Wl,-rpath-link -Wl,"/home/pi/libtorrent-rasterbar-1.2.6/bin/gcc-8/release/threading-multi" -o "bin/gcc-8/release/threading-multi/client_test" -Wl,--start-group "bin/gcc-8/release/threading-multi/client_test.o" "bin/gcc-8/release/threading-multi/print.o" "bin/gcc-8/release/threading-multi/torrent_view.o" "bin/gcc-8/release/threading-multi/session_view.o" "../bin/gcc-8/release/threading-multi/libtorrent.so.1.2.6" "/home/pi/boost_1_73_0/bin.v2/libs/system/build/gcc-8/release/threading-multi/visibility-hidden/libboost_system.so.1.73.0"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -pthread

...failed gcc.link bin/gcc-8/release/threading-multi/client_test...
...failed updating 1 target...


b2 release -j 2 client_test
../Jamroot.jam:1: syntax error at EOF
CXXFLAGS =
LDFLAGS =
OS = LINUX
building boost from source directory:  /home/pi/boost_1_73_0
Performing configuration checks

    - default address-model    : 32-bit (cached)
    - default architecture     : arm (cached)
...patience...
...patience...
...patience...
...found 3220 targets...
...updating 1 target...
gcc.link bin/gcc-8/release/link-static/threading-multi/client_test
/usr/bin/ld: ../bin/gcc-8/release/link-static/threading-multi/libtorrent.a(performance_counters.o): in function 'libtorrent::counters::counters()':
performance_counters.cpp:(.text+0x30): undefined reference to '__atomic_store_8'
/usr/bin/ld: ../bin/gcc-8/release/link-static/threading-multi/libtorrent.a(performance_counters.o): in function 'libtorrent::counters::counters(libtorrent::counters const&)':
performance_counters.cpp:(.text+0x70): undefined reference to '__atomic_load_8'
/usr/bin/ld: performance_counters.cpp:(.text+0x88): undefined reference to '__atomic_store_8'
/usr/bin/ld: ../bin/gcc-8/release/link-static/threading-multi/libtorrent.a(performance_counters.o): in function 'libtorrent::counters::operator=(libtorrent::counters const&)':
performance_counters.cpp:(.text+0xd4): undefined reference to '__atomic_load_8'
/usr/bin/ld: performance_counters.cpp:(.text+0xec): undefined reference to '__atomic_store_8'
/usr/bin/ld: ../bin/gcc-8/release/link-static/threading-multi/libtorrent.a(performance_counters.o): in function 'libtorrent::counters::operator[](int) const':
performance_counters.cpp:(.text+0x110): undefined reference to '__atomic_load_8'
/usr/bin/ld: ../bin/gcc-8/release/link-static/threading-multi/libtorrent.a(performance_counters.o): in function 'libtorrent::counters::inc_stats_counter(int, long long)':
performance_counters.cpp:(.text+0x130): undefined reference to '__atomic_fetch_add_8'
/usr/bin/ld: ../bin/gcc-8/release/link-static/threading-multi/libtorrent.a(performance_counters.o): in function 'libtorrent::counters::blend_stats_counter(int, long long, int)':
performance_counters.cpp:(.text+0x164): undefined reference to '__atomic_load_8'
/usr/bin/ld: performance_counters.cpp:(.text+0x1d0): undefined reference to '__atomic_compare_exchange_8'
/usr/bin/ld: ../bin/gcc-8/release/link-static/threading-multi/libtorrent.a(performance_counters.o): in function 'libtorrent::counters::set_value(int, long long)':
performance_counters.cpp:(.text+0x230): undefined reference to '__atomic_store_8'
collect2: error: ld returned 1 exit status

    "g++"    -o "bin/gcc-8/release/link-static/threading-multi/client_test" -Wl,--start-group "bin/gcc-8/release/link-static/threading-multi/client_test.o" "bin/gcc-8/release/link-static/threading-multi/print.o" "bin/gcc-8/release/link-static/threading-multi/torrent_view.o" "bin/gcc-8/release/link-static/threading-multi/session_view.o" "../bin/gcc-8/release/link-static/threading-multi/libtorrent.a" "/home/pi/boost_1_73_0/bin.v2/libs/system/build/gcc-8/release/link-static/threading-multi/visibility-hidden/libboost_system.a"  -Wl,-Bstatic  -Wl,-Bdynamic -lrt -Wl,--end-group -pthread

...failed gcc.link bin/gcc-8/release/link-static/threading-multi/client_test...
...failed updating 1 target...
@arvidn
Copy link
Owner

arvidn commented May 17, 2020

I don't think those are boost.atomic symbols. Those look like runtime or libgcc symbols

@arvidn
Copy link
Owner

arvidn commented May 17, 2020

they seem to be part of libccc: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

@jamesr42
Copy link
Author

Apologies I am duh I did not even google that. May also be libatomic, although I Raspbian has that. Continuing to investigate.

@jamesr42
Copy link
Author

Yup it's libatomic; if I do this:

export LD_PRELOAD=/usr/lib/arm-linux-gnueabihf/libatomic.so.1

Then python3 imports libtorrent ok.

Would Boost be responsible for linking in libatomic? My theory is performance_counters -> atomic -> libatomic

@arvidn
Copy link
Owner

arvidn commented May 17, 2020

no, I just use the standard library. i.e. std::atomic

@arvidn
Copy link
Owner

arvidn commented May 17, 2020

"no" to it being a transitive dependency via boost. "yes" on the performance counters use atomic operations

@jamesr42
Copy link
Author

OK gotcha. Now to figure out why libatomic is not being linked in.

@johang
Copy link
Contributor

johang commented May 24, 2020

They're hitting this problem for certain archs in Debian too:

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=958958

@stale
Copy link

stale bot commented Aug 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 22, 2020
@micdonato
Copy link

Wait, I am not sure how to solve this yet. I followed the tutorial on the deluge webpage, everything goes well until I try to import libtorrent from python and I get this error:

elusero:elcomputero~ $ python -c "import libtorrent; print (libtorrent.version)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: /usr/local/lib/libtorrent-rasterbar.so.10: undefined symbol: __atomic_fetch_add_8

@arvidn
Copy link
Owner

arvidn commented Aug 27, 2020

this might give some hints: https://stackoverflow.com/questions/42887975/how-to-link-against-the-libatomic-library-in-gcc

if you run ldd on the libtorrent module, do you see a dependency on libatomic?

@stale stale bot removed the stale label Aug 27, 2020
@micdonato
Copy link

this might give some hints: https://stackoverflow.com/questions/42887975/how-to-link-against-the-libatomic-library-in-gcc

if you run ldd on the libtorrent module, do you see a dependency on libatomic?

Hmmm no, I do not see the dependency:

elusero:elcomputero:~ $ ldd /usr/local/lib/libtorrent-rasterbar.so.10
	linux-vdso.so.1 (0x7ec41000)
	/usr/lib/arm-linux-gnueabihf/libarmmem-${PLATFORM}.so => /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so (0x76c10000)
	libssl.so.1.1 => /usr/lib/arm-linux-gnueabihf/libssl.so.1.1 (0x76b91000)
	libcrypto.so.1.1 => /usr/lib/arm-linux-gnueabihf/libcrypto.so.1.1 (0x76978000)
	libboost_system.so.1.67.0 => /usr/lib/arm-linux-gnueabihf/libboost_system.so.1.67.0 (0x76964000)
	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x7693a000)
	libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x767f3000)
	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76771000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76623000)
	/lib/ld-linux-armhf.so.3 (0x76f7c000)
	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x765f6000)
	libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x765e3000)
	librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x765ca000)
elusero:elcomputero:~ $ ldd /usr/local/lib/libtorrent-rasterbar.so.10 | grep ato
elusero:elcomputero:~ $ 

About the stackoverflow post, they suggest to look at the file /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libatomic.so. I did not have one there, and I thought it would be because of the different version of gcc (I have 8.3) so I checked /usr/lib/gcc/x86_64-redhat-linux/8/libatomic.so but it is not the "single line of text" described in the stackoverflow post, but it seems to be a binary file.

Maybe I should open a different issue?

@stale
Copy link

stale bot commented Nov 26, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 26, 2020
@stale stale bot closed this as completed Dec 16, 2020
@FranciscoPombal
Copy link
Contributor

I think this is basically a duplicate of #5117 (or, rather, that new one is a duplicate of this one). I have worked on a suitable patch and will submit it soon.

@FranciscoPombal
Copy link
Contributor

#5748

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

No branches or pull requests

5 participants