diff mbox series

[v2,1/1] package/zlib-ng: fix arm build

Message ID 20240221181650.1115046-1-fontaine.fabrice@gmail.com
State Accepted
Headers show
Series [v2,1/1] package/zlib-ng: fix arm build | expand

Commit Message

Fabrice Fontaine Feb. 21, 2024, 6:16 p.m. UTC
zlib-ng usage uses CMAKE_C_COMPILER_TARGET which is non-standard and
is not supposed to be used by the CMakeLists.txt machinery of a
particular package.

Indeed, [1] specifies that:

  Some compiler drivers are inherently cross-compilers, such as clang
  and QNX qcc. These compiler drivers support a command-line argument
  to specify the target to cross-compile for.

buildroot is not using clang nor QNX qcc.
[2] also refers to this variable only for clang [3] and QNX [4].

Therefore, zlib-ng's usage of this variable is a bit of a hack, and it's
actually why it works when passed as an argument, because they are in
fact not supposed to use this variable.

So set CMAKE_C_COMPILER_TARGET to BR2_ARCH to fix the following arm
build failure raised since bump to version 2.0.6 in commit
d2249821d3f30202ca2a35ad24918378d9a0a0e8:

-- Detecting C compile features - done
-- Arch not recognized, falling back to cmake arch: 'l'
-- Basearch 'l' not recognized, defaulting to 'x86'.
-- Basearch of 'l' has been detected as: 'x86'

[...]

/home/buildroot/autobuild/instance-0/output-1/build/zlib-ng-2.1.3/arch/x86/x86_features.c:17:12: fatal error: cpuid.h: No such file or directory
   17 | #  include <cpuid.h>
      |            ^~~~~~~~~

[1] https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html
[2] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
[3] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-using-clang
[4] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-qnx

Fixes: d2249821d3f30202ca2a35ad24918378d9a0a0e8
 - http://autobuild.buildroot.org/results/1551aa69be19239a8d8e081f033e4027d679ab8f
 - http://autobuild.buildroot.org/results/075d704c0f11710353bac43478e4501addcd747d

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
Changes v1 -> v2 (after review of Thomas Petazzoni and Peter Korsgaard):
 - Update commit message

 package/zlib-ng/zlib-ng.mk | 1 +
 1 file changed, 1 insertion(+)

Comments

Yann E. MORIN Feb. 21, 2024, 8:19 p.m. UTC | #1
Fabrice, All,

On 2024-02-21 19:16 +0100, Fabrice Fontaine spake thusly:
> zlib-ng usage uses CMAKE_C_COMPILER_TARGET which is non-standard and
> is not supposed to be used by the CMakeLists.txt machinery of a
> particular package.
> 
> Indeed, [1] specifies that:
> 
>   Some compiler drivers are inherently cross-compilers, such as clang
>   and QNX qcc. These compiler drivers support a command-line argument
>   to specify the target to cross-compile for.
> 
> buildroot is not using clang nor QNX qcc.
> [2] also refers to this variable only for clang [3] and QNX [4].
> 
> Therefore, zlib-ng's usage of this variable is a bit of a hack, and it's
> actually why it works when passed as an argument, because they are in
> fact not supposed to use this variable.
> 
> So set CMAKE_C_COMPILER_TARGET to BR2_ARCH to fix the following arm
> build failure raised since bump to version 2.0.6 in commit
> d2249821d3f30202ca2a35ad24918378d9a0a0e8:
> 
> -- Detecting C compile features - done
> -- Arch not recognized, falling back to cmake arch: 'l'
> -- Basearch 'l' not recognized, defaulting to 'x86'.
> -- Basearch of 'l' has been detected as: 'x86'
> 
> [...]
> 
> /home/buildroot/autobuild/instance-0/output-1/build/zlib-ng-2.1.3/arch/x86/x86_features.c:17:12: fatal error: cpuid.h: No such file or directory
>    17 | #  include <cpuid.h>
>       |            ^~~~~~~~~
> 
> [1] https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html
> [2] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
> [3] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-using-clang
> [4] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-qnx
> 
> Fixes: d2249821d3f30202ca2a35ad24918378d9a0a0e8
>  - http://autobuild.buildroot.org/results/1551aa69be19239a8d8e081f033e4027d679ab8f
>  - http://autobuild.buildroot.org/results/075d704c0f11710353bac43478e4501addcd747d
> 
> Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>

Applied to master, thanks.

Regards,
Yann E. MORIN.

> ---
> Changes v1 -> v2 (after review of Thomas Petazzoni and Peter Korsgaard):
>  - Update commit message
> 
>  package/zlib-ng/zlib-ng.mk | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/package/zlib-ng/zlib-ng.mk b/package/zlib-ng/zlib-ng.mk
> index fbb906503a..33e8754c9d 100644
> --- a/package/zlib-ng/zlib-ng.mk
> +++ b/package/zlib-ng/zlib-ng.mk
> @@ -13,6 +13,7 @@ ZLIB_NG_PROVIDES = zlib
>  
>  # Build with zlib compatible API, gzFile support and optimizations on
>  ZLIB_NG_CONF_OPTS += \
> +	-DCMAKE_C_COMPILER_TARGET=$(BR2_ARCH) \
>  	-DWITH_GZFILEOP=1 \
>  	-DWITH_OPTIM=1 \
>  	-DZLIB_COMPAT=1 \
> -- 
> 2.43.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Peter Korsgaard March 17, 2024, 11:22 a.m. UTC | #2
>>>>> "Fabrice" == Fabrice Fontaine <fontaine.fabrice@gmail.com> writes:

 > zlib-ng usage uses CMAKE_C_COMPILER_TARGET which is non-standard and
 > is not supposed to be used by the CMakeLists.txt machinery of a
 > particular package.

 > Indeed, [1] specifies that:

 >   Some compiler drivers are inherently cross-compilers, such as clang
 >   and QNX qcc. These compiler drivers support a command-line argument
 >   to specify the target to cross-compile for.

 > buildroot is not using clang nor QNX qcc.
 > [2] also refers to this variable only for clang [3] and QNX [4].

 > Therefore, zlib-ng's usage of this variable is a bit of a hack, and it's
 > actually why it works when passed as an argument, because they are in
 > fact not supposed to use this variable.

 > So set CMAKE_C_COMPILER_TARGET to BR2_ARCH to fix the following arm
 > build failure raised since bump to version 2.0.6 in commit
 > d2249821d3f30202ca2a35ad24918378d9a0a0e8:

 > -- Detecting C compile features - done
 > -- Arch not recognized, falling back to cmake arch: 'l'
 > -- Basearch 'l' not recognized, defaulting to 'x86'.
 > -- Basearch of 'l' has been detected as: 'x86'

 > [...]

 > /home/buildroot/autobuild/instance-0/output-1/build/zlib-ng-2.1.3/arch/x86/x86_features.c:17:12: fatal error: cpuid.h: No such file or directory
 >    17 | #  include <cpuid.h>
 >       |            ^~~~~~~~~

 > [1] https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_TARGET.html
 > [2] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
 > [3] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-using-clang
 > [4] https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-qnx

 > Fixes: d2249821d3f30202ca2a35ad24918378d9a0a0e8
 >  - http://autobuild.buildroot.org/results/1551aa69be19239a8d8e081f033e4027d679ab8f
 >  - http://autobuild.buildroot.org/results/075d704c0f11710353bac43478e4501addcd747d

 > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
 > ---
 > Changes v1 -> v2 (after review of Thomas Petazzoni and Peter Korsgaard):
 >  - Update commit message

Committed to 2023.02.x and 2023.11.x, thanks.
diff mbox series

Patch

diff --git a/package/zlib-ng/zlib-ng.mk b/package/zlib-ng/zlib-ng.mk
index fbb906503a..33e8754c9d 100644
--- a/package/zlib-ng/zlib-ng.mk
+++ b/package/zlib-ng/zlib-ng.mk
@@ -13,6 +13,7 @@  ZLIB_NG_PROVIDES = zlib
 
 # Build with zlib compatible API, gzFile support and optimizations on
 ZLIB_NG_CONF_OPTS += \
+	-DCMAKE_C_COMPILER_TARGET=$(BR2_ARCH) \
 	-DWITH_GZFILEOP=1 \
 	-DWITH_OPTIM=1 \
 	-DZLIB_COMPAT=1 \