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

gccgo: libgo: Syscall statfs/fstatfs not aware of the target syscalls with hardcoded _FILE_OFFSET_BITS=64. #20922

Closed
jeesteve opened this issue Jul 6, 2017 · 1 comment
Milestone

Comments

@jeesteve
Copy link

jeesteve commented Jul 6, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

I do not have go for the host only for the target and not using it.... on the host only cross compiler gccgo
gccgo:
Using built-in specs.
COLLECT_GCC=/home/devuser/x-tools/powerpc-e500-linux-gnu/bin/powerpc-e500-linux-gnu-gccgo
COLLECT_LTO_WRAPPER=/home/devuser/x-tools/powerpc-e500-linux-gnu/libexec/gcc/powerpc-e500-linux-gnu/7.1.0/lto-wrapper
Target: powerpc-e500-linux-gnu
Configured with: /home/devuser/cc4target/.build/src/gcc-7.1.0/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=powerpc-e500-linux-gnu --prefix=/home/devuser/x-tools/powerpc-e500-linux-gnu --with-sysroot=/home/devuser/x-tools/powerpc-e500-linux-gnu/powerpc-e500-linux-gnu/sysroot --enable-languages=c,c++,go --with-cpu=8540 --with-float=soft --with-pkgversion='crosstool-NG crosstool-ng-1.23.0-90-g81327dd9' --disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --enable-libsanitizer --disable-libmpx --with-gmp=/home/devuser/cc4target/.build/powerpc-e500-linux-gnu/buildtools --with-mpfr=/home/devuser/cc4target/.build/powerpc-e500-linux-gnu/buildtools --with-mpc=/home/devuser/cc4target/.build/powerpc-e500-linux-gnu/buildtools --with-isl=/home/devuser/cc4target/.build/powerpc-e500-linux-gnu/buildtools --disable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++ -lm' --enable-threads=posix --without-long-double-128 --disable-plugin --disable-nls --disable-multilib --with-local-prefix=/home/devuser/x-tools/powerpc-e500-linux-gnu/powerpc-e500-linux-gnu/sysroot --enable-long-long
Thread model: posix
gcc version 7.1.0 (crosstool-NG crosstool-ng-1.23.0-90-g81327dd9)

  • go1.8.1 gccgo (crosstool-NG crosstool-ng-1.23.0-90-g81327dd9) 7.1.0 linux-ppc

What operating system and processor architecture are you using (go env)?

GOARCH=ppc
GOOS=LINUX
_FILE_OFFSET_BITS=none.
I have both system calls statfs and statfs64.

What did you do?

generate cross-compiler and executed https://github.com/calmh/du
the results are simply wrong. The statfs (32 bits) system call ended up being called with the Statfs type of the 64 bits i.e (Statfs.Bfree (64 bits)).

You can see that something is wrong below, the syscalls statfs returns f_bfree 176657 and when printing the field in go you have 758736037651579.

maybe not the best fix for me but I removed on the configure.ac _FILE_OFFSET_BITS=64 as it was hardcoded. and made the go syscall point to the 64 version libgo/go/syscall/libcall_linux.go.
i.e:
//sys Statfs(path string, buf *Statfs_t) (err error)
//statfs64(path *byte, buf *Statfs_t) _C_int

If possible, provide a recipe for reproducing the error.

system where _FILE_OFFSET_BITS=64. is not set and _LARGEFILE64_SOURCE is set.

A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

That the go structures follows the type of the system call.
(strace)
[pid 12357] <... statfs64 resumed> {f_type=0xeffa, f_bsize=512, f_blocks=189473, f_bfree=177475, f_bavail=177475, f_files=42107, f_ffree=42042, f_fsid={0, 0}, f_namelen=67, f_frsize=512}) = 0

Free: 86 MiB
Available: 86 MiB
Size: 92 MiB
Free: 86 MiB
Available: 86 MiB
Size: 92 MiB
BlockSize: 512 Bytes
stat.BfreeFree: 177457 Bytes
stat.Bavail: 177457 Bytes
stat.Blocks 189473 Bytes
type: 61434 Bytes

What did you see instead?

strace:
[pid 30602] <... statfs resumed> {f_type=0xeffa, f_bsize=512, f_blocks=189473, f_bfree=176657, f_bavail=176657, f_files=42107, f_ffree=42042, f_fsid={0, 0}, f_namelen=67, f_frsize=512}) = 0

[002 1/16/active 19:21:57 /mib] ./du.goExec /pram
Free: 370476580884 MiB
Available: 88168464384 MiB
Size: 397353680982 MiB
BlockSize: 512 Bytes
stat.BfreeFree: 758736037651579 Bytes
stat.Bavail: 180569015058432 Bytes
stat.Blocks 813780338651665 Bytes
type: 61434 Bytes

@gopherbot gopherbot added this to the Gccgo milestone Jul 6, 2017
@bradfitz bradfitz changed the title gccgo libgo: Syscall statfs/fstatfs not aware of the target syscalls with hardcoded _FILE_OFFSET_BITS=64. gccgo: libgo: Syscall statfs/fstatfs not aware of the target syscalls with hardcoded _FILE_OFFSET_BITS=64. Jul 6, 2017
@gopherbot
Copy link

CL https://golang.org/cl/50635 mentions this issue.

hubot pushed a commit to gcc-mirror/gcc that referenced this issue Jul 21, 2017
    
    We unconditionally set _FILE_OFFSET_BITS to 64 in configure.ac, so we
    should unconditionally call the statfs64 and fstatfs64 functions.
    These functions should be available on all versions of GNU/Linux since 2.6.
    On 64-bit systems they are aliased to statfs/fstatfs, and on 32-bit
    systems they use the 64-bit data structures.
    
    Fixes golang/go#20922
    
    Reviewed-on: https://go-review.googlesource.com/50635


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@250443 138bc75d-0d04-0410-961f-82ee72b054a4
@golang golang locked and limited conversation to collaborators Jul 21, 2018
asiekierka pushed a commit to WonderfulToolchain/gcc-ia16 that referenced this issue May 16, 2022
    
    We unconditionally set _FILE_OFFSET_BITS to 64 in configure.ac, so we
    should unconditionally call the statfs64 and fstatfs64 functions.
    These functions should be available on all versions of GNU/Linux since 2.6.
    On 64-bit systems they are aliased to statfs/fstatfs, and on 32-bit
    systems they use the 64-bit data structures.
    
    Fixes golang/go#20922
    
    Reviewed-on: https://go-review.googlesource.com/50635

From-SVN: r250443
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants