diff options
author | Dan McGregor <dan.mcgregor@usask.ca> | 2014-12-10 20:14:03 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-01-23 11:36:29 +0000 |
commit | 166015c809889ad66f1359520206ef3e52a81135 (patch) | |
tree | 3fd45cff4a594988c85030706d417d26691a83d2 /meta/recipes-devtools | |
parent | 5b985fd364c44d7067a7b63f119ec7ad04dcec33 (diff) | |
download | poky-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.inc | 111 | ||||
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-sanitizers_4.8.bb | 2 | ||||
-rw-r--r-- | meta/recipes-devtools/gcc/gcc-sanitizers_4.9.bb | 2 |
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 @@ | |||
1 | require gcc-configure-common.inc | ||
2 | |||
3 | EXTRA_OECONF_PATHS = "\ | ||
4 | --with-sysroot=/not/exist \ | ||
5 | --with-build-sysroot=${STAGING_DIR_TARGET} \ | ||
6 | " | ||
7 | |||
8 | do_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 | |||
31 | do_compile () { | ||
32 | target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##` | ||
33 | cd ${B}/$target/libsanitizer/ | ||
34 | oe_runmake MULTIBUILDTOP=${B}/$target/libsanitizer/ | ||
35 | } | ||
36 | |||
37 | do_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 | |||
47 | INHIBIT_DEFAULT_DEPS = "1" | ||
48 | ALLOW_EMPTY_${PN} = "1" | ||
49 | DEPENDS = "gcc-runtime" | ||
50 | |||
51 | BBCLASSEXTEND = "nativesdk" | ||
52 | |||
53 | PACKAGES = "${PN}" | ||
54 | PACKAGES += "libasan libubsan liblsan libtsan" | ||
55 | PACKAGES += "libasan-dev libubsan-dev liblsan-dev libtsan-dev" | ||
56 | PACKAGES += "libasan-dbg libubsan-dbg liblsan-dbg libtsan-dbg" | ||
57 | PACKAGES += "libasan-staticdev libubsan-staticdev liblsan-staticdev libtsan-staticdev" | ||
58 | |||
59 | RDEPENDS_libasan += "libstdc++" | ||
60 | RDEPENDS_libubsan += "libstdc++" | ||
61 | RDEPENDS_liblsan += "libstdc++" | ||
62 | RDEPENDS_libtsan += "libstdc++" | ||
63 | RDEPENDS_libasan-dev += "${PN}" | ||
64 | RDEPENDS_libubsan-dev += "${PN}" | ||
65 | RDEPENDS_liblsan-dev += "${PN}" | ||
66 | RDEPENDS_libtsan-dev += "${PN}" | ||
67 | RRECOMMENDS_${PN} += "libasan libubsan" | ||
68 | RRECOMMENDS_${PN}_append_x86-64 = " liblsan libtsan" | ||
69 | RRECOMMENDS_${PN}_append_x86 = " liblsan" | ||
70 | |||
71 | do_package_write_ipk[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata" | ||
72 | do_package_write_deb[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata" | ||
73 | do_package_write_rpm[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata" | ||
74 | |||
75 | # MIPS, aarch64, and SPARC are broken. | ||
76 | COMPATIBLE_HOST = '(x86_64|i.86|powerpc|arm).*-linux' | ||
77 | |||
78 | FILES_libasan += "${libdir}/libasan.so.*" | ||
79 | FILES_libasan-dbg += "${libdir}/.debug/libasan.so.*" | ||
80 | FILES_libasan-dev += "\ | ||
81 | ${libdir}/libasan_preinit.o \ | ||
82 | ${libdir}/libasan.so \ | ||
83 | ${libdir}/libasan.la \ | ||
84 | " | ||
85 | FILES_libasan-staticdev += "${libdir}/libasan.a" | ||
86 | |||
87 | FILES_libubsan += "${libdir}/libubsan.so.*" | ||
88 | FILES_libubsan-dbg += "${libdir}/.debug/libubsan.so.*" | ||
89 | FILES_libubsan-dev += "\ | ||
90 | ${libdir}/libubsan.so \ | ||
91 | ${libdir}/libubsan.la \ | ||
92 | " | ||
93 | FILES_libubsan-staticdev += "${libdir}/libubsan.a" | ||
94 | |||
95 | FILES_liblsan += "${libdir}/liblsan.so.*" | ||
96 | FILES_liblsan-dbg += "${libdir}/.debug/liblsan.so.*" | ||
97 | FILES_liblsan-dev += "\ | ||
98 | ${libdir}/liblsan.so \ | ||
99 | ${libdir}/liblsan.la \ | ||
100 | " | ||
101 | FILES_liblsan-staticdev += "${libdir}/liblsan.a" | ||
102 | |||
103 | FILES_libtsan += "${libdir}/libtsan.so.*" | ||
104 | FILES_libtsan-dbg += "${libdir}/.debug/libtsan.so.*" | ||
105 | FILES_libtsan-dev += "\ | ||
106 | ${libdir}/libtsan.so \ | ||
107 | ${libdir}/libtsan.la \ | ||
108 | " | ||
109 | FILES_libtsan-staticdev += "${libdir}/libtsan.a" | ||
110 | |||
111 | FILES_${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 @@ | |||
1 | require recipes-devtools/gcc/gcc-${PV}.inc | ||
2 | require 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 @@ | |||
1 | require recipes-devtools/gcc/gcc-${PV}.inc | ||
2 | require gcc-sanitizers.inc | ||