[Pixman] [PATCH] build: Ensure config.h does not undefine `sqrtf`

Peter TB Brett peter at peter-b.co.uk
Thu Oct 6 10:32:00 UTC 2016



On 06/10/2016 05:25, Siarhei Siamashka wrote:
> On Mon, 26 Sep 2016 10:46:50 +0100
> Peter TB Brett <peter at peter-b.co.uk> wrote:
>
>> When compiling for Windows using MSVC, `sqrtf` is a macro.
>> Previously, `configure` was detecting `sqrtf`'s availability, but then
>> undefining it in `config.h`, resulting in link failures.
>>
>> This patch modifies `configure` to use `HAVE_SQRTF` as a feature macro
>> for the `sqrtf()` function, and adds an additional stanza to
>> `config.h` which defines a suitable alternative when `HAVE_SQRTF` is
>> not defined.
  >>
  >> [snip]
>
> Thanks for posting the patch here.
>
> As I asked in https://bugs.freedesktop.org/show_bug.cgi?id=97898
> earlier, a bit more details would be very much welcome. Such as a
> complete configure error report (then a relevant part of it may be
> also included in the commit message).

Hi Sarhei,

There's nothing to see in the output of the configure script -- it succeeds.

> There is just one thing that I don't quite understand. I'm not a
> Windows person, but I believe that the MSVC compiler is not exactly
> compatible with GCC command line options. And autotools generally
> expect a GCC compatible compiler. So I'm quite curious about how
> you managed to use autotools with the MSVC compiler for compiling
> pixman.

We build pixman for a large number of platform/architecture 
combinations, and need to have as similar a behaviour as possible on 
each.  In order to achieve this, we:

1. Run autoconf on a suitable reference host [1] with our desired 
configuration options.  It is impossible to run ./configure for several 
of our targets.

2. Make (very few) modifications to the config.h file, and check this 
into our configuration management system. [2]

3. Ignore pixman's generated Makefiles and use other tools to actually 
compile.  On Windows we use Visual Studio. [3]

On a recent pixman update we did not initially make _any_ modifications 
to the generated config.h (this is ideal!)  Unfortunately, the Windows 
build link failed in Visual Studio because "sqrtf" was an unresolved 
symbol.  In the Windows x86 library, "sqrtf" is a macro, not a function.

The only reason this occurred because AC_DEFINE generates "#undef 
<macro>" in config.h by default (in this case, on AC_SEARCH_LIBS 
success).  In this case, the clear intent of the person who originally 
wrote the test was that if AC_SEARCH_LIBS succeeds, "sqrtf" is left 
_unchanged_.

The patch I provided makes it considerably easier for other users in our 
position to get pixman to build correctly, by making it clearer what's 
going on when reading "config.h" in order to make appropriate edits.

Do you have any specific objections to merging it?

                                        Peter

[1] I believe the config.h we're currently using was generated on an OS 
X 10.9 machine (but that's not really relevant).

[2] 
https://github.com/livecode/livecode-thirdparty/commits/develop/libcairo/src/pixman-config.h

[3] We generate all build control files with gyp.

-- 
Dr Peter Brett <peter at peter-b.co.uk>


More information about the Pixman mailing list