New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build fails with uclibc: src/util.cc:426:28: error: 'getloadavg' was not declared in this scope #985
Comments
http://linux.die.net/man/3/getloadavg says that this is in stdlib.h which util.cc does include, and http://linux.die.net/man/7/feature_test_macros says "If no feature test macros are explicitly defined, then the following feature test macros are defined by default: _BSD_SOURCE, _SVID_SOURCE, _POSIX_SOURCE, and _POSIX_C_SOURCE=200809L". So I'm not sure what uclibc needs. |
I think those man pages are for glibc an not linux in general. My understanding is that the reason uclibc doesn't implement getloadavg, is because it is not part of the POSIX specification. I think uses of getloadavg on linux will need to be guarded by something like #if defined(GLIBC) if ninja wants to support alternative standard library implementations, like uclibc. |
ninja doesn't have an opinion on this. If someone wants to use ninja with uclibc and doing so isn't too ugly, we'd merge the patch. |
musl provides a generic getloadavg.c to mitigate this (pretty common use). I reckon we copy that, put it into ninja and provide it for systems that lack it (so far, my only knowns are ulibc and ulibc-ng) |
musl's implementation is essentially this with error handling, where "b" is the output array:
https://github.com/cloudius-systems/musl/search?utf8=%E2%9C%93&q=getloadavg |
@martine thats the old version. The newer uses |
Want me to file a PR with the suggested change? |
Hi,
The ninja builds fails on Linux systems that use uclibc as the C standard library rather than glibc:
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) {
^
The text was updated successfully, but these errors were encountered: