Skip to content

main/linux-*: export HOSTCC to fix linter warning

Minecrell requested to merge Minecrell/aports:export-hostcc into master

apkbuild-lint complains about the use of HOSTCC in the linux-* APKBUILDs:

IC:[AL6]:main/linux-lts/APKBUILD:66:prefix custom variable with _: HOSTCC="${CC:-gcc}"
IC:[AL6]:main/linux-lts/APKBUILD:67:prefix custom variable with _: HOSTCC="${HOSTCC#${CROSS_COMPILE}}"
MC:[AL31]:main/linux-lts/APKBUILD:66:variables must not have capital letters
MC:[AL31]:main/linux-lts/APKBUILD:67:variables must not have capital letters

The first two were fixed in Leo/atools!24 (merged). But apkbuild-lint still complains about the capitalized variable. Adding an exception for this in atools seems quite complicated.

I suspect HOSTCC is supposed to override the environment variable set by abuild when cross compiling (see https://gitlab.alpinelinux.org/alpine/abuild/blob/57185172c502812aa59b3fd28360377477a1a65e/functions.sh.in#L155).

In that case, another way to avoid the linter warning is to make that explicit: If we add "export" in front of the variable declaration apkbuild-lint will ignore it entirely. Another advantage is that it is consistently set as environment variable no matter if we are cross compiling or not.

This also allows dropping some explicit HOSTCC="$HOSTCC" arguments for make since these will be taken from the environment instead.

A different option might be to rename the variable to e.g. _hostcc, and then explicitly set it for all make calls (e.g. make HOSTCC="$_hostcc"). Not sure.
This is mostly a RFC - I'm looking for a way to avoid the HOSTCC linter warnings for the kernel packages that exist in postmarketOS.

Cc: @PureTryOut @Leo

Merge request reports