getsentry / sentry-native

Sentry SDK for C, C++ and native applications.
MIT License
403 stars 170 forks source link

Can not compile breakpad for ios #682

Closed zhaowq32 closed 2 years ago

zhaowq32 commented 2 years ago

compile error

/Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/common/mac/bootstrap_compat.h:33:10: fatal error: 'servers/bootstrap.h' file not found
#include <servers/bootstrap.h>
         ^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/bootstrap_compat.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/common/mac/MachIPC.mm:34:
/Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/common/mac/MachIPC.h:39:9: fatal error: In file included from /Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/client/mac/crash_generation/crash_generation_client.cc:30:
In file included from /Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/client/mac/crash_generation/crash_generation_client.h:33:
'servers/bootstrap.h'/Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/common/mac/MachIPC.h :file39 :not9 :found
fatal error: 'servers/bootstrap.h' file not found

cmake command

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode -DCMAKE_ASM_FLAGS=-fembed-bitcode -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=armv7 -DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 -DSENTRY_BUILD_TESTS=OFF -DSENTRY_BUILD_EXAMPLES=OFF -DSENTRY_BUILD_SHARED_LIBS=OFF -DSENTRY_BUILD_EXAMPLES=OFF -DSENTRY_BACKEND=breakpad -DSENTRY_TRANSPORT=curl -DCURL_INCLUDE_DIR=/Users/xxx/Develope/Tools/Library/ios/libcurl/include -DCURL_LIBRARY=/Users/xxx/Develope/Tools/Library/ios/libcurl/lib/libcurl.a -DCMAKE_INSTALL_PREFIX=/Users/xxx/Develope/PublicCodes/sentry-native/build/dest ..

Environment

Steps To Reproduce

cd sentry_native
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode -DCMAKE_ASM_FLAGS=-fembed-bitcode -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_ARCHITECTURES=armv7 -DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 -DSENTRY_BUILD_TESTS=OFF -DSENTRY_BUILD_EXAMPLES=OFF -DSENTRY_BUILD_SHARED_LIBS=OFF -DSENTRY_BUILD_EXAMPLES=OFF -DSENTRY_BACKEND=breakpad -DSENTRY_TRANSPORT=curl -DCURL_INCLUDE_DIR=/Users/xxx/Develope/Tools/Library/ios/libcurl/include -DCURL_LIBRARY=/Users/xxx/Develope/Tools/Library/ios/libcurl/lib/libcurl.a -DCMAKE_INSTALL_PREFIX=/Users/xxx/Develope/PublicCodes/sentry-native/build/dest ..
make -j

Log output

-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- SENTRY_TRANSPORT=curl
-- SENTRY_BACKEND=breakpad
-- SENTRY_LIBRARY_TYPE=STATIC
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of long
-- Check size of long - done
-- Found CURL: /Users/xxx/Develope/Tools/Library/ios/libcurl/lib/libcurl.a (found version "7.78.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/xxx/Develope/PublicCodes/sentry-native/build
+ make -j
[  8%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/string_conversion.cc.o
[  8%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/convert_UTF.cc.o
[ 10%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/md5.cc.o
[ 10%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/file_id.cc.o
[ 10%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/macho_utilities.cc.o
[ 12%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/macho_id.cc.o
[ 16%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/string_utilities.cc.o
[ 16%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/macho_walker.cc.o
[ 18%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/client/minidump_file_writer.cc.o
[ 20%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/client/mac/handler/breakpad_nlist_64.cc.o
[ 22%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/client/mac/handler/dynamic_images.cc.o
[ 24%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/client/mac/handler/exception_handler.cc.o
[ 26%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/client/mac/handler/minidump_generator.cc.o
[ 28%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/MachIPC.mm.o
[ 30%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/common/mac/bootstrap_compat.cc.o
[ 32%] Building CXX object external/CMakeFiles/breakpad_client.dir/breakpad/src/client/mac/crash_generation/crash_generation_client.cc.o
In file included from /Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/common/mac/bootstrap_compat.cc:30:
/Users/xxx/Develope/PublicCodes/sentry-native/external/breakpad/src/common/mac/bootstrap_compat.h:33:10: fatal error: 'servers/bootstrap.h' file not found
Swatinem commented 2 years ago

Hi!

Thanks for the report. We added experimental support for this some time ago indeed. But it seems the README is a bit out of sync, as we are not testing the breakpad backend in CI, but rather the inproc backend, which at least builds fine.

zhaowq32 commented 2 years ago

I found a solution.The reason for the problem is because cmake cannot recognize the IOS variable.Setting CMAKE_SYSTEM_NAME to IOS solved the problem.

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS=-fembed-bitcode -DCMAKE_CXX_FLAGS=-fembed-bitcode -DCMAKE_ASM_FLAGS=-fembed-bitcode -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_ARCHITECTURES=i386 -DCMAKE_OSX_DEPLOYMENT_TARGET=9.0 -DSENTRY_BUILD_TESTS=OFF -DSENTRY_BUILD_EXAMPLES=OFF -DSENTRY_BUILD_SHARED_LIBS=OFF -DSENTRY_BUILD_EXAMPLES=OFF -DSENTRY_BACKEND=breakpad -DSENTRY_TRANSPORT=curl -DCURL_INCLUDE_DIR=/Users/xxx/Develope/Tools/Library/ios/libcurl/include -DCURL_LIBRARY=/Users/xxx/Develope/Tools/Library/ios/libcurl/lib/libcurl.a -DCMAKE_INSTALL_PREFIX=/Users/xxx/Develope/PublicCodes/sentry-native/build/dest -DCMAKE_SYSTEM_NAME=IOS ..
Swatinem commented 2 years ago

Oh, thats good to hear. Does that mean we can close this issue?

zhaowq32 commented 2 years ago

The cmakelists.txt file is missing some files. I will submit a PR.

zhaowq32 commented 2 years ago

It has been compiled normally by modifying cmakelists.txt. But it crashes when calling sentry_init.