HdrHistogram / HdrHistogram/HdrHistogram_c

ARM (Raspberry PI) build

Open
#98 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
290
Forks
111
Avg merge
1d 16h
Merged PRs (30d)
3

Description

I'm trying to build this project for ARM but I'm having an issue. Please bear with me as I'm very rusty when it comes to C/C++ builds.

During the cmake --build . process I get the following error:

[ 50%] Linking C executable hdr_histogram_test
/usr/bin/ld: ../src/libhdr_histogram_static.a(hdr_histogram.c.o): in function `counts_inc_normalised_atomic':
hdr_histogram.c:(.text+0x204): undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: hdr_histogram.c:(.text+0x220): undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: ../src/libhdr_histogram_static.a(hdr_histogram.c.o): in function `update_min_max_atomic':
hdr_histogram.c:(.text+0x2dc): undefined reference to `__atomic_load_8'
/usr/bin/ld: hdr_histogram.c:(.text+0x32c): undefined reference to `__atomic_compare_exchange_8'
/usr/bin/ld: hdr_histogram.c:(.text+0x354): undefined reference to `__atomic_load_8'
/usr/bin/ld: hdr_histogram.c:(.text+0x398): undefined reference to `__atomic_compare_exchange_8'
/usr/bin/ld: ../src/libhdr_histogram_static.a(hdr_writer_reader_phaser.c.o): in function `_hdr_phaser_get_epoch':
hdr_writer_reader_phaser.c:(.text+0x18): undefined reference to `__atomic_load_8'
/usr/bin/ld: ../src/libhdr_histogram_static.a(hdr_writer_reader_phaser.c.o): in function `_hdr_phaser_set_epoch':
hdr_writer_reader_phaser.c:(.text+0x58): undefined reference to `__atomic_store_8'
/usr/bin/ld: ../src/libhdr_histogram_static.a(hdr_writer_reader_phaser.c.o): in function `_hdr_phaser_reset_epoch':
hdr_writer_reader_phaser.c:(.text+0x8c): undefined reference to `__atomic_exchange_8'
/usr/bin/ld: ../src/libhdr_histogram_static.a(hdr_writer_reader_phaser.c.o): in function `hdr_phaser_writer_enter':
hdr_writer_reader_phaser.c:(.text+0x1c0): undefined reference to `__atomic_fetch_add_8'
/usr/bin/ld: ../src/libhdr_histogram_static.a(hdr_writer_reader_phaser.c.o): in function `hdr_phaser_writer_exit':
hdr_writer_reader_phaser.c:(.text+0x238): undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
gmake[2]: *** [test/CMakeFiles/hdr_histogram_test.dir/build.make:120: test/hdr_histogram_test] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1007: test/CMakeFiles/hdr_histogram_test.dir/all] Error 2
gmake: *** [Makefile:182: all] Error 2

Now I went ahead, deleted my "build" folder and re-did it all like so:

LDFLAGS="-latomic" cmake ../HdrHistogram_c/
LDFLAGS="-latomic" cmake --build . -v

Got same error, but this time I can see this (thanks to "-v" argument):

/usr/bin/cc -latomic CMakeFiles/hdr_histogram_test.dir/hdr_histogram_test.c.o CMakeFiles/hdr_histogram_test.dir/minunit.c.o -o hdr_histogram_test  ../src/libhdr_histogram_static.a /usr/lib/arm-linux-gnueabihf/libz.so -lpthread -lm -lrt 

Now that won't work because -latomic is like first argument here.
But this works just fine, with -latomic at the end:

/usr/bin/cc CMakeFiles/hdr_histogram_test.dir/hdr_histogram_test.c.o CMakeFiles/hdr_histogram_test.dir/minunit.c.o -o hdr_histogram_test  ../src/libhdr_histogram_static.a /usr/lib/arm-linux-gnueabihf/libz.so -lpthread -lm -lrt  -latomic

What am I doing wrong? Anyone managed to build this project for ARM (Raspberry PI)?

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the ARM Raspberry Pi build with the CMake commands and verbose output shown, then inspect how the hdr_histogram_test target links ../src/libhdr_histogram_static.a. Done means the linker receives -latomic after the static library and cmake --build . completes successfully on ARM.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cmake, raspberry-pi
Domain
build-system, embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.