Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing large file support on 32bits #10

Open
panlinux opened this issue Jun 2, 2022 · 3 comments
Open

Missing large file support on 32bits #10

panlinux opened this issue Jun 2, 2022 · 3 comments

Comments

@panlinux
Copy link

panlinux commented Jun 2, 2022

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
mvo5 added a commit that referenced this issue Jun 3, 2022
The latest debian version of libsmbclient-dev no longer sets
the large file support cflags in libsmbclient.h [1]. This
leads to build failures on 32bit systems.

It seems to me that ideally `pkg-config --cflags smbclient` would
DTRT and return `-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64` along
with `-I/usr/include/samba-4.0`. However this is not the case.

The cgo system also does not allow running arbitrary scripts so
just calling `getconf LFS_CFLAGS` is not an option.

This commit adds a new `libsmbclient_lfs.go` file that is only
build on 386/arm and defined the needed LFS cflags.

[1] #10
mvo5 added a commit that referenced this issue Jun 3, 2022
The latest debian version of libsmbclient-dev no longer sets
the large file support cflags in libsmbclient.h [1]. This
leads to build failures on 32bit systems.

It seems to me that ideally `pkg-config --cflags smbclient` would
DTRT and return `-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64` along
with `-I/usr/include/samba-4.0`. However this is not the case.

The cgo system also does not allow running arbitrary scripts so
just calling `getconf LFS_CFLAGS` is not an option.

This commit adds a new `libsmbclient_lfs.go` file that is only
build on 386/arm and defined the needed LFS cflags.

[1] #10
mvo5 added a commit that referenced this issue Jun 3, 2022
The latest debian version of libsmbclient-dev no longer sets
the large file support cflags in libsmbclient.h [1]. This
leads to build failures on 32bit systems.

It seems to me that ideally `pkg-config --cflags smbclient` would
DTRT and return `-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64` along
with `-I/usr/include/samba-4.0`. However this is not the case.

The cgo system also does not allow running arbitrary scripts so
just calling `getconf LFS_CFLAGS` is not an option.

This commit adds a new `libsmbclient_lfs.go` file that is only
build on 386/arm and defined the needed LFS cflags.

[1] #10
@mvo5
Copy link
Owner

mvo5 commented Jun 3, 2022

Thanks for your bugreport. I opened #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 added a commit that referenced this issue Jun 3, 2022
The latest debian version of libsmbclient-dev no longer sets
the large file support cflags in libsmbclient.h [1]. This
leads to build failures on 32bit systems.

It seems to me that ideally `pkg-config --cflags smbclient` would
DTRT and return `-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64` along
with `-I/usr/include/samba-4.0`. However this is not the case.

The cgo system also does not allow running arbitrary scripts so
just calling `getconf LFS_CFLAGS` is not an option.

This commit adds a new `libsmbclient_lfs.go` file that is only
build on 386/arm and defined the needed LFS cflags.

[1] #10
@panlinux
Copy link
Author

panlinux commented Jun 3, 2022

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
Copy link
Author

panlinux commented Jun 3, 2022

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

mvo5 added a commit that referenced this issue Jun 7, 2022
…#11)

The latest debian version of libsmbclient-dev no longer sets
the large file support cflags in libsmbclient.h [1]. This
leads to build failures on 32bit systems.

It seems to me that ideally `pkg-config --cflags smbclient` would
DTRT and return `-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64` along
with `-I/usr/include/samba-4.0`. However this is not the case.

The cgo system also does not allow running arbitrary scripts so
just calling `getconf LFS_CFLAGS` is not an option.

This commit adds a new `libsmbclient_lfs.go` file that is only
build on 386/arm and defined the needed LFS cflags.

[1] #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants