Skip to content

musl build fails due to stat64 call #5668

@leso-kn

Description

@leso-kn

Bug Report

Describe the bug

The usage of stat64() currently breaks the build on non-glibc linux systems (e.g. musl), as those systems like Apple and WASM do not support LFS64.

System information

  • OS Platform and Distribution: Alpine Linux 64-bit amd64 (3.18)
  • ONNX version: 1.14.1
  • Python version: n/a
  • GCC/Compiler version: 12.2.1
  • CMake version: 3.26.5
  • Protobuf version: 3.21.12
  • Visual Studio version: n/a

Reproduction instructions

See aports!52138 and the associated pipeline log for reproduction reference.

Expected behavior

checker.cc should use stat() instead of stat64() on non-glibc linux systems.

Notes

Build log:

/usr/bin/g++ -DEIGEN_MPL2_ONLY -DONNX_ML=1 -DONNX_NAMESPACE=onnx -DONNX_USE_LITE_PROTO=1 -DORT_ENABLE_STREAM -D_GNU_SOURCE -D__ONNX_DISABLE_STATIC_REGISTRATION -D__ONNX_NO_DOC_STRINGS -D__STDC_FORMAT_MACROS -I/builds/leso-kn/aports/testing/onnxruntime/src/onnxruntime-1.16.1/build/_deps/onnx-src -I/builds/leso-kn/aports/testing/onnxruntime/src/onnxruntime-1.16.1/build/_deps/onnx-build -Os -fstack-clash-protection -Wformat -Werror=format-security -D_GLIBCXX_ASSERTIONS=1 -fno-plt -O2 -Wno-deprecated-declarations -flto=auto -ffunction-sections -fdata-sections -DCPUINFO_SUPPORTED -Wnon-virtual-dtor -std=gnu++17 -fPIC -Wall -Wextra -MD -MT _deps/onnx-build/CMakeFiles/onnx.dir/onnx/checker.cc.o -MF _deps/onnx-build/CMakeFiles/onnx.dir/onnx/checker.cc.o.d -o _deps/onnx-build/CMakeFiles/onnx.dir/onnx/checker.cc.o -c /builds/leso-kn/aports/testing/onnxruntime/src/onnxruntime-1.16.1/build/_deps/onnx-src/onnx/checker.cc
/builds/leso-kn/aports/testing/onnxruntime/src/onnxruntime-1.16.1/build/_deps/onnx-src/onnx/checker.cc: In function 'void onnx::checker::check_tensor(const onnx::TensorProto&, const CheckerContext&)':
/builds/leso-kn/aports/testing/onnxruntime/src/onnxruntime-1.16.1/build/_deps/onnx-src/onnx/checker.cc:191:23: error: aggregate 'onnx::checker::check_tensor(const onnx::TensorProto&, const CheckerContext&)::stat64 buffer' has incomplete type and cannot be defined
  191 |         struct stat64 buffer; // All POSIX except APPLE have stat64
      |                       ^~~~~~
/builds/leso-kn/aports/testing/onnxruntime/src/onnxruntime-1.16.1/build/_deps/onnx-src/onnx/checker.cc:192:48: error: invalid use of incomplete type 'struct onnx::checker::check_tensor(const onnx::TensorProto&, const CheckerContext&)::stat64'
  192 |         if (stat64((data_path).c_str(), &buffer) != 0) {
      |                                                ^
/builds/leso-kn/aports/testing/onnxruntime/src/onnxruntime-1.16.1/build/_deps/onnx-src/onnx/checker.cc:191:16: note: forward declaration of 'struct onnx::checker::check_tensor(const onnx::TensorProto&, const CheckerContext&)::stat64'
  191 |         struct stat64 buffer; // All POSIX except APPLE have stat64
      |                ^~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions