Repository: pytorch
Issue: Compilation error on loongarch64
Labels: module: build,triaged,module: third_party

### 🐛 Describe the bug

export NO_CUDA=0
export BUILD_TEST=0

git clone https://github.com/pytorch/pytorch --recursive
cd pytorch
python setup.py install

error:
In file included from /home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm/sleefsimdsp.c:358:
/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/arch/helperpurec_scalar.h:69:2: error: #error FP_FAST_FMA or FP_FAST_FMAF not                                                 defined
 #error FP_FAST_FMA or FP_FAST_FMAF not defined
  ^~~~~
cc1: warning: unrecognized command line option ‘-Wno-absolute-value’
[500/1709] Building C object sleef/src/libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimdsp.c.o
FAILED: sleef/src/libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimdsp.c.o
/usr/bin/cc -DDETERMINISTIC=1 -DDORENAME=1 -DENABLE_ALIAS=1 -DENABLE_BUILTIN_MATH=1 -DENABLE_PURECFMA_SCALAR=1 -DENABLE_SYS_getrandom=1 -DHA                                                VE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -                                                DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DSLEEF_STATIC_LIBS=1 -DUSE_EXTERNAL_MZCRC -D_FILE_OFFSET_BITS=64 -I/home/sunway-cloud-dam-py/pytorch                                                -v2.1.0/build/aten/src -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/aten/src -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build -I/home/sunway-c                                                loud-dam-py/pytorch-v2.1.0 -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/onnx -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/thir                                                d_party/onnx -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/foxi -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/third_party/foxi -                                                I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/common -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/arch                                                 -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/sleef/src/libm/include -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/li                                                bm -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/build/third_party/gloo -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third                                                _party/gloo -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third_party/tensorpipe/third_party/libuv/include -isystem /home/sunwa                                                y-cloud-dam-py/pytorch-v2.1.0/third_party/protobuf/src -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third_party/eigen -DNDEBUG                                                 -Wno-ignored-qualifiers -Wno-absolute-value -Wall -Wno-unused -Wno-attributes -Wno-unused-result -Wno-psabi -ffp-contract=off -fno-math-err                                                no -fno-trapping-math -O3 -DNDEBUG -DNDEBUG -fPIC -DTORCH_USE_LIBUV -DCAFFE2_USE_GLOO -DTH_HAVE_THREAD -std=gnu99 -MD -MT sleef/src/libm/CMa                                                keFiles/sleefdetpurecfma_scalar.dir/sleefsimdsp.c.o -MF sleef/src/libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimdsp.c.o.d -o sleef/src                                                /libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimdsp.c.o -c /home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm/sleefsim                                                dsp.c
cat: /.build.command: 没有那个文件或目录
In file included from /home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm/sleefsimdsp.c:358:
/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/arch/helperpurec_scalar.h:69:2: error: #error FP_FAST_FMA or FP_FAST_FMAF not                                                 defined
 #error FP_FAST_FMA or FP_FAST_FMAF not defined
  ^~~~~
cc1: warning: unrecognized command line option ‘-Wno-absolute-value’
[501/1709] Building C object sleef/src/libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimddp.c.o
FAILED: sleef/src/libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimddp.c.o
/usr/bin/cc -DDETERMINISTIC=1 -DDORENAME=1 -DENABLE_ALIAS=1 -DENABLE_BUILTIN_MATH=1 -DENABLE_PURECFMA_SCALAR=1 -DENABLE_SYS_getrandom=1 -DHA                                                VE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -                                                DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DSLEEF_STATIC_LIBS=1 -DUSE_EXTERNAL_MZCRC -D_FILE_OFFSET_BITS=64 -I/home/sunway-cloud-dam-py/pytorch                                                -v2.1.0/build/aten/src -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/aten/src -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build -I/home/sunway-c                                                loud-dam-py/pytorch-v2.1.0 -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/onnx -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/thir                                                d_party/onnx -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/foxi -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/third_party/foxi -                                                I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/common -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/arch                                                 -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/sleef/src/libm/include -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/li                                                bm -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/build/third_party/gloo -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third                                                _party/gloo -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third_party/tensorpipe/third_party/libuv/include -isystem /home/sunwa                                                y-cloud-dam-py/pytorch-v2.1.0/third_party/protobuf/src -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third_party/eigen -DNDEBUG                                                 -Wno-ignored-qualifiers -Wno-absolute-value -Wall -Wno-unused -Wno-attributes -Wno-unused-result -Wno-psabi -ffp-contract=off -fno-math-err                                                no -fno-trapping-math -O3 -DNDEBUG -DNDEBUG -fPIC -DTORCH_USE_LIBUV -DCAFFE2_USE_GLOO -DTH_HAVE_THREAD -std=gnu99 -MD -MT sleef/src/libm/CMa                                                keFiles/sleefdetpurecfma_scalar.dir/sleefsimddp.c.o -MF sleef/src/libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimddp.c.o.d -o sleef/src                                                /libm/CMakeFiles/sleefdetpurecfma_scalar.dir/sleefsimddp.c.o -c /home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm/sleefsim                                                ddp.c
cat: /.build.command: 没有那个文件或目录
In file included from /home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm/sleefsimddp.c:249:
/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/arch/helperpurec_scalar.h:69:2: error: #error FP_FAST_FMA or FP_FAST_FMAF not                                                 defined
 #error FP_FAST_FMA or FP_FAST_FMAF not defined
  ^~~~~
cc1: warning: unrecognized command line option ‘-Wno-absolute-value’
[502/1709] Linking C executable sleef/bin/mkdisp
cat: /.build.command: 没有那个文件或目录
[503/1709] Building C object sleef/src/libm/CMakeFiles/sleefpurecfma_scalar.dir/sleefsimddp.c.o
FAILED: sleef/src/libm/CMakeFiles/sleefpurecfma_scalar.dir/sleefsimddp.c.o
/usr/bin/cc -DDORENAME=1 -DENABLE_ALIAS=1 -DENABLE_BUILTIN_MATH=1 -DENABLE_PURECFMA_SCALAR=1 -DENABLE_SYS_getrandom=1 -DHAVE_MALLOC_USABLE_S                                                IZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_                                                NAMESPACE=onnx_torch -DSLEEF_STATIC_LIBS=1 -DUSE_EXTERNAL_MZCRC -D_FILE_OFFSET_BITS=64 -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/aten                                                /src -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/aten/src -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build -I/home/sunway-cloud-dam-py/pytorc                                                h-v2.1.0 -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/onnx -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/third_party/onnx -I/ho                                                me/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/foxi -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/build/third_party/foxi -I/home/sunway-clou                                                d-dam-py/pytorch-v2.1.0/third_party/sleef/src/common -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/arch -I/home/sunway-cl                                                oud-dam-py/pytorch-v2.1.0/build/sleef/src/libm/include -I/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm -isystem /home/                                                sunway-cloud-dam-py/pytorch-v2.1.0/build/third_party/gloo -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third_party/gloo -isyst                                                em /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third_party/tensorpipe/third_party/libuv/include -isystem /home/sunway-cloud-dam-py/pyt                                                orch-v2.1.0/third_party/protobuf/src -isystem /home/sunway-cloud-dam-py/pytorch-v2.1.0/cmake/../third_party/eigen -DNDEBUG -Wno-ignored-qual                                                ifiers -Wno-absolute-value -Wall -Wno-unused -Wno-attributes -Wno-unused-result -Wno-psabi -ffp-contract=off -fno-math-errno -fno-trapping-m                                                ath -O3 -DNDEBUG -DNDEBUG -fPIC -DTORCH_USE_LIBUV -DCAFFE2_USE_GLOO -DTH_HAVE_THREAD -std=gnu99 -MD -MT sleef/src/libm/CMakeFiles/sleefpurec                                                fma_scalar.dir/sleefsimddp.c.o -MF sleef/src/libm/CMakeFiles/sleefpurecfma_scalar.dir/sleefsimddp.c.o.d -o sleef/src/libm/CMakeFiles/sleefpu                                                recfma_scalar.dir/sleefsimddp.c.o -c /home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm/sleefsimddp.c
cat: /.build.command: 没有那个文件或目录
In file included from /home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/libm/sleefsimddp.c:249:
/home/sunway-cloud-dam-py/pytorch-v2.1.0/third_party/sleef/src/arch/helperpurec_scalar.h:69:2: error: #error FP_FAST_FMA or FP_FAST_FMAF not                                                 defined
 #error FP_FAST_FMA or FP_FAST_FMAF not defined
  ^~~~~
cc1: warning: unrecognized command line option ‘-Wno-absolute-value’
[504/1709] Building CXX object c10/CMakeFiles/c10.dir/util/Logging.cpp.o
cat: /.build.command: 没有那个文件或目录
[505/1709] Building C object sleef/src/common/CMakeFiles/arraymap.dir/arraymap.c.o
cat: /.build.command: 没有那个文件或目录
[506/1709] Building CXX object c10/CMakeFiles/c10.dir/util/intrusive_ptr.cpp.o
cat: /.build.command: 没有那个文件或目录
[507/1709] Building CXX object c10/CMakeFiles/c10.dir/util/int128.cpp.o
cat: /.build.command: 没有那个文件或目录
[508/1709] Building CXX object c10/CMakeFiles/c10.dir/util/flags_use_no_gflags.cpp.o
cat: /.build.command: 没有那个文件或目录
[509/1709] Building CXX object c10/CMakeFiles/c10.dir/mobile/CPUProfilingAllocator.cpp.o
cat: /.build.command: 没有那个文件或目录
[510/1709] Building CXX object c10/CMakeFiles/c10.dir/util/numa.cpp.o
cat: /.build.command: 没有那个文件或目录
[511/1709] Building CXX object c10/CMakeFiles/c10.dir/core/TensorImpl.cpp.o
cat: /.build.command: 没有那个文件或目录
[512/1709] Building CXX object c10/CMakeFiles/c10.dir/util/typeid.cpp.o
cat: /.build.command: 没有那个文件或目录
[513/1709] Building C object sleef/src/libm/CMakeFiles/sleefpurec_scalar.dir/sleefsimdsp.c.o
cat: /.build.command: 没有那个文件或目录
[514/1709] Building CXX object c10/CMakeFiles/c10.dir/util/signal_handler.cpp.o
cat: /.build.command: 没有那个文件或目录
[515/1709] Building CXX object third_party/onnx/CMakeFiles/onnx.dir/onnx/version_converter/convert.cc.o
cat: /.build.command: 没有那个文件或目录
[516/1709] Generating /home/sunway-cloud-dam-py/pytorch-v2.1.0/torch...ytorch-v2.1.0/torch/testing/_internal/generated/annotated_fn_args.py
ninja: build stopped: subcommand failed.


### Versions

v2.1.0

cc @malfet @seemethere