Gentoo Archives: gentoo-dev

From: Sam James <sam@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] Clang 16 is coming - and it'll break your packages!
Date: Sun, 09 Oct 2022 21:29:47
Message-Id: 87tu4c8z49.fsf@mop.mail-host-address-is-not-set
1 Hi all,
2
3 Clang 16 is going to break a lot of packages. We need your help to fix
4 the huge number of bugs [0] already reported - and there's more coming.
5
6 These fixes are almost always trivial, the issue is the _volume_ of
7 bugs. The compiler even
8 tells you how to fix them most of the time.
9
10 I absolutely cannot do any of this by myself, and nor can the small
11 number of people who have been helping: ionen has done the biggest
12 number of bugs, and soap is helping out too.
13
14 Developers, contributors, and users alike are encouraged to help! This
15 task is massive.
16
17 They originally made this change for Clang 15 but reverted it until
18 Clang 16 [1].
19
20 ## The problem
21
22 There are *two* classes of bug caused by these changes:
23 1. Obvious build failures. They're just normal errors and it's clear
24 when you see it;
25
26 2. `./configure` tests getting the wrong result but silently
27 miscompiling. You need to grep `config.log` for `error:` to spot these.
28
29 I have a cheesy hook at https://gist.github.com/thesamesam/4ddaa95f3f42c2be312b676476cbf505
30 which I use to run configure commands twice (old/new Clang options) and then
31 diff them.
32
33 I don't mind which people help with. Ideally both, but if you only want
34 to do 1., at least until we have bugs filed for 2. (it's harder to detect,
35 so no bugs filed for it yet), that's fine.
36
37 ## The actual changes
38
39 It enables the following by default:
40 * -Werror=implicit-function-declaration (C only)
41 * -Werror=implict-int (C only)
42 * -Werror=incompatible-function-pointer-types (affects both C and C++)
43
44 Note that for implicit-function-declaration (and obviously
45 incompatible-function-pointer-types), a new revision is needed as it
46 affects code generation - think of this like the 32-bit -> 64-bit days when
47 pointers got truncated. It's also useful for finding out quickly if
48 there's an issue with your fix.
49
50 GCC will end up following at least some of these changes in time [2][3].
51
52 ## Bonus
53
54 It also *warns* about K&R declarations and ill-defined, deprecated
55 prototypes,
56 so for bonus work, test with:
57 * -Werror=strict-prototypes (C only)
58 * -Werror=deprecated-non-prototype (C only)
59
60 It's suggested that if you don't want to fix these errors, you try
61 adding the -std=gnu89 flag instead.
62
63 ## Helping out
64
65 * Please feel free to ask me, soap, ionen, or generally in #gentoo-dev /
66 #gentoo-toolchain
67 if you need help fixing a bug.
68
69 * To reproduce these bugs, we recommend you use the new improved Clang
70 config file support [4]:
71 1. Upgrade to >=sys-devel/clang-15.0.2 and make sure you have
72 >=sys-devel/clang-common-15.0.2-r1[stricter].
73
74 This creates `/etc/clang/clang-stricter.cfg` where you can adjust
75 the flags manually if desired (like commenting out strict prototypes etc).
76
77 This does not copy Clang 16 behaviour 100%, but it's close enough
78 for the purposes of these bugs.
79
80 2. Build packages with `CC=clang CXX=clang++ emerge -v1 ...` or
81 `CC=clang CXX=clang++ ebuild ...`
82
83 3. Enjoy!
84
85 * Some bugs simply need an `eautoreconf` because older
86 autoconf-generated configure files had issues.
87
88 * It is *critical* that you send fixes upstream where upstream is still
89 active or we're going to have a huge amount of duplicate work across distros.
90
91 [0] https://bugs.gentoo.org/870412 (tracker bug)
92 [1] https://discourse.llvm.org/t/configure-script-breakage-with-the-new-werror-implicit-function-declaration/65213
93 (upstream Clang discussion)
94 [2] https://www.youtube.com/watch?v=q5itHU2T5xU&t=2862s
95 [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91092
96 [4] https://blogs.gentoo.org/mgorny/2022/10/07/clang-in-gentoo-now-sets-default-runtimes-via-config-file/

Replies