Hi, it'd be great if ONNX Runtime was available through Homebrew on Mac.
I submitted a formula (https://github.com/Homebrew/homebrew-core/pull/43500) and it's working on Mojave (10.14) and High Sierra (10.13), but failing on Sierra (10.12) with:
[ 5%] Building CXX object external/protobuf/cmake/CMakeFiles/libprotobuf.dir/__/src/google/protobuf/io/zero_copy_stream.cc.o
<instantiation>:115:27: error: cannot use base register with variable reference
mov rbp,QWORD PTR _MlasMaskMoveAvx@GOTPCREL[rip]
^
/tmp/onnxruntime-20190827-79574-11wk5rl/onnxruntime/core/mlas/lib/x86_64/SgemmKernelAvx.S:557:9: note: while in macro instantiation
SgemmKernelAvxFunction Zero
^
Link: https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/47230/version=sierra/testReport/junit/brew-test-bot/sierra/install___build_bottle_onnxruntime/
Any ideas how to resolve this build error?
@tracysh Any idea?
I'm "fixing" this now. I see in Compiler Explorer at gcc.godbolt.org that clang 5.0 isn't happy with the @GOTPCREL notation for some reason. I had put that in for -fPIC usage a few months ago, but a better way to fix this is by marking the globals accessed in assembly as visiblity("hidden") explicitly so that users that link the ORT libraries into their own shared library don't hit link errors. I'm working on a change for this now and will resolve this issue when that is submitted.
Thanks for the quick responses. Will sit tight and run the tests again when it's landed.
The changes have been merged. The @GOTPCREL syntax is no longer used. I can't be certain though that clang 5.0 won't have other issues that may or may not be worth addressing.
Thanks @tracysh, it fixed that error. Now seeing a different one:
[ 6%] Building ASM object CMakeFiles/onnxruntime_mlas.dir/tmp/onnxruntime-20190828-75996-hb0b9z/onnxruntime/core/mlas/lib/x86_64/SgemmKernelAvx.S.o
<instantiation>:116:40: error: cannot use base register with variable reference
vpcmpgtd xmm1,xmm0,XMMWORD PTR _MlasMaskMoveAvx[rip+16]
I'm not super familiar with compilers, but fwiw, looks like it's running clang 9.
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
Link: https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/47282/version=sierra/testReport/brew-test-bot/sierra/install___build_bottle_onnxruntime/
clang 5.0 apparently only works if the syntax is:
vpcmpgtd xmm1,xmm0,XMMWORD PTR [C_UNDERSCORE(MlasMaskMoveAvx)+rip+16]
The C_UNDERSCORE stuff needs to be inside the brackets instead. This form seems to work with gcc/clang, but I only tried this from Compiler Explorer.
You could try making just that change and see if the build has any other issues.
Made the change and hit another error.
[ 6%] Building ASM object CMakeFiles/onnxruntime_mlas.dir/tmp/onnxruntime-20190829-92727-1inevjs/onnxruntime/core/mlas/lib/x86_64/SpoolKernelAvx.S.o
<instantiation>:3:23: error: expected a positive immediate displacement before bracketed expr.
mov DWORD PTR .LSpoolKernelFrame_BroadcastValue[rsp],0xFF7FFFFF
If you think it'd help, I can try switching to GCC 9. I tried this yesterday as well but ran into the error that was fixed earlier today.
Sorry, it's not going to be practical to change all of the kernels just for this older toolset. If you can try to upgrade to a newer compiler (even something based on clang 6.0 instead), then you should have more success.
Makes sense. Thanks for your help on this. Will try it with gcc 9.2.
Hey @tracysh, sorry for all the back and forth. I tried with gcc 9.2 and got:
[ 6%] Building ASM object CMakeFiles/onnxruntime_mlas.dir/tmp/onnxruntime-20190829-92818-1hqia8n/onnxruntime/core/mlas/lib/x86_64/SgemmKernelAvx.S.o
Generating symbol file for ['cpu']
VERSION:0.5.0
[ 6%] Built target onnxruntime_generate_def
<instantiation>:116:40: error: cannot use base register with variable reference
vpcmpgtd xmm1,xmm0,XMMWORD PTR _MlasMaskMoveAvx[rip+16]
From what I can tell from the build docs, it looks like the library should work with gcc >= 5 (at least on Linux). Any idea why it would be failing with the latest gcc on Mac?
Link: https://jenkins.brew.sh/job/Homebrew%20Core%20Pull%20Requests/47304/version=sierra/testReport/brew-test-bot/sierra/install___build_bottle_onnxruntime/
@ankane: The error still looks like something that came from the clang assembler, not the GNU assembler. Seems like there is some compatibility code in gcc to invoke the system assembler because the stock GNU assembler is too old: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80782. Maybe either try updating binutils to pick up a newer assembler or maybe just use a newer clang on this system instead?
I can confirm mlas works with gcc 4.8 and 9.1. I haven't tested 9.2, but I guess it should work.
The build logs in the link above make it seem like it's using the ASM assembler, but agree something seems off.
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
...
-- The ASM compiler identification is GNU
-- Found assembler: /usr/local/Homebrew/Library/Homebrew/shims/mac/super/gcc-9
I think I'll just wait until Homebrew drops support for Sierra to revisit. I appreciate all the help from you both (I'm sure you spent more time on this than you wanted). Thanks again!
Just fyi, I submitted a new PR to Homebrew now that Sierra is no longer supported. https://github.com/Homebrew/homebrew-core/pull/45659
Just wanted to let you know that the Homebrew PR was accepted, so users can now do:
brew install onnxruntime
:tada:
Most helpful comment
Just wanted to let you know that the Homebrew PR was accepted, so users can now do:
:tada: