Subject: Re: [PATCH] ewah: fix building with gcc < 3.4.0

From: Jeff King <[email-masked]>
Date: Tue, 3 Feb 2015 11:35:45 -0500

On Tue, Feb 03, 2015 at 11:27:07AM +0100, Tom G. Christensen wrote:

> The __builtin_ctzll function was added in gcc 3.4.0.
> This extends the check for gcc so that use of __builtin_ctzll is only
> enabled if gcc >= 3.4.0.
> ---
> 
> I noticed this on RHEL3 during 2.0.0rc phase but I see that the same
> issue was noticed on Debian Sarge:
> http://article.gmane.org/gmane.comp.version-control.git/255190
> RHEL3 ships with gcc 3.2.3.
> 
> With this patch git can build on RHEL3 provided cURL support is disabled.

Thanks. I built with some older gcc's at the time this was developed,
but I don't think I went past what was in Debian stable, which was
probably 4.something.

> -#ifdef __GNUC__
> +/* __builtin_ctzll was not available until 3.4.0 */
> +#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3  && __GNUC_MINOR > 3))
>  #define ewah_bit_ctz64(x) __builtin_ctzll(x)
>  #else
>  static inline int ewah_bit_ctz64(uint64_t x)

We could turn this into a HAS_CTZLL Makefile knob (and auto-set it as
above), but I don't think it is worth it. I don't expect anybody to need
to tweak it. I double-checked that clang sets the value of __GNUC__
appropriately.

-Peff