• [gentoo-dev] Clang 16 is coming - and it'll break your packages!

    From Sam James@21:1/5 to All on Sun Oct 9 23:30:01 2022
    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/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sam James@21:1/5 to Sam James on Mon Oct 10 00:10:01 2022
    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

    -----BEGIN PGP SIGNATURE-----

    iOUEARYKAI0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCY0NEml8UgAAAAAAuAChp c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MA8cc2FtQGdlbnRv by5vcmcACgkQc4QJ9SDfkZANCgD+PqiQ7KnUpOqkuYVrTMr6tQBGUSjqDDFZ9NSr MRxfXVMA/1ozspXlMfD/1SHR7NHDmV2GEBeJqRiaeMfxAJuaRjwM
    =q/qF
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Orlitzky@21:1/5 to Sam James on Mon Oct 10 04:10:01 2022
    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.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Sam James on Tue Oct 11 11:10:01 2022
    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

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmNFMkwACgkQskQGsLCs QzTZrwgAyigixwEE+8aEb6Wfm2XAS1A8Yb3eogTevIB+zg/NXQ4gphIb9bJXel6L LjpjuuHBlnSKe6BPfBTGPIFo8m5Y1PnVGLDvJ1Oq392S8hVG+Nf3dvFQzL6kn1hK m31BPcU1FC5N92ygmj/JQSeM6krgvAYxi38tkFIx0bH9l1lpGLG3Ik5noDJeWjSn R1H5K0He/ZqFjvzi2CaL2t5sojf2/8/gxQbKaY4KXzjA/7VVsLfayz49TtwP7brx 3uq58++rGXVL70zXZBL+o/eoEAy+3N9z5k58XQ1HSmqr/dC50ivKBt6fublh7Vep N03WCGE9C7UvGPAtaDe0x9b3RdcrFA==
    =ah8A
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)