libsmbclient-go icon indicating copy to clipboard operation
libsmbclient-go copied to clipboard

Missing large file support on 32bits

Open panlinux opened this issue 2 years ago • 3 comments

Hi,

for a long time, due to debian bug #221618[1] libsmbclient.h in debian and ubuntu shipped a patch[2] that forcibly defined LFS.

In the latest uploads to Debian, that patch was changed to [3], which now fails a build if the app linking with libsmbclient doesn't set the LFS flags. Note that libsmbclient itself is always built with LFS support, and the build will fail[4] if that's not available, so all libsmbclient binaries out there have a 64bits off_t.

All of this to say that without setting the LFS flags in the libsmbclient-go build, we now get this error on 32 bits (armhf below):

ubuntu@k1-armhf:~/src/libsmbclient-go$ go build ./cmd/smb
# github.com/mvo5/libsmbclient-go
In file included from ./libsmbclient.go:17:
/usr/include/samba-4.0/libsmbclient.h:84:13: error: size of array 'smbc_off_t_should_be_at_least_64bits_use_LFS_CFLAGS' is too large
   84 | typedef int smbc_off_t_should_be_at_least_64bits_use_LFS_CFLAGS[sizeof(off_t)-7];
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ubuntu@k1-armhf:~/src/libsmbclient-go$ getconf LFS_CFLAGS
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64

I don't know where this would be set in the go build system. Maybe in libsmbclient.go itself, in the #cgo header lines?

To fix the build of adsys, which uses this project, I did this in the packaging as an experiment:

--- a/debian/rules
+++ b/debian/rules
@@ -10,6 +10,10 @@ export DH_GOLANG_INSTALL_ALL := 1
 # Skip integration tests when building package: they need docker images.
 export ADSYS_SKIP_INTEGRATION_TESTS=1

+# be sure to set LFS_CFLAGS if needed, required for libsmbclient on 32bits
+CGO_CFLAGS  := $(shell getconf LFS_CFLAGS)
+export CGO_CFLAGS
+
 %:
        dh $@ --buildsystem=golang --with=golang,apport
  1. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=221618
  2. https://git.launchpad.net/ubuntu/+source/samba/tree/debian/patches/bug_221618_precise-64bit-prototype.patch?h=import/2%254.13.2%2bdfsg-1
  3. https://salsa.debian.org/samba-team/samba/-/blob/d0d8db5c6d6e8b5e26944031f6786031c1a389ca/debian/patches/libsmbclient-ensure-lfs-221618.patch
  4. https://github.com/samba-team/samba/blob/ac16351ff5a0c5b46f461c26516b85e8483bba83/buildtools/wafsamba/wscript#L611

panlinux avatar Jun 02 '22 20:06 panlinux

Thanks for your bugreport. I opened https://github.com/mvo5/libsmbclient-go/pull/11 to fix this, please have a look it works fine in my i386 debian sid lxc container and should also work on arm. ~AFAIK i386/arm are the only supported 32bit platforms for golang so this should be fine~ [edit] I added a bunch more even though they are not supported by Ubuntu but it's easy enough to do (it is not ideal because it will require changes if the cflags change or more 32bit platforms are added but seems the only way short of adding pkg-config flags to libsmbclient).

mvo5 avatar Jun 03 '22 08:06 mvo5

Also works fine on my i386 sid lxd. I don't have access anymore to the arm64 host where I can spawn armhf, but it should be fine.

panlinux avatar Jun 03 '22 14:06 panlinux

And on my pi3 for some reason I couldn't reproduce the build failure, unsure why...

panlinux avatar Jun 03 '22 14:06 panlinux