Unverified Commit 22292ed4 authored by dotlambda's avatar dotlambda Committed by GitHub
Browse files

python3Packages.rapidocr-onnxruntime: fix aarch64-linux build (#458575)

parents bb50b0be 3f0c046c
Loading
Loading
Loading
Loading
+45 −0
Original line number Diff line number Diff line
diff --git a/onnxruntime/core/common/cpuid_info.cc b/onnxruntime/core/common/cpuid_info.cc
--- a/onnxruntime/core/common/cpuid_info.cc
+++ b/onnxruntime/core/common/cpuid_info.cc
@@ -3,6 +3,7 @@
 #include "core/common/cpuid_info.h"
 #include "core/common/logging/logging.h"
 #include "core/common/logging/severity.h"
+#include <iostream>
 
 #ifdef __linux__
 
@@ -364,8 +365,14 @@
 #if defined(CPUINFO_SUPPORTED)
   pytorch_cpuinfo_init_ = cpuinfo_initialize();
   if (!pytorch_cpuinfo_init_) {
-    LOGS_DEFAULT(WARNING) << "Failed to initialize PyTorch cpuinfo library. May cause CPU EP performance degradation "
-                             "due to undetected CPU features.";
+    constexpr const char* message =
+        "Failed to initialize PyTorch cpuinfo library. May cause CPU EP performance degradation due to undetected CPU "
+        "features.";
+    if (logging::LoggingManager::HasDefaultLogger()) {
+      LOGS_DEFAULT(WARNING) << message;
+    } else {
+      std::cerr << "onnxruntime cpuid_info warning: " << message << std::endl;
+    }
   }
 #endif  // defined(CPUINFO_SUPPORTED)
 #if defined(__linux__)
diff --git a/onnxruntime/core/platform/posix/env.cc b/onnxruntime/core/platform/posix/env.cc
--- a/onnxruntime/core/platform/posix/env.cc
+++ b/onnxruntime/core/platform/posix/env.cc
@@ -605,7 +605,12 @@
   PosixEnv() {
     cpuinfo_available_ = cpuinfo_initialize();
     if (!cpuinfo_available_) {
-      LOGS_DEFAULT(INFO) << "cpuinfo_initialize failed";
+      constexpr const char* message = "cpuinfo_initialize failed";
+      if (logging::LoggingManager::HasDefaultLogger()) {
+        LOGS_DEFAULT(INFO) << message;
+      } else {
+        std::cerr << "onnxruntime cpuid_info warning: " << message << std::endl;
+      }
     }
   }
   bool cpuinfo_available_{false};
+6 −0
Original line number Diff line number Diff line
@@ -97,6 +97,12 @@ effectiveStdenv.mkDerivation rec {
      url = "https://github.com/microsoft/onnxruntime/commit/f7619dc93f592ddfc10f12f7145f9781299163a0.patch";
      hash = "sha256-jxfMB+/Zokcu5DSfZP7QV1E8mTrsLe/sMr+ZCX/Y3m0=";
    })
    # Handle missing default logger when cpuinfo initialization fails in the build sandbox
    # TODO: Remove on next release
    # https://github.com/microsoft/onnxruntime/issues/10038
    # https://github.com/microsoft/onnxruntime/pull/15661
    # https://github.com/microsoft/onnxruntime/pull/20509
    ./cpuinfo-logging.patch
  ]
  ++ lib.optionals cudaSupport [
    # We apply the referenced 1064.patch ourselves to our nix dependency.
+0 −3
Original line number Diff line number Diff line
@@ -120,9 +120,6 @@ buildPythonPackage {
  passthru.skipBulkUpdate = true;

  meta = {
    # This seems to be related to https://github.com/microsoft/onnxruntime/issues/10038
    # Also some related issue: https://github.com/NixOS/nixpkgs/pull/319053#issuecomment-2167713362
    badPlatforms = [ "aarch64-linux" ];
    changelog = "https://github.com/RapidAI/RapidOCR/releases/tag/${src.tag}";
    description = "Cross platform OCR Library based on OnnxRuntime";
    homepage = "https://github.com/RapidAI/RapidOCR";
+0 −3
Original line number Diff line number Diff line
@@ -110,9 +110,6 @@ buildPythonPackage {
  doCheck = false;

  meta = {
    # This seems to be related to https://github.com/microsoft/onnxruntime/issues/10038
    # Also some related issue: https://github.com/NixOS/nixpkgs/pull/319053#issuecomment-2167713362
    badPlatforms = [ "aarch64-linux" ];
    changelog = "https://github.com/RapidAI/RapidOCR/releases/tag/${src.tag}";
    description = "Cross platform OCR Library based on OnnxRuntime";
    homepage = "https://github.com/RapidAI/RapidOCR";