commit:     10d48fa421fd7eb5e2d0f492c6a158a853b670d1
Author:     Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 16 05:01:26 2024 +0000
Commit:     Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Mon Dec 16 05:01:26 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=10d48fa4

sys-fs/bcachefs-tools: add 1.13.0-r2

Backport patch to pass `-C default-linker-libraries` to rustc.

Closes: https://bugs.gentoo.org/935305
Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>

 ...9999.ebuild => bcachefs-tools-1.13.0-r2.ebuild} | 18 ++++++++---
 sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild   |  6 ++--
 .../bcachefs-tools-1.13.0-rustc-default-libs.patch | 36 ++++++++++++++++++++++
 3 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild 
b/sys-fs/bcachefs-tools/bcachefs-tools-1.13.0-r2.ebuild
similarity index 92%
copy from sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild
copy to sys-fs/bcachefs-tools/bcachefs-tools-1.13.0-r2.ebuild
index d31d231164a9..5545edff08b1 100644
--- a/sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild
+++ b/sys-fs/bcachefs-tools/bcachefs-tools-1.13.0-r2.ebuild
@@ -87,10 +87,11 @@ CRATES="
        [email protected]
 "
 
-LLVM_COMPAT=( {16..18} )
+LLVM_COMPAT=( {17..19} )
 PYTHON_COMPAT=( python3_{10..13} )
 VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/kentoverstreet.asc
-inherit cargo flag-o-matic llvm-r1 python-any-r1 shell-completion 
toolchain-funcs unpacker verify-sig
+
+inherit cargo flag-o-matic  llvm-r1 python-any-r1 shell-completion 
toolchain-funcs unpacker verify-sig
 
 DESCRIPTION="Tools for bcachefs"
 HOMEPAGE="https://bcachefs.org/";
@@ -124,7 +125,7 @@ DEPEND="
 "
 
 RDEPEND="${DEPEND}"
-#
+
 # Clang is required for bindgen
 BDEPEND="
        ${PYTHON_DEPS}
@@ -142,6 +143,10 @@ BDEPEND="
 
 QA_FLAGS_IGNORED="/sbin/bcachefs"
 
+PATCHES=(
+       "${FILESDIR}/${P}-rustc-default-libs.patch"
+)
+
 python_check_deps() {
        python_has_version "dev-python/docutils[${PYTHON_USEDEP}]"
 }
@@ -165,8 +170,6 @@ src_prepare() {
        default
        tc-export CC
 
-       # Version sed needed because the Makefile hasn't been bumped yet
-       # Check if it is no longer before bumping
        sed \
                -e '/^CFLAGS/s:-O2::' \
                -e '/^CFLAGS/s:-g::' \
@@ -181,6 +184,11 @@ src_compile() {
 
        default
 
+       # This version mangles the symbolic link,
+       # please check if this can be removed before bumping
+       rm "${S}"/bcachefs
+       ln -s "${S}"/target/release/bcachefs bcachefs
+
        local shell
        for shell in bash fish zsh; do
                ./bcachefs completions ${shell} > ${shell}.completion || die

diff --git a/sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild 
b/sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild
index d31d231164a9..101ecf0c2584 100644
--- a/sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild
+++ b/sys-fs/bcachefs-tools/bcachefs-tools-9999.ebuild
@@ -87,7 +87,7 @@ CRATES="
        [email protected]
 "
 
-LLVM_COMPAT=( {16..18} )
+LLVM_COMPAT=( {17..19} )
 PYTHON_COMPAT=( python3_{10..13} )
 VERIFY_SIG_OPENPGP_KEY_PATH=/usr/share/openpgp-keys/kentoverstreet.asc
 inherit cargo flag-o-matic llvm-r1 python-any-r1 shell-completion 
toolchain-funcs unpacker verify-sig
@@ -124,7 +124,7 @@ DEPEND="
 "
 
 RDEPEND="${DEPEND}"
-#
+
 # Clang is required for bindgen
 BDEPEND="
        ${PYTHON_DEPS}
@@ -165,8 +165,6 @@ src_prepare() {
        default
        tc-export CC
 
-       # Version sed needed because the Makefile hasn't been bumped yet
-       # Check if it is no longer before bumping
        sed \
                -e '/^CFLAGS/s:-O2::' \
                -e '/^CFLAGS/s:-g::' \

diff --git 
a/sys-fs/bcachefs-tools/files/bcachefs-tools-1.13.0-rustc-default-libs.patch 
b/sys-fs/bcachefs-tools/files/bcachefs-tools-1.13.0-rustc-default-libs.patch
new file mode 100644
index 000000000000..dad793cbe5e3
--- /dev/null
+++ b/sys-fs/bcachefs-tools/files/bcachefs-tools-1.13.0-rustc-default-libs.patch
@@ -0,0 +1,36 @@
+https://github.com/koverstreet/bcachefs-tools/commit/10dc29d5b9a44e7bb8aff657e73c0c68dccc32b9
+From: Alyssa Ross <[email protected]>
+Date: Sat, 12 Oct 2024 18:13:19 +0200
+Subject: [PATCH] Pass -C default-linker-libraries to rustc
+
+By default, rustc passes -nodefaultlibs to the linker.  In some cases,
+this can cause compiler builtins (e.g. __cpu_model, used by
+__builtin_cpu_supports) not to be linked in:
+
+= note: 
/nix/store/s2cjhni3s6shh0n35ay1hpj8d85k44qk-x86_64-unknown-linux-musl-binutils-2.43.1/bin/x86_64-unknown-linux-musl-ld:
 ./libbcachefs.a(tools-util.o): in function `resolve_crc32c':
+        /build/source/c_src/tools-util.c:457:(.text+0x1023): undefined 
reference to `__cpu_model'
+        collect2: error: ld returned 1 exit status
+
+I saw this with static musl GCC builds, and others have reported it with
+Clang.
+
+Link: https://github.com/koverstreet/bcachefs-tools/issues/300
+Signed-off-by: Alyssa Ross <[email protected]>
+Signed-off-by: Kent Overstreet <[email protected]>
+--- a/Makefile
++++ b/Makefile
+@@ -73,12 +73,13 @@ CFLAGS+=$(call cc-disable-warning, zero-length-array)
+ CFLAGS+=$(call cc-disable-warning, shift-overflow)
+ CFLAGS+=$(call cc-disable-warning, enum-conversion)
+ CFLAGS+=$(call cc-disable-warning, gnu-variable-sized-type-not-at-end)
++export RUSTFLAGS=-C default-linker-libraries
+ 
+ PKGCONFIG_LIBS="blkid uuid liburcu libsodium zlib liblz4 libzstd libudev 
libkeyutils"
+ ifdef BCACHEFS_FUSE
+       PKGCONFIG_LIBS+="fuse3 >= 3.7"
+       CFLAGS+=-DBCACHEFS_FUSE
+-      export RUSTFLAGS=--cfg fuse
++      RUSTFLAGS+=--cfg fuse
+ endif
+ 
+ PKGCONFIG_CFLAGS:=$(shell $(PKG_CONFIG) --cflags $(PKGCONFIG_LIBS))

Reply via email to