Suppressing specific Unknown Attribute '__alloc_size__' warnings
Dear Inkscape-devel,
I became tired of seeing these same warning messages over and over again whenever I compile and debug the code:
/opt/local/include/gc/gc.h:804:23: warning: unknown attribute '__alloc_size__' ignored [-Wunknown-attributes] GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL
For the record, I compile Inkscape 0.91(trunk) with XQuartz backend using latest clang from Xcode. Someone also has seen https://answers.launchpad.net/inkscape/+question/256081 this before (I’m glad the instructions I posted on the mailing list a year earlier were useful :-)), and the thing about warnings was ignored because the issue there was about getting the code to run.
It seems that clang has removed alloc_size attribute https://github.com/neovim/neovim/issues/429 a while ago. But these warnings would pop up about gazillion times per compiling session, from gc.h, so I am wondering if I can suppress this warning specifically. I’m not familiar with how to add a suppression in autoconf. Do I just do the following in configure step?
../trunk/configure --prefix=YOUR_BUILD_DIRECTORY --disable-static --enable-shared CC="clang" CXX="clang++" CXXFLAGS="-std=c++11 -stdlib=libc++ -I/opt/local/include -Wno-unknown-attributes" CPPFLAGS="-I/opt/local/include -U__STRICT_ANSI__ -Wno-unknown-attributes"
If I re-configure the build, do I have to run "make install" again before "make -j 4"?
I’m also not sure if globally suppressing this kind of warning is recommended. I have not seen this kind of warning other than this, and I couldn’t even find its definition on the official Clang documentation http://clang.llvm.org/docs/UsersManual.html. If this is not recommended, does anyone know how I can specifically suppress this particular warning?
Regards, _______________________ Papoj "Hua" Thamjaroenporn papoj@...3117...
2015-11-04 18:03 GMT+01:00 Papoj Thamjaroenporn <pt2277@...3110...>:
Dear Inkscape-devel,
I became tired of seeing these same warning messages over and over again whenever I compile and debug the code:
/opt/local/include/gc/gc.h:804:23: warning: unknown attribute '__alloc_size__' ignored [-Wunknown-attributes] GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL
It would be best if libgc was fixed so that it defined GC_ATTR_ALLOC_SIZE to nothing when it detects clang.
../trunk/configure --prefix=YOUR_BUILD_DIRECTORY --disable-static --enable-shared CC="clang" CXX="clang++" CXXFLAGS="-std=c++11 -stdlib=libc++ -I/opt/local/include -Wno-unknown-attributes" CPPFLAGS="-I/opt/local/include -U__STRICT_ANSI__ -Wno-unknown-attributes"
You only need the parameter in CPPFLAGS. (CPPFLAGS stands for "C preprocessor flags", but in practice it means flags common to C and C++ files.)
If I re-configure the build, do I have to run "make install" again before "make -j 4"?
No, you need to run "make install" only after "make -jN".
I’m also not sure if globally suppressing this kind of warning is recommended. I have not seen this kind of warning other than this, and I couldn’t even find its definition on the official Clang documentation. If this is not recommended, does anyone know how I can specifically suppress this particular warning?
Attributes are often compiler-specific, so specifying -Wno-unknown-attributes globally may be a reasonable idea. Is anyone against this?
Regards, Krzysztof
On Wed, Nov 4, 2015, at 10:34 AM, Krzysztof Kosiński wrote:
I’m also not sure if globally suppressing this kind of warning is recommended. I have not seen this kind of warning other than this, and I couldn’t even find its definition on the official Clang documentation. If this is not recommended, does anyone know how I can specifically suppress this particular warning?
Attributes are often compiler-specific, so specifying -Wno-unknown-attributes globally may be a reasonable idea. Is anyone against this?
Yes, I think this would be too broad, at least as a general principal.
If we disable *all* unknown attributes then we might be missing some that are important. Trying to limit is best. If it's like some other warnings one example had a 2% non-trivial rate. That is, only 2% of the occurrences took anything other than trivial fixes to get rid of. However... that remaining number were important. For unused parameters that 2% counted when you have hundreds of instances (6 out of 300, IIRC). And specifically we were able to spot low-level primitives (might have been in libgeom) that were being given X and Y, but then storing X twice and dropping Y.
So... at the very least we would want to be sure to only set that flag if the current compiler was a problem (e.g. is clang and also is a known picky version). Next, I'd like to see if we could limit the number of files the flag were added to.
However... in this case better than hoping the libgc maintainers fix things would be instead to just finish dropping it altogether. It did not end up solving key problems, as developers still need to follow special use-case rules in order to not leak things (which we aren't and thus do leak). Gtk+/Gtkmm have their own rules that address memory ownership so we need to just follow one set of rules instead of two.
On 2015-11-04 18:03 (+0100), Papoj Thamjaroenporn wrote:
I became tired of seeing these same warning messages over and over again whenever I compile and debug the code:
/opt/local/include/gc/gc.h:804:23: warning: unknown attribute '__alloc_size__' ignored [-Wunknown-attributes] GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL
<...>
It seems that clang has removed alloc_size attribute https://github.com/neovim/neovim/issues/429 a while ago. But these warnings would pop up about gazillion times per compiling session, from gc.h, so I am wondering if I can suppress this warning specifically. I’m not familiar with how to add a suppression in autoconf. Do I just do the following in configure step?
../trunk/configure --prefix=YOUR_BUILD_DIRECTORY--disable-static --enable-shared CC="clang" CXX="clang++" CXXFLAGS="-std=c++11 -stdlib=libc++ -I/opt/local/include *-Wno-unknown-attributes*" CPPFLAGS="-I/opt/local/include -U__STRICT_ANSI__ *-Wno-unknown-attributes*"
If I re-configure the build, do I have to run "make install" again before "make -j 4"?
I’m also not sure if globally suppressing this kind of warning is recommended. I have not seen this kind of warning other than this, and I couldn’t even find its definition on the official Clang documentation http://clang.llvm.org/docs/UsersManual.html. If this is not recommended, does anyone know how I can specifically suppress this particular warning?
boehmgc git master seems to have fixes committed already, but they are not part of a stable release yet - a possible workaround would be to file a trac ticket for MacPorts and ask to have the commits used as patches for the boehmgc port (or to installed boehmgc via portfile in local port repository which includes the upstream patches):
File: https://github.com/ivmai/bdwgc/commits/master/include/gc_config_macros.h
Commits related to recent clang: https://github.com/ivmai/bdwgc/commit/8fc1f3b61b02320848b035ccccd59e04e77d3f... https://github.com/ivmai/bdwgc/commit/b725923951d77f5c6792c2797f89179267c58c...
Thank you ~suv. I have filed a trac ticket https://trac.macports.org/ticket/49590. Meanwhile I’d properly just silence the warnings for time being.
Regards, _______________________ Papoj "Hua" Thamjaroenporn papoj@...3117...
On Nov 4, 2015, at 5:12 PM, su_v <suv@...2204...> wrote:
On 2015-11-04 18:03 (+0100), Papoj Thamjaroenporn wrote:
I became tired of seeing these same warning messages over and over again whenever I compile and debug the code:
/opt/local/include/gc/gc.h:804:23: warning: unknown attribute '__alloc_size__' ignored [-Wunknown-attributes] GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL
<...>
It seems that clang has removed alloc_size attribute https://github.com/neovim/neovim/issues/429 a while ago. But these warnings would pop up about gazillion times per compiling session, from gc.h, so I am wondering if I can suppress this warning specifically. I’m not familiar with how to add a suppression in autoconf. Do I just do the following in configure step?
../trunk/configure --prefix=YOUR_BUILD_DIRECTORY--disable-static --enable-shared CC="clang" CXX="clang++" CXXFLAGS="-std=c++11 -stdlib=libc++ -I/opt/local/include *-Wno-unknown-attributes*" CPPFLAGS="-I/opt/local/include -U__STRICT_ANSI__ *-Wno-unknown-attributes*"
If I re-configure the build, do I have to run "make install" again before "make -j 4"?
I’m also not sure if globally suppressing this kind of warning is recommended. I have not seen this kind of warning other than this, and I couldn’t even find its definition on the official Clang documentation http://clang.llvm.org/docs/UsersManual.html. If this is not recommended, does anyone know how I can specifically suppress this particular warning?
boehmgc git master seems to have fixes committed already, but they are not part of a stable release yet - a possible workaround would be to file a trac ticket for MacPorts and ask to have the commits used as patches for the boehmgc port (or to installed boehmgc via portfile in local port repository which includes the upstream patches):
File: https://github.com/ivmai/bdwgc/commits/master/include/gc_config_macros.h
Commits related to recent clang: https://github.com/ivmai/bdwgc/commit/8fc1f3b61b02320848b035ccccd59e04e77d3f... https://github.com/ivmai/bdwgc/commit/b725923951d77f5c6792c2797f89179267c58c...
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
If anyone is interested, the patch has been applied to boehmgc port.
Regards, _______________________ Papoj "Hua" Thamjaroenporn papoj@...3117...
On Nov 4, 2015, at 6:43 PM, Papoj Thamjaroenporn <pt2277@...3110...> wrote:
Thank you ~suv. I have filed a trac ticket https://trac.macports.org/ticket/49590. Meanwhile I’d properly just silence the warnings for time being.
Regards, _______________________ Papoj "Hua" Thamjaroenporn papoj@...3117... mailto:papoj@...3117...
On Nov 4, 2015, at 5:12 PM, su_v <suv@...2204... mailto:suv@...2204...> wrote:
On 2015-11-04 18:03 (+0100), Papoj Thamjaroenporn wrote:
I became tired of seeing these same warning messages over and over again whenever I compile and debug the code:
/opt/local/include/gc/gc.h:804:23: warning: unknown attribute '__alloc_size__' ignored [-Wunknown-attributes] GC_API GC_ATTR_MALLOC GC_ATTR_ALLOC_SIZE(1) void * GC_CALL
<...>
It seems that clang has removed alloc_size attribute <https://github.com/neovim/neovim/issues/429 https://github.com/neovim/neovim/issues/429> a while ago. But these warnings would pop up about gazillion times per compiling session, from gc.h, so I am wondering if I can suppress this warning specifically. I’m not familiar with how to add a suppression in autoconf. Do I just do the following in configure step?
../trunk/configure --prefix=YOUR_BUILD_DIRECTORY--disable-static --enable-shared CC="clang" CXX="clang++" CXXFLAGS="-std=c++11 -stdlib=libc++ -I/opt/local/include *-Wno-unknown-attributes*" CPPFLAGS="-I/opt/local/include -U__STRICT_ANSI__ *-Wno-unknown-attributes*"
If I re-configure the build, do I have to run "make install" again before "make -j 4"?
I’m also not sure if globally suppressing this kind of warning is recommended. I have not seen this kind of warning other than this, and I couldn’t even find its definition on the official Clang documentation <http://clang.llvm.org/docs/UsersManual.html http://clang.llvm.org/docs/UsersManual.html>. If this is not recommended, does anyone know how I can specifically suppress this particular warning?
boehmgc git master seems to have fixes committed already, but they are not part of a stable release yet - a possible workaround would be to file a trac ticket for MacPorts and ask to have the commits used as patches for the boehmgc port (or to installed boehmgc via portfile in local port repository which includes the upstream patches):
File: https://github.com/ivmai/bdwgc/commits/master/include/gc_config_macros.h https://github.com/ivmai/bdwgc/commits/master/include/gc_config_macros.h
Commits related to recent clang: https://github.com/ivmai/bdwgc/commit/8fc1f3b61b02320848b035ccccd59e04e77d3f... https://github.com/ivmai/bdwgc/commit/b725923951d77f5c6792c2797f89179267c58c...
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
participants (4)
-
Jon A. Cruz
-
Krzysztof Kosiński
-
Papoj Thamjaroenporn
-
su_v