[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gentoo-dev
Subject:    [gentoo-dev] Re: Header files and ABI_X86
From:       Nikos Chantziaras <realnc () gmail ! com>
Date:       2013-08-22 8:27:58
Message-ID: kv4i2k$46l$1 () ger ! gmane ! org
[Download RAW message or body]

On 22/08/13 11:16, Michał Górny wrote:
> Dnia 2013-08-22, o godz. 10:56:10
> Nikos Chantziaras <realnc@gmail.com> napisał(a):
>
>> Now that Gentoo is much better in handling multilib libraries, but
>> Gentoo is source-based, there's the question of which header files are
>> used between different ABI builds.
>>
>> As I understand it, only the headers from the default ABI are installed.
>>    That means that building for abi_x86_32 on a amd64 system will use the
>> headers installed by the abi_x86_64 build of the used library.
>
> The build process installs alls headers by default and compares
> if they're the same. The ebuild can also specify that some headers need
> to be wrapped -- in that case they are installed with an ABI-detecting
> wrapper on top.

Perfect.  That's exactly what I wanted to know :-)


>> From a developer's point of view, does that mean that we now have to
>> keep Gentoo in mind when writing header files, or does Gentoo apply any
>> kind of magic here to fix differences between header files for different
>> archs?  For example, if I need to provide a PTR_SIZE macro in a header
>> that contains the size of void pointers on this particular system, I
>> would detect this with autoconf and then just use that, so the header
>> file would end up simply containing:
>>
>>       #define PTR_SIZE 8
>>
>> on x86-64, and:
>>
>>       #define PTR_SIZE 4
>>
>> on x86.  The x86-64 header won't work properly when building on Gentoo
>> for abi_x86_32.  As a developer, this is a no-no for me:
>>
>>       #ifdef THIS_ARCH
>>           #define PTR_SIZE 8
>>       #elif defined THAT_ARCH
>>           #define PTR_SIZE 4
>>       ...
>>
>> because detection should be done in autoconf, not in the header file.
>
> As a developer, you should learn not to put anything system- or machine-
> -specific in public headers. This is simply wrong, and will break more
> ways than you could imagine.
>
> We're hacking it over but it's far from perfect, and is not an excuse
> to write more screwed up software. Anything you detect about the host
> should be used *only* inside C files, and header files that are only
> used during build-time and not installed.

That's good advice in general, but sometimes this can't be done.  C++ 
templates for example need to be in headers, and thus there's sometimes 
gonna be platform-specific stuff in them.  Even if the headers are 
private, they still need to be there and will get included indirectly.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic