All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED
@ 2015-02-06  9:35 Kyle J. McKay
  2015-02-06 10:00 ` Eric Sunshine
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle J. McKay @ 2015-02-06  9:35 UTC (permalink / raw)
  To: Eric Sunshine, Junio C Hamano; +Cc: Git mailing list

MAC_OS_X_VERSION_MIN_REQUIRED may be defined by the builder to a
specific version in order to produce compatible binaries for a
particular system.  Blindly defining it to MAC_OS_X_VERSION_10_6
is bad.

Additionally MAC_OS_X_VERSION_10_6 will not be defined on older
systems and should AvailabilityMacros.h be included on such as
system an error will result.  However, using the explicit value
of 1060 (which is what MAC_OS_X_VERSION_10_6 is defined to) does
not solve the problem.

The changes that introduced stepping on MAC_OS_X_VERSION_MIN were
made in b195aa00 (git-compat-util: suppress unavoidable
Apple-specific deprecation warnings) to avoid deprecation
warnings.

Instead of blindly setting MAC_OS_X_VERSION_MIN to 1060 change
the definition of DEPRECATED_ATTRIBUTE to empty to avoid the
warnings.  This preserves any MAC_OS_X_VERSION_MIN_REQUIRED
setting while avoiding the warnings as intended by b195aa00.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
---
 git-compat-util.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/git-compat-util.h b/git-compat-util.h
index eb9b0ff3..0efd32c4 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -212,12 +212,15 @@ extern char *gitbasename(char *);
 #endif
 
 #ifndef NO_OPENSSL
+#ifdef __APPLE__
 #define __AVAILABILITY_MACROS_USES_AVAILABILITY 0
-#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
+#include <AvailabilityMacros.h>
+#undef DEPRECATED_ATTRIBUTE
+#define DEPRECATED_ATTRIBUTE
+#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
+#endif
 #include <openssl/ssl.h>
 #include <openssl/err.h>
-#undef MAC_OS_X_VERSION_MIN_REQUIRED
-#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
 #ifdef NO_HMAC_CTX_CLEANUP
 #define HMAC_CTX_cleanup HMAC_cleanup
 #endif
--

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED
  2015-02-06  9:35 [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED Kyle J. McKay
@ 2015-02-06 10:00 ` Eric Sunshine
  2015-02-06 19:47   ` Kyle J. McKay
  0 siblings, 1 reply; 6+ messages in thread
From: Eric Sunshine @ 2015-02-06 10:00 UTC (permalink / raw)
  To: Kyle J. McKay; +Cc: Junio C Hamano, Git mailing list

On Fri, Feb 6, 2015 at 4:35 AM, Kyle J. McKay <mackyle@gmail.com> wrote:
> MAC_OS_X_VERSION_MIN_REQUIRED may be defined by the builder to a
> specific version in order to produce compatible binaries for a
> particular system.  Blindly defining it to MAC_OS_X_VERSION_10_6
> is bad.
>
> Additionally MAC_OS_X_VERSION_10_6 will not be defined on older
> systems and should AvailabilityMacros.h be included on such as
> system an error will result.  However, using the explicit value
> of 1060 (which is what MAC_OS_X_VERSION_10_6 is defined to) does
> not solve the problem.
>
> The changes that introduced stepping on MAC_OS_X_VERSION_MIN were
> made in b195aa00 (git-compat-util: suppress unavoidable
> Apple-specific deprecation warnings) to avoid deprecation
> warnings.
>
> Instead of blindly setting MAC_OS_X_VERSION_MIN to 1060 change
> the definition of DEPRECATED_ATTRIBUTE to empty to avoid the
> warnings.  This preserves any MAC_OS_X_VERSION_MIN_REQUIRED
> setting while avoiding the warnings as intended by b195aa00.
>
> Signed-off-by: Kyle J. McKay <mackyle@gmail.com>

Tested on 10.10.2 (Yosemite) and 10.5.8 (Snow Leopard).

Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>

More below...

> ---
>  git-compat-util.h | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/git-compat-util.h b/git-compat-util.h
> index eb9b0ff3..0efd32c4 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -212,12 +212,15 @@ extern char *gitbasename(char *);
>  #endif
>
>  #ifndef NO_OPENSSL
> +#ifdef __APPLE__
>  #define __AVAILABILITY_MACROS_USES_AVAILABILITY 0
> -#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
> +#include <AvailabilityMacros.h>
> +#undef DEPRECATED_ATTRIBUTE
> +#define DEPRECATED_ATTRIBUTE
> +#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
> +#endif
>  #include <openssl/ssl.h>
>  #include <openssl/err.h>
> -#undef MAC_OS_X_VERSION_MIN_REQUIRED
> -#undef __AVAILABILITY_MACROS_USES_AVAILABILITY

DEPRECATED_ATTRIBUTE is a fairly generic name. Do we want to be extra
careful and #undef it here to avoid potential unintended interactions
with other #includes (Apple or not)?

    #ifdef __APPLE__
    #undef DEPRECATED_ATTRIBUTE
    #endif

On the other hand, we've already mucked with it, so #undef may be superfluous.

>  #ifdef NO_HMAC_CTX_CLEANUP
>  #define HMAC_CTX_cleanup HMAC_cleanup
>  #endif
> --

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED
  2015-02-06 10:00 ` Eric Sunshine
@ 2015-02-06 19:47   ` Kyle J. McKay
  2015-02-06 20:05     ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle J. McKay @ 2015-02-06 19:47 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Junio C Hamano, Git mailing list

On Feb 6, 2015, at 02:00, Eric Sunshine wrote:
> On Fri, Feb 6, 2015 at 4:35 AM, Kyle J. McKay <mackyle@gmail.com>  
> wrote:
>> #ifndef NO_OPENSSL
>> +#ifdef __APPLE__
>> #define __AVAILABILITY_MACROS_USES_AVAILABILITY 0
>> -#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_6
>> +#include <AvailabilityMacros.h>
>> +#undef DEPRECATED_ATTRIBUTE
>> +#define DEPRECATED_ATTRIBUTE
>> +#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
>> +#endif
>> #include <openssl/ssl.h>
>> #include <openssl/err.h>
>> -#undef MAC_OS_X_VERSION_MIN_REQUIRED
>> -#undef __AVAILABILITY_MACROS_USES_AVAILABILITY
>
> DEPRECATED_ATTRIBUTE is a fairly generic name. Do we want to be extra
> careful and #undef it here to avoid potential unintended interactions
> with other #includes (Apple or not)?

The new patch only mucks with it when we have #ifdef __APPLE__ and  
pretty much any apple code is going to end up including the  
availability stuff sooner or later which manipulates  
DEPRECATED_ATTRIBUTE.  Essentially that makes "DEPRECATED_ATTRIBUTE" a  
reserved macro name on __APPLE__.

>
>    #ifdef __APPLE__
>    #undef DEPRECATED_ATTRIBUTE
>    #endif

If we do that, won't the compiler then helpfully supply a "0" when the  
macro is used?  Or is that only when an undefined macro is used inside  
an #if or #elif ?

That would break all later declarations that use it.

> On the other hand, we've already mucked with it, so #undef may be  
> superfluous.

Actually I just tested it.  If we #undef it we could end up producing  
these:

   error: syntax error before ‘DEPRECATED_ATTRIBUTE’

So I think it needs to stay #define'd to nothing to be safe in case  
anything later on ends up including stuff that uses it.  The worst  
that happens is you don't see some deprecation warnings that you  
otherwise would.  It won't make any functions available that shouldn't  
be or make unavailable functions that should be.

-Kyle

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED
  2015-02-06 19:47   ` Kyle J. McKay
@ 2015-02-06 20:05     ` Junio C Hamano
  2015-02-06 20:43       ` Kyle J. McKay
  0 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2015-02-06 20:05 UTC (permalink / raw)
  To: Kyle J. McKay; +Cc: Eric Sunshine, Git mailing list

"Kyle J. McKay" <mackyle@gmail.com> writes:

> Actually I just tested it.  If we #undef it we could end up producing  
> these:
>
>    error: syntax error before DEPRECATED_ATTRIBUTE
>
> So I think it needs to stay #define'd to nothing to be safe in case  
> anything later on ends up including stuff that uses it.

Doesn't the fact that your test failed indicates that it is not jsut
"to be safe in case" but is required for correctness?

The first hit for "MAC_OS_X_VERSION_MIN_REQUIRED" was this:

  https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AvailabilityMacros.h

which marks quite a many macros to that value.  I do not know what
changes they make to openssl/*.h (which is included just after the
above header is included, but I would imagine that is where the
AVAILABLE_MAC_OS_X_VERSION_XXX_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_VERSION_YYY
macros are checked and annoying warnings that are being squelched by
the previous change are given?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED
  2015-02-06 20:05     ` Junio C Hamano
@ 2015-02-06 20:43       ` Kyle J. McKay
  2015-02-06 22:01         ` Eric Sunshine
  0 siblings, 1 reply; 6+ messages in thread
From: Kyle J. McKay @ 2015-02-06 20:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Eric Sunshine, Git mailing list

On Feb 6, 2015, at 12:05, Junio C Hamano wrote:

> "Kyle J. McKay" <mackyle@gmail.com> writes:
>
>> Actually I just tested it.  If we #undef it we could end up producing
>> these:
>>
>>   error: syntax error before DEPRECATED_ATTRIBUTE
>>
>> So I think it needs to stay #define'd to nothing to be safe in case
>> anything later on ends up including stuff that uses it.
>
> Doesn't the fact that your test failed indicates that it is not jsut
> "to be safe in case" but is required for correctness?
>
> The first hit for "MAC_OS_X_VERSION_MIN_REQUIRED" was this:
>
>  https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AvailabilityMacros.h
>
> which marks quite a many macros to that value.  I do not know what
> changes they make to openssl/*.h (which is included just after the
> above header is included, but I would imagine that is where the
> AVAILABLE_MAC_OS_X_VERSION_XXX_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_VERSION_YYY
> macros are checked and annoying warnings that are being squelched by
> the previous change are given?

Yes.

Although Eric didn't specify exactly where when he suggested adding  
this:

On Feb 6, 2015, at 02:00, Eric Sunshine wrote:
>    #ifdef __APPLE__
>    #undef DEPRECATED_ATTRIBUTE
>    #endif


I took the suggestion to be after the openssl/*.h headers are included  
which would avoid the error of having DEPRECATED_ATTRIBUTE be #undef'd  
for them.  But, even math.h can end up including AvailabilityMacros.h,  
so I think #undef'ing DEPRECATED_ATTRIBUTE after the openssl/*.h  
headers are included would be unsafe in general.  While we might  
happen to get away with that today, if say compat/apple-common- 
crypto.h changes in the future (or for that matter any sequence of  
includes in other files or any headers in the Apple SDK) we could  
start seeing the error.

TLDR; yeah, DEPRECATED_ATTRIBUTE needs to remain defined to nothing.

-Kyle

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED
  2015-02-06 20:43       ` Kyle J. McKay
@ 2015-02-06 22:01         ` Eric Sunshine
  0 siblings, 0 replies; 6+ messages in thread
From: Eric Sunshine @ 2015-02-06 22:01 UTC (permalink / raw)
  To: Kyle J. McKay; +Cc: Junio C Hamano, Git mailing list

On Fri, Feb 6, 2015 at 3:43 PM, Kyle J. McKay <mackyle@gmail.com> wrote:
> On Feb 6, 2015, at 12:05, Junio C Hamano wrote:
>> "Kyle J. McKay" <mackyle@gmail.com> writes:
>>> So I think it needs to stay #define'd to nothing to be safe in case
>>> anything later on ends up including stuff that uses it.
>>
>> Doesn't the fact that your test failed indicates that it is not jsut
>> "to be safe in case" but is required for correctness?
>>
>> [...] I do not know what
>> changes they make to openssl/*.h (which is included just after the
>> above header is included, but I would imagine that is where the
>> AVAILABLE_MAC_OS_X_VERSION_XXX_AND_LATER_BUT_DEPRECATED_IN_MAC_OS_VERSION_YYY
>> macros are checked and annoying warnings that are being squelched by
>> the previous change are given?
>
> Yes.
>
> Although Eric didn't specify exactly where when he suggested adding this:
>
> On Feb 6, 2015, at 02:00, Eric Sunshine wrote:
>>
>>    #ifdef __APPLE__
>>    #undef DEPRECATED_ATTRIBUTE
>>    #endif
>
> I took the suggestion to be after the openssl/*.h headers are included which
> would avoid the error of having DEPRECATED_ATTRIBUTE be #undef'd for them.
> But, even math.h can end up including AvailabilityMacros.h, so I think
> #undef'ing DEPRECATED_ATTRIBUTE after the openssl/*.h headers are included
> would be unsafe in general.  While we might happen to get away with that
> today, if say compat/apple-common-crypto.h changes in the future (or for
> that matter any sequence of includes in other files or any headers in the
> Apple SDK) we could start seeing the error.
>
> TLDR; yeah, DEPRECATED_ATTRIBUTE needs to remain defined to nothing.

I agree with this analysis. An alternative would be to revert b195aa00
(and not apply this patch), but then we risk having legitimate
Git-related compilation warnings lost in the noise of the useless
Apple deprecation warnings.  Given the glacial pace at which Apple
headers changes, and considering the rapid pace of change in Git, it
still seems the lesser evil to suppress the useless warnings Apple
thrust upon us when they deprecated OpenSSL in its entirety without
providing replacements. It's unfortunate that the DEPRECATED_ATTRIBUTE
#define will bleed beyond the OpenSSL #includes and potentially allow
us to miss some future Apple deprecations, however, given the
shortcomings of b195aa00, the proposed patch seems to be the best we
can do.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-02-06 22:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-06  9:35 [PATCH] git-compat-util: do not step on MAC_OS_X_VERSION_MIN_REQUIRED Kyle J. McKay
2015-02-06 10:00 ` Eric Sunshine
2015-02-06 19:47   ` Kyle J. McKay
2015-02-06 20:05     ` Junio C Hamano
2015-02-06 20:43       ` Kyle J. McKay
2015-02-06 22:01         ` Eric Sunshine

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.