Open jmontleon opened 11 months ago
Why is syscall
undeclared on Red Hat?
Also, cpuinfo doesn't support ppc64 and s390x
Is there a way to build pytorch without it?
I don't know, you should ask PyTorch devs
Did I file this in the wrong place? cpuinfo is included in the third_party deps of pytorch and this repo is within the pytorch org. I had assumed you all talk occasionally?
The only option I see available in pytorch is -DUSE_SYSTEM_PYTORCH
to use a version provided by the system rather than bundled in the third party repo.
And the cmake warning when building on unsupported architectures:
CMake Warning at third_party/cpuinfo/CMakeLists.txt:81 (MESSAGE):
Target processor architecture "s390x" is not supported in cpuinfo. cpuinfo
will compile, but cpuinfo_initialize() will always fail.
To you question, "Why is syscall undeclared on Red Hat?", I don't think this is distribution specific. As mentioned I don't have this problem on amd64 or aarch64 using the same version of clang. Rather it seems a difference in architectures.
One of the explanations I see is: "#define _GNU_SOURCE before including unistd.h or any other header as syscall(2) is not POSIX." https://stackoverflow.com/questions/42469583/problems-calling-syscall-function-in-c
It's also present in the example within the man page https://man7.org/linux/man-pages/man2/syscall.2.html#EXAMPLES
Putting this define at the top of the file does seem to resolve the build failure. I don't have a strong enough understanding at present to say why it's necessary for some architectures and not others.
@Maratyszcza syscall is not a standard function in posix.
It is implemented in glibc. It looks like the Clang has strict constraints (compared to GCC) ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
.
The man page https://linux.die.net/man/2/syscall also show that we should add #define _GNU_SOURCE
before including headers.
I am seeing the following trying to build on Fedora 38 ppc64;e and s390x. I do not have this problem on x86_64 or aarch64.
I believe it is coming from the change in behavior to
Wimplicit-function-declaration
. https://www.redhat.com/en/blog/new-warnings-and-errors-clang-16A full build log can be found here: https://download.copr.fedorainfracloud.org/results/jmontleon/pytorch/fedora-38-s390x/06239794-pytorch/builder-live.log.gz