commit:     547fc02f60ead03d2784039314d2e2638c330de4
Author:     Ilya Tumaykin <itumaykin <AT> gmail <DOT> com>
AuthorDate: Sun Jan 21 16:47:44 2018 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Jan 21 20:56:12 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=547fc02f

app-i18n/uchardet: backport patch to override dumb CPU autodetection

Closes: https://github.com/gentoo/gentoo/pull/6923
Closes: https://bugs.gentoo.org/641716
Package-Manager: Portage-2.3.20, Repoman-2.3.6
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 ...det-0.0.6-enforce-IEEE-float-precision-r1.patch | 59 ++++++++++++++++++++++
 app-i18n/uchardet/uchardet-0.0.6-r2.ebuild         | 31 ++++++++++++
 2 files changed, 90 insertions(+)

diff --git 
a/app-i18n/uchardet/files/uchardet-0.0.6-enforce-IEEE-float-precision-r1.patch 
b/app-i18n/uchardet/files/uchardet-0.0.6-enforce-IEEE-float-precision-r1.patch
new file mode 100644
index 00000000000..2bc4977a5f0
--- /dev/null
+++ 
b/app-i18n/uchardet/files/uchardet-0.0.6-enforce-IEEE-float-precision-r1.patch
@@ -0,0 +1,59 @@
+Add configuration option to enable SSE2.
+Add -ffloat-store flag on x86 without SSE2.
+
+Gentoo bug: https://bugs.gentoo.org/631852
+Gentoo bug: https://bugs.gentoo.org/641716
+Upstream bug: https://bugs.freedesktop.org/show_bug.cgi?id=101033
+
+This patch is an aggregation of the following upstream commits:
+5996bbd995aed5045cc22e4d1fab08c989377983
+77bf71ea365a19ac55c59cf10399b566a02d82c1
+939482ab2b5a6585bdd2e5251f3f2f113d64686f
+cd617d181de03a7a13c2020e6c73cd14585e24b6
+f136d434f0809e064ac195b5bc4e0b50484a474c
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e9a699e..d140a24 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,5 +1,6 @@
+ ######## Project settings
+ cmake_minimum_required(VERSION 2.8.5)
++include(CheckCCompilerFlag)
+ set (PACKAGE_NAME uchardet)
+ project (${PACKAGE_NAME} CXX C)
+ enable_testing()
+@@ -33,13 +34,31 @@ include(GNUInstallDirs)
+
+ ######## Configuration
+
+-option(BUILD_BINARY "Build executable" ON)
+-option(BUILD_SHARED_LIBS "Build shared library and link executable to it" ON)
++option(BUILD_BINARY "Build the CLI tool." ON)
++option(BUILD_SHARED_LIBS "Build shared library and link executable to it." ON)
++option(CHECK_SSE2 "Check and enable SSE2 extensions if supported. Disabling 
SSE on platforms which support it may decrease performances." ON)
++set(TARGET_ARCHITECTURE "" CACHE STRING "Target CPU architecture. It is 
autodetected if not specified.")
+
+ if (BUILD_SHARED_LIBS)
+       option(BUILD_STATIC "Build static library" ON)
+ endif (BUILD_SHARED_LIBS)
+
++if (TARGET_ARCHITECTURE STREQUAL "")
++    string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} TARGET_ARCHITECTURE)
++endif (TARGET_ARCHITECTURE STREQUAL "")
++
++if (TARGET_ARCHITECTURE MATCHES ".*(x86)|(amd).*")
++    CHECK_C_COMPILER_FLAG(-msse2 SUPPORTS_CFLAG_SSE2)
++    CHECK_C_COMPILER_FLAG(-mfpmath=sse SUPPORTS_CFLAG_SSE_MATH)
++    if (CHECK_SSE2 AND SUPPORTS_CFLAG_SSE2 AND SUPPORTS_CFLAG_SSE_MATH)
++        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mfpmath=sse")
++        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2 -mfpmath=sse")
++    else (CHECK_SSE2 AND SUPPORTS_CFLAG_SSE2 AND SUPPORTS_CFLAG_SSE_MATH)
++        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffloat-store")
++        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffloat-store")
++    endif (CHECK_SSE2 AND SUPPORTS_CFLAG_SSE2 AND SUPPORTS_CFLAG_SSE_MATH)
++endif (TARGET_ARCHITECTURE MATCHES ".*(x86)|(amd).*")
++
+ configure_file(
+       uchardet.pc.in
+       uchardet.pc

diff --git a/app-i18n/uchardet/uchardet-0.0.6-r2.ebuild 
b/app-i18n/uchardet/uchardet-0.0.6-r2.ebuild
new file mode 100644
index 00000000000..e5b19449663
--- /dev/null
+++ b/app-i18n/uchardet/uchardet-0.0.6-r2.ebuild
@@ -0,0 +1,31 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit cmake-utils
+
+DESCRIPTION="An encoding detector library"
+HOMEPAGE="https://www.freedesktop.org/wiki/Software/uchardet/";
+SRC_URI="https://www.freedesktop.org/software/uchardet/releases/${P}.tar.xz";
+
+LICENSE="|| ( MPL-1.1 GPL-2+ LGPL-2.1+ )"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ppc ~ppc64 ~x86"
+IUSE="cpu_flags_x86_sse2 static-libs test"
+
+PATCHES=( "${FILESDIR}/${P}-enforce-IEEE-float-precision-r1.patch" )
+
+src_prepare() {
+       cmake-utils_src_prepare
+       use test || cmake_comment_add_subdirectory test
+}
+
+src_configure() {
+       local mycmakeargs=(
+               -DTARGET_ARCHITECTURE="${ARCH}"
+               -DBUILD_STATIC=$(usex static-libs)
+               -DCHECK_SSE2=$(usex cpu_flags_x86_sse2)
+       )
+       cmake-utils_src_configure
+}

Reply via email to