diff options
| author | Khem Raj <raj.khem@gmail.com> | 2018-06-21 20:02:34 -0700 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2018-06-22 10:52:33 -0700 |
| commit | eec73ed7c6441bf87477d8b192613c3452bdcf34 (patch) | |
| tree | 2b24c68df08e7d0427e3675a6d011cce83c30569 /meta-oe/recipes-benchmark/libhugetlbfs | |
| parent | 1477cf5460fa1e99abbd1117aa7007c89e173680 (diff) | |
| download | meta-openembedded-eec73ed7c6441bf87477d8b192613c3452bdcf34.tar.gz | |
libhugetlbfs: Fix build on musl
needs more runtime testing
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-benchmark/libhugetlbfs')
7 files changed, 219 insertions, 0 deletions
diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/files/0001-include-stddef.h-for-ptrdiff_t.patch b/meta-oe/recipes-benchmark/libhugetlbfs/files/0001-include-stddef.h-for-ptrdiff_t.patch new file mode 100644 index 0000000000..bae90b4edc --- /dev/null +++ b/meta-oe/recipes-benchmark/libhugetlbfs/files/0001-include-stddef.h-for-ptrdiff_t.patch | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | From d3c2187716a0a1f9359a869ca383c129603554d9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 21 Jun 2018 19:25:57 -0700 | ||
| 4 | Subject: [PATCH 1/6] include stddef.h for ptrdiff_t | ||
| 5 | |||
| 6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 7 | --- | ||
| 8 | morecore.c | 1 + | ||
| 9 | 1 file changed, 1 insertion(+) | ||
| 10 | |||
| 11 | diff --git a/morecore.c b/morecore.c | ||
| 12 | index 62ad252..c5981d2 100644 | ||
| 13 | --- a/morecore.c | ||
| 14 | +++ b/morecore.c | ||
| 15 | @@ -19,6 +19,7 @@ | ||
| 16 | |||
| 17 | #define _GNU_SOURCE | ||
| 18 | |||
| 19 | +#include <stddef.h> | ||
| 20 | #include <stdio.h> | ||
| 21 | #include <stdlib.h> | ||
| 22 | #include <malloc.h> | ||
| 23 | -- | ||
| 24 | 2.17.1 | ||
| 25 | |||
diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/files/0002-Mark-glibc-specific-code-so.patch b/meta-oe/recipes-benchmark/libhugetlbfs/files/0002-Mark-glibc-specific-code-so.patch new file mode 100644 index 0000000000..4354d78615 --- /dev/null +++ b/meta-oe/recipes-benchmark/libhugetlbfs/files/0002-Mark-glibc-specific-code-so.patch | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | From b72bf6a81fa879f32a074fe53776fc8291c83b6f Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 21 Jun 2018 19:32:59 -0700 | ||
| 4 | Subject: [PATCH 2/6] Mark glibc specific code so | ||
| 5 | |||
| 6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 7 | --- | ||
| 8 | morecore.c | 3 ++- | ||
| 9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
| 10 | |||
| 11 | diff --git a/morecore.c b/morecore.c | ||
| 12 | index c5981d2..ec9fafa 100644 | ||
| 13 | --- a/morecore.c | ||
| 14 | +++ b/morecore.c | ||
| 15 | @@ -347,6 +347,7 @@ void hugetlbfs_setup_morecore(void) | ||
| 16 | |||
| 17 | INFO("setup_morecore(): heapaddr = 0x%lx\n", heapaddr); | ||
| 18 | |||
| 19 | +#ifdef __GLIBC__ | ||
| 20 | heaptop = heapbase = (void *)heapaddr; | ||
| 21 | if (__hugetlb_opts.thp_morecore) | ||
| 22 | __morecore = &thp_morecore; | ||
| 23 | @@ -354,7 +355,6 @@ void hugetlbfs_setup_morecore(void) | ||
| 24 | __morecore = &hugetlbfs_morecore; | ||
| 25 | |||
| 26 | /* Set some allocator options more appropriate for hugepages */ | ||
| 27 | - | ||
| 28 | if (__hugetlb_opts.shrink_ok) | ||
| 29 | mallopt(M_TRIM_THRESHOLD, hpage_size / 2); | ||
| 30 | else | ||
| 31 | @@ -364,4 +364,5 @@ void hugetlbfs_setup_morecore(void) | ||
| 32 | * This doesn't appear to prohibit malloc() from falling back | ||
| 33 | * to mmap() if we run out of hugepages. */ | ||
| 34 | mallopt(M_MMAP_MAX, 0); | ||
| 35 | +#endif | ||
| 36 | } | ||
| 37 | -- | ||
| 38 | 2.17.1 | ||
| 39 | |||
diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/files/0003-alloc.c-Avoid-sysconf-_SC_LEVEL2_CACHE_LINESIZE-on-l.patch b/meta-oe/recipes-benchmark/libhugetlbfs/files/0003-alloc.c-Avoid-sysconf-_SC_LEVEL2_CACHE_LINESIZE-on-l.patch new file mode 100644 index 0000000000..f6d8a10a9a --- /dev/null +++ b/meta-oe/recipes-benchmark/libhugetlbfs/files/0003-alloc.c-Avoid-sysconf-_SC_LEVEL2_CACHE_LINESIZE-on-l.patch | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | From 3d6ab5ea8e23f96ee6fdd915e05acd9a751dd876 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 21 Jun 2018 19:44:26 -0700 | ||
| 4 | Subject: [PATCH 3/6] alloc.c: Avoid sysconf(_SC_LEVEL2_CACHE_LINESIZE) on | ||
| 5 | linux | ||
| 6 | |||
| 7 | musl does not have it | ||
| 8 | |||
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 10 | --- | ||
| 11 | alloc.c | 15 ++++++++++++++- | ||
| 12 | 1 file changed, 14 insertions(+), 1 deletion(-) | ||
| 13 | |||
| 14 | diff --git a/alloc.c b/alloc.c | ||
| 15 | index bce9464..cf7eb40 100644 | ||
| 16 | --- a/alloc.c | ||
| 17 | +++ b/alloc.c | ||
| 18 | @@ -245,6 +245,19 @@ void free_huge_pages(void *ptr) | ||
| 19 | __free_huge_pages(ptr, 1); | ||
| 20 | } | ||
| 21 | |||
| 22 | +static size_t get_cacheline_size() { | ||
| 23 | +#if defined(__linux__) | ||
| 24 | + FILE * fp = fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r"); | ||
| 25 | + unsigned int line_size = 0; | ||
| 26 | + if (fp) { | ||
| 27 | + fscanf(fp, "%d", &line_size); | ||
| 28 | + fclose(fp); | ||
| 29 | + } | ||
| 30 | + return line_size; | ||
| 31 | +#else | ||
| 32 | + return sysconf(_SC_LEVEL2_CACHE_LINESIZE); | ||
| 33 | +#endif | ||
| 34 | +} | ||
| 35 | /* | ||
| 36 | * Offset the buffer using bytes wasted due to alignment to avoid using the | ||
| 37 | * same cache lines for the start of every buffer returned by | ||
| 38 | @@ -261,7 +274,7 @@ void *cachecolor(void *buf, size_t len, size_t color_bytes) | ||
| 39 | |||
| 40 | /* Lookup our cacheline size once */ | ||
| 41 | if (cacheline_size == 0) { | ||
| 42 | - cacheline_size = sysconf(_SC_LEVEL2_CACHE_LINESIZE); | ||
| 43 | + cacheline_size = get_cacheline_size(); | ||
| 44 | linemod = time(NULL); | ||
| 45 | } | ||
| 46 | |||
| 47 | -- | ||
| 48 | 2.17.1 | ||
| 49 | |||
diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/files/0004-shm.c-Mark-glibc-specific-changes-so.patch b/meta-oe/recipes-benchmark/libhugetlbfs/files/0004-shm.c-Mark-glibc-specific-changes-so.patch new file mode 100644 index 0000000000..960e152939 --- /dev/null +++ b/meta-oe/recipes-benchmark/libhugetlbfs/files/0004-shm.c-Mark-glibc-specific-changes-so.patch | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | From 7002dec46dae375e8aa1aa8577a5b274c02fc697 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 21 Jun 2018 19:48:04 -0700 | ||
| 4 | Subject: [PATCH 4/6] shm.c: Mark glibc specific changes so | ||
| 5 | |||
| 6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 7 | --- | ||
| 8 | shm.c | 3 ++- | ||
| 9 | 1 file changed, 2 insertions(+), 1 deletion(-) | ||
| 10 | |||
| 11 | diff --git a/shm.c b/shm.c | ||
| 12 | index 1f82cab..9447b63 100644 | ||
| 13 | --- a/shm.c | ||
| 14 | +++ b/shm.c | ||
| 15 | @@ -48,10 +48,11 @@ | ||
| 16 | * system shmget() may be performed without worry as there is no dynamic | ||
| 17 | * call chain. | ||
| 18 | */ | ||
| 19 | +#ifdef __GLIBC__ | ||
| 20 | extern void *dlsym (void *__restrict __handle, __const char *__restrict __name) | ||
| 21 | __attribute__((weak)) __THROW __nonnull ((2)); | ||
| 22 | extern char *dlerror (void) __attribute__((weak)) __THROW; | ||
| 23 | - | ||
| 24 | +#endif | ||
| 25 | |||
| 26 | /* call syscall shmget through the generic syscall mechanism */ | ||
| 27 | static int syscall_shmget(key_t key, size_t size, int shmflg) | ||
| 28 | -- | ||
| 29 | 2.17.1 | ||
| 30 | |||
diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/files/0005-Include-dirent.h-for-ino_t.patch b/meta-oe/recipes-benchmark/libhugetlbfs/files/0005-Include-dirent.h-for-ino_t.patch new file mode 100644 index 0000000000..543302b135 --- /dev/null +++ b/meta-oe/recipes-benchmark/libhugetlbfs/files/0005-Include-dirent.h-for-ino_t.patch | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | From 87ed1706f426ed27fc4eeca7c3b09a4086c9a2a9 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 21 Jun 2018 19:51:02 -0700 | ||
| 4 | Subject: [PATCH 5/6] Include dirent.h for ino_t | ||
| 5 | |||
| 6 | Fixes | ||
| 7 | error: unknown type name 'ino_t'; did you mean 'int'? | ||
| 8 | |||
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 10 | --- | ||
| 11 | tests/hugetests.h | 1 + | ||
| 12 | 1 file changed, 1 insertion(+) | ||
| 13 | |||
| 14 | diff --git a/tests/hugetests.h b/tests/hugetests.h | ||
| 15 | index 8b1d8d9..056042c 100644 | ||
| 16 | --- a/tests/hugetests.h | ||
| 17 | +++ b/tests/hugetests.h | ||
| 18 | @@ -22,6 +22,7 @@ | ||
| 19 | |||
| 20 | #include <errno.h> | ||
| 21 | #include <string.h> | ||
| 22 | +#include <dirent.h> | ||
| 23 | |||
| 24 | #include "libhugetlbfs_privutils.h" | ||
| 25 | #include "libhugetlbfs_testprobes.h" | ||
| 26 | -- | ||
| 27 | 2.17.1 | ||
| 28 | |||
diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/files/0006-include-limits.h-for-PATH_MAX.patch b/meta-oe/recipes-benchmark/libhugetlbfs/files/0006-include-limits.h-for-PATH_MAX.patch new file mode 100644 index 0000000000..35dd6e11cc --- /dev/null +++ b/meta-oe/recipes-benchmark/libhugetlbfs/files/0006-include-limits.h-for-PATH_MAX.patch | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | From 96c012ea31a2d124528f3b6f3b9857b71b059db3 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <raj.khem@gmail.com> | ||
| 3 | Date: Thu, 21 Jun 2018 19:58:53 -0700 | ||
| 4 | Subject: [PATCH 6/6] include limits.h for PATH_MAX | ||
| 5 | |||
| 6 | Fixes | ||
| 7 | |||
| 8 | error: 'PATH_MAX' undeclared | ||
| 9 | |||
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
| 11 | --- | ||
| 12 | hugeadm.c | 1 + | ||
| 13 | tests/gethugepagesizes.c | 1 + | ||
| 14 | 2 files changed, 2 insertions(+) | ||
| 15 | |||
| 16 | diff --git a/hugeadm.c b/hugeadm.c | ||
| 17 | index fe4211d..8db274c 100644 | ||
| 18 | --- a/hugeadm.c | ||
| 19 | +++ b/hugeadm.c | ||
| 20 | @@ -33,6 +33,7 @@ | ||
| 21 | #include <grp.h> | ||
| 22 | #include <pwd.h> | ||
| 23 | #include <fcntl.h> | ||
| 24 | +#include <limits.h> | ||
| 25 | |||
| 26 | #include <sys/stat.h> | ||
| 27 | #include <sys/types.h> | ||
| 28 | diff --git a/tests/gethugepagesizes.c b/tests/gethugepagesizes.c | ||
| 29 | index 9551b38..2645e3f 100644 | ||
| 30 | --- a/tests/gethugepagesizes.c | ||
| 31 | +++ b/tests/gethugepagesizes.c | ||
| 32 | @@ -29,6 +29,7 @@ | ||
| 33 | #include <fcntl.h> | ||
| 34 | #include <stdarg.h> | ||
| 35 | #include <hugetlbfs.h> | ||
| 36 | +#include <limits.h> | ||
| 37 | |||
| 38 | #include "hugetests.h" | ||
| 39 | |||
| 40 | -- | ||
| 41 | 2.17.1 | ||
| 42 | |||
diff --git a/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_git.bb b/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_git.bb index ee1b9d0507..14c909e758 100644 --- a/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_git.bb +++ b/meta-oe/recipes-benchmark/libhugetlbfs/libhugetlbfs_git.bb | |||
| @@ -19,6 +19,12 @@ SRC_URI = " \ | |||
| 19 | file://0001-run_test.py-not-use-hard-coded-path-.-obj-hugeadm.patch \ | 19 | file://0001-run_test.py-not-use-hard-coded-path-.-obj-hugeadm.patch \ |
| 20 | file://libhugetlbfs-elf_i386-avoid-search-host-library-path.patch \ | 20 | file://libhugetlbfs-elf_i386-avoid-search-host-library-path.patch \ |
| 21 | file://Force-text-segment-alignment-to-0x08000000-for-i386-.patch \ | 21 | file://Force-text-segment-alignment-to-0x08000000-for-i386-.patch \ |
| 22 | file://0001-include-stddef.h-for-ptrdiff_t.patch \ | ||
| 23 | file://0002-Mark-glibc-specific-code-so.patch \ | ||
| 24 | file://0003-alloc.c-Avoid-sysconf-_SC_LEVEL2_CACHE_LINESIZE-on-l.patch \ | ||
| 25 | file://0004-shm.c-Mark-glibc-specific-changes-so.patch \ | ||
| 26 | file://0005-Include-dirent.h-for-ino_t.patch \ | ||
| 27 | file://0006-include-limits.h-for-PATH_MAX.patch \ | ||
| 22 | " | 28 | " |
| 23 | 29 | ||
| 24 | UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)" | 30 | UPSTREAM_CHECK_GITTAGREGEX = "(?P<pver>\d+(\.\d+)+)" |
