All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] libsanitizer: Enable GCC sanitizers
@ 2014-09-15  4:00 Dan McGregor
  2014-09-15 15:00 ` Burton, Ross
  0 siblings, 1 reply; 9+ messages in thread
From: Dan McGregor @ 2014-09-15  4:00 UTC (permalink / raw)
  To: Patches and discussions about the oe-core layer

From: Dan McGregor <dan.mcgregor@usask.ca>

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.

Signed-off-by: Dan McGregor <dan.mcgregor@usask.ca>
---
 meta/conf/distro/include/tcmode-default.inc   |  1 +
 meta/recipes-devtools/gcc/libsanitizer.inc    | 49 +++++++++++++++++++++++++++
 meta/recipes-devtools/gcc/libsanitizer_4.8.bb |  3 ++
 meta/recipes-devtools/gcc/libsanitizer_4.9.bb |  3 ++
 4 files changed, 56 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/libsanitizer.inc
 create mode 100644 meta/recipes-devtools/gcc/libsanitizer_4.8.bb
 create mode 100644 meta/recipes-devtools/gcc/libsanitizer_4.9.bb

diff --git a/meta/conf/distro/include/tcmode-default.inc
b/meta/conf/distro/include/tcmode-default.inc
index 6c0f102..3eed903 100644
--- a/meta/conf/distro/include/tcmode-default.inc
+++ b/meta/conf/distro/include/tcmode-default.inc
@@ -35,6 +35,7 @@ PREFERRED_VERSION_gcc-cross-initial-${TARGET_ARCH}
?= "${GCCVERSION}"
 PREFERRED_VERSION_gcc-crosssdk-${SDK_ARCH} ?= "${SDKGCCVERSION}"
 PREFERRED_VERSION_gcc-crosssdk-initial-${SDK_ARCH} ?= "${SDKGCCVERSION}"
 PREFERRED_VERSION_gcc-cross-canadian-${TRANSLATED_TARGET_ARCH} ?=
"${GCCVERSION}"
+PREFERRED_VERSION_libsanitizer ?= "${GCCVERSION}"
 PREFERRED_VERSION_gcc-runtime ?= "${GCCVERSION}"
 PREFERRED_VERSION_nativesdk-gcc-runtime ?= "${SDKGCCVERSION}"
 PREFERRED_VERSION_libgcc ?= "${GCCVERSION}"
diff --git a/meta/recipes-devtools/gcc/libsanitizer.inc
b/meta/recipes-devtools/gcc/libsanitizer.inc
new file mode 100644
index 0000000..6d5f53e
--- /dev/null
+++ b/meta/recipes-devtools/gcc/libsanitizer.inc
@@ -0,0 +1,49 @@
+require gcc-configure-common.inc
+
+EXTRA_OECONF_PATHS = "\
+    --with-sysroot=${STAGING_DIR_TARGET} \
+    --with-build-sysroot=${STAGING_DIR_TARGET} \
+"
+
+do_configure () {
+    mtarget=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+    target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+    hardlinkdir ${STAGING_INCDIR_NATIVE}/gcc-build-internal-$mtarget ${B}
+
+    echo "Configuring libsanitizer"
+    rm -rf ${B}/$target/libsanitizer/
+    mkdir -p ${B}/$target/libsanitizer/
+    # This is kind of gross, but it's an easy way to make configure happy
+    # without hacking it up to use the system stdc++ instead of the one it
+    # expects to be newly built.
+    rm -rf ${B}/$target/libstdc++-v3/
+    mkdir -p ${B}/$target/libstdc++-v3/src/
+    ln -s ${STAGING_LIBDIR}/libstdc++.la ${B}/$target/libstdc++-v3/src/
+    ln -s ${STAGING_LIBDIR}/libstdc++.so ${B}/$target/libstdc++-v3/src/
+    cd ${B}/$target/libsanitizer/
+    chmod a+x ${S}/libsanitizer/configure
+    ${S}/libsanitizer/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
+}
+
+do_compile () {
+    target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+    cd ${B}/$target/libsanitizer/
+    oe_runmake MULTIBUILDTOP=${B}/$target/libsanitizer/
+}
+
+do_install () {
+    target=`echo ${TARGET_SYS} | sed -e s#-${SDKPKGSUFFIX}##`
+    cd ${B}/$target/libsanitizer/
+    oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/$target/libsanitizer/ install
+    if [ -d ${D}${infodir} ]; then
+        rmdir --ignore-fail-on-non-empty -p ${D}${infodir}
+    fi
+    chown -R root:root ${D}
+}
+
+DEPENDS = "gcc-runtime"
+
+FILES_${PN}-dev += "\
+    ${libdir}/*preinit.o \
+    ${libdir}/*.spec \
+"
diff --git a/meta/recipes-devtools/gcc/libsanitizer_4.8.bb
b/meta/recipes-devtools/gcc/libsanitizer_4.8.bb
new file mode 100644
index 0000000..f3ced76
--- /dev/null
+++ b/meta/recipes-devtools/gcc/libsanitizer_4.8.bb
@@ -0,0 +1,3 @@
+require recipes-devtools/gcc/gcc-${PV}.inc
+require libsanitizer.inc
+
diff --git a/meta/recipes-devtools/gcc/libsanitizer_4.9.bb
b/meta/recipes-devtools/gcc/libsanitizer_4.9.bb
new file mode 100644
index 0000000..f3ced76
--- /dev/null
+++ b/meta/recipes-devtools/gcc/libsanitizer_4.9.bb
@@ -0,0 +1,3 @@
+require recipes-devtools/gcc/gcc-${PV}.inc
+require libsanitizer.inc
+
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-12-12  3:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-15  4:00 [PATCH v3] libsanitizer: Enable GCC sanitizers Dan McGregor
2014-09-15 15:00 ` Burton, Ross
2014-09-15 20:20   ` Dan McGregor
2014-09-15 20:28     ` Burton, Ross
2014-09-16 18:45       ` Dan McGregor
2014-11-04 13:45         ` Burton, Ross
2014-11-13 23:35           ` Dan McGregor
2014-12-10 11:58             ` Burton, Ross
2014-12-12  3:15               ` Dan McGregor

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.