From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 232B6158094 for ; Sun, 9 Oct 2022 21:29:47 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 36625E0863; Sun, 9 Oct 2022 21:29:43 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 01C0EE0839 for ; Sun, 9 Oct 2022 21:29:42 +0000 (UTC) Received: from mop (unknown [82.8.138.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AF0BC340F81 for ; Sun, 9 Oct 2022 21:29:41 +0000 (UTC) User-agent: mu4e 1.8.10; emacs 29.0.50 From: Sam James To: gentoo-dev@lists.gentoo.org Subject: [gentoo-dev] Clang 16 is coming - and it'll break your packages! Date: Sun, 09 Oct 2022 22:25:47 +0100 Message-ID: <87tu4c8z49.fsf@mop.mail-host-address-is-not-set> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain X-Archives-Salt: 2086d24d-8572-461f-8e85-ce953a175fdb X-Archives-Hash: dd9f2d3082b8b6f8dfbccb0639e6e240 Hi all, Clang 16 is going to break a lot of packages. We need your help to fix the huge number of bugs [0] already reported - and there's more coming. These fixes are almost always trivial, the issue is the _volume_ of bugs. The compiler even tells you how to fix them most of the time. I absolutely cannot do any of this by myself, and nor can the small number of people who have been helping: ionen has done the biggest number of bugs, and soap is helping out too. Developers, contributors, and users alike are encouraged to help! This task is massive. They originally made this change for Clang 15 but reverted it until Clang 16 [1]. ## The problem There are *two* classes of bug caused by these changes: 1. Obvious build failures. They're just normal errors and it's clear when you see it; 2. `./configure` tests getting the wrong result but silently miscompiling. You need to grep `config.log` for `error:` to spot these. I have a cheesy hook at https://gist.github.com/thesamesam/4ddaa95f3f42c2be312b676476cbf505 which I use to run configure commands twice (old/new Clang options) and then diff them. I don't mind which people help with. Ideally both, but if you only want to do 1., at least until we have bugs filed for 2. (it's harder to detect, so no bugs filed for it yet), that's fine. ## The actual changes It enables the following by default: * -Werror=implicit-function-declaration (C only) * -Werror=implict-int (C only) * -Werror=incompatible-function-pointer-types (affects both C and C++) Note that for implicit-function-declaration (and obviously incompatible-function-pointer-types), a new revision is needed as it affects code generation - think of this like the 32-bit -> 64-bit days when pointers got truncated. It's also useful for finding out quickly if there's an issue with your fix. GCC will end up following at least some of these changes in time [2][3]. ## Bonus It also *warns* about K&R declarations and ill-defined, deprecated prototypes, so for bonus work, test with: * -Werror=strict-prototypes (C only) * -Werror=deprecated-non-prototype (C only) It's suggested that if you don't want to fix these errors, you try adding the -std=gnu89 flag instead. ## Helping out * Please feel free to ask me, soap, ionen, or generally in #gentoo-dev / #gentoo-toolchain if you need help fixing a bug. * To reproduce these bugs, we recommend you use the new improved Clang config file support [4]: 1. Upgrade to >=sys-devel/clang-15.0.2 and make sure you have >=sys-devel/clang-common-15.0.2-r1[stricter]. This creates `/etc/clang/clang-stricter.cfg` where you can adjust the flags manually if desired (like commenting out strict prototypes etc). This does not copy Clang 16 behaviour 100%, but it's close enough for the purposes of these bugs. 2. Build packages with `CC=clang CXX=clang++ emerge -v1 ...` or `CC=clang CXX=clang++ ebuild ...` 3. Enjoy! * Some bugs simply need an `eautoreconf` because older autoconf-generated configure files had issues. * It is *critical* that you send fixes upstream where upstream is still active or we're going to have a huge amount of duplicate work across distros. [0] https://bugs.gentoo.org/870412 (tracker bug) [1] https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213 (upstream Clang discussion) [2] https://www.youtube.com/watch?v=q5itHU2T5xU&t=2862s [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91092 [4] https://blogs.gentoo.org/mgorny/2022/10/07/clang-in-gentoo-now-sets-default-runtimes-via-config-file/