Subject: Re: [PATCH] remove configure-time type size checks

Re: [PATCH] remove configure-time type size checks

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Thu, 1 Sep 2016 23:39:26 +0200 (CEST)

On Thu, 1 Sep 2016, Brad House via c-ares wrote:

> Configure-time type size checks are a really bad idea, especially for things
> like Apple (MacOS, iOS) where you could be building multi-arch, where you
> run configure once, but the compiler, internally, is building the source
> more than once (per architecture).

It would be nice to get rid of those, yes.

The problem isn't the configure checks really, but if some code really needs
the sizes there's really no good way around the checks. Ideally we should of
course write code that relies as little as possible on such.

> That means if you hard-code SIZEOF_LONG 4 based on what configure detected,
> but building arm32 and arm64 simultaneously, you get a misbuild on at least
> one of the platforms!

For such platforms - if the size checks are really necessary - configure
should be run twice. Once for each architecture and then two separate builds.

> Its a fairly trivial patch to remove these dependencies on detected preprocessor
> macros, for the most part they aren't used, except for a couple of cases.

So how can you remove them for the cases where they are needed?

Also, this little changelog note from Jan 14 2009 seems relevant (I didn't
really get into the exact details, maybe ẃe can still just work around it).

- ares.h no longer uses the HAVE_STRUCT_IN6_ADDR define check, but instead it
   now declares the private struct ares_in6_addr for all systems instead of
   relying on one possibly not present in the system.

> Any preprocessor macros provided by the OS for similar purposes are
> considered to be safe.

If they exist for the OSes/platforms, sure. c-ares has after all been compiled
and run on a really vast number of platforms so it is a bit of a fragile area
to just rip out large pieces from. It needs careful attention to details.

-- 
  / daniel.haxx.se
Received on 2016-09-01