google / souper

A superoptimizer for LLVM IR
Apache License 2.0
2.13k stars 170 forks source link

building for m1 #868

Open liamsemeria opened 1 year ago

liamsemeria commented 1 year ago

I've been trying to build souper locally on my m1 MacBook. Originally Alive2 wasn't working so I updated the ALive2 repo from what is currently used to the most recent Alive2 version on its master branch. Now that it works I passed the cmake step.

(base) Liam@macbook-pro-76 souper_build % cmake -DCMAKE_BUILD_TYPE=$buildtype .. -- Alive2 IR -- Alive2 SMT -- Alive2 TOOLS -- Alive2 UTIL -- Z3 shared lib: /Users/Liam/Desktop/Projects/research/souper/third_party/z3-install/lib/libz3.dylib -- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) -- Configuring done (0.2s) -- Generating done (0.1s) -- Build files have been written to: /Users/Liam/Desktop/Projects/research/souper/souper_build (base) Liam@macbook-pro-76 souper_build % make [ 9%] Built target kleeExpr [ 11%] Built target souperCodegen [ 12%] Built target souperKVStore [ 14%] Built target souperInst [ 16%] Built target souperParser [ 22%] Built target souperInfer [ 26%] Built target souperExtractor [ 28%] Built target souperSMTLIB2 [ 30%] Built target souperTool [ 53%] Built target souperPass [ 76%] Linking CXX shared library libsouperPassProfileAll.dylib ld: warning: -undefined dynamic_lookup may not work with chained fixups ld: warning: ignoring file /Users/Liam/Desktop/Projects/research/souper/third_party/hiredis-install/lib/libhiredis.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 [ 76%] Built target souperPassProfileAll [ 77%] Building CXX object CMakeFiles/souper.dir/tools/souper.cpp.o [ 78%] Linking CXX executable souper ld: library not found for -lzstd clang: error: linker command failed with exit code 1 (use -v to see invocation)

make[2]: [souper] Error 1 make[1]: [CMakeFiles/souper.dir/all] Error 2 make: *** [all] Error 2

In a make call earlier I got this message:

[ 53%] Linking CXX shared library libsouperPass.dylib ld: warning: -undefined dynamic_lookup may not work with chained fixups ld: warning: ignoring file /Users/Liam/Desktop/Projects/research/souper/third_party/hiredis-install/lib/libhiredis.a, building for macOS-x86_64 but attempting to link with file built for macOS-arm64 [ 53%] Built target souperPass

Has anyone built souper locally on m1? If so have you encountered this issue? Thanks

regehr commented 1 year ago

hi, you can't just update Alive2 yourself, we patch it and use internal APIs. I don't know that any of us currently uses Souper on a Mac but let's wait for @manasij7479 to do the Alive2 update and then I'll see if I can make it work

radhika1601 commented 1 year ago

Hello, I was trying to build on Mac M1 and encountered a similar issue with make. However, I did not have to install Alive2 manually (just installed a dependency r2ec). To remove the hiredis warning, I ran the command make in third_party/hiredis which created hiredis.dylib and moved it to hiredis-installer/lib.

For lzstd, I found that the Library_path was not correct for me. The library was in /opt/homebrew/lib. I passed it before cmake and make using LIBRARY_PATH=$path_to_libzstd.

However, when running make check 611 tests fail.