* [Buildroot] [PATCH] package/exiv2: fix compiler flags detection
@ 2020-07-19 14:34 Thomas Petazzoni
2020-07-19 16:17 ` Yann E. MORIN
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2020-07-19 14:34 UTC (permalink / raw)
To: buildroot
Add a patch, which has been submitted upstream, to properly detect the
availability of compiler flags before using them.
This will fix the build of exiv2 on CPU architectures for which gcc
doesn't implement -fcf-protection.
Fixes:
http://autobuild.buildroot.net/results/ef6a6fa2309e66a7a36fface626ae0da1a7ec633/
(and many similar build failures on other architectures)
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
...ags.cmake-properly-detect-availabili.patch | 58 +++++++++++++++++++
1 file changed, 58 insertions(+)
create mode 100644 package/exiv2/0001-cmake-compilerFlags.cmake-properly-detect-availabili.patch
diff --git a/package/exiv2/0001-cmake-compilerFlags.cmake-properly-detect-availabili.patch b/package/exiv2/0001-cmake-compilerFlags.cmake-properly-detect-availabili.patch
new file mode 100644
index 0000000000..6302d4cfcf
--- /dev/null
+++ b/package/exiv2/0001-cmake-compilerFlags.cmake-properly-detect-availabili.patch
@@ -0,0 +1,58 @@
+From 2f6d2e5795382f0d6e22f5aea52e8104110d24ad Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Sun, 19 Jul 2020 16:29:15 +0200
+Subject: [PATCH] cmake/compilerFlags.cmake: properly detect availability of
+ flags
+
+Instead of relying on fragile and complex logic to decide if a
+compiler flag is available or not, use the check_c_compiler_flag()
+macro provided by the CMake standard library.
+
+This for example avoids using -fcf-protection on architectures that
+don't support this option.
+
+[Upstream: https://github.com/Exiv2/exiv2/pull/1252. The submitted
+patch is slightly different than this one, due to other changes
+between 0.27.3 and master.]
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+---
+ cmake/compilerFlags.cmake | 18 +++++++++++-------
+ 1 file changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake
+index 0418aa61..be430977 100644
+--- a/cmake/compilerFlags.cmake
++++ b/cmake/compilerFlags.cmake
+@@ -1,4 +1,5 @@
+ # These flags applies to exiv2lib, the applications, and to the xmp code
++include(CheckCCompilerFlag)
+
+ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
+ if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
+@@ -25,13 +26,16 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
+
+ # This fails under Fedora, MinGW GCC 8.3.0 and CYGWIN/MSYS 9.3.0
+ if (NOT (MINGW OR CMAKE_HOST_SOLARIS OR CYGWIN OR MSYS) )
+- if (COMPILER_IS_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
+- add_compile_options(-fstack-clash-protection -fcf-protection)
+- endif()
+-
+- if( (COMPILER_IS_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) # Not in GCC 4.8
+- OR (COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.7) # Not in Clang 3.4.2
+- )
++ check_c_compiler_flag(-fstack-clash-protection HAS_FSTACK_CLASH_PROTECTION)
++ check_c_compiler_flag(-fcf-protection HAS_FCF_PROTECTION)
++ check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG)
++ if(HAS_FSTACK_CLASH_PROTECTION)
++ add_compile_options(-fstack-clash-protection)
++ endif()
++ if(GCC_HAS_FCF_PROTECTION)
++ add_compile_options(-fcf-protection)
++ endif()
++ if(GCC_HAS_FSTACK_PROTECTOR_STRONG)
+ add_compile_options(-fstack-protector-strong)
+ endif()
+ endif()
+--
+2.26.2
+
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH] package/exiv2: fix compiler flags detection
2020-07-19 14:34 [Buildroot] [PATCH] package/exiv2: fix compiler flags detection Thomas Petazzoni
@ 2020-07-19 16:17 ` Yann E. MORIN
2020-07-20 16:08 ` Thomas Petazzoni
0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2020-07-19 16:17 UTC (permalink / raw)
To: buildroot
Thomas, All,
On 2020-07-19 16:34 +0200, Thomas Petazzoni spake thusly:
> Add a patch, which has been submitted upstream, to properly detect the
> availability of compiler flags before using them.
>
> This will fix the build of exiv2 on CPU architectures for which gcc
> doesn't implement -fcf-protection.
> +--- a/cmake/compilerFlags.cmake
> ++++ b/cmake/compilerFlags.cmake
> +@@ -1,4 +1,5 @@
> + # These flags applies to exiv2lib, the applications, and to the xmp code
> ++include(CheckCCompilerFlag)
> +
> + if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
> + if (${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
> +@@ -25,13 +26,16 @@ if ( MINGW OR UNIX OR MSYS ) # MINGW, Linux, APPLE, CYGWIN
> +
> + # This fails under Fedora, MinGW GCC 8.3.0 and CYGWIN/MSYS 9.3.0
> + if (NOT (MINGW OR CMAKE_HOST_SOLARIS OR CYGWIN OR MSYS) )
> +- if (COMPILER_IS_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
> +- add_compile_options(-fstack-clash-protection -fcf-protection)
> +- endif()
> +-
> +- if( (COMPILER_IS_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.0) # Not in GCC 4.8
> +- OR (COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.7) # Not in Clang 3.4.2
> +- )
> ++ check_c_compiler_flag(-fstack-clash-protection HAS_FSTACK_CLASH_PROTECTION)
> ++ check_c_compiler_flag(-fcf-protection HAS_FCF_PROTECTION)
> ++ check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG)
> ++ if(HAS_FSTACK_CLASH_PROTECTION)
> ++ add_compile_options(-fstack-clash-protection)
> ++ endif()
> ++ if(GCC_HAS_FCF_PROTECTION)
> ++ add_compile_options(-fcf-protection)
> ++ endif()
> ++ if(GCC_HAS_FSTACK_PROTECTOR_STRONG)
You've used TABs in this file that otherwise uses spaces. Hence,
indentation is off; I've "fixed" that.
Additionally, the file uses CRLF, so I had to also fix that (not your
fault, patchowrk is picky about CRLF).
Applied to master with the two fixes, thanks.
Note also that he patch you sent upstream has the same TAB issue,
causing incorrect rendering of the diff:
https://github.com/Exiv2/exiv2/pull/1252/commits/4a76388f7f03e8ec73730292aa6866eda83df4e7
Regards,
Yann E. MORIN.
> + add_compile_options(-fstack-protector-strong)
> + endif()
> + endif()
> +--
> +2.26.2
> +
> --
> 2.26.2
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Buildroot] [PATCH] package/exiv2: fix compiler flags detection
2020-07-19 16:17 ` Yann E. MORIN
@ 2020-07-20 16:08 ` Thomas Petazzoni
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Petazzoni @ 2020-07-20 16:08 UTC (permalink / raw)
To: buildroot
On Sun, 19 Jul 2020 18:17:21 +0200
"Yann E. MORIN" <yann.morin.1998@free.fr> wrote:
> You've used TABs in this file that otherwise uses spaces. Hence,
> indentation is off; I've "fixed" that.
Gah, stupid Emacs :-/
> Additionally, the file uses CRLF, so I had to also fix that (not your
> fault, patchowrk is picky about CRLF).
Yes, I knew about CRLF, but I can't do much here, as you say, it's
patchwork that messes up with CRLF line endings.
> Note also that he patch you sent upstream has the same TAB issue,
> causing incorrect rendering of the diff:
> https://github.com/Exiv2/exiv2/pull/1252/commits/4a76388f7f03e8ec73730292aa6866eda83df4e7
It seems like anyway it is not going to be the variant that will be
applied. The project maintainer is looking for help to resolve this
issue more globally, but oh well it's not as if Buildroot wasn't
keeping me busy enough already!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-20 16:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-19 14:34 [Buildroot] [PATCH] package/exiv2: fix compiler flags detection Thomas Petazzoni
2020-07-19 16:17 ` Yann E. MORIN
2020-07-20 16:08 ` Thomas Petazzoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox