termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.24k stars 3.04k forks source link

[TRACKER] packaging: Clang 16 porting (C) #15852

Closed xtkoba closed 1 year ago

xtkoba commented 1 year ago

See also https://wiki.gentoo.org/wiki/Modern_C_porting.

In Clang/LLVM 16 the following errors are enabled by default:

-Werror=implicit-function-declaration
-Werror=implicit-int
-Werror=int-conversion
-Werror=incompatible-function-pointer-types

In our packaging scripts, TERMUX_PKG_ENABLE_CLANG16_PORTING variable is introduced (6938b7c4b4d0e9b297fb0153560358706fc57b60) to control whether to enable these errors when using NDK r25 (based on Clang 14), to discover possible build failures/breakages with Clang 16.

Note that TERMUX_PKG_ENABLE_CLANG16_PORTING is enabled by default (set to true), and it is very likely that simply trying to rebuild some package leads to build failure/breakage.

To avoid catastrophic breakges or unnoticed breakages, it is explicitly (in build.sh of each package) disabled for essential packages (3c88b5956171da75c9a26178e9a92c28c09fd04f) and auto-updating packages (10ada7e4d39bcb7d3ec14a16dbf4b61c62a6af3d), until for each package it is sure that build failure/breakage does not occur.

It is acceptable that TERMUX_PKG_ENABLE_CLANG16_PORTING is set to false for each package by maintainer's decision, if this change of behavior is unwanted. But it is highly recommended that build failures/breakages be fixed instead.

xtkoba commented 1 year ago

Maybe not in effect when using CMake (termux_step_configure_cmake) because IIRC CMake does not use target-prefixed wrapper but calls /path/to/clang directly. There may be other cases where the clang16-porting switch does not effect. [EDIT] Now a workaround has been added for CMake (0ead023121901676ce6a731e29fbd7b8fccb5db0).

I believe it is working for Autotools and Meson, unless the build scripts in the source do something insane.

finagolfin commented 1 year ago

This is only relevant for on-device packaging?

xtkoba commented 1 year ago

Only affects non-on-device building. Does not affect on-device building at all, unless I'm doing anything wrong.

finagolfin commented 1 year ago

OK, I thought this is because on-device builds use clang 16 from now on. Instead, you are getting these packages ready for the next NDK upgrade that uses clang 16? Because the current NDK 25 uses clang 14.

xtkoba commented 1 year ago

Porting to (upcoming) NDK r26 is one of the purposes. Another is to improve on-device building because our clang package is now Clang 16.

truboxl commented 1 year ago

So manual bump until NDK r26?

TomJo2000 commented 1 year ago

So does this effect every package written in C/C++ in the repos or do you have like a list of (potentially) effected packages?

xtkoba commented 1 year ago

The following packages have passed the test as of now.

main

x11

xtkoba commented 1 year ago

This does not check the C++ portability and I'm not going to do that in this issue.