Skip to content

onnx-mlir --EmitJNI failed on windows, run wrong command  #2580

@armgong

Description

@armgong

run build on windows today, build ok, run --EmitObj --EmitLib also is a go, but --EmitJNI failed. onnx-mlir run wrong command on windows

 lib.exe x D:\onnx\onnx-mlir\build\Release\lib/libjniruntime.a jnidummy.c.o

on linux

/usr/bin/ar: ar x /src/onnx-mlir/buildr/Release/lib/libjniruntime.a jnidummy.c.o

on windows when run --emitjni, it only replace ar with lib, but this is wrong. file name are also wrong, should be jniruntime.lib and jnidummy.c.obj.

This is detail output of --EmitJNI on windows

D:\onnx\onnx-mlir\build\Release\bin>onnx-mlir.exe --EmitJNI -v add.onnx
The ONNX model has 0 elements in its initializers. This value would be close to and greater than the number of parameters in the model. Because there is no way to exactly count the number of parameters, this value can be used to have a rough idea of the number of parameters in the model.
[D:\onnx\onnx-mlir\build\Release\bin\]D:/onnx/llvm-project/build/bin/opt.exe: opt.exe -O0 --mtriple=x86_64-pc-windows-msvc --code-model small -o add.bc add.unoptimized.bc
[D:\onnx\onnx-mlir\build\Release\bin\]D:/onnx/llvm-project/build/bin/llc.exe: llc.exe -O0 --mtriple=x86_64-pc-windows-msvc --code-model small -filetype=obj -relocation-model=pic -o add.obj add.bc
[D:\onnx\onnx-mlir\build\Release\bin\.]C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/lib.exe: lib.exe x D:\onnx\onnx-mlir\build\Release\lib/libjniruntime.a jnidummy.c.o
Microsoft (R) Library Manager Version 14.37.32824.0
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : fatal error LNK1181: 无法打开输入文件“x”
lib.exe x D:\onnx\onnx-mlir\build\Release\lib/libjniruntime.a jnidummy.c.o
Error message:
Program path: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/lib.exe
Command execution failed.

compare with linux , --EmitJNI is ok

[root@uos-compiler bin]# ./onnx-mlir --EmitJNI -v mnist.onnx
The ONNX model has 26506 elements in its initializers. This value would be close to and greater than the number of parameters in the model. Because there is no way to exactly count the number of parameters, this value can be used to have a rough idea of the number of parameters in the model.
[/src/onnx-mlir/buildr/Release/bin/]/src/llvm-project/build/bin/opt: opt -O0 --mtriple=x86_64-unknown-linux-gnu --code-model small -o mnist.bc mnist.unoptimized.bc
[/src/onnx-mlir/buildr/Release/bin/]/src/llvm-project/build/bin/llc: llc -O0 --mtriple=x86_64-unknown-linux-gnu --code-model small -filetype=obj -relocation-model=pic -o mnist.o mnist.bc
[/src/onnx-mlir/buildr/Release/bin/.]/usr/bin/ar: ar x /src/onnx-mlir/buildr/Release/lib/libjniruntime.a jnidummy.c.o
[/src/onnx-mlir/buildr/Release/bin/]/usr/local/bin/c++: c++ -z noexecstack mnist.o ./jnidummy.c.o -o ./libmodel.so -shared -fPIC -L/src/onnx-mlir/buildr/Release/lib -ljniruntime -lcruntime
[/src/onnx-mlir/buildr/Release/bin/]/usr/bin/jar: jar uf mnist.jar -C . libmodel.so
JNI archive mnist.jar has been compiled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions