[systemd-devel] compile with clang broken

David Herrmann dh.herrmann at gmail.com
Fri Aug 15 02:53:20 PDT 2014


Hi

On Fri, Aug 15, 2014 at 11:38 AM, Lennart Poettering
<lennart at poettering.net> wrote:
> On Fri, 15.08.14 10:55, David Herrmann (dh.herrmann at gmail.com) wrote:
>
>> Hm, I don't know whether that works. See the description here:
>>     https://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Other-Builtins.html
>>
>> What you propose is something like my attached patch, I guess? Along
>> the lines of:
>>     (__builtin_constant_p(A) && __builtin_constant_p(B)) ?
>>         ((A) > (B) ? (A) : (B)) :
>>         ({ ....OLD_MAX.... })
>
> Yes, correct.
>
>> Thing is, the ELSE case is not considered a compile-time constant by
>> LLVM.
>
> In that case __builtin_constant_p() would be entirely useless on LLVM,
> right? And all uses by this construct in glibc would not work, right?

No, it's just useless for our case.

glibc uses __builtin_constant_p() heavily to validate parameters. For
instance, it's very handy to verify length restrictions and so on. And
I think it was introduced mainly to allow optimizations, not to allow
conditional compilations. But maybe __builtin_choose_expr() works like
that.

Example: strlen() can use __builtin_constant_p() to use sizeof() - 1
on constant expressions (ok, it cannot, because there might be a NUL
in the middle, but I guess you get the idea?).

Thanks
David


More information about the systemd-devel mailing list