summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
diff options
context:
space:
mode:
authorDan McGregor <dan.mcgregor@usask.ca>2014-12-10 20:14:03 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-01-23 11:36:29 +0000
commit166015c809889ad66f1359520206ef3e52a81135 (patch)
tree3fd45cff4a594988c85030706d417d26691a83d2 /meta/recipes-devtools
parent5b985fd364c44d7067a7b63f119ec7ad04dcec33 (diff)
downloadpoky-166015c809889ad66f1359520206ef3e52a81135.tar.gz
gcc-sanitizers: Enable GCC sanitizers
AddressSanitizer is a fast memory error detector. ThreadSanitizer detects data races. UBSanitizer detectes undefined behaviour. All consist of compiler instrumentation and a run-time library. The compiler instrumentation was already enabled, this builds the run-time library component. (From OE-Core rev: 1709bf0c3a84bb04bc52e9104ad8e09fba6c6f91) Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r--meta/recipes-devtools/gcc/gcc-sanitizers.inc111
-rw-r--r--meta/recipes-devtools/gcc/gcc-sanitizers_4.8.bb2
-rw-r--r--meta/recipes-devtools/gcc/gcc-sanitizers_4.9.bb2
3 files changed, 115 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers.inc b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
new file mode 100644
index 0000000000..892dfe0476
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
@@ -0,0 +1,111 @@
1require gcc-configure-common.inc
2
3EXTRA_OECONF_PATHS = "\
4 --with-sysroot=/not/exist \
5 --with-build-sysroot=${STAGING_DIR_TARGET} \
6"
7
8do_configure () {
9 mtarget=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
10 target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
11 hardlinkdir ${STAGING_INCDIR_NATIVE}/gcc-build-internal-$mtarget ${B}
12
13 echo "Configuring libsanitizer"
14 rm -rf ${B}/$target/libsanitizer/
15 mkdir -p ${B}/$target/libsanitizer/
16 # This is kind of gross, but it's an easy way to make configure happy
17 # without hacking it up to use the system stdc++ instead of the one it
18 # expects to be newly built.
19 rm -rf ${B}/$target/libstdc++-v3/
20 mkdir -p ${B}/$target/libstdc++-v3/src/
21 ln -s ${STAGING_LIBDIR}/libstdc++.la ${B}/$target/libstdc++-v3/src/
22 ln -s ${STAGING_LIBDIR}/libstdc++.so ${B}/$target/libstdc++-v3/src/
23 cd ${B}/$target/libsanitizer/
24 chmod a+x ${S}/libsanitizer/configure
25 ${S}/libsanitizer/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
26 # Easiest way to stop bad RPATHs getting into the library since we have a
27 # broken libtool here
28 sed -i -e 's/hardcode_into_libs=yes/hardcode_into_libs=no/' ${B}/$target/libsanitizer/libtool
29}
30
31do_compile () {
32 target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
33 cd ${B}/$target/libsanitizer/
34 oe_runmake MULTIBUILDTOP=${B}/$target/libsanitizer/
35}
36
37do_install () {
38 target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
39 cd ${B}/$target/libsanitizer/
40 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/$target/libsanitizer/ install
41 if [ -d ${D}${infodir} ]; then
42 rmdir --ignore-fail-on-non-empty -p ${D}${infodir}
43 fi
44 chown -R root:root ${D}
45}
46
47INHIBIT_DEFAULT_DEPS = "1"
48ALLOW_EMPTY_${PN} = "1"
49DEPENDS = "gcc-runtime"
50
51BBCLASSEXTEND = "nativesdk"
52
53PACKAGES = "${PN}"
54PACKAGES += "libasan libubsan liblsan libtsan"
55PACKAGES += "libasan-dev libubsan-dev liblsan-dev libtsan-dev"
56PACKAGES += "libasan-dbg libubsan-dbg liblsan-dbg libtsan-dbg"
57PACKAGES += "libasan-staticdev libubsan-staticdev liblsan-staticdev libtsan-staticdev"
58
59RDEPENDS_libasan += "libstdc++"
60RDEPENDS_libubsan += "libstdc++"
61RDEPENDS_liblsan += "libstdc++"
62RDEPENDS_libtsan += "libstdc++"
63RDEPENDS_libasan-dev += "${PN}"
64RDEPENDS_libubsan-dev += "${PN}"
65RDEPENDS_liblsan-dev += "${PN}"
66RDEPENDS_libtsan-dev += "${PN}"
67RRECOMMENDS_${PN} += "libasan libubsan"
68RRECOMMENDS_${PN}_append_x86-64 = " liblsan libtsan"
69RRECOMMENDS_${PN}_append_x86 = " liblsan"
70
71do_package_write_ipk[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
72do_package_write_deb[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
73do_package_write_rpm[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
74
75# MIPS, aarch64, and SPARC are broken.
76COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm).*-linux'
77
78FILES_libasan += "${libdir}/libasan.so.*"
79FILES_libasan-dbg += "${libdir}/.debug/libasan.so.*"
80FILES_libasan-dev += "\
81 ${libdir}/libasan_preinit.o \
82 ${libdir}/libasan.so \
83 ${libdir}/libasan.la \
84"
85FILES_libasan-staticdev += "${libdir}/libasan.a"
86
87FILES_libubsan += "${libdir}/libubsan.so.*"
88FILES_libubsan-dbg += "${libdir}/.debug/libubsan.so.*"
89FILES_libubsan-dev += "\
90 ${libdir}/libubsan.so \
91 ${libdir}/libubsan.la \
92"
93FILES_libubsan-staticdev += "${libdir}/libubsan.a"
94
95FILES_liblsan += "${libdir}/liblsan.so.*"
96FILES_liblsan-dbg += "${libdir}/.debug/liblsan.so.*"
97FILES_liblsan-dev += "\
98 ${libdir}/liblsan.so \
99 ${libdir}/liblsan.la \
100"
101FILES_liblsan-staticdev += "${libdir}/liblsan.a"
102
103FILES_libtsan += "${libdir}/libtsan.so.*"
104FILES_libtsan-dbg += "${libdir}/.debug/libtsan.so.*"
105FILES_libtsan-dev += "\
106 ${libdir}/libtsan.so \
107 ${libdir}/libtsan.la \
108"
109FILES_libtsan-staticdev += "${libdir}/libtsan.a"
110
111FILES_${PN} = "${libdir}/*.spec ${libdir}/gcc/${TARGET_SYS}/${BINV}/include/sanitizer/*.h"
diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers_4.8.bb b/meta/recipes-devtools/gcc/gcc-sanitizers_4.8.bb
new file mode 100644
index 0000000000..601f666023
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-sanitizers_4.8.bb
@@ -0,0 +1,2 @@
1require recipes-devtools/gcc/gcc-${PV}.inc
2require gcc-sanitizers.inc
diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers_4.9.bb b/meta/recipes-devtools/gcc/gcc-sanitizers_4.9.bb
new file mode 100644
index 0000000000..601f666023
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-sanitizers_4.9.bb
@@ -0,0 +1,2 @@
1require recipes-devtools/gcc/gcc-${PV}.inc
2require gcc-sanitizers.inc