eurecom-s3 / symcc

SymCC: efficient compiler-based symbolic execution
http://www.s3.eurecom.fr/tools/symbolic_execution/symcc.html
GNU General Public License v3.0
773 stars 135 forks source link

Compilation on macOS #38

Closed rindPHI closed 3 years ago

rindPHI commented 3 years ago

Dear all,

I'd love to experiment a little with your implementation, but am currently struggling with getting the project compiled on macOS. What happens:

Everything works until ninja check, then I first get the error ld: unknown option: -z. I "solve" this my changing build.ninja, by removing -z, in line 107. Now the process proceeds further, but I get a number of new errors:

[1/5] Linking CXX shared module libSymbolize.so
FAILED: libSymbolize.so 
: && /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -std=c++17 -Wredundant-decls -Wcast-align -Wmissing-include-dirs -Wswitch-default -Wextra -Wall -Winvalid-pch -Wredundant-decls -Wformat=2 -Wmissing-format-attribute -Wformat-nonliteral -Werror -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -bundle -Wl,-headerpad_max_install_names -Wl,nodelete -o libSymbolize.so CMakeFiles/Symbolize.dir/compiler/Symbolizer.cpp.o CMakeFiles/Symbolize.dir/compiler/Pass.cpp.o CMakeFiles/Symbolize.dir/compiler/Runtime.cpp.o CMakeFiles/Symbolize.dir/compiler/Main.cpp.o   && :
ld: file not found: nodelete

...

[9/21] Building CXX object qsym_backend/CMakeFiles/SymRuntime.dir/qsym/qsym/pintool/solver.cpp.o
FAILED: qsym_backend/CMakeFiles/SymRuntime.dir/qsym/qsym/pintool/solver.cpp.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DSymRuntime_EXPORTS -Isymcc/runtime/qsym_backend -Isymcc/runtime/qsym_backend/.. -isystem /opt/local/libexec/llvm-10/include -isystem /opt/local/include -isystem symcc/runtime/qsym_backend/qsym/qsym/pintool -std=c++17 -Wredundant-decls -Wcast-align -Wmissing-include-dirs -Wswitch-default -Wextra -Wall -Winvalid-pch -Wredundant-decls -Wformat=2 -Wmissing-format-attribute -Wformat-nonliteral -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -fPIC   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT qsym_backend/CMakeFiles/SymRuntime.dir/qsym/qsym/pintool/solver.cpp.o -MF qsym_backend/CMakeFiles/SymRuntime.dir/qsym/qsym/pintool/solver.cpp.o.d -o qsym_backend/CMakeFiles/SymRuntime.dir/qsym/qsym/pintool/solver.cpp.o -c symcc/runtime/qsym_backend/qsym/qsym/pintool/solver.cpp
symcc/runtime/qsym_backend/qsym/qsym/pintool/solver.cpp:2:10: fatal error: 'byteswap.h' file not found
#include <byteswap.h>
         ^~~~~~~~~~~~

...

[11/21] Building CXX object qsym_backend/CMakeFiles/SymRuntime.dir/__/LibcWrappers.cpp.o
FAILED: qsym_backend/CMakeFiles/SymRuntime.dir/__/LibcWrappers.cpp.o 
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -DSymRuntime_EXPORTS -Isymcc/runtime/qsym_backend -Isymcc/runtime/qsym_backend/.. -isystem /opt/local/libexec/llvm-10/include -isystem /opt/local/include -isystem symcc/runtime/qsym_backend/qsym/qsym/pintool -std=c++17 -Wredundant-decls -Wcast-align -Wmissing-include-dirs -Wswitch-default -Wextra -Wall -Winvalid-pch -Wredundant-decls -Wformat=2 -Wmissing-format-attribute -Wformat-nonliteral -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -fPIC   -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -MD -MT qsym_backend/CMakeFiles/SymRuntime.dir/__/LibcWrappers.cpp.o -MF qsym_backend/CMakeFiles/SymRuntime.dir/__/LibcWrappers.cpp.o.d -o qsym_backend/CMakeFiles/SymRuntime.dir/__/LibcWrappers.cpp.o -c symcc/runtime/LibcWrappers.cpp
symcc/runtime/LibcWrappers.cpp:97:18: error: use of undeclared identifier 'mmap64'; did you mean 'mmap'?
  auto *result = mmap64(addr, len, prot, flags, fildes, off);
                 ^~~~~~
                 mmap
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/sys/mman.h:238:9: note: 'mmap' declared here
void *  mmap(void *, size_t, int, int, int, off_t) __DARWIN_ALIAS(mmap);
        ^
symcc/runtime/LibcWrappers.cpp:165:17: error: use of undeclared identifier 'lseek64'; did you mean 'lseek'?
  auto result = lseek64(fd, offset, whence);
                ^~~~~~~
                lseek
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/unistd.h:465:8: note: 'lseek' declared here
off_t    lseek(int, off_t, int);
         ^
symcc/runtime/LibcWrappers.cpp:211:18: error: use of undeclared identifier 'fopen64'; did you mean 'fopen'?
  auto *result = fopen64(pathname, mode);
                 ^~~~~~~
                 fopen
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include/stdio.h:153:7: note: 'fopen' declared here
FILE    *fopen(const char * __restrict __filename, const char * __restrict __mode) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fopen));
         ^
3 errors generated.

as well as a couple of warnings I won't post.

Anybody has any idea about how to proceed? Thanks!!! :)

vanhauser-thc commented 3 years ago

as you are on Mac OS - where does your clang come from? Xcode and brew are not good sources as these are cripplied. I highly recommend you compile your own llvm.

rindPHI commented 3 years ago

I took my clang from MacPorts... Think I'll better set up an Ubuntu VM before I spent more time on compiling different libraries, who knows what comes after ;) But if anyone ever manages to build symcc on a Mac, I'd anyway appreciate updated instructions with lists of caveats. VMs are nice, but it's even nicer if things work just without them. Thanks!

sebastianpoeplau commented 3 years ago

Hi @rindPHI,

The initial error sounds as if your linker didn't support some of the options that CMake is setting. (build.ninja is generated by CMake.) It seems that, even if you have Clang from MacPorts on your system, the compiler that you're using is the system's Clang, which in turn calls the system's default linker. You could try to export CXX=/your/macports/clang and CXXFLAGS="-use-ld=lld" to force use of the MacPorts compiler and linker.

The other errors, however, look as if the code needed some adjustments to compile on MacOS. I believe the 64-bit variants of those library functions are particularities of glibc, and the missing header might just not exist on a Mac. Unfortunately, I don't have one to test with...