Zygo / bees

Best-Effort Extent-Same, a btrfs dedupe agent
GNU General Public License v3.0
647 stars 55 forks source link

Compilation failed on Raspian 10 with "/usr/bin/ld: ../lib/libcrucible.so: undefined reference to `__atomic_fetch_add_8'" #150

Open Alexey-Tsarev opened 4 years ago

Alexey-Tsarev commented 4 years ago

I am using Raspberry Pi 4 and trying to make the app:

echo "const char *BEES_VERSION = \"v0.6-80-g9514b89\";" > bees-version.new.c
mv -f bees-version.new.c bees-version.c
cc -Wall -Wextra -Werror -O3 -I../include -D_FILE_OFFSET_BITS=64 -std=c99  -o bees-version.o -c bees-version.c
g++ -Wall -Wextra -Werror -O3 -I../include -D_FILE_OFFSET_BITS=64 -std=c++11 -Wold-style-cast  -L../lib  -o ../bin/bees bees.o bees-context.o bees-hash.o bees-resolve.o bees-roots.o bees-thread.o bees-types.o bees-version.o -lcrucible -luuid -lpthread
/usr/bin/ld: bees.o: in function `wait_for_term_signal()':
bees.cc:(.text+0x34f4): undefined reference to `crucible::signal_ntoa[abi:cxx11](int)'
/usr/bin/ld: bees-context.o: in function `std::_Function_handler<void (std::ostream&), BeesContext::resolve_addr_uncached(BeesAddress)::{lambda(std::ostream&)#1}>::_M_invoke(std::_Any_data const&, std::ostream&)':
bees-context.cc:(.text+0x2604): undefined reference to `crucible::BtrfsIoctlLogicalInoArgs::BtrfsInodeOffsetRootSpan::size() const'
/usr/bin/ld: bees-context.o: in function `BeesContext::dump_status()':
bees-context.cc:(.text+0x3d80): undefined reference to `crucible::TaskMaster::get_thread_count()'
/usr/bin/ld: bees-context.o: in function `BeesContext::resolve_addr_uncached(BeesAddress)':
bees-context.cc:(.text+0x659c): undefined reference to `crucible::BtrfsIoctlLogicalInoArgs::BtrfsInodeOffsetRootSpan::operator std::vector<crucible::BtrfsInodeOffsetRoot, std::allocator<crucible::BtrfsInodeOffsetRoot> >() const'
/usr/bin/ld: bees-context.cc:(.text+0x6700): undefined reference to `crucible::BtrfsIoctlLogicalInoArgs::BtrfsInodeOffsetRootSpan::size() const'
/usr/bin/ld: bees-context.o: in function `BeesContext::stop()':
bees-context.cc:(.text+0x77e0): undefined reference to `crucible::TaskMaster::cancel()'
/usr/bin/ld: bees-hash.o: in function `BeesHashTable::flush_dirty_extents(bool)':
bees-hash.cc:(.text+0x4514): undefined reference to `crucible::RateLimiter::sleep_time(double)'
/usr/bin/ld: ../lib/libcrucible.so: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:48: ../bin/bees] Error 1
make[1]: Leaving directory '/home/pi/dev/bees/src'
make: *** [Makefile:38: src] Error 2
pi@laser-pi:~/dev/bees$
pi@laser-pi:~/dev/bees$ git branch
* master
pi@laser-pi:~/dev/bees$

How it can be fixed?

Alexey-Tsarev commented 4 years ago

Solution:

make LDFLAGS="-latomic"
Zygo commented 3 years ago

Does cherry-picking 7933ccb660de3f4b5cd8d2ac2af00d4d4e6acdf3 also fix the issue? There is no libcrucible.so in the master branch any more, only libcrucible.a.

Alexey-Tsarev commented 3 years ago

Shortly, NO.

pi@laser-pi:~/dev/bees$ git branch
* master
pi@laser-pi:~/dev/bees$ git pull
Already up to date.
pi@laser-pi:~/dev/bees$ make -j 4
...
task.cc:(.text+0x42f8): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:48: ../bin/bees] Error 1
make[1]: Leaving directory '/home/pi/dev/bees/src'
make: *** [Makefile:38: src] Error 2

Looks like the pointed commit is already included in the master:

➜  bees git:(master) ✗ git cherry-pick 7933ccb660de3f4b5cd8d2ac2af00d4d4e6acdf3
Auto-merging lib/Makefile
Auto-merging docs/install.md
On branch master
Your branch is up to date with 'origin/master'.

You are currently cherry-picking commit 7933ccb.
  (all conflicts fixed: run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    .idea/

nothing added to commit but untracked files present (use "git add" to track)
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git cherry-pick --skip'
➜  bees git:(master) ✗

So, reverse mode. From the scratch:

pi@laser-pi:~/dev/bees$ git revert 7933ccb660de3f4b5cd8d2ac2af00d4d4e6acdf3
pi@laser-pi:~/dev/bees$ git log
commit 7e57a5e2562ee7cfd0f42b8ef3b7bcf98b38d310 (HEAD -> master)
Author: Zygo Blaxell <bees@furryterror.org>
Date:   Sun Dec 9 17:23:54 2018 -0500

    Revert "build: make libcrucible a static library"

    This reverts commit 7933ccb660de3f4b5cd8d2ac2af00d4d4e6acdf3.

commit 05bd65444d7f6735a68292c299adaa26bd92e3dc (origin/master, origin/HEAD)
Author: Zygo Blaxell <bees@furryterror.org>
Date:   Mon Aug 31 22:22:57 2020 -0400

    bees: initialize context in the correct order

    We cannot use BeesContext::roots() until after
    BeesContext::set_root_path() has been called.
    Save up the parameter settings until then.

    Signed-off-by: Zygo Blaxell <bees@furryterror.org>

pi@laser-pi:~/dev/bees$ make clean
pi@laser-pi:~/dev/bees$ make
...
/usr/bin/ld: ../lib/libcrucible.so: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:48: ../bin/bees] Error 1
make[1]: Leaving directory '/home/pi/dev/bees/src'
make: *** [Makefile:38: src] Error 2