Bug 196135 - Fix graphics/ImageMagick installed headers, and some other clang 3.5.0 warnings
Summary: Fix graphics/ImageMagick installed headers, and some other clang 3.5.0 warnings
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Koop Mast
URL:
Keywords:
Depends on:
Blocks: 195480
  Show dependency treegraph
 
Reported: 2014-12-19 16:55 UTC by Dimitry Andric
Modified: 2014-12-20 20:25 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (kwm)


Attachments
Fix several clang 3.5.0 warnings in graphics/ImageMagick (6.17 KB, patch)
2014-12-19 16:55 UTC, Dimitry Andric
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric freebsd_committer 2014-12-19 16:55:06 UTC
Created attachment 150782 [details]
Fix several clang 3.5.0 warnings in graphics/ImageMagick

In bug 195480, which is about fixing as many ports as possible for the clang 3.5.0 import, there are some newly reported port failures, which are caused by ImageMagick headers [1].  In case of graphics/dcraw-m, this results in -Werror warnings:

In file included from dcraw-m.c:53:
In file included from /usr/local/include/ImageMagick-6/wand/MagickWand.h:72:
In file included from /usr/local/include/ImageMagick-6/magick/MagickCore.h:120:
/usr/local/include/ImageMagick-6/magick/memory_.h:29:36: error: unknown attribute '__alloc_size__' ignored [-Werror,-Wunknown-attributes]
  *(*AcquireMemoryHandler)(size_t) magick_alloc_size(1),
                                   ^
/usr/local/include/ImageMagick-6/magick/method-attribute.h:127:48: note: expanded from macro 'magick_alloc_size'
#  define magick_alloc_size(x)  __attribute__((__alloc_size__(x)))
                                               ^

This is because the ImageMagick headers erroneously assume that clang supports the __alloc_size__ attribute.  See also the upstream commit [2] which introduced this error.

The fix for this is to define the magic_alloc_size, magic_alloc_sizes, wand_alloc_size and wand_alloc_sizes macros as empty, when clang is used.

Additionally, since clang does support the __hot__ and __cold__ attributes, these can be split off to a separate #ifdef block.

Another cause of many warnings is the sloppy usage of fabs(), even for float or long double type, resulting in hundreds of warnings like:

In file included from coders/tga.c:47:
./magick/color-private.h:44:8: warning: absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value [-Wabsolute-value]
  if ((fabs(red-q->red) < MagickEpsilon) &&
       ^
./magick/color-private.h:44:8: note: use function 'fabsl' instead
  if ((fabs(red-q->red) < MagickEpsilon) &&
       ^~~~
       fabsl

ImageMagick should really define a magick_fabs() macro for this, and do a global search and replace, but for our port that results in a diff that is very big, and fragile to apply.

Therefore, fix this by #define'ing fabs as the correct function to call for each particular MagickRealType (e.g. float, double or long double).

It would be nice if these changes go upstream.

[1] http://pb2.nyi.freebsd.org/data/head-amd64-PR195480-default/2014-12-12_23h17m02s/logs/errors/dcraw-m-9.22.log
[2] http://trac.imagemagick.org/changeset/14360
Comment 1 Bugzilla Automation freebsd_committer 2014-12-19 16:55:06 UTC
Auto-assigned to maintainer kwm@FreeBSD.org
Comment 2 commit-hook freebsd_committer 2014-12-20 20:24:34 UTC
A commit references this bug:

Author: kwm
Date: Sat Dec 20 20:23:36 UTC 2014
New revision: 375128
URL: https://svnweb.freebsd.org/changeset/ports/375128

Log:
  Fix several clang 3.5.0 warnings in the IM code.

  PR:		196135
  Submitted by:	dim@

Changes:
  head/graphics/ImageMagick/files/
  head/graphics/ImageMagick/files/patch-magic__magick-type.h
  head/graphics/ImageMagick/files/patch-magic__method-attribute.h
  head/graphics/ImageMagick/files/patch-wand__method-attribute.h