Re: What is the best practice to use both gcc and clang flags macros in %check?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 5, 2020 at 7:36 PM Jun Aruga <jaruga@xxxxxxxxxx> wrote:
>
> In my case on rpms/simde, I want to compile the testing source in
> "both" gcc and clang changing the toolchain macro in the %check
> section.
>
> I am seeing this file to use toolchain macro.
> https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/master/f/macros#_44
> > # %global toolchain clang
>
> In this case what is the best practice to use %{optflags},
> %{build_cflags}, %{build_cxxflags} macros?
> Because after setting `%global toolchain clang` in the %check section,
> these macros are empty.
>
> Here is the simde.spec having both gcc and clang built test cases in
> the%check section.
> https://src.fedoraproject.org/fork/jaruga/rpms/simde/blob/wip/clang-flto-ftbfs/f/simde.spec#_136
>
> ```
> %check
> ...
> echo "=== 1.2. tests on gcc with flags ==="
> mkdir test/build-gcc-with-flags
> pushd test/build-gcc-with-flags
> CC=gcc CXX=g++ cmake \
>   -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
>   -DCMAKE_C_FLAGS="%{build_cflags}" \
>   -DCMAKE_CXX_FLAGS="%{build_cxxflags}" \
>   ..
> ...
> %global toolchain clang
> ...
> echo "=== 2.2. tests on clang with flags ==="
> mkdir test/build-clang-with-flags
> pushd test/build-clang-with-flags
> CC=clang CXX=clang++ cmake \
>   -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
>   -DCMAKE_C_FLAGS="${build_cflags}" \ # <= ${build_cflags} is empty!
>   -DCMAKE_CXX_FLAGS="${build_cxxflags}" \ # <= ${build_cxxflags} is empty!
>   ..
> ```

I see no way this can actually work.

For one, there's typos in the second part ($ instead of %, which of
course makes them empty when those environment variables aren't
defined).

Also I don't think you can set RPM .spec macros *within* a %check
script (which is executed by bash), so `%global toolchain clang` would
get passed to bash in this case, instead of getting parsed by RPM, no?
So the errors after this line are understandable to me.

I also wonder why you are trying to override `toolchain` manually in
this case, which I don't think is necessary at all. Reading the docs
for those macros, it looks like using %set_build_flags and setting CC
and CXX correctly should do what you want to do (unless CMake doesn't
read those environment variables correctly, then you need to use
%build_cflags, %build_cxxflags, %build_ldflags as you did before).

Fabio
_______________________________________________
packaging mailing list -- packaging@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to packaging-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/packaging@xxxxxxxxxxxxxxxxxxxxxxx




[Index of Archives]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite Forum]     [KDE Users]

  Powered by Linux