public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Clang 16 is coming - and it'll break your packages!
@ 2022-10-09 21:25 Sam James
  2022-10-09 22:00 ` Sam James
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sam James @ 2022-10-09 21:25 UTC (permalink / raw)
  To: gentoo-dev


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/


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] Clang 16 is coming - and it'll break your packages!
  2022-10-09 21:25 [gentoo-dev] Clang 16 is coming - and it'll break your packages! Sam James
@ 2022-10-09 22:00 ` Sam James
  2022-10-10  2:05 ` Michael Orlitzky
  2022-10-11  9:07 ` Ionen Wolkens
  2 siblings, 0 replies; 4+ messages in thread
From: Sam James @ 2022-10-09 22:00 UTC (permalink / raw)
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 348 bytes --]


Sam James <sam@gentoo.org> writes:

> 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.
>

I should've added: here's a nice list of things to work on.

https://bugs.gentoo.org/showdependencytree.cgi?id=870412&hide_resolved=1

:)

best,
sam

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 377 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] Clang 16 is coming - and it'll break your packages!
  2022-10-09 21:25 [gentoo-dev] Clang 16 is coming - and it'll break your packages! Sam James
  2022-10-09 22:00 ` Sam James
@ 2022-10-10  2:05 ` Michael Orlitzky
  2022-10-11  9:07 ` Ionen Wolkens
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Orlitzky @ 2022-10-10  2:05 UTC (permalink / raw)
  To: gentoo-dev

On Sun, 2022-10-09 at 22:25 +0100, Sam James wrote:
> 
> * Some bugs simply need an `eautoreconf` because older
>   autoconf-generated configure files had issues.
> 

Vanilla autoconf still emits busted tests for e.g. AC_CHECK_FUNC, so
you'll want the ~arch autoconf with sam's backported patches in the
meantime. (Surely they'll be stable before clang-16 is available.)



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [gentoo-dev] Clang 16 is coming - and it'll break your packages!
  2022-10-09 21:25 [gentoo-dev] Clang 16 is coming - and it'll break your packages! Sam James
  2022-10-09 22:00 ` Sam James
  2022-10-10  2:05 ` Michael Orlitzky
@ 2022-10-11  9:07 ` Ionen Wolkens
  2 siblings, 0 replies; 4+ messages in thread
From: Ionen Wolkens @ 2022-10-11  9:07 UTC (permalink / raw)
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]

On Sun, Oct 09, 2022 at 10:25:47PM +0100, Sam James wrote:
> ## 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.

Note that -Werror=strict-prototypes breaks /tons/ because it fails on
the following:

    int myfunc() { return 0; }

But the above is fine with -std=c2x, and I don't think it's worth
starting to add (void) /everywhere/ downstream if it's going to be
okay'ish.

"Hopefully" clang won't try to do that check by default again, the
breakage would be on the next level... so I'd tentatively say, don't
worry about this and focus attention where it's more urgent (aka
implicits and incompatible pointer types, may even fix other bugs
at same time).


On the other hand, warnings from -Wdeprecated-non-prototype do
fail with `clang -std=c2x`. So if come across a K&R-style source
mostly beyond fixing, do consider `append-cflags -std=gnu89`.

An alternative way to test so don't need to add -Wno* everywhere on
top of -std=gnu* is to straight up test with `clang -std=c2x` rather
than the -Werror (not to say it's perfect given c2x makes assumptions,
but doing this can pick up more errors too).

(reminder that gcc/clang don't enable c2x by default and isn't urgent,
but this will happen sooner or later)
-- 
ionen

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-11  9:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-09 21:25 [gentoo-dev] Clang 16 is coming - and it'll break your packages! Sam James
2022-10-09 22:00 ` Sam James
2022-10-10  2:05 ` Michael Orlitzky
2022-10-11  9:07 ` Ionen Wolkens

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox