onnx-mlir icon indicating copy to clipboard operation
onnx-mlir copied to clipboard

cmake build broken on Mac

Open etiotto opened this issue 2 years ago • 4 comments

The latest version of onnx-mlir can no longer build cleanly on Mac using ninja. This is the error:

CMake Error:
  Running

   '/usr/local/bin/ninja' '-C' '/Users/[email protected]/Source/onnx/onnx-mlir/build' '-t' 'recompact'

  failed with:

   ninja: error: build.ninja:3419: bad $-escape (literal $ must be written as $$)

I believe the error stems from the following line in zdnn.cmake:

    BUILD_COMMAND sh -c "MAKEFLAGS=--no-print-directory \
                      make -j$(nproc) -C zdnn lib/libzdnn.so && \
                      ar -rc ${ZDNN_LIBDIR}/libzdnn.a ${ZDNN_OBJDIR}/*.o"

etiotto avatar Apr 18 '22 17:04 etiotto

@gongsu832 should -j$(nproc) be -j${nproc} ?

etiotto avatar Apr 18 '22 17:04 etiotto

nproc is not a command on Mac. -j${nproc} needs variable nproc to be set. Not sure why you are trying to build zdnn on Mac. It's not meant to be built on anything other than zLinux and z/OS.

gongsu832 avatar Apr 19 '22 01:04 gongsu832

@gongsu832 I am aware that the ZDNN library isn't meant to be built on Mac and I wasn't intentionally attempting to build it. What I did was to pull the latest code, configure the project as I usually do (with NNPA support given I want to run the lit tests for the accelerator):

$CMAKE -GNinja -DCMAKE_BUILD_TYPE=Debug \
   -DCMAKE_C_COMPILER=$C_COMPILER \
   -DCMAKE_CXX_COMPILER=$CXX_COMPILER \
   -DCMAKE_VERBOSE_MAKEFILE=true \
   -DACCELERATORS_TO_BUILD="NNPA" \
   -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..

cmake failed with:

-- Accelerators             : NNPAAccel
-- Parallel backend tests   : ON
-- JNI backend tests        : ON
-- JSONITER_JAR             : /Users/[email protected]/Source/onnx/onnx-mlir/build/src/Runtime/jni/jsoniter/jsoniter-0.9.23.jar
-- Configuring done
-- Generating done
CMake Error:
  Running

   '/usr/local/bin/ninja' '-C' '/Users/[email protected]/Source/onnx/onnx-mlir/build' '-t' 'recompact'

  failed with:

   ninja: error: build.ninja:3419: bad $-escape (literal $ must be written as $$)

  



CMake Generate step failed.  Build files cannot be regenerated correctly.

etiotto avatar Apr 20 '22 15:04 etiotto

I built on Mac natively with cmake. For the new onnx, I need to specify where my python is:

cmake -DPYTHON_EXECUTABLE:FILEPATH=/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -DPYTHON_LIBRARIES=/Library/Frameworks/Python.framework/Versions/3.8/lib/libpython3.8.dylib ..

Not sure whether this is related to your issue.

chentong319 avatar May 11 '22 00:05 chentong319