Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] package/kmsxx: add patch to fix LTO support
@ 2016-08-26 21:34 Arnout Vandecappelle
  2016-08-27  7:22 ` Thomas Petazzoni
  2016-08-27  9:03 ` Samuel Martin
  0 siblings, 2 replies; 5+ messages in thread
From: Arnout Vandecappelle @ 2016-08-26 21:34 UTC (permalink / raw)
  To: buildroot

The LTO support in the kmsxx package uses the host gcc-ar and gcc-ranlib
instead of the ones from the cross-toolchain. Add a patch that tries to
find the right one based on CMAKE_C_COMPILER.

Fixes:
http://autobuild.buildroot.net/results/16a/16a38a4277dd1152a5955d62cb92f85447791ef3

Possibly also fixes:
http://autobuild.buildroot.net/results/f3c/f3c48da3a9706cd366c0e0a96c3cd0ff959f2a78
(it fails later, possibly because an incompatible host ar)

Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Cc: Samuel Martin <s.martin49@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
Thomas P. proposed to instead add a variable for LTO_AR and LTO_RANLIB
that we would override. However, this version works and is upstreamable
and currently we don't even "know" if cross-gcc-ar exists or not.

CMake actually has a target property INTERPROCEDURAL_OPTIMIZATION but
it seems that this is currently only implemented for Intel ICC. Cfr.
https://cmake.org/Bug/view.php?id=15939
---
 ...001-Fix-LTO-support-for-cross-compilation.patch | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)
 create mode 100644 package/kmsxx/0001-Fix-LTO-support-for-cross-compilation.patch

diff --git a/package/kmsxx/0001-Fix-LTO-support-for-cross-compilation.patch b/package/kmsxx/0001-Fix-LTO-support-for-cross-compilation.patch
new file mode 100644
index 0000000..9b4a582
--- /dev/null
+++ b/package/kmsxx/0001-Fix-LTO-support-for-cross-compilation.patch
@@ -0,0 +1,45 @@
+From 5da1f631bc753655ac94b08a6233eecd0d451327 Mon Sep 17 00:00:00 2001
+From: "Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be>
+Date: Fri, 26 Aug 2016 21:55:06 +0200
+Subject: [PATCH] Fix LTO support for cross-compilation.
+
+When cross-compiling, the ar and ranlib to be used for LTO are prefixed
+by the cross-tuple. gcc-ar and gcc-ranlib may not exist. Cfr.
+http://autobuild.buildroot.net/results/f3c/f3c48da3a9706cd366c0e0a96c3cd0ff959f2a78/
+
+Therefore, search for an appropriate lto-ar and lto-ranlib before
+enabling LTO.
+
+Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
+---
+Submitted upstream: https://github.com/tomba/kmsxx/pull/14
+---
+ CMakeLists.txt | 12 +++++++++---
+ 1 file changed, 9 insertions(+), 3 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e5b5ea5..c61c81d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -39,9 +39,15 @@ if (NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
+     CHECK_CXX_COMPILER_FLAG("-flto" HAS_LTO_FLAG)
+ 
+     if (HAS_LTO_FLAG)
+-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
+-        set(CMAKE_AR gcc-ar)
+-        set(CMAKE_RANLIB gcc-ranlib)
++        find_program(LTO_AR NAMES "${CMAKE_C_COMPILER}-ar" gcc-ar)
++        find_program(LTO_RANLIB NAMES "${CMAKE_C_COMPILER}-ranlib" /usr/bin/gcc-ranlib)
++        if (LTO_AR AND LTO_RANLIB)
++            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
++            set(CMAKE_AR "${LTO_AR}")
++            set(CMAKE_RANLIB "${LTO_RANLIB}")
++        else()
++            message(STATUS "gcc-ar or gcc-ranlib not found, disabling LTO")
++        endif()
+     endif()
+ endif()
+ 
+-- 
+2.9.3
+
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-08-27 10:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-26 21:34 [Buildroot] [PATCH] package/kmsxx: add patch to fix LTO support Arnout Vandecappelle
2016-08-27  7:22 ` Thomas Petazzoni
2016-08-27 10:21   ` Arnout Vandecappelle
2016-08-27  9:03 ` Samuel Martin
2016-08-27 10:40   ` Arnout Vandecappelle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox