mirror of
https://github.com/curl/curl.git
synced 2024-12-21 06:50:10 +08:00
e91fcbac7d
Homebrew gcc builds starting with 12.4.0, 13.3.0 and 14.1.0 enabled the `availability` attribute. This broke builds because the way the Apple SDK uses attributes (when available) are incompatible with how gcc accepts them. Causing these errors: ``` error: attributes should be specified before the declarator in a function definition error: expected ',' or '}' before ``` Upstream commits implementing the `availability` macro: gcc-12:fd5530b7cb
gcc-13:cb7e4eca68
gcc-14:ff62a10886
The project above is a Darwin gcc compatibility pack, that is applied to Homebrew gcc builds. This patch works by redefining the `availability` macro to an invalid value, making `__has_attribute(availability)` checks fail, stopping Apple SDK from inserting the incompatible attributes. It also replaces the previous, local workaround for `lib/macos.c`. Example with gcc 12.4.0 with macOS SDK 14.0 (Xcode 15.0.1): ``` In file included from <path-to-sdk>/MacOSX14.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:54, from <path-to-sdk>/MacOSX14.0.sdk/System/Library/Frameworks/SystemConfiguration.framework/Headers/SCDynamicStoreCopySpecific.h:30, from /Users/runner/work/curl/curl/lib/macos.c:33, from /Users/runner/work/curl/curl/build/lib/CMakeFiles/libcurl_shared.dir/Unity/unity_0_c.c:244: <path-to-sdk>/MacOSX14.0.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CFUserNotification.h:126:1: error: attributes should be specified before the declarator in a function definition 126 | CF_INLINE CFOptionFlags CFUserNotificationCheckBoxChecked(CFIndex i) API_AVAILABLE(macos(10.0)) API_UNAVAILABLE(ios, watchos, tvos) {return ((CFOptionFlags)(1UL << (8 + i)));} | ^~~~~~~~~ ``` Ref: https://github.com/curl/curl/actions/runs/9787982387/job/27025351601?pr=14096#step:7:18 The gcc vs. llvm/clang incompatibility possibly tracked here upstream: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108796 More info: https://github.com/llvm/llvm-project/issues/817678433baadec
https://discourse.llvm.org/t/changing-attribute-ast-printing-location-for-gcc-compatibility/73215 https://reviews.llvm.org/D159362 Follow-up todb135f8d72
#14119 Ref: https://github.com/curl/curl/pull/14091#issuecomment-2222703468 Fixes #13700 Cherry-picked from #14097 Closes #14155
56 lines
1.8 KiB
C
56 lines
1.8 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* Project ___| | | | _ \| |
|
|
* / __| | | | |_) | |
|
|
* | (__| |_| | _ <| |___
|
|
* \___|\___/|_| \_\_____|
|
|
*
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
*
|
|
* This software is licensed as described in the file COPYING, which
|
|
* you should have received as part of this distribution. The terms
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
*
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
* SPDX-License-Identifier: curl
|
|
*
|
|
***************************************************************************/
|
|
|
|
#include "curl_setup.h"
|
|
|
|
#ifdef CURL_MACOS_CALL_COPYPROXIES
|
|
|
|
#include <curl/curl.h>
|
|
|
|
#include "macos.h"
|
|
|
|
#include <SystemConfiguration/SCDynamicStoreCopySpecific.h>
|
|
|
|
CURLcode Curl_macos_init(void)
|
|
{
|
|
{
|
|
/*
|
|
* The automagic conversion from IPv4 literals to IPv6 literals only
|
|
* works if the SCDynamicStoreCopyProxies system function gets called
|
|
* first. As Curl currently does not support system-wide HTTP proxies, we
|
|
* therefore do not use any value this function might return.
|
|
*
|
|
* This function is only available on macOS and is not needed for
|
|
* IPv4-only builds, hence the conditions for defining
|
|
* CURL_MACOS_CALL_COPYPROXIES in curl_setup.h.
|
|
*/
|
|
CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL);
|
|
if(dict)
|
|
CFRelease(dict);
|
|
}
|
|
return CURLE_OK;
|
|
}
|
|
|
|
#endif
|