Fix syscall() undeclared error if built with stricter build options#374
Fix syscall() undeclared error if built with stricter build options#374lumag wants to merge 1 commit intopytorch:mainfrom
Conversation
If cpuinfo is built with a stricer build flags, it fails on some systems
with the undeclared function error, because on Glibc syscall() is not a
part of the headers unless one of the feature macros is defined. Add the
least intrusive one, _DEFAULT_SOURCE.
cpuinfo/src/api.c:319:23: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if CPUINFO_UNLIKELY(syscall(__NR_getcpu, &cpu, NULL, NULL) != 0) {
^
cpuinfo/src/api.c:338:23: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if CPUINFO_UNLIKELY(syscall(__NR_getcpu, &cpu, NULL, NULL) != 0) {
Closes pytorch#171
|
Hi @lumag! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
seems okay but is there a way to reproduce the 'strict build flags'? |
|
I stumbled upon the issue when building TensorFlow-lite for ARMv7 platforms in Yocto. |
|
i asked gemini and it says this is the better fix: #define _GNU_SOURCE // This is the "gold standard" for Linux/glibc systems |
manpage also recommends just _DEFAULT_SOURCE. |
If cpuinfo is built with a stricer build flags, it fails on some systems with the undeclared function error, because on Glibc syscall() is not a part of the headers unless one of the feature macros is defined. Add the least intrusive one, _DEFAULT_SOURCE.
cpuinfo/src/api.c:319:23: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if CPUINFO_UNLIKELY(syscall(__NR_getcpu, &cpu, NULL, NULL) != 0) {
^
cpuinfo/src/api.c:338:23: error: call to undeclared function 'syscall'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
if CPUINFO_UNLIKELY(syscall(__NR_getcpu, &cpu, NULL, NULL) != 0) {
Closes #171