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/

Reply via email to