On Wed, Dec 17, 2014 at 10:54 AM, Uros Bizjak <ubiz...@gmail.com> wrote: > On Tue, Dec 16, 2014 at 8:58 PM, Uros Bizjak <ubiz...@gmail.com> wrote: > >>>> When building libgo on CentOS 5.11, following warnings appear: >>>> >>>> In file included from /usr/include/fcntl.h:38:0, >>>> from sysinfo.c:6: >>>> /home/uros/gcc-build/gcc/include-fixed/sys/stat.h:317:16: warning: >>>> inline function ‘lstat64’ declared but never defined >>>> __inline__ int lstat64 (__const char *__restrict __file, >>>> ^ >>>> /home/uros/gcc-build/gcc/include-fixed/sys/stat.h:286:16: warning: >>>> inline function ‘fstatat64’ declared but never defined >>>> __inline__ int fstatat64 (int __fd, __const char *__restrict __file, >>>> ^ >>>> /home/uros/gcc-build/gcc/include-fixed/sys/stat.h:255:16: warning: >>>> inline function ‘fstat64’ declared but never defined >>>> __inline__ int fstat64 (int __fd, struct stat64 *__buf) __THROW >>>> __nonnull ((2)); >>>> ^ >>>> /home/uros/gcc-build/gcc/include-fixed/sys/stat.h:250:16: warning: >>>> inline function ‘stat64’ declared but never defined >>>> __inline__ int stat64 (__const char *__restrict __file, >>>> ^ >>>> These are emitted from: >>>> >>>> CC="/home/uros/gcc-build/./gcc/xgcc -B/home/uros/gcc-build/./gcc/ >>>> -B/usr/local/x86_64-unknown-linux-gnu/bin/ >>>> -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem /usr/ >>>> local/x86_64-unknown-linux-gnu/include -isystem >>>> /usr/local/x86_64-unknown-linux-gnu/sys-include -DHAVE_CONFIG_H -I. >>>> -I../../../gcc-svn/trunk/libgo -I ../../../gcc-svn/trunk/libgo/run >>>> time -I../../../gcc-svn/trunk/libgo/../libffi/include >>>> -I../libffi/include -pthread -D_GNU_SOURCE -D_LARGEFILE_SOURCE >>>> -D_FILE_OFFSET_BITS=64" /bin/sh ../../../gcc-svn/trunk/libgo/mksysin >>>> fo.sh >>>> >>>> due to the sys/stat.h, which protects above functions with: >>>> >>>> # if defined __USE_LARGEFILE64 \ >>>> && (! defined __USE_FILE_OFFSET64 \ >>>> || (defined __REDIRECT_NTH && defined __OPTIMIZE__)) >>>> >>>> Adding -O to OSCFLAGS fixes this issue, as __OPTIMIZE__ is defined with -O. >>>> >>>> Patch was bootstrapped and regression tested on x86_64-linux-gnu >>>> (CentOS 5.11), where it removes the above warnings. >>>> >>>> OK for mainline? >>> >>> >>> This seems a bit dubious, as it seems that the same problem would >>> occur for any C program that #include's <sys/stat.h> and is compiled >>> without optimization. >> >> Please note that the above command also defines __USE_FILE_OFFSET64, >> but indeed, I don't see these warnings on Fedora 20. >> >>> I don't mind passing -O when running mksysinfo.sh, but your patch will >>> pass -O to all the C file compilations. That doesn't seem like a good >>> idea--some people might want to debug that code. Can you try either >>> only addding -O for CentOS, or addding it only to mksysinfo.sh? >> >> You are right, the proposed change was too broad. I am testing following >> patch: > > The (now attached, to avoid mailer mangling) patch also fixes > mentioned build warnings. > > Bootstrapped and regression tested on CentOS 5.11.
As an alternative, we can change mksysinfo.sh directly: --cut here-- Index: mksysinfo.sh =================================================================== --- mksysinfo.sh (revision 218813) +++ mksysinfo.sh (working copy) @@ -204,7 +204,7 @@ }; EOF -${CC} -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c +${CC} -O -fdump-go-spec=gen-sysinfo.go -std=gnu99 -S -o sysinfo.s sysinfo.c echo 'package syscall' > ${OUT} echo 'import "unsafe"' >> ${OUT} --cut here-- Also bootstrapped and regression tested on x86_64-linux-gnu, CentOS 5.11. Uros.