From 2771f79232c273bc2a57d23bf335dd81ccf6af28 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 5 Dec 2021 02:47:11 +0000 Subject: gentoo resync : 05.12.2021 --- sys-libs/libhugetlbfs/Manifest | 3 +- ...fs-2.23-allow-building-against-glibc-2.34.patch | 258 +++++++++++++++++++++ sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild | 1 + 3 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-allow-building-against-glibc-2.34.patch (limited to 'sys-libs/libhugetlbfs') diff --git a/sys-libs/libhugetlbfs/Manifest b/sys-libs/libhugetlbfs/Manifest index 8ae94cbdaf41..16046e398d08 100644 --- a/sys-libs/libhugetlbfs/Manifest +++ b/sys-libs/libhugetlbfs/Manifest @@ -1,5 +1,6 @@ +AUX libhugetlbfs-2.23-allow-building-against-glibc-2.34.patch 10055 BLAKE2B 38b3c28321bdaa5271d8655823ea00952ca8571c84bfe9ec980a35ad7ad77e382ac9235c058597628cc574e03ce0dadbe19bab298c30763e03508aff01275e4b SHA512 abfcfdd87cf7c17663ba466c46182ac04aac454bcedc55a5032bd142419388daa8b0ca0a885f3aedfc830bbd2c58dfd15c4a3499a6fb26df679d8cbe87bf2143 AUX libhugetlbfs-2.23-uncompressed-man-pages.patch 1515 BLAKE2B b43415a3059f1071f0fc04ec834cd51d87a8bd93f2df6b428a33296b1b55745f23861415a463d5899b12699c5f4a3e5bdd837a8ec2894d1fc89039924330d77d SHA512 ea3ef19a688866676315af59422233681a41338fd049cfa50ed91f660f0baf1950ba056b9fcd540e6694b8ec348c0d1fbb3aa6b8c1840e22a77634e26555c9bc AUX libhugetlbfs-2.6-fixup-testsuite.patch 1231 BLAKE2B e49ac448b4ac17a6ce9c32543e3ad7391bc8525e147d7a5100ef7ae15e4b0cf48b58ff1fe62d9a0fa61f142b7b8366228974c6628999edaa61d96114371bc09d SHA512 af9ee541ac4a30260e17baab1616cee13fdcc679ae3fdceed29ca6282c12a6b60d24b04bb61e3aa5f42092e017eb3bae59a56fd2b03954e40803f9f6f2cc4f80 DIST libhugetlbfs-2.23.tar.gz 175459 BLAKE2B f469ff9a65364e9f0e04c11c8010c958855ebd4d50e1dd719576cda7c280586623404304be64a794907a5fb1d97bd9c0620a91d7a2492577e04fa40ff432b4c7 SHA512 fc9a7d59bcda9d3ca9c9e43a3a348f989c9cbdbbb77f21a43a06e71eacd05bbe5a7b2b51e20ae9ea00da9f1c4d1130da529bbfb702e8c9d11cab6efadd3dc168 -EBUILD libhugetlbfs-2.23.ebuild 4218 BLAKE2B bd527e5c16ef3f0f9a4a4a7743755d1dc1aac2a6caad747182347600d04ff26ff72b2ea7f4a874ac1e34bfddd38845e69186ae864c7408d759320ca1ff777fe3 SHA512 60facbec943112d3eedfbc66133ee26a9300271ba4e9bca14e7e2f0c01145eedba2d6dbfb9e79183f827e9707be9ae5e3ddd087bdb415fd34aaaed3939e57f63 +EBUILD libhugetlbfs-2.23.ebuild 4284 BLAKE2B 544569161a2110825e2919e7556947f8730531db4a5dc23bfc887fe5066226e9f9a54ce9efb44eb6537fc68080a76e5aba20018e5b4df8825735a4149f94d0b3 SHA512 98d912b5ff58d48f3e4bdbb64e5e33d4eb5700d52227d3f314179a2b9552ce605c32a4a7b24f8c212d94c8b75cd8bef7527daa85a4b7b09579c4d53e496c3655 MISC metadata.xml 397 BLAKE2B 7b521a2822a494f6a2b7a85420a38edd396ca0e3856faeb682378c48eda3d1932788af7ac7bbb4e07cae37b2119afd386f75c5dc0ab1f69c8e4630be16cc549e SHA512 96065769a7893c1e05bc3ab9396eb01a60a293dac9b090419087a9bb5a152b2f291a950e8217ffcb7bed34262a5369119da469e22cc3171fdc0ad2b87ae6d698 diff --git a/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-allow-building-against-glibc-2.34.patch b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-allow-building-against-glibc-2.34.patch new file mode 100644 index 000000000000..68e121e240ab --- /dev/null +++ b/sys-libs/libhugetlbfs/files/libhugetlbfs-2.23-allow-building-against-glibc-2.34.patch @@ -0,0 +1,258 @@ +From 959d74fd0fbbff310943096e15024a84e8f5cba4 Mon Sep 17 00:00:00 2001 +From: Matheus Castanho +Date: Thu, 12 Aug 2021 16:38:46 -0300 +Subject: [PATCH] Disable hugepage-backed malloc if __morecore is not available + +Starting with glibc 2.32, __morecore hook has been marked as deprecated, and was +completely removed on glibc 2.34, which causes an undefined symbol error during +the build of libhugetlbfs. + +Greater changes are needed in order to keep providing the same functionality +with future versions of glibc (see issue #52). Meanwhile, we can disable +hugepage-backed malloc setup if __morecore is not available so users can at +least keep using the other features provided by the library. Related tests are +also conditionally disabled, and will show as SKIPPED if __morecore is not +available. + +Tested on powerpc64le and x86_64 with glibc 2.34 and olders. + +Signed-off-by: Matheus Castanho +--- + Makefile | 6 +++++ + morecore.c | 8 ++++++ + tests/run_tests.py | 67 +++++++++++++++++++++++++++++++++++++++------- + 3 files changed, 71 insertions(+), 10 deletions(-) + +diff --git a/Makefile b/Makefile +index 8b73523..35e53e7 100644 +--- a/Makefile ++++ b/Makefile +@@ -192,6 +192,12 @@ endif + endif + endif + ++# glibc 2.34 removed __morecore, so it may not be available with recent versions ++HAS_MORECORE := $(shell /bin/echo -e '\#include \nvoid * morecore_exists() { return &__morecore; }' | $(CC) -c -xc -o /dev/null - &> /dev/null && /bin/echo yes || /bin/echo no) ++ifeq ($(HAS_MORECORE),yes) ++CFLAGS += -DHAS_MORECORE ++endif ++ + HEADERDIR = $(PREFIX)/include + LIBDIR32 = $(PREFIX)/$(LIB32) + LIBDIR64 = $(PREFIX)/$(LIB64) +diff --git a/morecore.c b/morecore.c +index 6563bbd..405c566 100644 +--- a/morecore.c ++++ b/morecore.c +@@ -33,6 +33,13 @@ + + #include "libhugetlbfs_internal.h" + ++#ifndef HAS_MORECORE ++void hugetlbfs_setup_morecore(void) ++{ ++ INFO("Not setting up morecore because it's not available (see issue #52).\n"); ++} ++#else ++ + static int heap_fd; + + static void *heapbase; +@@ -381,3 +388,4 @@ void hugetlbfs_setup_morecore(void) + * to mmap() if we run out of hugepages. */ + mallopt(M_MMAP_MAX, 0); + } ++#endif /* HAS_MORECORE */ +diff --git a/tests/run_tests.py b/tests/run_tests.py +index 018264d..871d04d 100755 +--- a/tests/run_tests.py ++++ b/tests/run_tests.py +@@ -60,7 +60,7 @@ def snapshot_pool_state(): + l.append((d, tuple(substate))) + return tuple(l) + +-def run_test_prog(bits, pagesize, cmd, **env): ++def run_test_prog(bits, pagesize, cmd, output='stdout', **env): + if paranoid_pool_check: + beforepool = snapshot_pool_state() + print("Pool state: %s" % str(beforepool)) +@@ -73,15 +73,17 @@ def run_test_prog(bits, pagesize, cmd, **env): + % (bits, bits, local_env.get("LD_LIBRARY_PATH", "")) + local_env["HUGETLB_DEFAULT_PAGE_SIZE"] = repr(pagesize) + ++ popen_args = {'env' : local_env, output : subprocess.PIPE} ++ + try: +- p = subprocess.Popen(cmd, env=local_env, stdout=subprocess.PIPE) ++ p = subprocess.Popen(cmd, **popen_args) + rc = p.wait() + except KeyboardInterrupt: + # Abort and mark this a strange test result + return (None, "") + except OSError as e: + return (-e.errno, "") +- out = p.stdout.read().decode().strip() ++ out = getattr(p, output).read().decode().strip() + + if paranoid_pool_check: + afterpool = snapshot_pool_state() +@@ -309,6 +311,33 @@ def check_linkhuge_tests(): + okbits.add(bits) + return okbits + ++def check_morecore_disabled(): ++ """ ++ Check if support for morecore is available. ++ ++ Newer glibc versions (>= 2.34) removed the __morecore malloc hook, so tests ++ relying on that functionality will not work as expected, and should be ++ disabled. ++ """ ++ global morecore_disabled, wordsizes, pagesizes ++ ++ # Quick and dirty way to get a word and page size. Which one doesn't really ++ # matter in this case. ++ for wsz in wordsizes: ++ b = wsz ++ break ++ for psz in pagesizes: ++ p = psz ++ break ++ ++ # Run an arbitrary program and check stderr for the "morecore disabled" ++ # message ++ (rc, out) = run_test_prog(b, p, "gethugepagesize", output='stderr', ++ HUGETLB_MORECORE="yes", ++ HUGETLB_VERBOSE="3") ++ ++ morecore_disabled = "Not setting up morecore" in out ++ + def print_cmd(pagesize, bits, cmd, env): + if env: + print(' '.join(['%s=%s' % (k, v) for k, v in env.items()]), end=" ") +@@ -357,14 +386,17 @@ def skip_test(pagesize, bits, cmd, **env): + print_cmd(pagesize, bits, cmd, env) + print("SKIPPED") + +-def do_test(cmd, bits=None, **env): ++def do_test(cmd, bits=None, skip=False, **env): + """ + Run a test case, testing each page size and each indicated word size. + """ + if bits == None: bits = wordsizes + for p in pagesizes: + for b in (set(bits) & wordsizes_by_pagesize[p]): +- run_test(p, b, cmd, **env) ++ if skip: ++ skip_test(p, b, cmd, **env) ++ else: ++ run_test(p, b, cmd, **env) + + def do_test_with_rlimit(rtype, limit, cmd, bits=None, **env): + """ +@@ -375,7 +407,7 @@ def do_test_with_rlimit(rtype, limit, cmd, bits=None, **env): + do_test(cmd, bits, **env) + resource.setrlimit(rtype, oldlimit) + +-def do_test_with_pagesize(pagesize, cmd, bits=None, **env): ++def do_test_with_pagesize(pagesize, cmd, bits=None, skip=False, **env): + """ + Run a test case, testing with a specified huge page size and + each indicated word size. +@@ -383,7 +415,10 @@ def do_test_with_pagesize(pagesize, cmd, bits=None, **env): + if bits == None: + bits = wordsizes + for b in (set(bits) & wordsizes_by_pagesize[pagesize]): +- run_test(pagesize, b, cmd, **env) ++ if skip: ++ skip_test(pagesize, b, cmd, **env) ++ else: ++ run_test(pagesize, b, cmd, **env) + + def do_elflink_test(cmd, **env): + """ +@@ -533,7 +568,7 @@ def functional_tests(): + """ + Run the set of functional tests. + """ +- global linkhuge_wordsizes ++ global linkhuge_wordsizes, morecore_disabled + + # Kernel background tests not requiring hugepage support + do_test("zero_filesize_segment") +@@ -598,19 +633,24 @@ def functional_tests(): + do_test("fork-cow") + do_test("direct") + do_test_with_pagesize(system_default_hpage_size, "malloc") ++ + do_test_with_pagesize(system_default_hpage_size, "malloc", ++ skip=morecore_disabled, + LD_PRELOAD="libhugetlbfs.so", + HUGETLB_MORECORE="yes") + do_test_with_pagesize(system_default_hpage_size, "malloc", ++ skip=morecore_disabled, + LD_PRELOAD="libhugetlbfs.so", + HUGETLB_MORECORE="yes", + HUGETLB_RESTRICT_EXE="unknown:none") + do_test_with_pagesize(system_default_hpage_size, "malloc", ++ skip=morecore_disabled, + LD_PRELOAD="libhugetlbfs.so", + HUGETLB_MORECORE="yes", + HUGETLB_RESTRICT_EXE="unknown:malloc") + do_test_with_pagesize(system_default_hpage_size, "malloc_manysmall") + do_test_with_pagesize(system_default_hpage_size, "malloc_manysmall", ++ skip=morecore_disabled, + LD_PRELOAD="libhugetlbfs.so", + HUGETLB_MORECORE="yes") + +@@ -630,26 +670,32 @@ def functional_tests(): + do_test_with_pagesize(system_default_hpage_size, "heapshrink", + GLIBC_TUNABLES="glibc.malloc.tcache_count=0", + LD_PRELOAD="libheapshrink.so") ++ + do_test_with_pagesize(system_default_hpage_size, "heapshrink", ++ skip=morecore_disabled, + GLIBC_TUNABLES="glibc.malloc.tcache_count=0", + LD_PRELOAD="libhugetlbfs.so", + HUGETLB_MORECORE="yes") + do_test_with_pagesize(system_default_hpage_size, "heapshrink", ++ skip=morecore_disabled, + GLIBC_TUNABLES="glibc.malloc.tcache_count=0", + LD_PRELOAD="libhugetlbfs.so libheapshrink.so", + HUGETLB_MORECORE="yes") + do_test_with_pagesize(system_default_hpage_size, "heapshrink", ++ skip=morecore_disabled, + GLIBC_TUNABLES="glibc.malloc.tcache_count=0", + LD_PRELOAD="libheapshrink.so", + HUGETLB_MORECORE="yes", + HUGETLB_MORECORE_SHRINK="yes") + do_test_with_pagesize(system_default_hpage_size, "heapshrink", ++ skip=morecore_disabled, + GLIBC_TUNABLES="glibc.malloc.tcache_count=0", + LD_PRELOAD="libhugetlbfs.so libheapshrink.so", + HUGETLB_MORECORE="yes", + HUGETLB_MORECORE_SHRINK="yes") + +- do_test("heap-overflow", HUGETLB_VERBOSE="1", HUGETLB_MORECORE="yes") ++ do_test("heap-overflow", skip=morecore_disabled, HUGETLB_VERBOSE="1", ++ HUGETLB_MORECORE="yes") + + # Run the remapping tests' up-front checks + linkhuge_wordsizes = check_linkhuge_tests() +@@ -747,7 +793,7 @@ def print_help(): + + def main(): + global wordsizes, pagesizes, dangerous, paranoid_pool_check, system_default_hpage_size +- global custom_ldscripts ++ global custom_ldscripts, morecore_disabled + testsets = set() + env_override = {"QUIET_TEST": "1", "HUGETLBFS_MOUNTS": "", + "HUGETLB_ELFMAP": None, "HUGETLB_MORECORE": None} +@@ -802,6 +848,7 @@ def main(): + return 1 + + check_hugetlbfs_path() ++ check_morecore_disabled() + + if "func" in testsets: functional_tests() + if "stress" in testsets: stress_tests() diff --git a/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild b/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild index ce5da82ddfcd..c091b4a8c00b 100644 --- a/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild +++ b/sys-libs/libhugetlbfs/libhugetlbfs-2.23.ebuild @@ -22,6 +22,7 @@ BDEPEND="test? ( ${PYTHON_DEPS} )" PATCHES=( "${FILESDIR}"/${PN}-2.6-fixup-testsuite.patch "${FILESDIR}"/${PN}-2.23-uncompressed-man-pages.patch + "${FILESDIR}"/${PN}-2.23-allow-building-against-glibc-2.34.patch ) src_prepare() { -- cgit v1.2.3