On uclibc systems, ninja fails to compile with the following error: i686-gentoo-linux-uclibc-g++ -O2 -march=i686 -pipe -Wno-deprecated -DNINJA_PYTHON="/usr/bin/python2.7" -DNI/graphviz.cc src/manifest_parser.cc src/eval_env.cc src/line_printer.cc src/subprocess-posix.cc src/debug_fc src/lexer.cc -o ninja.bootstrap src/util.cc: In function 'double GetLoadAverage()': src/util.cc:426:28: error: 'getloadavg' was not declared in this scope if (getloadavg(loadavg, 3) < 0) { ^ uclibc does not implement getloadavg like glibc does. Looking at the ninja source, their use of getloadavg is already guarded by an ifdef, but it assumes this function is always present on Linux. Reproducible: Always
It seems that uclibc has not gained this function in the 10 years since Mike suggested that a patch would be welcome. http://lists.busybox.net/pipermail/uclibc/2005-November/033909.html I would suggest that you write a patch for uclibc, or consult with the developers of ninja upstream on a workaround for this.
I've filed a bug for this upstream in the ninja project: https://github.com/martine/ninja/issues/985
Created attachment 413284 [details, diff] loadavg() patch working with uclibc (probably any libc anyway) The Patch is untested but basically a no frills variant of what glibc does on linux, esp since ninja only uses the first loadavg() value anyway - and ninja ignores errors too
(In reply to Sven E. from comment #3) > Created attachment 413284 [details, diff] [details, diff] > loadavg() patch working with uclibc (probably any libc anyway) > > The Patch is untested but basically a no frills variant of what glibc does > on linux, esp since ninja only uses the first loadavg() value anyway - and > ninja ignores errors too BTW: Patch is against 1.6 as I ran into the same bug for 1.6.
(In reply to Mike Gilbert from comment #1) > It seems that uclibc has not gained this function in the 10 years since Mike > suggested that a patch would be welcome. > > http://lists.busybox.net/pipermail/uclibc/2005-November/033909.html > > I would suggest that you write a patch for uclibc, or consult with the > developers of ninja upstream on a workaround for this. We do have other functions in uClibc not specified in POSIX or SUSv3. There are other pkgs making use of getloadavg() so maybe its time to think about its implementation.
Uploaded https://github.com/ninja-build/ninja/pull/1220 .
Backported the fix in https://gitweb.gentoo.org/repo/gentoo.git/commit/dev-util/ninja?id=39dfff0ac9b8476c238397d90651d2d4309806e5 . I'll work on getting 1.7.2 stabilized.
ninja-1.7.2 is now stable on most arches, closing.