|
From: | Philipp Stephani |
Subject: | Re: 27bb4de72b * Port cleanup attribute to Oracle Studio 12.5 |
Date: | Thu, 15 Jun 2017 19:20:26 +0000 |
On 06/15/2017 05:54 AM, Philipp Stephani wrote:
> I've considered a couple of options. I think the simplest and most
> portable one would be to compile as C++, which has destructors built
> into the language.
That would require some autoconf and makefile hacking, but it would
work. That is, if modules are enabled, and __attribute__ ((cleanup)) is
not available but a C++ compiler is available, then the build process
could use the C++ compiler. Admittedly this is low priority.
> How about using #pragma clang diagnostic push/pop/ignore to ignore the
> warnings in the specific statements where they arise and we know that
> they are false positives? I'd much prefer that over disabling them
> globally in configure, because most of the time the warnings are useful.
Although many warnings are useful, in my experience these particular
warnings are not useful for Emacs. That is, the hassle they cause by
false alarms costs more than the benefits of actual bugs that they fix.
It's OK to disable such warnings globally.
>
> And I'm still puzzled as to why you're getting the Clang warnings
> but I
> am not. Are you using an older Clang? Are you passing it extra warning
> options?
>
>
> I'm using the Apple fork on macOS. It's mostly identical to upstream
> Clang and compiles Emacs just fine, but it is a fork and not 100%
> identical. I also get some of the warnings only when building with -O3
> (haven't checked other optimization levels).
I just now applied the attached patch, configured with:
./configure --enable-gcc-warnings CC=clang CFLAGS='-O3'
and had no problems on Fedora 25. If you have a problem with this patch,
can you please send relevant output from 'clang --version' and 'make
V=1'?
$ git rev-parse HEAD
emacs.c:835:12: warning: comparison of 0 <= unsigned _expression_ is always true
[-Wtautological-compare]
&& 0 <= rlim.rlim_cur && rlim.rlim_cur <= LONG_MAX)
~ ^ ~~~~~~~~~~~~~
emacs.c:869:10: warning: comparison of 0 <= unsigned _expression_ is always true
[-Wtautological-compare]
if (0 <= rlim.rlim_max && rlim.rlim_max < newlim)
~ ^ ~~~~~~~~~~~~~
2 warnings generated.
$ ./config.status --config
'--with-modules' '--without-xml2' '--without-pop' '--with-mailutils' '--enable-checking' '--enable-check-lisp-object-type' 'MAKEINFO=/usr/local/opt/texinfo/bin/makeinfo' 'CFLAGS=-ggdb3 -O0'
(i.e. this doesn't even need --enable-gcc-warnings)
The other case, same repo version, but the other commit reverted:
$ make -C lib-src make-docfile V=1
gcc -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-string-plus-int -Wno-unknown-attributes -I. -I../src -I../lib -I. -I./../src -I./../lib -O3 -save-temps make-docfile.c ../lib/libgnu.a -o make-docfile
make-docfile.c:227:19: warning: equality comparison with extraneous parentheses
[-Wparentheses-equality]
if (((*tmp) == '/'))
~~~~~~~^~~~~~
make-docfile.c:227:19: note: remove extraneous parentheses around the comparison
to silence this warning
if (((*tmp) == '/'))
~ ^ ~
make-docfile.c:227:19: note: use '=' to turn this equality comparison into an
assignment
if (((*tmp) == '/'))
^~
=
1 warning generated.
$ ./config.status --config
'--with-modules' '--without-xml2' '--without-pop' '--with-mailutils' '--enable-checking' '--enable-check-lisp-object-type' 'MAKEINFO=/usr/local/opt/texinfo/bin/makeinfo' 'CFLAGS=-O3 -save-temps'
Note that the -save-temps is crucial here, without it the compiler doesn't look at the preprocessed output.
It's weird that -save-temps generates more warnings, but GCC has similar issues (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57201). -save-temps also generates tons of warnings for other files, even without --enable-gcc-warnings.
Not sure what to do about the -save-temps problem. Maybe that's just something to document somewhere, because there seems to be little we can do about it.
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/c++/4.2.1
Apple LLVM version 8.1.0 (clang-802.0.42)
Target: x86_64-apple-darwin16.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
[Prev in Thread] | Current Thread | [Next in Thread] |