Hello! Thank you so much for your feedback!
Yep, that's actually what we're trying to do. My code looks like: __atomic_add_fetch(&total_simple_packets_processed, 1, __ATOMIC_RELAXED); Full link to code: https://github.com/pavel-odintsov/fastnetmon/blob/master/src/fastnetmon_logic.cpp#L2675 And we try to explicitly link with -latomic and cmake does right thing by adding -atomic: /usr/bin/c++ -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security ..... -o fastnetmon -latomic But liker fails to link it to atomic due to missing function call: /usr/bin/ld: libfastnetmon_logic.a(fastnetmon_logic.cpp.o): undefined reference to symbol '__atomic_fetch_add_8@@LIBATOMIC_1.0' We do not call __atomic_fetch_add_8 directly, it's just how lineker sees it. On Thu, 5 May 2022 at 15:44, Jeffrey Walton <noloa...@gmail.com> wrote: > > -- Looking for __sync_fetch_and_add_8 in atomic > > -- Looking for __sync_fetch_and_add_8 in atomic - not found > > I hit this a long time ago in a non-CMake project. If memory serves me > correctly... > > According to Jakub Jelinek, you should use the GCC builtin and link to > libatomic. GCC will emulate the missing primitive through the builtin. > Instead of using __atomic_fetch_add_8 directly, use > __atomic_fetch_add. > > Also see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56296#c1 and > https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html . > > Jeff > > On Thu, May 5, 2022 at 7:54 AM Patrick Matthäi <patr...@linux-dev.org> > wrote: > > > > Hello mips(el) porters, > > > > (please CC us, we are not subscribed). > > > > We are trying to build fastnetmon on mipsel, without success. Maybe you > can help us on fixing this?: > > > > /usr/bin/c++ -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. > -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time > -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now -rdynamic > CMakeFiles/fastnetmon.dir/fastnetmon.cpp.o -o fastnetmon -latomic > libgraphite_metrics.a libinfluxdb_metrics.a -lgpr -lgrpc++ -lgrpc > libfastnetmon_grpc_pb_cc.a libfastnetmon_pb_cc.a -lprotobuf -lhiredis > -lmongoc-1.0 -lbson-1.0 -llog4cpp -lpthread libpatricia.a > libfastnetmon_pcap_format.a libipfix_rfc.a libfast_library.a > libunified_parser.a -lssl -lcrypto libgobgp_action.a libexabgp_action.a > libafpacket_plugin.a libsflow_plugin.a libnetflow_plugin.a libpcap_plugin.a > libexample_plugin.a libfastnetmon_logic.a > /usr/lib/mipsel-linux-gnu/libboost_thread.so.1.74.0 > /usr/lib/mipsel-linux-gnu/libboost_atomic.so.1.74.0 -lpthread > /usr/lib/mipsel-linux-gnu/libboost_regex.so.1.74.0 > /usr/lib/mipsel-linux-gnu/libboost_program_options.so.1.74.0 > /usr/lib/mipsel-linux-gnu/libboost_system.so.1.74.0 libpatricia.a > libfastnetmon_pcap_format.a libsimple_packet_capnp.a -lcapnp -lkj -ljson-c > -lssl -lcrypto -lgpr -lgrpc++ -lgrpc -lprotobuf libgobgp_api_client_pb_cc.a > libgobgp_api_client_grpc_pb_cc.a libattribute_pb_cc.a libunified_parser.a > libfastnetmon_packet_parser.a libsimple_packet_parser_ng.a > libnetwork_data_structures.a liblibsflow.a libipfix_rfc.a libnetflow.a > -lpcap -lhiredis -lmongoc-1.0 -lbson-1.0 libexabgp_action.a > libbgp_protocol.a > > /usr/bin/ld: libfastnetmon_logic.a(fastnetmon_logic.cpp.o): undefined > reference to symbol '__atomic_fetch_add_8@@LIBATOMIC_1.0' > > /usr/bin/ld: /usr/lib/gcc/mipsel-linux-gnu/11/libatomic.so: error adding > symbols: DSO missing from command line > > > > -------- Weitergeleitete Nachricht -------- > > Betreff: Re: GoBGP and FastNetMon on Debian > > Datum: Thu, 5 May 2022 11:33:33 +0100 > > Von: Pavel Odintsov <pavel.odint...@gmail.com> > > An: Patrick Matthäi <patr...@linux-dev.org> > > > > Hello! > > > > That's extremely strange indeed. > > > > Cmake claims that library is here: > > > > -- Performing Test HAVE__ATOMIC_ADD_FETCH - Failed > > -- We have no __atomic_add_fetch, will try linking with libatomic > > -- Looking for __atomic_add_fetch_8 in atomic > > -- Looking for __atomic_add_fetch_8 in atomic - found > > -- Linked with atomic library > > -- Performing Test HAVE__SYNC_FETCH_AND_ADD > > -- Performing Test HAVE__SYNC_FETCH_AND_ADD - Failed > > -- We have no __sync_fetch_and_add on this platform, will try linking > with libatomic > > -- Looking for __sync_fetch_and_add_8 in atomic > > -- Looking for __sync_fetch_and_add_8 in atomic - not found > > -- We have no support for __sync_fetch_and_add in atomic library, skip > linking > > > > Do you have ssh access to any machine with this such architecture? > > > > On Thu, 5 May 2022 at 10:37, Patrick Matthäi <patr...@linux-dev.org> > wrote: > >> > >> Hey, > >> > >> hmpf, I hate mipsel.. > >> > https://buildd.debian.org/status/fetch.php?pkg=fastnetmon&arch=mipsel&ver=1.2.0%2Bgit20220505-1&stamp=1651743326&raw=0 > >> > >> Am 05.05.2022 um 02:14 schrieb Pavel Odintsov: > >> > >> Good morning! > >> > >> I hope you liked your movie yesterday. > >> > >> I did my side of task and resurrected logic which uses > __atomic_add_fetch instead of __sync_fetch_and_add: > https://github.com/pavel-odintsov/fastnetmon/commit/dad1c7b0b9fe16d24566649aa92d757050f4ec2a > >> > >> Good news that we have it in place for Debian build for multiple > platforms we had issues previously: > https://salsa.debian.org/debian/fastnetmon/-/blob/master/debian/rules#L11 > >> > >> Please keep me updated about mipsel builds. > >> > >> We have some work to get rid of atomic increments and replace them by > locks and I hope we will drop this magic in coming releases. > >> > >> > >> On Wed, 4 May 2022 at 18:54, Pavel Odintsov <pavel.odint...@gmail.com> > wrote: > >>> > >>> Hello! > >>> > >>> Excellent! > >>> > >>> Have a great evening! > >>> > >>> On Wed, 4 May 2022 at 18:54, Patrick Matthäi <patr...@linux-dev.org> > wrote: > >>>> > >>>> Yes i will try tomorrow, now i Went to the Cinema :) > >>>> > >>>> Am 04.05.2022 19:45 schrieb Pavel Odintsov <pavel.odint...@gmail.com > >: > >>>> > >>>> Hello! > >>>> > >>>> It may be really fun but I even had fix for it back in time: > https://github.com/pavel-odintsov/fastnetmon/commit/d5711bb3da43bff3f90a33c5d5ab9b5a262660c5 > >>>> > >>>> I think it was removed during one of many code refactorings from > previous years. > >>>> > >>>> I'll return this logic back shortly. > >>>> > >>>> Is it possible to set flag cmake .. -DUSE_NEW_ATOMIC_BUILTINS=ON only > for mipsel targets? I'm not 100% sure about this patch to enable it for all > platforms. > >>>> > >>>> Thank you! > >>>> > >>>> On Wed, 4 May 2022 at 18:41, Pavel Odintsov <pavel.odint...@gmail.com> > wrote: > >>>> > >>>> Hello! > >>>> > >>>> Oh, sad stuff indeed. > >>>> > >>>> -- Will use new memory model aware atomic builtins > >>>> -- Performing Test HAVE__ATOMIC_ADD_FETCH > >>>> -- Performing Test HAVE__ATOMIC_ADD_FETCH - Failed > >>>> -- We have no __atomic_add_fetch, will try linking with libatomic > >>>> -- Looking for __atomic_add_fetch_8 in atomic > >>>> -- Looking for __atomic_add_fetch_8 in atomic - found > >>>> -- Linked with atomic library > >>>> -- Performing Test HAVE__SYNC_FETCH_AND_ADD > >>>> -- Performing Test HAVE__SYNC_FETCH_AND_ADD - Failed > >>>> -- We have no __sync_fetch_and_add on this platform, will try linking > with libatomic > >>>> -- Looking for __sync_fetch_and_add_8 in atomic > >>>> -- Looking for __sync_fetch_and_add_8 in atomic - not found > >>>> -- We have no support for __sync_fetch_and_add in atomic library, > skip linking > >>>> > >>>> We actually linked with libatomic for __atomic_add_fetch but it looks > like __sync_fetch_and_add_8 is missing from libatomic. > >>>> > >>>> But I found something in Debian's bug tracker: > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=869805 which is quite > insightful about this exact issue. > >>>> > >>>> On Wed, 4 May 2022 at 18:17, Patrick Matthäi <patr...@linux-dev.org> > wrote: > >>>> > >>>> > https://buildd.debian.org/status/fetch.php?pkg=fastnetmon&arch=mipsel&ver=1.2.0%2Bgit20220504-1&stamp=1651682939&raw=0 > >>>> > >>>> Does not work :/ But I see the -latomic humpf.. > >>>> > >>>> Am 04.05.2022 um 14:49 schrieb Pavel Odintsov: > >>>> > >>>> Hello! > >>>> > >>>> Thank you for feedback. > >>>> > >>>> I added some logic to fix it or at least confirm root cause of this > issue with atomic: > >>>> > https://github.com/pavel-odintsov/fastnetmon/commit/89e8923759175a104aa491d4d0b683d627088110 > >>>> > >>>> Would you mind adding this patch and trying build again? > >>>> > >>>> Thank you! > >>>> > >>>> On Tue, 3 May 2022 at 19:18, Patrick Matthäi <patr...@linux-dev.org> > wrote: > > > > > -- Sincerely yours, Pavel Odintsov