google / benchmark

A microbenchmark support library
Apache License 2.0
8.91k stars 1.62k forks source link

master is broken on Android #731

Open Maratyszcza opened 5 years ago

Maratyszcza commented 5 years ago

master version (I tested revision c9311a44e1280853632fe2472345dd04514a2f74) fails to build on Android, with the error:

/Users/marat/benchmark/src/sysinfo.cc:586:21: error: use of undeclared identifier 'getloadavg'
  const int nelem = getloadavg(res.data(), kMaxSamples);
                    ^
1 error generated.

Repro:

git clone https://github.com/google/benchmark.git
cd benchmark
mkdir build && cd build
cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/android/ndk/build/cmake/android.toolchain.cmake -DBENCHMARK_ENABLE_TESTING=OFF ..
make
dmah42 commented 5 years ago

It looks like android is being reported as BENCHMARK_OS_LINUX, but it doesn't have getloadavg.

The right fix is likely to define a BENCHMARK_OS_ANDROID and then make sure everything that currently is compiled in is also compiled when that is defined.

On Mon, Nov 26, 2018 at 6:50 PM Marat Dukhan notifications@github.com wrote:

master version (I tested revision c9311a4 https://github.com/google/benchmark/commit/c9311a44e1280853632fe2472345dd04514a2f74) fails to build on Android, with the error:

/Users/marat/benchmark/src/sysinfo.cc:586:21: error: use of undeclared identifier 'getloadavg' const int nelem = getloadavg(res.data(), kMaxSamples); ^ 1 error generated.

Repro:

git clone https://github.com/google/benchmark.gitcd benchmark mkdir build && cd build cmake -DCMAKE_TOOLCHAIN_FILE=/path/to/android/ndk/build/cmake/android.toolchain.cmake -DBENCHMARK_ENABLE_TESTING=OFF .. make

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/google/benchmark/issues/731, or mute the thread https://github.com/notifications/unsubscribe-auth/AAfIMlIQxqbi9f7pKq3cQXelyOCoz8M6ks5uzDfxgaJpZM4Yznil .

RuABraun commented 5 years ago

So how does one fix this? I do not understand @dominichamon 's answer.

LebedevRI commented 5 years ago

Someone using android will have to make it build, and submit a PR.