Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/onnxruntime-linux-riscv64-spacemit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ if(NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "This file is for building shared libraries. BUILD_SHARED_LIBS: ${BUILD_SHARED_LIBS}, SHERPA_ONNX_ENABLE_SPACEMIT: ${SHERPA_ONNX_ENABLE_SPACEMIT}")
endif()

set(onnxruntime_version "2.0.2")
set(onnxruntime_version "2.0.6")
set(onnxruntime_pkg_name "spacemit-ort.riscv64.${onnxruntime_version}.tar.gz")
set(onnxruntime_URL "https://github.com/spacemit-com/onnxruntime/releases/download/${onnxruntime_version}/${onnxruntime_pkg_name}")
set(onnxruntime_HASH "SHA256=b9d038eab644c42712b93e14648427467a02d1b66115795033093efbeb53c868")
set(onnxruntime_HASH "SHA256=bebcdfb7df6b49eefa3863afcd85a3da2aa83c3ae9252d7d856188c38a70b0e6")
Comment on lines +16 to +19

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

version=2.0.6
asset="spacemit-ort.riscv64.${version}.tar.gz"
url="https://github.com/spacemit-com/onnxruntime/releases/download/${version}/${asset}"
expected="bebcdfb7df6b49eefa3863afcd85a3da2aa83c3ae9252d7d856188c38a70b0e6"
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT

curl --fail --location --output "$tmp" "$url"
test "$(sha256sum "$tmp" | cut -d' ' -f1)" = "$expected"

tar -tzf "$tmp" | grep -Eq '(^|/)lib/libonnxruntime\.so$'
tar -tzf "$tmp" | grep -Eq '(^|/)lib/libspacemit_ep\.so$'
tar -tzf "$tmp" | grep -Eq '(^|/)include/'

Repository: k2-fsa/sherpa-onnx

Length of output: 668


🏁 Script executed:

#!/bin/bash
set -euo pipefail

version=2.0.6
asset="spacemit-ort.riscv64.${version}.tar.gz"
url="https://github.com/spacemit-com/onnxruntime/releases/download/${version}/${asset}"
expected="bebcdfb7df6b49eefa3863afcd85a3da2aa83c3ae9252d7d856188c38a70b0e6"
tmp="$(mktemp)"
trap 'rm -f "$tmp"' EXIT

echo "Downloading archive..."
curl --fail --location --output "$tmp" "$url"

echo "Computing SHA256..."
sha256="$(python3 - <<'PY'
import hashlib
data = open("tmp", "rb").buffer.read()
PY
)"
sha256="$(openssl dgst -sha256 -hex "$tmp" | awk '{print $NF}')"
echo "expected=$expected"
echo "actual=$sha256"
test "$sha256" = "$expected"

echo "Archive contents for required contracts:"
python3 - <<'PY'
import tarfile, sys
path=sys.argv[1]
tar=tarfile.open(path)
names=[m.name for m in tar.getmembers() if ('/' in m.name or m.name.endswith('.so'))]
checks={
 "lib/libonnxruntime.so": any(n=="lib/libonnxruntime.so" for n in names),
 "lib/libspacemit_ep.so": any(n=="lib/libspacemit_ep.so" for n in names),
 "include/": any(n.startswith("include/") for n in names),
}
for k,v in checks.items():
    print(f"{k}: {v}")
sys.exit(0 if all(checks.values()) else 1)
PY

echo "Extracted layout sample:"
export TAR_TMP="${TAR_TMP:-}"
mkdir -p "$TAR_TMP"
(cd "$TAR_TMP" && tar -tzf "$tmp" "$tmp" | head -80)

Repository: k2-fsa/sherpa-onnx

Length of output: 806


🏁 Script executed:

#!/bin/bash
set -euo pipefail

version=2.0.6
asset="spacemit-ort.riscv64.${version}.tar.gz"
url="https://github.com/spacemit-com/onnxruntime/releases/download/${version}/${asset}"
expected="bebcdfb7df6b49eefa3863afcd85a3da2aa83c3ae9252d7d856188c38a70b0e6"
tmp="$(mktemp --suffix=.tar.gz)"
tmpdir="$(mktemp -d)"
trap 'rm -f "$tmp" ; rm -rf "$tmpdir"' EXIT

echo "Downloading archive..."
curl --fail --location --output "$tmp" "$url"

echo "Computing SHA256..."
actual="$(openssl dgst -sha256 -hex "$tmp" | awk '{print $NF}')"
echo "expected=$expected"
echo "actual=$actual"

echo "Checksum check:"
if [ "$actual" = "$expected" ]; then
  echo "OK"
else
  echo "MISMATCH"
  exit 1
fi

echo "Archive contents for required contracts:"
python3 - "$tmp" <<'PY'
import tarfile, sys
path=sys.argv[1]
names=[m.name for m in tarfile.open(path).getmembers()]
checks={
 "lib/libonnxruntime.so": any(n=="lib/libonnxruntime.so" for n in names),
 "lib/libspacemit_ep.so": any(n=="lib/libspacemit_ep.so" for n in names),
 "include/": any(n.startswith("include/") for n in names),
}
for k,v in checks.items():
    print(f"{k}: {v}")
sys.exit(0 if all(checks.values()) else 1)
PY

echo "Root-level names:"
tar -tzf "$tmp" | head -30

Repository: k2-fsa/sherpa-onnx

Length of output: 717


🏁 Script executed:

#!/bin/bash
set -euo pipefail

version=2.0.6
asset="spacemit-ort.riscv64.${version}.tar.gz"
url="https://github.com/spacemit-com/onnxruntime/releases/download/${version}/${asset}"
expected="bebcdfb7df6b49eefa3863afcd85a3da2aa83c3ae9252d7d856188c38a70b0e6"
tmp="$(mktemp --suffix=.tar.gz)"
tmpdir="$(mktemp -d)"
trap 'rm -f "$tmp" ; rm -rf "$tmpdir"' EXIT

echo "Downloading archive..."
curl --fail --location --output "$tmp" "$url"

echo "Computing SHA256 with Python hashlib..."
actual="$(python3 - <<'PY' "$tmp"
import hashlib, pathlib, sys
h = hashlib.sha256()
with open(sys.argv[1], "rb") as f:
    while True:
        data = f.read(65536)
        if not data:
            break
        h.update(data)
print(h.hexdigest())
PY
)"
echo "expected=$expected"
echo "actual=$actual"

echo "Checksum check:"
if [ "$actual" = "$expected" ]; then
  echo "OK"
else
  echo "MISMATCH"
  exit 1
fi

echo "Root-level archive entries:"
python3 - "$tmp" <<'PY'
import tarfile, sys
with tarfile.open(sys.argv[1], "r:gz") as tar:
    for m in tar.getmembers():
        if m.name.find("/") == -1:
            print(m.name)
PY

echo "Required contract entries:"
python3 - "$tmp" <<'PY'
import tarfile, sys
with tarfile.open(sys.argv[1], "r:gz") as tar:
    names = {m.name for m in tar.getmembers()}
checks={
 "lib/libonnxruntime.so": "lib/libonnxruntime.so" in names,
 "lib/libspacemit_ep.so": "lib/libspacemit_ep.so" in names,
 "include/": any(n.startswith("include/") for n in names),
 "CMakeLists.txt": any(n.startswith("lib/cmake/") or n == "CMakeLists.txt" for n in names),
}
for k,v in checks.items():
    print(f"{k}: {v}")
PY

echo "Relevant install snippets in onnxruntime config:"
sed -n '1,220p' cmake/onnxruntime-linux-riscv64-spacemit.cmake 2>/dev/null || true

Repository: k2-fsa/sherpa-onnx

Length of output: 4443


Fix the onnxruntime artifact layout.

The downloaded 2.0.6 archive is valid, but it stores everything under spacemit-ort.riscv64.2.0.6/, so ${onnxruntime_SOURCE_DIR}/lib/libonnxruntime.so and the imported targets’ include/ paths won’t resolve. Update the expected paths or switch to an archive whose root contains lib/ and include/.

[functional_correctness, stability_and_availability]

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/onnxruntime-linux-riscv64-spacemit.cmake` around lines 16 - 19, Update
the ONNX Runtime artifact handling associated with onnxruntime_URL and
onnxruntime_SOURCE_DIR so the extracted root directory
spacemit-ort.riscv64.2.0.6 is included when resolving lib/libonnxruntime.so and
imported-target include paths. Alternatively, switch to an archive whose root
directly contains lib/ and include/, while preserving the existing version,
package, and hash consistency.


# If you don't have access to the Internet,
# please download onnxruntime to one of the following locations.
Expand Down
9 changes: 5 additions & 4 deletions cxx-api-examples/version-cxx-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
#include "sherpa-onnx/c-api/cxx-api.h"

auto main() -> int {
std::cout << "sherpa-onnx version : " << sherpa_onnx::GetVersionStr()
using namespace sherpa_onnx::cxx; // NOLINT
std::cout << "sherpa-onnx version : " << GetVersionStr()
<< "\n";
std::cout << "sherpa-onnx Git SHA1: " << sherpa_onnx::GetGitSha1() << "\n";
std::cout << "sherpa-onnx Git date: " << sherpa_onnx::GetGitDate() << "\n";
std::cout << "onnxruntime version : " << sherpa_onnx::GetOnnxruntimeVersionStr()
std::cout << "sherpa-onnx Git SHA1: " << GetGitSha1() << "\n";
std::cout << "sherpa-onnx Git date: " << GetGitDate() << "\n";
std::cout << "onnxruntime version : " << GetOnnxruntimeVersionStr()
<< "\n";

return 0;
Expand Down