Skip to content

Commit

Permalink
community/the_silver_searcher: patch lfs64 usage
Browse files Browse the repository at this point in the history
Apply the patch from [a PR][0] to the_silver_searcher.

[0]:ggreer/the_silver_searcher#1525
  • Loading branch information
Ikke committed Oct 22, 2023
1 parent d8baa0c commit d134407
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 2 deletions.
8 changes: 6 additions & 2 deletions community/the_silver_searcher/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ subpackages="$pkgname-doc
$pkgname-bash-completion:bashcomp:noarch"
source="https://geoff.greer.fm/ag/releases/the_silver_searcher-$pkgver.tar.gz
gcc-10.patch
no-lfs64.patch
"

build() {
Expand Down Expand Up @@ -55,5 +56,8 @@ zshcomp() {
rmdir -p "$pkgdir"/usr/share/zsh/site-functions/ 2>&1 || true
}

sha512sums="89d4e4f7f34c0d57aa880e7c3466f0373b961744a89ad30541e89e2d614322ab46c8044ec458406a117f74b0fea14cd3063fa4e0624a96526aa23eaccd6f1141 the_silver_searcher-2.2.0.tar.gz
efda96b0f6371827e0fd568cdb751c059a8985fd263415616c9bd19e991e54e03c8ceb29c187b87146f8dcf730bb06abb065e6e6aa6a6342b3a4507ba1ab6501 gcc-10.patch"
sha512sums="
89d4e4f7f34c0d57aa880e7c3466f0373b961744a89ad30541e89e2d614322ab46c8044ec458406a117f74b0fea14cd3063fa4e0624a96526aa23eaccd6f1141 the_silver_searcher-2.2.0.tar.gz
efda96b0f6371827e0fd568cdb751c059a8985fd263415616c9bd19e991e54e03c8ceb29c187b87146f8dcf730bb06abb065e6e6aa6a6342b3a4507ba1ab6501 gcc-10.patch
551e9d50fc761b6bbd1ce54cfcc140016de7302d733e73146f842cc4c683854b7b7bb3b7c20b3a1e3cf114669c5e22459a3998e6ae54b2154e1319ce168105a4 no-lfs64.patch
"
70 changes: 70 additions & 0 deletions community/the_silver_searcher/no-lfs64.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From d7d30d821d4209ab0467c471e4b418a5be7e8c4d Mon Sep 17 00:00:00 2001
From: Brahmajit Das <[email protected]>
Date: Thu, 20 Jul 2023 10:58:34 +0530
Subject: [PATCH] src/zfile.c: Use off_t instead of off64_t

First discovered in while building on musl [1]. This is because
musl-1.2.4 (9999 right now) will remove/removes the LFS compatibility
hacks, like fopen64:
- https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4
- https://git.musl-libc.org/cgit/musl/commit/?id=25e6fee27f4a293728dd15b659170e7b9c7db9bc

The gist is that bad configure tests (suffering from
-Wimplicit-function-declaration) would build and link
successfully because musl provided these symbols as aliases, despite not
needing them (musl natively supports both LFS & time64).

To head this off, these aliases are now gone, but remain in libc.so for binary compatibility.

The proper fix is to just use the regular functions and not anything _LARGEFILE64_SOURCE
As a temporary workaround you can typedef off_t to off64_t [2] to get it
working.

[1]: https://bugs.gentoo.org/908582
[2]: https://github.com/gentoo/gentoo/pull/31186
Signed-off-by: Brahmajit Das <[email protected]>
---
Source: https://github.com/ggreer/the_silver_searcher/pull/1525
src/zfile.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/zfile.c b/src/zfile.c
index e4b756627..c11d090a2 100644
--- a/src/zfile.c
+++ b/src/zfile.c
@@ -4,7 +4,7 @@
#include <sys/types.h>

#ifdef __CYGWIN__
-typedef _off64_t off64_t;
+typedef _off64_t off_t;
#endif

#include <assert.h>
@@ -331,14 +331,14 @@ zfile_read(void *cookie_, char *buf, size_t size) {
}

static int
-zfile_seek(void *cookie_, off64_t *offset_, int whence) {
+zfile_seek(void *cookie_, off_t *offset_, int whence) {
struct zfile *cookie = cookie_;
- off64_t new_offset = 0, offset = *offset_;
+ off_t new_offset = 0, offset = *offset_;

if (whence == SEEK_SET) {
new_offset = offset;
} else if (whence == SEEK_CUR) {
- new_offset = (off64_t)cookie->logic_offset + offset;
+ new_offset = (off_t)cookie->logic_offset + offset;
} else {
/* SEEK_END not ok */
return -1;
@@ -348,7 +348,7 @@ zfile_seek(void *cookie_, off64_t *offset_, int whence) {
return -1;

/* Backward seeks to anywhere but 0 are not ok */
- if (new_offset < (off64_t)cookie->logic_offset && new_offset != 0) {
+ if (new_offset < (off_t)cookie->logic_offset && new_offset != 0) {
return -1;
}

0 comments on commit d134407

Please sign in to comment.