stressapptest: Fix build with libc++
PATCH 1/3 stressapptest: Fix build with libc++
when using libc++ instead of libstdc++, __gnu_cxx namespace is not available
Signed-off-by Khem Raj <[email protected]>
--- .../stressapptest/libcplusplus-compat.patch | 28 +++++++++++++++++++ .../stressapptest/stressapptest_1.0.9.bb | 4 ++- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 meta-oe/recipes-benchmark/stressapptest/stressapptest/libcplusplus-compat.patch
meta-oe/recipes-benchmark/stressapptest/stressapptest/libcplusplus-compat.patch new file +28 -0
@@ -0,0 +1,28 @@ +Fix compile on sytems using libc++ instead of libstdc++ + +libc++ does not really implement __gnu_cxx namespace and it +compiles fine without this namespace, therefore detect libc++ +and if it is used them exclude this namespace + +See https://github.com/stressapptest/stressapptest/issues/47 + +Fixes + +./sattypes.h:33:17: error: expected namespace name +using namespace __gnu_cxx; //NOLINT + +Upstream-Status: Pending +Signed-off-by: Khem Raj <[email protected]> + +--- stressapptest-1.0.9.orig/src/sattypes.h ++++ stressapptest-1.0.9/src/sattypes.h +@@ -30,7 +30,9 @@ + #include "stressapptest_config_android.h" // NOLINT + #else + #include "stressapptest_config.h" // NOLINT ++#ifndef _LIBCPP_VERSION + using namespace __gnu_cxx; //NOLINT ++#endif // _LIBCPP_VERSION + #endif // __ANDROID__ + using namespace std; +
meta-oe/recipes-benchmark/stressapptest/stressapptest_1.0.9.bb +3 -1
@@ -9,7 +9,9 @@ SECTION = "benchmark" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://COPYING;md5=55ea9d559f985fb4834317d8ed6b9e58" -SRC_URI = "https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz" +SRC_URI = "https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz \ + file://libcplusplus-compat.patch \ + " SRC_URI[md5sum] = "d3a526c174c049dd7a1068dc74a62be2" SRC_URI[sha256sum] = "2ba470587ad4f6ae92057d427c3a2a2756e5f10bd25cd91e62eaef55a40b30a1"
Signature · 1 line
2.22.0
PATCH 2/3 stressapptest: Implement reading sysfs and use it if sysconf is not there
This helps in building on musl platform where _SC_LEVEL1_DCACHE_LINESIZE is not available
Signed-off-by Khem Raj <[email protected]>
--- .../read_sysfs_for_cachesize.patch | 72 +++++++++++++++++++ .../stressapptest/stressapptest_1.0.9.bb | 1 + 2 files changed, 73 insertions(+) create mode 100644 meta-oe/recipes-benchmark/stressapptest/stressapptest/read_sysfs_for_cachesize.patch
meta-oe/recipes-benchmark/stressapptest/stressapptest/read_sysfs_for_cachesize.patch new file +72 -0
@@ -0,0 +1,72 @@ +sysconf params like _SC_LEVEL1_DCACHE_LINESIZE are not universally +implemented, therefore check for them being available, if not there +then read the sysfs directly to get the value + +Upstream-Status: Pending +Signed-off-by: Khem Raj <[email protected]> +--- a/src/sat.cc ++++ b/src/sat.cc +@@ -1482,15 +1482,47 @@ int Sat::CpuCount() { + return sysconf(_SC_NPROCESSORS_CONF); + } + ++int Sat::ReadInt(const char *filename, int *value) { ++ char line[64]; ++ int fd = open(filename, O_RDONLY), err = -1; ++ ++ if (fd < 0) ++ return -1; ++ if (read(fd, line, sizeof(line)) > 0) { ++ *value = atoi(line); ++ err = 0; ++ } ++ ++ close(fd); ++ return err; ++} ++ + // Return the worst case (largest) cache line size of the various levels of + // cache actually prsent in the machine. + int Sat::CacheLineSize() { +- int max_linesize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); +- int linesize = sysconf(_SC_LEVEL2_CACHE_LINESIZE); ++ int max_linesize, linesize; ++#ifdef _SC_LEVEL1_DCACHE_LINESIZE ++ max_linesize = sysconf(_SC_LEVEL1_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", &max_linesize); ++#endif ++#ifdef _SC_LEVEL2_DCACHE_LINESIZE ++ linesize = sysconf(_SC_LEVEL2_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index1/coherency_line_size", &linesize); ++#endif + if (linesize > max_linesize) max_linesize = linesize; +- linesize = sysconf(_SC_LEVEL3_CACHE_LINESIZE); ++#ifdef _SC_LEVEL3_DCACHE_LINESIZE ++ linesize = sysconf(_SC_LEVEL3_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index2/coherency_line_size", &linesize); ++#endif + if (linesize > max_linesize) max_linesize = linesize; +- linesize = sysconf(_SC_LEVEL4_CACHE_LINESIZE); ++#ifdef _SC_LEVEL4_DCACHE_LINESIZE ++ linesize = sysconf(_SC_LEVEL4_DCACHE_LINESIZE); ++#else ++ ReadInt("/sys/devices/system/cpu/cpu0/cache/index3/coherency_line_size", &linesize); ++#endif + if (linesize > max_linesize) max_linesize = linesize; + return max_linesize; + } +--- a/src/sat.h ++++ b/src/sat.h +@@ -136,7 +136,8 @@ class Sat { + int CpuCount(); + // Return the worst-case (largest) cache line size of the system. + int CacheLineSize(); +- ++ // Read int values from kernel file system e.g. sysfs ++ int ReadInt(const char *filename, int *value); + // Collect error counts from threads. + int64 GetTotalErrorCount(); +
meta-oe/recipes-benchmark/stressapptest/stressapptest_1.0.9.bb +1 -0
@@ -11,6 +11,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=55ea9d559f985fb4834317d8ed6b9e58" SRC_URI = "https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz \ file://libcplusplus-compat.patch \ + file://read_sysfs_for_cachesize.patch \ " SRC_URI[md5sum] = "d3a526c174c049dd7a1068dc74a62be2"
Signature · 1 line
2.22.0
PATCH 3/3 stressapptest: Use git SHA instead of git archive
In reply to Khem Rajgit archives get regenerated randomly so lets use git fetcher instead
Signed-off-by Khem Raj <[email protected]>
--- .../stressapptest/stressapptest_1.0.9.bb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
meta-oe/recipes-benchmark/stressapptest/stressapptest_1.0.9.bb +4 -5
@@ -9,14 +9,13 @@ SECTION = "benchmark" LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://COPYING;md5=55ea9d559f985fb4834317d8ed6b9e58" -SRC_URI = "https://github.com/${PN}/${PN}/archive/v${PV}.tar.gz \ +SRCREV = "fb72e5e5f0879231f38e0e826a98a6ca2d1ca38e" + +SRC_URI = "git://github.com/stressapptest/stressapptest \ file://libcplusplus-compat.patch \ file://read_sysfs_for_cachesize.patch \ " -SRC_URI[md5sum] = "d3a526c174c049dd7a1068dc74a62be2" -SRC_URI[sha256sum] = "2ba470587ad4f6ae92057d427c3a2a2756e5f10bd25cd91e62eaef55a40b30a1" - -S = "${WORKDIR}/${PN}-${PV}" +S = "${WORKDIR}/git" inherit autotools
Signature · 1 line
2.22.0