summaryrefslogtreecommitdiffstats
path: root/third_party
diff options
context:
space:
mode:
authoralextaran@chromium.org <alextaran@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 13:41:30 +0000
committeralextaran@chromium.org <alextaran@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-12 13:41:30 +0000
commitc8103a492afbb6735ddfc86510f917b5f7c1eee1 (patch)
tree79db92dcef94961a23856b4be51e5fab6d0b6eee /third_party
parent27c0ca61f422dfed5fa86812ca0a6595d53ee916 (diff)
downloadchromium_src-c8103a492afbb6735ddfc86510f917b5f7c1eee1.zip
chromium_src-c8103a492afbb6735ddfc86510f917b5f7c1eee1.tar.gz
chromium_src-c8103a492afbb6735ddfc86510f917b5f7c1eee1.tar.bz2
Adds a flag "use_instrumented_libraries" and corresponding target with 2 simple libraries
BUG=313751 R=glider@chromium.org,thakis@chromium.org TBR=cpu@chromium.org Review URL: https://codereview.chromium.org/50423003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234498 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/instrumented_libraries/README.chromium14
-rwxr-xr-xthird_party/instrumented_libraries/download_build_install.sh138
-rwxr-xr-xthird_party/instrumented_libraries/fix_rpaths.sh22
-rw-r--r--third_party/instrumented_libraries/instrumented_libraries.gyp41
-rw-r--r--third_party/instrumented_libraries/standard_instrumented_library_target.gypi22
5 files changed, 237 insertions, 0 deletions
diff --git a/third_party/instrumented_libraries/README.chromium b/third_party/instrumented_libraries/README.chromium
new file mode 100644
index 0000000..222a25c
--- /dev/null
+++ b/third_party/instrumented_libraries/README.chromium
@@ -0,0 +1,14 @@
+Name: instrumented_libbraries
+URL: n/a
+Version: 0
+Security Critical: no
+License: n/a
+License File: NOT_SHIPPED
+
+Description:
+Scripts which can download and build several third party libraries
+using different instrumentation tools (AddressSanitizer, etc.).
+
+Flag "use_instrumented_libraries=1" in GYP_DEFINES enables usage of
+instrumented libraries and final binary will use them instead of standard
+system shared libraries.
diff --git a/third_party/instrumented_libraries/download_build_install.sh b/third_party/instrumented_libraries/download_build_install.sh
new file mode 100755
index 0000000..150deb3
--- /dev/null
+++ b/third_party/instrumented_libraries/download_build_install.sh
@@ -0,0 +1,138 @@
+#!/bin/bash
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Downloads, builds (with instrumentation) and installs shared libraries.
+
+# Go to this shell script directory
+cd $(dirname "$0")
+
+# Colored print.
+
+RED_COLOR='\e[0;31m'
+GREEN_COLOR='\e[0;32m'
+NO_COLOR='\e[0m'
+
+function echo_red {
+ echo -e "${RED_COLOR}$1${NO_COLOR}"
+}
+
+function echo_green {
+ echo -e "${GREEN_COLOR}$1${NO_COLOR}"
+}
+
+# Default values.
+
+product_dir=$(pwd)
+intermediate_dir=$(pwd)
+
+# Should be without spaces to pass it to dpkg-buildpackage.
+makejobs="-j14"
+
+# Parsing args.
+
+while getopts ":i:l:m:hp:s:j:" opt; do
+ case ${opt} in
+ p)
+ echo_green "Only installing dependencies (requires root access)"
+ echo_green "Installing dependencies for: ${OPTARG}"
+ sudo apt-get -y --no-remove build-dep ${OPTARG}
+ exit
+ ;;
+ h)
+ echo "Possible flags:
+ -p - install dependencies for packages,
+ -h - this help,
+ -l - which library to build,
+ -i - sets relative product_dir,
+ -s - sanitizer (only asan is supported now)."
+ echo "Environment variabless, which affect this script: CC and CXX"
+ exit
+ ;;
+ i)
+ product_dir="$(pwd)/${OPTARG}"
+ ;;
+ l)
+ library="${OPTARG}"
+ ;;
+ m)
+ intermediate_dir="${OPTARG}"
+ ;;
+ j)
+ makejobs="-j${OPTARG}"
+ ;;
+ s)
+ sanitizer_type="${OPTARG}"
+ if [[ "${OPTARG}" == "asan" ]]; then
+ sanitizer_flag_string="address"
+ else
+ echo_red "Invalid sanitizer: ${OPTARG}" >&2
+ exit 1
+ fi
+ ;;
+ *)
+ echo_red "Invalid option: -${OPTARG}" >&2
+ exit 1
+ ;;
+ esac
+done
+
+if [[ -z "${library}" ]]; then
+ echo_red "No library specified to build" >&2
+ exit 1
+fi
+
+if [[ -z "${sanitizer_type}" ]]; then
+ echo_red "No sanitizer specified" >&2
+ exit
+fi
+
+export CFLAGS="-fsanitize=${sanitizer_flag_string} -g -fPIC -w"
+export CXXFLAGS="-fsanitize=${sanitizer_flag_string} -g -fPIC -w"
+
+# We use XORIGIN as RPATH and after building library replace it to $ORIGIN
+# The reason: this flag goes through configure script and makefiles
+# differently for different libraries. So the dollar sign "$" should be
+# differently escaped. Instead of having problems with that it just
+# uses XORIGIN to build library and after that replaces it to $ORIGIN
+# directly in .so file.
+export LDFLAGS="-Wl,-z,origin -Wl,-R,XORIGIN/."
+
+mkdir -p ${product_dir}/instrumented_libraries/${sanitizer_type}
+
+needed_dependencies=$(apt-get -s build-dep ${library} | grep Inst \
+ | cut -d " " -f 2)
+
+if [[ -n "${needed_dependencies}" ]]; then
+ echo_red "Library ${library} needs dependencies: ${needed_dependencies}" >&2
+ echo_red "Please, install dependencies using:
+ third_party/instrumented_libraries/download_build_install -p ${library}" >&2
+ exit 1
+fi
+
+(
+ # Downloading library
+ mkdir -p ${intermediate_dir}/${library}
+ cd ${intermediate_dir}/${library}
+ apt-get source ${library} 2>&1
+
+ # cd into the only directory in the current folder
+ # where our package has been unpacked.
+ cd $(ls -F |grep \/$)
+
+ # Build library
+ ./configure --prefix="${product_dir}/instrumented_libraries/${sanitizer_type}"
+ make ${makejobs}
+
+ # Install library
+ make ${makejobs} install 2>&1
+) > /dev/null
+
+# Mark that library is installed.
+# This file is used by GYP as 'output' to mark that it's already build
+# while making incremental build.
+touch ${product_dir}/instrumented_libraries/${sanitizer_type}/${library}.txt
+
+# Clean up.
+rm -rf ${intermediate_dir}/${library}
diff --git a/third_party/instrumented_libraries/fix_rpaths.sh b/third_party/instrumented_libraries/fix_rpaths.sh
new file mode 100755
index 0000000..053c6ab
--- /dev/null
+++ b/third_party/instrumented_libraries/fix_rpaths.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Changes all RPATHs in a given directory from XORIGIN to $ORIGIN
+# See the comment about XORIGIN in download_build_install.sh
+
+# Fixes rpath from XORIGIN to $ORIGIN in a single file $1.
+function fix_rpath {
+ chrpath -r $(chrpath $1 | cut -d " " -f 2 | sed s/XORIGIN/\$ORIGIN/g \
+ | sed s/RPATH=//g) $1 > /dev/null
+}
+
+for i in $(find $1 | grep "\.so$"); do
+ fix_rpath $i
+done
+
+# Mark that rpaths are fixed.
+# This file is used by GYP as 'output' to mark that RPATHs are already fixed
+# for incremental builds.
+touch $1/rpaths.fixed.txt
diff --git a/third_party/instrumented_libraries/instrumented_libraries.gyp b/third_party/instrumented_libraries/instrumented_libraries.gyp
new file mode 100644
index 0000000..f7e4f72
--- /dev/null
+++ b/third_party/instrumented_libraries/instrumented_libraries.gyp
@@ -0,0 +1,41 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'instrumented_libraries',
+ 'type': 'none',
+ 'variables': {
+ 'prune_self_dependency': 1,
+ },
+ 'dependencies': [
+ 'libpng12-0',
+ 'libxau6',
+ ],
+ 'actions': [
+ {
+ 'action_name': 'fix_rpaths',
+ 'inputs': [
+ 'fix_rpaths.sh',
+ ],
+ 'outputs': [
+ '<(PRODUCT_DIR)/instrumented_libraries/asan/rpaths.fixed.txt',
+ ],
+ 'action': ['./fix_rpaths.sh', '<(PRODUCT_DIR)/instrumented_libraries/asan'],
+ },
+ ],
+ },
+ {
+ 'target_name': 'libpng12-0',
+ 'dependencies=': [],
+ 'includes': ['standard_instrumented_library_target.gypi'],
+ },
+ {
+ 'target_name': 'libxau6',
+ 'dependencies=': [],
+ 'includes': ['standard_instrumented_library_target.gypi'],
+ },
+ ],
+}
diff --git a/third_party/instrumented_libraries/standard_instrumented_library_target.gypi b/third_party/instrumented_libraries/standard_instrumented_library_target.gypi
new file mode 100644
index 0000000..79b648b
--- /dev/null
+++ b/third_party/instrumented_libraries/standard_instrumented_library_target.gypi
@@ -0,0 +1,22 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file is meant to be included into a target for instrumented dynamic
+# libraries and describes standard build action for most of the libraries.
+
+{
+ 'type': 'none',
+ 'actions': [
+ {
+ 'action_name': '<(_target_name)',
+ 'inputs': [
+ 'download_build_install.sh',
+ ],
+ 'outputs': [
+ '<(PRODUCT_DIR)/instrumented_libraries/asan/<(_target_name).txt',
+ ],
+ 'action': ['./download_build_install.sh', '-i', '<(PRODUCT_DIR)', '-l', '<(_target_name)', '-m', '<(INTERMEDIATE_DIR)', '-s', 'asan'],
+ },
+ ],
+}