From patchwork Sat Jan 21 17:05:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 46844 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp805946wrn; Sat, 21 Jan 2023 09:06:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXvc5J+w/m+zVh6YLKq+SkfXw8v5FqW/s5EudRJZUu9PwI0md9C+m+cJs7LMLs6+rARTORZF X-Received: by 2002:a17:907:ca85:b0:7c1:1e5a:ed10 with SMTP id ul5-20020a170907ca8500b007c11e5aed10mr22313222ejc.8.1674320761615; Sat, 21 Jan 2023 09:06:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674320761; cv=none; d=google.com; s=arc-20160816; b=zFlXXxTyrzEf9g2IdrZm4354JOqBKxCkpycBUEFiMnt3WrIJZeLwu59qTJYOw8eYBg bTrdPrMyjrvnQCSbAKi331rU9Q1p0hpr2/9eaPzg+/yitKDS42IBTpihL8tu/vu4JWGK nTDgN9BqxcZ+nry0wsKGJXhwkGJ6Bcvd1wjBRUQ7rUf5dif6sYunY2S0jJlm7sY8mSWy fOu72Ikd+7+M8XIdkz2rDCiON7oTnsg/a1S7E0evAghzxzM7YaG6uXa+wep7iJbOlfqD klhhZR5t2Tgw5+YdEjuBsTc1f8xnE/T+eu9MMkeUDMWK9Tg0BsA1wCw1DAQe0HF40+2X J0bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=HZM4pBsNByaBsCbEMdcjL76exWU53uMRRugeulB5vgE=; b=dLHF5OM+VpZz6Wg+blbMHRc7eluPfrb7hReUEI2cKkNyyj8mWlF8yHFoZod+APgo+u IC9Ot/Vj3nE9DlD5eTc7ljGDtfYsTonJL0upvq9AIZz9snyQHmd1nKsqljlUPkcqZ7dj iQcB27i+tmXmwAR3Ujb1JZgYss8NW1RpMowfIs9mRwJKKVfPPvxwWKQ7hlrhFwac4Kq4 N3dx4Glitk+ZB8qhcriF/WVGHM6TD+AfhToslM1dc6P+ClAO1L03zEJCRM7kS7HXOmW0 XuG5MT7nSXhwIGgep5nP7090X5NY30z5nd6wbxBBudwNTPuAedIZOLypTDtTnfI9bHPN qaig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PqRUE0tY; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id xf3-20020a17090731c300b0084e3eac46ccsi38671590ejb.585.2023.01.21.09.06.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Jan 2023 09:06:01 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=PqRUE0tY; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B00FA3858C62 for ; Sat, 21 Jan 2023 17:05:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B00FA3858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674320759; bh=HZM4pBsNByaBsCbEMdcjL76exWU53uMRRugeulB5vgE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=PqRUE0tY+DZqvTUzv3clrqjw22/CFCTZHp2AxRnAbKoZgk8Zv9wiZeYaw4B2lWVYn SAXhJfEL6PQhxIb+7d9waOupJZdVoj8GIVmAFl1m5rDyE9KZWDsSzCv48IAg6rVI0Y 6KJUXfybUJOA7Ow1IHBAk8LJYLf1YzSePbHmdhek= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id A4EEF3858D32 for ; Sat, 21 Jan 2023 17:05:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A4EEF3858D32 Received: by mail-wr1-x42a.google.com with SMTP id d2so7337296wrp.8 for ; Sat, 21 Jan 2023 09:05:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=HZM4pBsNByaBsCbEMdcjL76exWU53uMRRugeulB5vgE=; b=x6nhp59Dg1XOBFdHiaIYeWPAY+jUbJONgHJg6JcVDoRIuMwg3yL8mtP71vaNi4oGyC fYI78O/5HYhMrIK5n53QHkHQqZEdW7LaRvCto+8XYECUarK+GuUHu/s/j1BgZLotoMcj jrjymr1lgQv0eYdmHjpzU1SlI7PdJqaVQEISM4dx4MZRlkIGeqFg9ZHPiEybs44W6DKo Zw0UqbmXHkA895IkzjMWX9OT1Xe4y/MTsKaAhsfFlAMd8Oi1oo8gTjMIpM/BNNjVabVc CPRQNKX96Moh66AcnnAIQWnrmdBHt1ijduI9bgOcTOsH+sqCdFf83viwsOCW41Q0KVdc 0MTg== X-Gm-Message-State: AFqh2kq/5FAp96UG9r/jUVbOdnnBJOzd2uzsuqnUR6BYlLwqSEUpNAVv I97t5mwqz4Dkv0TfF0I5vGisWgmRvjs= X-Received: by 2002:a5d:6350:0:b0:2bc:7d12:7400 with SMTP id b16-20020a5d6350000000b002bc7d127400mr16929832wrw.36.1674320709284; Sat, 21 Jan 2023 09:05:09 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id j7-20020a5d4487000000b002425be3c9e2sm806660wrq.60.2023.01.21.09.05.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 21 Jan 2023 09:05:08 -0800 (PST) X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Subject: [pushed] Darwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107586]. Date: Sat, 21 Jan 2023 17:05:07 +0000 Message-Id: <20230121170507.2193-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Sandoe via Gcc-patches From: Iain Sandoe Reply-To: iain@sandoe.co.uk Cc: Iain Sandoe Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755652566971387502?= X-GMAIL-MSGID: =?utf-8?q?1755652566971387502?= tested on i688-darwin9, x86_64-darwin20,21 and x86_64-linux-gnu. pushed to trunk, thanks Iain --- 8< --- The SDK for MacOS13 includes Apple-specific deprecations of some functions that are not deprecated in Posix, C or C++ and widely used in GCC. The fix makes the deprecation conditional on __APPLE_LOCAL_DEPRECATIONS so that end users may still observe them but they are hidden from normal compilations. Signed-off-by: Iain Sandoe PR target/107568 fixincludes/ChangeLog: * fixincl.x: Regenerate. * inclhack.def: Add a fix for MacOS13 SDK function deprecations in stdio.h. * tests/base/stdio.h (__deprecated_msg): New test. --- fixincludes/fixincl.x | 56 +++++++++++++++++++++++++++++++--- fixincludes/inclhack.def | 12 ++++++++ fixincludes/tests/base/stdio.h | 7 +++++ 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x index 20867548e24..35167dc82a8 100644 --- a/fixincludes/fixincl.x +++ b/fixincludes/fixincl.x @@ -2,11 +2,11 @@ * * DO NOT EDIT THIS FILE (fixincl.x) * - * It has been AutoGen-ed September 29, 2022 at 10:22:55 PM by AutoGen 5.18.16 + * It has been AutoGen-ed January 18, 2023 at 07:54:50 PM by AutoGen 5.18.7 * From the definitions inclhack.def * and the template file fixincl */ -/* DO NOT SVN-MERGE THIS FILE, EITHER Thu Sep 29 22:22:55 CEST 2022 +/* DO NOT SVN-MERGE THIS FILE, EITHER Wed Jan 18 19:54:50 GMT 2023 * * You must regenerate it. Use the ./genfixes script. * @@ -15,7 +15,7 @@ * certain ANSI-incompatible system header files which are fixed to work * correctly with ANSI C and placed in a directory that GNU C will search. * - * This file contains 272 fixup descriptions. + * This file contains 273 fixup descriptions. * * See README for more information. * @@ -2608,6 +2608,46 @@ static const char* apzBsd_Stdio_Attrs_ConflictPatch[] = { int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) \"__svfscanf\");", (char*)NULL }; +/* * * * * * * * * * * * * * * * * * * * * * * * * * + * + * Description of Apple_Local_Stdio_Fn_Deprecation fix + */ +tSCC zApple_Local_Stdio_Fn_DeprecationName[] = + "apple_local_stdio_fn_deprecation"; + +/* + * File name selection pattern + */ +tSCC zApple_Local_Stdio_Fn_DeprecationList[] = + "stdio.h\0"; +/* + * Machine/OS name selection pattern + */ +tSCC* apzApple_Local_Stdio_Fn_DeprecationMachs[] = { + "*-*-*darwin2*", + (const char*)NULL }; + +/* + * content selection pattern - do fix if pattern found + */ +tSCC zApple_Local_Stdio_Fn_DeprecationSelect0[] = + "__deprecated_msg([^\n\ +]*)$"; + +#define APPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT 1 +static tTestDesc aApple_Local_Stdio_Fn_DeprecationTests[] = { + { TT_EGREP, zApple_Local_Stdio_Fn_DeprecationSelect0, (regex_t*)NULL }, }; + +/* + * Fix Command Arguments for Apple_Local_Stdio_Fn_Deprecation + */ +static const char* apzApple_Local_Stdio_Fn_DeprecationPatch[] = { + "format", + "#if defined(__APPLE_LOCAL_DEPRECATIONS)\n\ +%0\n\ +#endif", + (char*)NULL }; + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * Description of Ctrl_Quotes_Def fix @@ -11075,9 +11115,9 @@ static const char* apzX11_SprintfPatch[] = { * * List of all fixes */ -#define REGEX_COUNT 310 +#define REGEX_COUNT 311 #define MACH_LIST_SIZE_LIMIT 187 -#define FIX_COUNT 272 +#define FIX_COUNT 273 /* * Enumerate the fixes @@ -11144,6 +11184,7 @@ typedef enum { BROKEN_CABS_FIXIDX, BROKEN_NAN_FIXIDX, BSD_STDIO_ATTRS_CONFLICT_FIXIDX, + APPLE_LOCAL_STDIO_FN_DEPRECATION_FIXIDX, CTRL_QUOTES_DEF_FIXIDX, CTRL_QUOTES_USE_FIXIDX, CXX_UNREADY_FIXIDX, @@ -11663,6 +11704,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = { BSD_STDIO_ATTRS_CONFLICT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, aBsd_Stdio_Attrs_ConflictTests, apzBsd_Stdio_Attrs_ConflictPatch, 0 }, + { zApple_Local_Stdio_Fn_DeprecationName, zApple_Local_Stdio_Fn_DeprecationList, + apzApple_Local_Stdio_Fn_DeprecationMachs, + APPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, + aApple_Local_Stdio_Fn_DeprecationTests, apzApple_Local_Stdio_Fn_DeprecationPatch, 0 }, + { zCtrl_Quotes_DefName, zCtrl_Quotes_DefList, apzCtrl_Quotes_DefMachs, CTRL_QUOTES_DEF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE, diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def index d4637470d7a..ea879b73bad 100644 --- a/fixincludes/inclhack.def +++ b/fixincludes/inclhack.def @@ -1269,6 +1269,18 @@ fix = { test_text = '#define vfscanf __svfscanf'; }; +fix = { + hackname = apple_local_stdio_fn_deprecation; + mach = "*-*-*darwin2*"; + files = stdio.h; + select = "__deprecated_msg([^\n]*)$"; + c_fix = format; + c_fix_arg = "#if defined(__APPLE_LOCAL_DEPRECATIONS)\n" + "%0\n" + "#endif"; + test_text = '__deprecated_msg("This function is provided for compat...")'; +}; + /* * Fix various macros used to define ioctl numbers. * The traditional syntax was: diff --git a/fixincludes/tests/base/stdio.h b/fixincludes/tests/base/stdio.h index 491c75da6e5..38381bacb2d 100644 --- a/fixincludes/tests/base/stdio.h +++ b/fixincludes/tests/base/stdio.h @@ -41,6 +41,13 @@ int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ (_BSD_STRING(__USER #endif /* BSD_STDIO_ATTRS_CONFLICT_CHECK */ +#if defined( APPLE_LOCAL_STDIO_FN_DEPRECATION_CHECK ) +#if defined(__APPLE_LOCAL_DEPRECATIONS) +__deprecated_msg("This function is provided for compat...") +#endif +#endif /* APPLE_LOCAL_STDIO_FN_DEPRECATION_CHECK */ + + #if defined( HPUX10_STDIO_DECLARATIONS_CHECK ) # define _iob __iob