All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch v2] libsanitizer: Enable GCC sanitizers
@ 2014-09-13  3:06 Dan McGregor
  2014-09-14 20:48 ` Burton, Ross
  0 siblings, 1 reply; 4+ messages in thread
From: Dan McGregor @ 2014-09-13  3:06 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    | 55 +++++++++++++++++++++++++++
 meta/recipes-devtools/gcc/libsanitizer_4.8.bb |  3 ++
 meta/recipes-devtools/gcc/libsanitizer_4.9.bb |  3 ++
 4 files changed, 62 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..8ff2a0f
--- /dev/null
+++ b/meta/recipes-devtools/gcc/libsanitizer.inc
@@ -0,0 +1,55 @@
+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 \
+"
+
+python __anonymous () {
+    arch = d.getVar("TRANSLATED_TARGET_ARCH", True)
+    if arch not in { "i586", "i686", "x86_64", "arm" }:
+        raise bb.parse.SkipPackage("libsanitizer only works on Intel and ARM.")
+}
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] 4+ messages in thread

* Re: [Patch v2] libsanitizer: Enable GCC sanitizers
  2014-09-13  3:06 [Patch v2] libsanitizer: Enable GCC sanitizers Dan McGregor
@ 2014-09-14 20:48 ` Burton, Ross
  2014-09-15  3:16   ` Dan McGregor
  0 siblings, 1 reply; 4+ messages in thread
From: Burton, Ross @ 2014-09-14 20:48 UTC (permalink / raw)
  To: Dan McGregor; +Cc: Patches and discussions about the oe-core layer

On 13 September 2014 04:06, Dan McGregor <danismostlikely@gmail.com> wrote:
> +python __anonymous () {
> +    arch = d.getVar("TRANSLATED_TARGET_ARCH", True)
> +    if arch not in { "i586", "i686", "x86_64", "arm" }:
> +        raise bb.parse.SkipPackage("libsanitizer only works on Intel and ARM.")
> +}

Shouldn't this be something like
COMPATIBLE_HOST=(x86_64.*|i.86.*|arm.*)? (assuming it doesn't work on
aarch64, which isn't matched by arm.*)

Ross


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

* Re: [Patch v2] libsanitizer: Enable GCC sanitizers
  2014-09-14 20:48 ` Burton, Ross
@ 2014-09-15  3:16   ` Dan McGregor
  2014-09-15  3:57     ` Dan McGregor
  0 siblings, 1 reply; 4+ messages in thread
From: Dan McGregor @ 2014-09-15  3:16 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Patches and discussions about the oe-core layer

On 14 September 2014 14:48, Burton, Ross <ross.burton@intel.com> wrote:
> On 13 September 2014 04:06, Dan McGregor <danismostlikely@gmail.com> wrote:
>> +python __anonymous () {
>> +    arch = d.getVar("TRANSLATED_TARGET_ARCH", True)
>> +    if arch not in { "i586", "i686", "x86_64", "arm" }:
>> +        raise bb.parse.SkipPackage("libsanitizer only works on Intel and ARM.")
>> +}
>
> Shouldn't this be something like
> COMPATIBLE_HOST=(x86_64.*|i.86.*|arm.*)? (assuming it doesn't work on
> aarch64, which isn't matched by arm.*)

Probably, yes. I'll look into whether they work on aarch64 and update this part.
In the mean time, this fixes Jonathan's issues with the last patch, so
I think I'm
at least heading in the right direction.

>
> Ross


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

* Re: [Patch v2] libsanitizer: Enable GCC sanitizers
  2014-09-15  3:16   ` Dan McGregor
@ 2014-09-15  3:57     ` Dan McGregor
  0 siblings, 0 replies; 4+ messages in thread
From: Dan McGregor @ 2014-09-15  3:57 UTC (permalink / raw)
  To: Burton, Ross; +Cc: Patches and discussions about the oe-core layer

On 14 September 2014 21:16, Dan McGregor <danismostlikely@gmail.com> wrote:
> On 14 September 2014 14:48, Burton, Ross <ross.burton@intel.com> wrote:
>> On 13 September 2014 04:06, Dan McGregor <danismostlikely@gmail.com> wrote:
>>> +python __anonymous () {
>>> +    arch = d.getVar("TRANSLATED_TARGET_ARCH", True)
>>> +    if arch not in { "i586", "i686", "x86_64", "arm" }:
>>> +        raise bb.parse.SkipPackage("libsanitizer only works on Intel and ARM.")
>>> +}
>>
>> Shouldn't this be something like
>> COMPATIBLE_HOST=(x86_64.*|i.86.*|arm.*)? (assuming it doesn't work on
>> aarch64, which isn't matched by arm.*)
>
> Probably, yes. I'll look into whether they work on aarch64 and update this part.
> In the mean time, this fixes Jonathan's issues with the last patch, so
> I think I'm
> at least heading in the right direction.
>

Even better! I've been ignoring the platform specific stuff in the
sanitizes. The only platform
that might give trouble is little-endian PowerPC. This entire clause
can be dropped. I'll test it
tomorrow on big-endian PPC to make sure this actually works.


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-13  3:06 [Patch v2] libsanitizer: Enable GCC sanitizers Dan McGregor
2014-09-14 20:48 ` Burton, Ross
2014-09-15  3:16   ` Dan McGregor
2014-09-15  3:57     ` 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.