On Tue, Dec 16, 2014 at 8:22 PM, Ian Lance Taylor <i...@golang.org> wrote: > On Tue, Dec 16, 2014 at 11:05 AM, 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: --cut here-- Index: Makefile.am =================================================================== --- Makefile.am (revision 218785) +++ Makefile.am (working copy) @@ -1812,7 +1812,7 @@ sysinfo.go: s-sysinfo; @true s-sysinfo: $(srcdir)/mksysinfo.sh config.h - CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh + CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS) -O" $(SHELL) $(srcdir)/mksysinfo.sh $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go $(STAMP) $@ Index: Makefile.in =================================================================== --- Makefile.in (revision 218785) +++ Makefile.in (working copy) @@ -4421,7 +4421,7 @@ sysinfo.go: s-sysinfo; @true s-sysinfo: $(srcdir)/mksysinfo.sh config.h - CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS)" $(SHELL) $(srcdir)/mksysinfo.sh + CC="$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(OSCFLAGS) -O" $(SHELL) $(srcdir)/mksysinfo.sh $(SHELL) $(srcdir)/mvifdiff.sh tmp-sysinfo.go sysinfo.go $(STAMP) $@ --cut here-- Uros.