Building crashpad for deployment target 10.9 / C++11

409 views
Skip to first unread message

tan...@gmail.com

unread,
Mar 27, 2015, 8:36:34 AM3/27/15
to crashp...@chromium.org
Hello,

the previous thread about using crashpad as a breakpad replacement had some useful hints, but I still cannot get crashpad linked correctly into our application. I also had that problem about _audit_token_to_pid not being defined. Setting the deployment target to 10.7 fixed that but introduced loads of errors about libbase not finding various std::string members. To me, that smells of libc++ - our project is built with -stdlib=libc++ and -std=c++11. So I changed the deployment target to 10.9 to make crashpad use the llvm standard library and passed -Dmac_sdk=10.9. Unfortunately, the linker is now complaining about _audit_token_to_pid again.

The (cleaned) linker call looks like this:

/usr/bin/c++    -mmacosx-version-min=10.9 -stdlib=libc++ -std=c++11 -Wall -Wextra -Wno-unused-parameter -Woverloaded-virtual -std=c++11 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -o [...] -framework Foundation -framework AppKit -framework ApplicationServices [...]/crashpad/out/Release/libcrashpad_client.a [...]/crashpad/out/Release/libbase.a [...]/crashpad/out/Release/libcrashpad_util.a -framework IOKit -framework Security

Do I need to explicitly tell crashpad to use libc++ or might something else be going wrong here?

Side note:
As we're using cmake, I tried generating a cmake file for crashpad using gyp as I don't really know ninja. Trying to build that I ended up like this:
-- Configuring done
CMake Error at CMakeLists.txt:1003 (add_library):
  Cannot find source file:

    $(SDKROOT)/usr/include/mach/exc.defs

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error at CMakeLists.txt:335 (add_library):
  Cannot find source file:

    ../../third_party/mini_chromium/mini_chromium/base/base/atomicops.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx


CMake Error: Cannot determine link language for target "crashpad_util".
CMake Error: CMake can not determine linker language for target: crashpad_util
CMake Error: Cannot determine link language for target "third_party_mini_chromium_mini_chromium_base_base_gyp_base".
CMake Error: CMake can not determine linker language for target: third_party_mini_chromium_mini_chromium_base_base_gyp_base
-- Generating done
Message has been deleted

Mark Mentovai

unread,
Mar 27, 2015, 10:59:19 AM3/27/15
to tan...@gmail.com, crashp...@chromium.org

the previous thread about using crashpad as a breakpad replacement had some useful hints, but I still cannot get crashpad linked correctly into our application. I also had that problem about _audit_token_to_pid not being defined. Setting the deployment target to 10.7 fixed that but introduced loads of errors about libbase not finding various std::string members. To me, that smells of libc++ - our project is built with -stdlib=libc++ and -std=c++11. So I changed the deployment target to 10.9 to make crashpad use the llvm standard library and passed -Dmac_sdk=10.9. Unfortunately, the linker is now complaining about _audit_token_to_pid again.

Set the deployment target to the minimum OS version that you intend to support at runtime. If you set the deployment target too high, Crashpad won’t work properly on earlier systems. It’s critical to set this correctly.

The compiler driver will choose a C++ runtime library based on the deployment target you’ve chosen. If the deployment target is 10.9 or higher, this will be libc++. Otherwise, it will be libstdc++. The C++ runtime library needs to match the one used by any other code that’s interfacing with the Crashpad client library. You can overcome the compiler driver’s default, if necessary, by setting the CLANG_CXX_LIBRARY xcode_setting in GYP. The easiest way to do this is to create ~/.gyp/include.gypi with the contents:

{
  'target_defaults': {
    'xcode_settings': {
      'CLANG_CXX_LIBRARY': 'libc++',  # Valid values are libc++ and libstdc++.
    },
  },
}

The new setting will take effect when you run “gclient sync” or “gclient runhooks”. Beware that if you use other projects that use GYP, ~/.gyp/include.gypi will apply to them as well.
 
The (cleaned) linker call looks like this:

/usr/bin/c++    -mmacosx-version-min=10.9 -stdlib=libc++ -std=c++11 -Wall -Wextra -Wno-unused-parameter -Woverloaded-virtual -std=c++11 -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -o [...] -framework Foundation -framework AppKit -framework ApplicationServices [...]/crashpad/out/Release/libcrashpad_client.a [...]/crashpad/out/Release/libbase.a [...]/crashpad/out/Release/libcrashpad_util.a -framework IOKit -framework Security

Do I need to explicitly tell crashpad to use libc++ or might something else be going wrong here?

Side note:
As we're using cmake, I tried generating a cmake file for crashpad using gyp as I don't really know ninja. Trying to build that I ended up like this:
-- Configuring done
CMake Error at CMakeLists.txt:1003 (add_library):
  Cannot find source file:

    $(SDKROOT)/usr/include/mach/exc.defs

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx

The CMake GYP generator must not understand $(SDKROOT) in the context of 'sources', but Crashpad doesn’t actually support building with any combination other than GYP-Ninja. If you wanted to make this work, you’d have to fix third_party/gyp/gyp/pylib/gyp/generator/cmake.py.

CMake Error at CMakeLists.txt:335 (add_library):
  Cannot find source file:

    ../../third_party/mini_chromium/mini_chromium/base/base/atomicops.h

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx

This is an actual bug in third_party/mini_chromium/mini_chromium/base/base.gyp. I’ll fix it.

tan...@gmail.com

unread,
Mar 27, 2015, 1:36:49 PM3/27/15
to crashp...@chromium.org, tan...@gmail.com
Having the confirmation that libc++ is used by default with 10.9 (which is our minimal target at the moment) I noticed your mentioning of libbsm.dylib in that other mail. That one was still missing from my linkage. Now Crashpad initializes without errors but doesn't seem to do much yet. Looks like I'll have to dig further through the other thread. :)
Reply all
Reply to author
Forward
0 new messages