%optflags macro for clang?

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

 



I am trying to run the unit tests for an application (that is only
header files) in the%check section of the RPM spec file, running cmake
on both gcc and clang with %optflags macro on Fedora rawhide.

According to the guideline
https://docs.fedoraproject.org/en-US/packaging-guidelines/#_compiler_flags
, it seems %optflags macro works with both gcc and clang without the
restriction for a specific compiler.

This cmake command for gcc works.

```
CC=gcc CXX=g++ cmake .. \
  -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
  -DCMAKE_C_FLAGS="%{optflags}" \
  -DCMAKE_CXX_FLAGS="%{optflags}"
%make_build
```

But this cmake command for clang does not work with the error
"clang-10: error: unknown argument: '-fstack-clash-protection'". The
used clang version is 10.0.0.
Should %{optflags} work for both gcc and clang? Is it a bug of the
%optflags macro?

```
CC=clang CXX=clang++ cmake .. \
  -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
  -DCMAKE_C_FLAGS="%{optflags}" \
  -DCMAKE_CXX_FLAGS="%{optflags}"
%make_build
```

The log is here.

```
+ CC=clang
+ CXX=clang++
+ cmake .. -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON '-DCMAKE_C_FLAGS=-O2 -g
-pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2
-Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong
-grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
'-DCMAKE_CXX_FLAGS=-O2 -g -pipe -Wall -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
-fstack-protector-strong -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection'
-- The C compiler identification is Clang 10.0.0
-- The CXX compiler identification is Clang 10.0.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler
    "/usr/bin/clang"
  is not able to compile a simple test program.
  It fails with the following output:
    Change Dir:
/builddir/build/BUILD/simde-0d632e1e0bd0a258ce3d3e240fbec4dd71234819/test/build-clang/CMakeFiles/CMakeTmp
----
    Run Build Command(s):/usr/bin/gmake cmTC_686bc/fast &&
/usr/bin/gmake -f CMakeFiles/cmTC_686bc.dir/build.make
CMakeFiles/cmTC_686bc.dir/build
    gmake[1]: Entering directory
'/builddir/build/BUILD/simde-0d632e1e0bd0a258ce3d3e240fbec4dd71234819/test/build-clang/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_686bc.dir/testCCompiler.c.o
    /usr/bin/clang   -O2 -g -pipe -Wall -Werror=format-security
-Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
-fstack-protector-strong -grecord-gcc-switches
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
  -o CMakeFiles/cmTC_686bc.dir/testCCompiler.c.o   -c
/builddir/build/BUILD/simde-0d632e1e0bd0a258ce3d3e240fbec4dd71234819/test/build-clang/CMakeFiles/CMakeTmp/testCCompiler.c
    clang-10: error: unknown argument: '-fstack-clash-protection'
    gmake[1]: *** [CMakeFiles/cmTC_686bc.dir/build.make:83:
CMakeFiles/cmTC_686bc.dir/testCCompiler.c.o] Error 1
    gmake[1]: Leaving directory
'/builddir/build/BUILD/simde-0d632e1e0bd0a258ce3d3e240fbec4dd71234819/test/build-clang/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:138: cmTC_686bc/fast] Error 2
```

Thanks.

-- 
Jun | He - His - Him
_______________________________________________
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