Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124706 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 1EA451A00B7 for ; Thu, 1 Aug 2024 21:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722549568; bh=+P3jlOEZwzs3bV9InwV6pj/A8UHcCvjuy59UQKHN7UQ=; h=From:Date:Subject:To:From; b=bVgQYMb8hX6l+xcuHsKXupZvC8e4vxl6/FQNbPIL5xGxGF5WKP0NEtzWuDv1k6rie CbjN5nQR/hqjF0YJQZyXIFH67Y6sCsDl180xVBZH12rVBZQ/D7jgt/ZnDEXFEpYpo2 gnAh5tXezHSD2ytCE4odBpbnT1vvIQFtqLnhmSVB8WVeRCYPYZ8t1/A+GXgOkIM2w/ F1vD18O+kdx710NKZxFW45Jzb/u/eDz2gML4Ewv3csBkTgzFfFirpnTHOvb2w53Dus wfUy2X2OwK5P5CA760CerFkR+YMqtQ0/rOWOltFrTwn5saVpDOMXTBfAjTYTyqdVJb qfZ0jTFg8lAqw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 26ABB18007B for ; Thu, 1 Aug 2024 21:59:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: ** X-Spam-Status: No, score=2.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,URI_TRY_3LD autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 1 Aug 2024 21:59:27 +0000 (UTC) Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7095bfd6346so2336673a34.0 for ; Thu, 01 Aug 2024 14:57:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722549468; x=1723154268; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=+P3jlOEZwzs3bV9InwV6pj/A8UHcCvjuy59UQKHN7UQ=; b=E1hbfEAMA0W5BHuiF9U7K/Frd/ZNZd8ATruiWMxaIuTyVDFdZlLv6xTxrq3WA8CxTp HIIAnet0M6X4lGS78lixUVG92FHcYJoKBebVnzx8RoSDirpcVPKsetMREtZqg0R46Ss9 3E5wacVj9LziBHn9Vj/Uwa0miM7c562xb8BR43c4LQC96co22gr0G/fuZhKLGbtLbOhz oMZ3nMPcs6CxoB2wcwMlrqajCfbdGZWPmkB4+jNVhCJ6L/Xpdks5asWstUDyt3KTwucd j42ugyTHwBKXn6tImw7VJ1pUmfOXxdvtSB5D9ap4HksdSbfktFEVgss2zL4G46d0VMtv weiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722549468; x=1723154268; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=+P3jlOEZwzs3bV9InwV6pj/A8UHcCvjuy59UQKHN7UQ=; b=W3Hi7OK+Dp/yTnX6yQlpCkTUKSZb92JGjf9wNoVGy+vz2A74rpAiFfVvL1oymJWQ3M x9oD786Trl4CUFPQHLf4owDHpEtrM9cLHAtNE9lRizRZxQJSxy4GDD817Ds6mGaACSeH VwsSF8Zltk9kgUi6MlWos96nS2QIpCwpHvReSo/lhs7jyVifZjr1e/GR8N1WE/x6e2kQ UY/HYGEHfrQxYlF9fRgG95yhF4CLUR0T2l36lIE91c8IFONmgr7sCCz6nwg3YWp0Bq4q n60/1doaRzvNk+3nyJyO5FwmckyOv9pE4B/UdZTDv2vUHxpb/4nS8HcegMlVnjom1O6R nT5g== X-Gm-Message-State: AOJu0Yzhfl0RBF+M5C9t/bu68KANmk9Anf4z6ValK8/RzqBvm5R2K4Q7 0c8xWSoKQMROs2TbwRsZ6iYd2qkydf7Gr1ZqGqv2EJJc1Ge23DPAWKhNJDIngh3ec5bXA0t7GQU mq/ZrzOSRREt4clw1yYu4P6Dnpr3P8Mjj/X179g== X-Google-Smtp-Source: AGHT+IGpi181k178C/YL0XtApNj4h4uxCZLJ2MQSzMIuyYJAPzJxfEwrsoUi72er6lSIdC5Z+kiCczraLbnMHpclXDE= X-Received: by 2002:a05:6359:7c16:b0:1ad:14ec:a011 with SMTP id e5c5f4694b2df-1af3ba4228dmr147372055d.12.1722549467451; Thu, 01 Aug 2024 14:57:47 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 1 Aug 2024 23:57:36 +0200 Message-ID: Subject: [PHP-DEV] Require C11 in PHP 8.4 To: PHP internals Content-Type: text/plain; charset="UTF-8" From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi everyone We've gotten a bug report about compile errors in the PHP 8.4 alpha on old C99 compilers (and on some modern compilers when passing the -std=c99 flag). Specifically, C99 does not support typedef redeclarations, which is a C11 feature. ```c // some_header.h typedef struct _zval_struct zval; void some_func(zval *zv); // zend_types.h struct _zval_struct { ... }; typedef struct _zval_struct zval; ``` Some headers might want to forward declare zval so that zend_types.h doesn't have to be included. The two primary reasons you might want to avoid that are 1. to reduce compile times if the header is very large and 2. to prevent recursive header dependencies. However, in C99 this code is actually illegal if both of these headers end up being included, because redeclarations of typedefs are not allowed. To fix it, the typedef must be removed and the signatures must refer to the struct directly. ```c // some_header.h struct _zval_struct; void some_func(struct _zval_struct *zv); ``` I started fixing these in a PR [1] which required more changes than expected. After a short discourse, we were wondering whether it might be better to switch to a newer C standard instead. Our coding standards [2] currently specify that compiling php-src requires C99. The Unix installation page on php.net [3] claims it is ANSI C, which is certainly outdated. There have been suggestions to require C11 for a while, which should be well supported by all compilers shipped with maintained distributions. GCC gained support for C11 in 4.7 [4], LLVM Clang in 3.1, both released in 2012. For context, Debian Bullseye comes with GCC 10.2 [5], Ubuntu Focal Fossa comes with GCC 9.3 [6], RHEL 8 comes with GCC 8.x [7]. The biggest blocker in the past was MSVC, which has finally added C11 support in Visual Studio 2019 [8]. Technically, Visual Studio 2015 and 2017 are still supported by Microsoft [9], but according to Christoph they are no longer used for PHP builds since version 8. Hence, it seems like it would be ok to bump our C compiler requirement to C11. We'd like to make this change before beta 1 if there are no objections. There are no immediate plans to make non-optional use of other C11 features, although that is conceivable at some point. Another benefit brought up by Christoph is that C11 relegated the requirement for the compiler to support VLAs (variable-length arrays) which was never implemented by MSVC, technically not complying with the currently required standard. If you do have any concerns, please let me know. Ilija [1] https://github.com/php/php-src/pull/15079 [2] [https://github.com/php/php-src/blob/8b6f14a9a221599b076e4bc3570f013a7e65aa21/CODING_STANDARDS.md?plain=1#L12](https://github.com/php/php-src/blob/8b6f14a9a221599b076e4bc3570f013a7e65aa21/CODING_STANDARDS.md?plain=1#L12) [3] https://www.php.net/manual/en/install.unix.php [4] https://stackoverflow.com/a/16256596 [5] https://packages.debian.org/bullseye/gcc [6] https://packages.ubuntu.com/focal/gcc [7] https://access.redhat.com/solutions/19458 [8] https://devblogs.microsoft.com/cppblog/c11-and-c17-standard-support-arriving-in-msvc/ [9] https://learn.microsoft.com/en-us/visualstudio/productinfo/vs-servicing