diff options
author | Sam James <sam@gentoo.org> | 2024-09-18 03:13:53 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2024-09-18 03:45:33 +0100 |
commit | 1cae6bea37065d9a98ba9dd4c1a4c6be626d086a (patch) | |
tree | 188086074a5250a81ef07781600a438040d7be5e /sys-devel | |
parent | app-admin/sysklogd: add 2.6.2 (diff) | |
download | gentoo-1cae6bea37065d9a98ba9dd4c1a4c6be626d086a.tar.gz gentoo-1cae6bea37065d9a98ba9dd4c1a4c6be626d086a.tar.bz2 gentoo-1cae6bea37065d9a98ba9dd4c1a4c6be626d086a.zip |
sys-devel/mold: fix --icf assert
Shows up when building Firefox.
Closes: https://bugs.gentoo.org/938009
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'sys-devel')
-rw-r--r-- | sys-devel/mold/files/mold-2.33.0-icf.patch | 41 | ||||
-rw-r--r-- | sys-devel/mold/mold-2.33.0-r1.ebuild | 103 |
2 files changed, 144 insertions, 0 deletions
diff --git a/sys-devel/mold/files/mold-2.33.0-icf.patch b/sys-devel/mold/files/mold-2.33.0-icf.patch new file mode 100644 index 000000000000..e5b90fbfd9e3 --- /dev/null +++ b/sys-devel/mold/files/mold-2.33.0-icf.patch @@ -0,0 +1,41 @@ +https://bugs.gentoo.org/938009 +https://github.com/rui314/mold/issues/1326 +https://github.com/rui314/mold/commit/5a9919b43344b4fb92ea701f0b32a7e20857b9ca + +From 5a9919b43344b4fb92ea701f0b32a7e20857b9ca Mon Sep 17 00:00:00 2001 +From: Rui Ueyama <ruiu@cs.stanford.edu> +Date: Fri, 9 Aug 2024 12:08:03 +0900 +Subject: [PATCH] Fix a crash bug + +Fixes https://github.com/rui314/mold/issues/1326 +--- a/elf/output-chunks.cc ++++ b/elf/output-chunks.cc +@@ -1730,21 +1730,18 @@ ElfSym<E> to_output_esym(Context<E> &ctx, Symbol<E> &sym, u32 st_name, + esym.st_type = STT_FUNC; + esym.st_visibility = sym.visibility; + esym.st_value = sym.get_plt_addr(ctx); +- } else if (!isec->output_section) { ++ } else if ((isec->shdr().sh_flags & SHF_MERGE) && ++ !(isec->shdr().sh_flags & SHF_ALLOC)) { + // Symbol in a mergeable non-SHF_ALLOC section, such as .debug_str +- assert(!(isec->shdr().sh_flags & SHF_ALLOC)); +- assert(isec->shdr().sh_flags & SHF_MERGE); +- assert(!sym.file->is_dso); +- + ObjectFile<E> *file = (ObjectFile<E> *)sym.file; +- MergeableSection<E> *m = +- file->mergeable_sections[file->get_shndx(sym.esym())].get(); ++ MergeableSection<E> &m = ++ *file->mergeable_sections[file->get_shndx(sym.esym())]; + + SectionFragment<E> *frag; + i64 frag_addend; +- std::tie(frag, frag_addend) = m->get_fragment(sym.esym().st_value); ++ std::tie(frag, frag_addend) = m.get_fragment(sym.esym().st_value); + +- shndx = m->parent.shndx; ++ shndx = m.parent.shndx; + esym.st_visibility = sym.visibility; + esym.st_value = frag->get_addr(ctx) + frag_addend; + } else { + diff --git a/sys-devel/mold/mold-2.33.0-r1.ebuild b/sys-devel/mold/mold-2.33.0-r1.ebuild new file mode 100644 index 000000000000..257d0d263979 --- /dev/null +++ b/sys-devel/mold/mold-2.33.0-r1.ebuild @@ -0,0 +1,103 @@ +# Copyright 2021-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cmake toolchain-funcs + +DESCRIPTION="A Modern Linker" +HOMEPAGE="https://github.com/rui314/mold" +if [[ ${PV} == 9999 ]] ; then + EGIT_REPO_URI="https://github.com/rui314/mold.git" + inherit git-r3 +else + SRC_URI="https://github.com/rui314/mold/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" + KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc ~riscv ~sparc ~x86" +fi + +# mold (MIT) +# - xxhash (BSD-2) +# - siphash ( MIT CC0-1.0 ) +LICENSE="MIT BSD-2 CC0-1.0" +SLOT="0" + +RDEPEND=" + app-arch/zstd:= + >=dev-cpp/tbb-2021.7.0-r1:= + dev-libs/blake3:= + sys-libs/zlib + !kernel_Darwin? ( + >=dev-libs/mimalloc-2:= + ) +" +DEPEND="${RDEPEND}" + +PATCHES=( + "${FILESDIR}"/${P}-icf.patch +) + +pkg_pretend() { + # Requires a c++20 compiler, see #831473 + if [[ ${MERGE_TYPE} != binary ]]; then + if tc-is-gcc && [[ $(gcc-major-version) -lt 10 ]]; then + die "${PN} needs at least gcc 10" + elif tc-is-clang && [[ $(clang-major-version) -lt 12 ]]; then + die "${PN} needs at least clang 12" + fi + fi +} + +src_prepare() { + cmake_src_prepare + + # Needs unpackaged dwarfdump + rm test/elf/{{dead,compress}-debug-sections,compressed-debug-info}.sh || die + + # Heavy tests, need qemu + rm test/elf/gdb-index-{compress-output,dwarf{2,3,4,5}}.sh || die + rm test/elf/lto-{archive,dso,gcc,llvm,version-script}.sh || die + + # Sandbox sadness + rm test/elf/run.sh || die + sed -i 's|`pwd`/mold-wrapper.so|"& ${LD_PRELOAD}"|' \ + test/elf/mold-wrapper{,2}.sh || die + + # static-pie tests require glibc built with static-pie support + if ! has_version -d 'sys-libs/glibc[static-pie(+)]'; then + rm test/elf/{,ifunc-}static-pie.sh || die + fi +} + +src_configure() { + local mycmakeargs=( + -DMOLD_ENABLE_QEMU_TESTS=OFF + -DMOLD_LTO=OFF # Should be up to the user to decide this with CXXFLAGS. + -DMOLD_USE_MIMALLOC=$(usex !kernel_Darwin) + -DMOLD_USE_SYSTEM_MIMALLOC=ON + -DMOLD_USE_SYSTEM_TBB=ON + ) + cmake_src_configure +} + +src_install() { + dobin "${BUILD_DIR}"/${PN} + + # https://bugs.gentoo.org/872773 + insinto /usr/$(get_libdir)/mold + doins "${BUILD_DIR}"/${PN}-wrapper.so + + dodoc docs/{design,execstack}.md + doman docs/${PN}.1 + + dosym ${PN} /usr/bin/ld.${PN} + dosym ${PN} /usr/bin/ld64.${PN} + dosym -r /usr/bin/${PN} /usr/libexec/${PN}/ld +} + +src_test() { + export TEST_CC="$(tc-getCC)" \ + TEST_GCC="$(tc-getCC)" \ + TEST_CXX="$(tc-getCXX)" \ + TEST_GXX="$(tc-getCXX)" + cmake_src_test +} |