Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(100)

Side by Side Diff: build/mac/copy_asan_runtime_dylib.sh

Issue 80603004: Handle both OSX and iOS Simulator runtimes in the ASan postbuild script. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2013 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # For app bundles built with ASan, copies the runtime lib 7 # For app bundles built with ASan, copies the runtime lib
8 # (libclang_rt.asan_osx_dynamic.dylib), on which their executables depend, from 8 # (libclang_rt.asan_osx_dynamic.dylib), on which their executables depend, from
9 # the compiler installation path into the bundle and fixes the dylib's install 9 # the compiler installation path into the bundle and fixes the dylib's install
10 # name in the binary to be relative to @executable_path. 10 # name in the binary to be relative to @executable_path.
11 11
12 set -e 12 set -e
13 13
14 BINARY="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" 14 BINARY="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}"
15
16 if [[ ! -f "$BINARY" ]]; then
17 # This is neither an .app bundle nor a standalone executable.
18 # Most certainly the script has been called for a data bundle.
19 exit 0
20 fi
21
15 BINARY_DIR="$(dirname "${BINARY}")" 22 BINARY_DIR="$(dirname "${BINARY}")"
16 ASAN_DYLIB_NAME=libclang_rt.asan_osx_dynamic.dylib 23
24 # Find the link to the ASan runtime encoded in the binary.
25 BUILTIN_DYLIB_PATH=$(otool -L "${BINARY}" | \
26 sed -Ene 's/^[[:blank:]]+(.*libclang_rt\.asan_.*_dynamic\.dylib).*$/\1/p')
27
28 if [[ "${BUILTIN_DYLIB_PATH}" == *asan_iossim_dynamic* ]]; then
29 ASAN_DYLIB_NAME=libclang_rt.asan_iossim_dynamic.dylib
30 elif [[ "${BUILTIN_DYLIB_PATH}" == *asan_osx_dynamic* ]]; then
31 ASAN_DYLIB_NAME=libclang_rt.asan_osx_dynamic.dylib
32 fi
33
34 if [[ -z "${BUILTIN_DYLIB_PATH}" ]]; then
35 echo "${BINARY} does not depend on the ASan runtime library!" >&2
36 exit 1
37 fi
38
39 # TODO(glider): this doesn't work if we set CC and CXX to override the default
40 # Clang.
17 ASAN_DYLIB=$(find \ 41 ASAN_DYLIB=$(find \
18 "${BUILT_PRODUCTS_DIR}/../../third_party/llvm-build/Release+Asserts/lib/clan g/" \ 42 "${BUILT_PRODUCTS_DIR}/../../third_party/llvm-build/Release+Asserts/lib/clan g/" \
19 -type f -path "*${ASAN_DYLIB_NAME}") 43 -type f -path "*${ASAN_DYLIB_NAME}")
20 44
21 # Find the link to the ASan runtime encoded in the binary.
22 BUILTIN_DYLIB_PATH=$(otool -L "${BINARY}" | \
23 sed -Ene 's/^[[:blank:]]+(.*libclang_rt\.asan_osx_dynamic\.dylib).*$/\1/p')
24
25 if [[ -z "${BUILTIN_DYLIB_PATH}" ]]; then
26 echo "${BINARY} does not depend on the ASan runtime library!" >&2
27 # TODO(glider): make this return 1 when we fully switch to the dynamic
28 # runtime in ASan.
29 exit 0
30 fi
31
32 DYLIB_BASENAME=$(basename "${ASAN_DYLIB}") 45 DYLIB_BASENAME=$(basename "${ASAN_DYLIB}")
33 if [[ "${DYLIB_BASENAME}" != "${ASAN_DYLIB_NAME}" ]]; then 46 if [[ "${DYLIB_BASENAME}" != "${ASAN_DYLIB_NAME}" ]]; then
34 echo "basename(${ASAN_DYLIB}) != ${ASAN_DYLIB_NAME}" >&2 47 echo "basename(${ASAN_DYLIB}) != ${ASAN_DYLIB_NAME}" >&2
35 exit 1 48 exit 1
36 fi 49 fi
37 50
38 # Check whether the directory containing the executable binary is named 51 # Check whether the directory containing the executable binary is named
39 # "MacOS". In this case we're building a full-fledged OSX app and will put 52 # "MacOS". In this case we're building a full-fledged OSX app and will put
40 # the runtime into appname.app/Contents/Libraries/. Otherwise this is probably 53 # the runtime into appname.app/Contents/Libraries/. Otherwise this is probably
41 # an iOS gtest app, and the ASan runtime is put next to the executable. 54 # an iOS gtest app, and the ASan runtime is put next to the executable.
(...skipping 12 matching lines...) Expand all
54 # Make LC_ID_DYLIB of the runtime copy point to its location. 67 # Make LC_ID_DYLIB of the runtime copy point to its location.
55 install_name_tool \ 68 install_name_tool \
56 -id "${NEW_LC_ID_DYLIB}" \ 69 -id "${NEW_LC_ID_DYLIB}" \
57 "${LIBRARIES_DIR}/${ASAN_DYLIB_NAME}" 70 "${LIBRARIES_DIR}/${ASAN_DYLIB_NAME}"
58 71
59 # Fix the rpath to the runtime library recorded in the binary. 72 # Fix the rpath to the runtime library recorded in the binary.
60 install_name_tool \ 73 install_name_tool \
61 -change "${BUILTIN_DYLIB_PATH}" \ 74 -change "${BUILTIN_DYLIB_PATH}" \
62 "${NEW_LC_ID_DYLIB}" \ 75 "${NEW_LC_ID_DYLIB}" \
63 "${BINARY}" 76 "${BINARY}"
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698