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

Unified Diff: build/mac/copy_asan_runtime_dylib.sh

Issue 11642018: Add a postbuild action for executables built with ASan on Mac OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« build/mac/asan.gyp ('K') | « build/mac/asan.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/mac/copy_asan_runtime_dylib.sh
===================================================================
--- build/mac/copy_asan_runtime_dylib.sh (revision 0)
+++ build/mac/copy_asan_runtime_dylib.sh (revision 0)
@@ -0,0 +1,43 @@
+#!/bin/bash
+
Mark Mentovai 2013/03/06 17:03:19 Copyright boilerplate goes here.
Alexander Potapenko 2013/03/07 08:29:22 Done.
+# For app bundles built with ASan, copies the runtime lib
+# (libclang_rt.asan_osx_dynamic.dylib), on which their executables depend, from
+# the compiler installation path to appname.app/Contents/Resources and fixes the
+# dylib's install name in the binary to be relative to @executable_path.
+
+set -e
+set -x
Mark Mentovai 2013/03/06 17:03:19 set -ex is fine for both of these.
Alexander Potapenko 2013/03/07 08:29:22 I actually don't need -x, it was only used for deb
+
+BINARY="${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}"
+BINARY_DIR="$(dirname "${BINARY}")"
+ASAN_DYLIB_NAME=libclang_rt.asan_osx_dynamic.dylib
+ASAN_DYLIB=$(find \
Mark Mentovai 2013/03/06 17:03:19 Again, this is really hokey. Can we get a fixed pa
Alexander Potapenko 2013/03/07 08:29:22 I'll look into this.
+ "${BUILT_PRODUCTS_DIR}/../../third_party/llvm-build/Release+Asserts/lib/clang/" \
+ -type f -path "*${ASAN_DYLIB_NAME}")
+BUILTIN_DYLIB_PATH=$(otool -L "${BINARY}" | \
+ grep "${ASAN_DYLIB_NAME}" | \
Mark Mentovai 2013/03/06 17:03:19 grep -F to prevent it from being treated as a regu
Alexander Potapenko 2013/03/07 08:29:22 Decided to replace with sed.
+ tr -d '\011' | \
+ sed 's/dylib .*/dylib/')
Mark Mentovai 2013/03/06 17:03:19 Or you can combine the grep, tr, and sed into one
Alexander Potapenko 2013/03/07 08:29:22 Done.
+
+if [ -z "${BUILTIN_DYLIB_PATH}" ]
Mark Mentovai 2013/03/06 17:03:19 1. Use [[ instead of [. 2. Put the “then” on the
Alexander Potapenko 2013/03/07 08:29:22 Done.
+then
+ echo "${BINARY} does not depend on the ASan runtime library!"
Mark Mentovai 2013/03/06 17:03:19 Send this to stderr with >&2. Same on line 32.
Alexander Potapenko 2013/03/07 08:29:22 Done.
+ # TODO(glider): make this return 1 when we fully switch to the dynamic
+ # runtime in ASan.
+ exit 0
+fi
+
+if [ "$(basename ${ASAN_DYLIB})" != "${ASAN_DYLIB_NAME}" ]
Mark Mentovai 2013/03/06 17:03:19 You should put quotes around ${ASAN_DYLIB} here.
Alexander Potapenko 2013/03/07 08:29:22 Done.
+then
+ echo "basename(${ASAN_DYLIB}) != ${ASAN_DYLIB_NAME}"
+ exit 1
+fi
+
+RESOURCES_DIR="$(dirname "${BINARY_DIR}")/Resources"
Mark Mentovai 2013/03/06 17:03:19 This isn’t really a resource and does not belong i
Alexander Potapenko 2013/03/07 08:29:22 Done.
+mkdir -p "${RESOURCES_DIR}"
+cp "${ASAN_DYLIB}" "${RESOURCES_DIR}"
+
+install_name_tool \
Mark Mentovai 2013/03/06 17:03:19 You might as well also change the LC_ID_DYLIB in $
Alexander Potapenko 2013/03/07 08:29:22 Good idea. Done.
+ -change "${BUILTIN_DYLIB_PATH}" \
+ "@executable_path/../Resources/${ASAN_DYLIB_NAME}" \
+ "${BINARY}"
Property changes on: build/mac/copy_asan_runtime_dylib.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
« build/mac/asan.gyp ('K') | « build/mac/asan.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698