How to build libfuzzer for iossim?

47 views Asked by At

I built an iOS app demo on my Mac using Xcode and now I want to fuzz it with LibFuzzer. After reading the LibFuzzer documentation, I found that it has a feature to use LibFuzzer as a library. However, when I modified my code and tried to link libclang_rt.fuzzer_no_main_osx.a, I encountered an error:

In /usr/local/Cellar/llvm/16.0.6/lib/clang/16/lib/darwin/libclang_rt.fuzzer_no_main_osx.a(FuzzerCrossOver.cpp.o), 
building for iOS Simulator, but linking in object file built for macOS,
file '/usr/local/Cellar/llvm/16.0.6/lib/clang/16/lib/darwin/libclang_rt.fuzzer_no_main_osx.a' for architecture x86_64

From my understanding, I need to specify the target architecture as iossim when compiling compiler-rt to obtain the corresponding library: libclang_rt.fuzzer_no_main_iossim.a. I'm not sure about the specific terminal command for this( Beginner to this area. T^T). I'm hoping to get some help here.

I tried to input those in the /llvm-project/compiler-rt/build-iossim:

$ cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=../../llvm/cmake/platforms/iOS.cmake ../

However, I get errors:

-- Using C compiler /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Using C++ compiler /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
CMake Error at CMakeLists.txt:38 (include):
  include could not find requested file:

    SetPlatformToolchainTools


CMake Error at cmake/base-config-ix.cmake:10 (include):
  include could not find requested file:

    ExtendPath
Call Stack (most recent call first):
  CMakeLists.txt:39 (include)


CMake Error at cmake/base-config-ix.cmake:110 (extend_path):
  Unknown CMake command "extend_path".
Call Stack (most recent call first):
  CMakeLists.txt:39 (include)


-- Configuring incomplete, errors occurred!
0

There are 0 answers