minidump_stackwalk.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/bin/bash
  2. #
  3. # This script builds minidump_stackwalk binaries from the Google Breakpad
  4. # source for all of the operating systems that we run Firefox tests on:
  5. # Linux x86, Linux x86-64, Windows x86, OS X x86-64.
  6. #
  7. # It expects to be run in the luser/breakpad-builder:0.7 Docker image and
  8. # needs access to the relengapiproxy to download internal tooltool files.
  9. set -v -e -x
  10. # This is a pain to support properly with gclient.
  11. #: BREAKPAD_REPO ${BREAKPAD_REPO:=https://google-breakpad.googlecode.com/svn/trunk/}
  12. : BREAKPAD_REV "${BREAKPAD_REV:=master}"
  13. : STACKWALK_HTTP_REPO "${STACKWALK_HTTP_REPO:=https://hg.mozilla.org/users/tmielczarek_mozilla.com/stackwalk-http}"
  14. : STACKWALK_HTTP_REV "${STACKWALK_HTTP_REV:=default}"
  15. ncpu=$(getconf _NPROCESSORS_ONLN)
  16. function build()
  17. {
  18. cd /tmp
  19. local platform=$1
  20. local strip_prefix=$2
  21. local configure_args=$3
  22. local make_args=$4
  23. local objdir=/tmp/obj-breakpad-$platform
  24. local ext=
  25. if test "$platform" = "win32"; then
  26. ext=.exe
  27. fi
  28. rm -rf "$objdir"
  29. mkdir "$objdir"
  30. # First, build Breakpad
  31. cd "$objdir"
  32. # shellcheck disable=SC2086
  33. CFLAGS="-O2 $CFLAGS" CXXFLAGS="-O2 $CXXFLAGS" /tmp/breakpad/src/configure --disable-tools $configure_args
  34. # shellcheck disable=SC2086
  35. make -j$ncpu $make_args src/libbreakpad.a src/third_party/libdisasm/libdisasm.a src/processor/stackwalk_common.o
  36. # Second, build stackwalk-http
  37. make -f /tmp/stackwalk-http/Makefile BREAKPAD_SRCDIR=/tmp/breakpad/src "BREAKPAD_OBJDIR=$(pwd)" "OS=$platform" "-j$ncpu"
  38. "${strip_prefix}strip" "stackwalk${ext}"
  39. cp "stackwalk${ext}" "/tmp/stackwalker/${platform}-minidump_stackwalk${ext}"
  40. }
  41. function linux64()
  42. {
  43. export LDFLAGS="-static-libgcc -static-libstdc++"
  44. build linux64
  45. unset LDFLAGS
  46. }
  47. function linux32()
  48. {
  49. export LDFLAGS="-static-libgcc -static-libstdc++ -L/tmp/libcurl-i386/lib"
  50. export CFLAGS="-m32 -I/tmp/libcurl-i386/include"
  51. export CXXFLAGS="-m32 -I/tmp/libcurl-i386/include"
  52. build linux32 "" "--enable-m32"
  53. unset LDFLAGS CFLAGS CXXFLAGS
  54. }
  55. function macosx64()
  56. {
  57. cd /tmp
  58. if ! test -d MacOSX10.7.sdk; then
  59. python tooltool.py -v --manifest=macosx-sdk.manifest --url=http://relengapi/tooltool/ fetch
  60. fi
  61. export MACOSX_SDK=/tmp/MacOSX10.7.sdk
  62. export CCTOOLS=/tmp/cctools
  63. local FLAGS="-stdlib=libc++ -target x86_64-apple-darwin10 -mlinker-version=136 -B /tmp/cctools/bin -isysroot ${MACOSX_SDK} -mmacosx-version-min=10.7"
  64. export CC="clang $FLAGS"
  65. export CXX="clang++ $FLAGS -std=c++11"
  66. local old_path="$PATH"
  67. export PATH="/tmp/clang/bin:/tmp/cctools/bin/:$PATH"
  68. export LD_LIBRARY_PATH=/usr/lib/llvm-3.6/lib/
  69. build macosx64 "/tmp/cctools/bin/x86_64-apple-darwin10-" "--host=x86_64-apple-darwin10" "AR=/tmp/cctools/bin/x86_64-apple-darwin10-ar"
  70. unset CC CXX LD_LIBRARY_PATH MACOSX_SDK CCTOOLS
  71. export PATH="$old_path"
  72. }
  73. function win32()
  74. {
  75. export LDFLAGS="-static-libgcc -static-libstdc++"
  76. export CFLAGS="-D__USE_MINGW_ANSI_STDIO=1"
  77. export CXXFLAGS="-D__USE_MINGW_ANSI_STDIO=1"
  78. export ZLIB_DIR=/tmp/zlib-mingw
  79. build win32 "i686-w64-mingw32-" "--host=i686-w64-mingw32"
  80. unset LDFLAGS CFLAGS CXXFLAGS ZLIB_DIR
  81. }
  82. cd /tmp
  83. if ! test -d depot_tools; then
  84. git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
  85. else
  86. (cd depot_tools; git pull origin master)
  87. fi
  88. export PATH=$(pwd)/depot_tools:"$PATH"
  89. if ! test -d breakpad; then
  90. mkdir breakpad
  91. pushd breakpad
  92. fetch breakpad
  93. popd
  94. else
  95. pushd breakpad/src
  96. git pull origin master
  97. popd
  98. fi
  99. pushd breakpad/src
  100. git checkout "${BREAKPAD_REV}"
  101. gclient sync
  102. popd
  103. (cd breakpad/src; git rev-parse master)
  104. if ! test -d stackwalk-http; then
  105. hg clone -u "$STACKWALK_HTTP_REV" "$STACKWALK_HTTP_REPO"
  106. else
  107. (cd stackwalk-http && hg pull "$STACKWALK_HTTP_REPO" && hg up "$STACKWALK_HTTP_REV")
  108. fi
  109. mkdir -p stackwalker
  110. linux64
  111. linux32
  112. macosx64
  113. win32