This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, libgo]: Fix build warning
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Ian Lance Taylor <iant at golang dot org>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "gofrontend-dev at googlegroups dot com" <gofrontend-dev at googlegroups dot com>
- Date: Wed, 17 Dec 2014 14:05:27 +0100
- Subject: Re: [PATCH, libgo]: Fix build warning
- Authentication-results: sourceware.org; auth=none
- References: <CAFULd4Zm1GuVLn9pHb4rd817AG+RWN2kh=BHrNc-7WNjkwiELA at mail dot gmail dot com> <CAOyqgcW-YAV__8vzDtWxh5BU7ykaMCHw7hx4B9N4iJ=OGSi=zg at mail dot gmail dot com> <CAFULd4YLm_xAWiKyCSTJGavB1a=dgk==wUprHGXBpT39V8=ZqA at mail dot gmail dot com> <CAFULd4ZZERu0EawpWBwoW3Rau7auNiB6HyY9i6epDRjg2JmNSg at mail dot gmail dot com>
On Wed, Dec 17, 2014 at 10:54 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Tue, Dec 16, 2014 at 8:58 PM, Uros Bizjak <ubizjak@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.