Skip to content

Fix syscall() undeclared error if built with stricter build options#374

Open
lumag wants to merge 1 commit intopytorch:mainfrom
lumag:arm-cpuinfo
Open

Fix syscall() undeclared error if built with stricter build options#374
lumag wants to merge 1 commit intopytorch:mainfrom
lumag:arm-cpuinfo

Conversation

@lumag
Copy link

@lumag lumag commented Feb 27, 2026

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

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
@meta-cla
Copy link

meta-cla bot commented Feb 27, 2026

Hi @lumag!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla meta-cla bot added the cla signed label Mar 3, 2026
@fbarchard
Copy link
Collaborator

seems okay but is there a way to reproduce the 'strict build flags'?

@lumag
Copy link
Author

lumag commented Mar 4, 2026

I stumbled upon the issue when building TensorFlow-lite for ARMv7 platforms in Yocto.

@fbarchard
Copy link
Collaborator

i asked gemini and it says this is the better fix:

#define _GNU_SOURCE // This is the "gold standard" for Linux/glibc systems
#include <unistd.h>
#include <sys/syscall.h>

@lumag
Copy link
Author

lumag commented Mar 4, 2026

i asked gemini and it says this is the better fix:

#define _GNU_SOURCE // This is the "gold standard" for Linux/glibc systems #include <unistd.h> #include <sys/syscall.h>

_GNU_SOURCE enables GNU Glibc extensions. _DEFAULT_SOURCE doesn't enable those and it's enough for this case.

manpage also recommends just _DEFAULT_SOURCE.
Net result: don't use Gemini for programming, it might hallucinate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compile fails with clang 16

2 participants