autoconf build: fix build on Alpine 3.11 where __attribute__((target_clones("fma","default"))) doesn't work for some reason
This commit is contained in:
+21
-1
@@ -125,9 +125,29 @@ if test "$HAVE_GCC_WARNING_ZERO_AS_NULL_POINTER_CONSTANT" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_GCC_WARNING_ZERO_AS_NULL_POINTER_CONSTANT, 1,
|
||||
[Define to 1 if the compiler supports -Wzero-as-null-pointer-constant])
|
||||
fi
|
||||
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Check if __attribute__((target_clones("fma","default"))) works
|
||||
dnl This is needed for example on Alpine Linux where for some reason, building
|
||||
dnl such tagged functions fails with 'error: the call requires 'ifunc', which is not supported by this target'
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
TARGET_CLONES_FMA_FLAGS=""
|
||||
AC_MSG_CHECKING([if target_clones_fma works])
|
||||
SAVED_CFLAGS="$CFLAGS"
|
||||
CFLAGS="$CFLAGS -Werror"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
|
||||
[[
|
||||
__attribute__((target_clones("fma","default"))) void foo() {}
|
||||
]])],
|
||||
[AC_MSG_RESULT([yes])]
|
||||
[TARGET_CLONES_FMA_FLAGS="-DTARGET_CLONES_FMA_ALLOWED"],
|
||||
[AC_MSG_RESULT([no])])
|
||||
CFLAGS="$SAVED_CFLAGS"
|
||||
AC_SUBST(TARGET_CLONES_FMA_FLAGS,$TARGET_CLONES_FMA_FLAGS)
|
||||
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl Check for --enable-lto
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ check_PROGRAMS = geodtest
|
||||
|
||||
AM_CPPFLAGS = -DPROJ_LIB=\"$(pkgdatadir)\" \
|
||||
-DMUTEX_@MUTEX_SETTING@ -I$(top_srcdir)/include @SQLITE3_CFLAGS@ @TIFF_CFLAGS@ @TIFF_ENABLED_FLAGS@ @CURL_CFLAGS@ @CURL_ENABLED_FLAGS@
|
||||
AM_CXXFLAGS = @CXX_WFLAGS@ @FLTO_FLAG@
|
||||
AM_CXXFLAGS = @CXX_WFLAGS@ @FLTO_FLAG@ @TARGET_CLONES_FMA_FLAGS@
|
||||
|
||||
include_HEADERS = proj.h proj_experimental.h proj_constants.h proj_api.h geodesic.h \
|
||||
proj_symbol_rename.h
|
||||
|
||||
@@ -301,6 +301,8 @@ source_group("CMake Files" FILES CMakeLists.txt)
|
||||
# Embed PROJ_LIB data files location
|
||||
add_definitions(-DPROJ_LIB="${CMAKE_INSTALL_PREFIX}/${DATADIR}")
|
||||
|
||||
add_definitions(-DTARGET_CLONES_FMA_ALLOWED)
|
||||
|
||||
#################################################
|
||||
## targets: libproj and proj_config.h
|
||||
#################################################
|
||||
|
||||
@@ -61,7 +61,7 @@ struct pj_opaque_exact {
|
||||
// mechanism for that, where the compiler builds a default version, and one that
|
||||
// uses FMA. And at runtimes it figures out automatically which version can be used
|
||||
// by the current CPU. This allows to create general purpose binaries.
|
||||
#if defined(__GNUC__) && __GNUC__ >= 6 && defined(__x86_64__) && !defined(__FMA__)
|
||||
#if defined(TARGET_CLONES_FMA_ALLOWED) && defined(__GNUC__) && __GNUC__ >= 6 && defined(__x86_64__) && !defined(__FMA__)
|
||||
#define BUILD_FMA_OPTIMIZED_VERSION
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user