Makefile.am (ARCH_AARCH64_LINUX): Add IFUNC_OPTIONS and libatomic_la_LIBADD.
authorSteve Ellcey <sellcey@cavium.com>
Tue, 5 Dec 2017 00:49:09 +0000 (00:49 +0000)
committerSteve Ellcey <sje@gcc.gnu.org>
Tue, 5 Dec 2017 00:49:09 +0000 (00:49 +0000)
2017-12-04  Steve Ellcey  <sellcey@cavium.com>

* Makefile.am (ARCH_AARCH64_LINUX): Add IFUNC_OPTIONS and
libatomic_la_LIBADD.
* config/linux/aarch64/host-config.h: New file.
* configure.ac (IFUNC_RESOLVER_ARGS): Define.
(ARCH_AARCH64_LINUX): New conditional for IFUNC builds.
* configure.tgt (aarch64): Set ARCH and try_ifunc.
(aarch64*-*-linux*) Update config_path.
(aarch64*-*-linux*) Set IFUNC_RESOLVER_ARGS.
* libatomic_i.h (GEN_SELECTOR): Add IFUNC_RESOLVER_ARGS argument.
* Makefile.in: Regenerate.
* auto-config.h.in: Regenerate.
* configure: Regenerate.

From-SVN: r255399

libatomic/ChangeLog
libatomic/Makefile.am
libatomic/Makefile.in
libatomic/auto-config.h.in
libatomic/config/linux/aarch64/host-config.h [new file with mode: 0644]
libatomic/configure
libatomic/configure.ac
libatomic/configure.tgt
libatomic/libatomic_i.h

index bc254ece628c549610e8762f32075db44b326193..39656cdffc186bb6d499c148ab7b5e597374fcc6 100644 (file)
@@ -1,3 +1,18 @@
+2017-12-04  Steve Ellcey  <sellcey@cavium.com>
+
+       * Makefile.am (ARCH_AARCH64_LINUX): Add IFUNC_OPTIONS and
+       libatomic_la_LIBADD.
+       * config/linux/aarch64/host-config.h: New file.
+       * configure.ac (IFUNC_RESOLVER_ARGS): Define.
+       (ARCH_AARCH64_LINUX): New conditional for IFUNC builds.
+       * configure.tgt (aarch64): Set ARCH and try_ifunc.
+       (aarch64*-*-linux*) Update config_path.
+       (aarch64*-*-linux*) Set IFUNC_RESOLVER_ARGS.
+       * libatomic_i.h (GEN_SELECTOR): Add IFUNC_RESOLVER_ARGS argument.
+       * Makefile.in: Regenerate.
+       * auto-config.h.in: Regenerate.
+       * configure: Regenerate.
+
 2017-11-17  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
 
        * configure.ac: Set CET_FLAGS, update XCFLAGS.
index 9c457008232dc6ead6d7ce1e4174b0101b705a0f..ec36c8ef207c601bc7b3012dba0df7784c75bdd7 100644 (file)
@@ -122,6 +122,10 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS)))
 
 ## On a target-specific basis, include alternates to be selected by IFUNC.
 if HAVE_IFUNC
+if ARCH_AARCH64_LINUX
+IFUNC_OPTIONS       = -march=armv8.1-a
+libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
+endif
 if ARCH_ARM_LINUX
 IFUNC_OPTIONS       = -march=armv7-a+fp -DHAVE_KERNEL64
 libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
index fac9bae6e1ff6a37507e0b23b9253a9536c1d0da..3c3db62de9186a94cd13b73daad039e19f3b0648 100644 (file)
@@ -52,13 +52,14 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_1 = $(foreach \
+@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_1 = $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = $(foreach \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ s,$(SIZES),$(addsuffix \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _$(s)_1_.lo,$(SIZEOBJS))) \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ $(addsuffix \
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _8_2_.lo,$(SIZEOBJS))
-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = $(addsuffix _8_1_.lo,$(SIZEOBJS))
-@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(addsuffix _16_1_.lo,$(SIZEOBJS))
+@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(addsuffix _8_1_.lo,$(SIZEOBJS))
+@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_4 = $(addsuffix _16_1_.lo,$(SIZEOBJS))
 subdir = .
 DIST_COMMON = ChangeLog $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
        $(top_srcdir)/configure $(am__configure_deps) \
@@ -346,7 +347,8 @@ all_c_files := $(foreach dir,$(search_path),$(wildcard $(dir)/*.c))
 M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files)))
 libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
        _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \
-       $(am__append_3)
+       $(am__append_3) $(am__append_4)
+@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv8.1-a
 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
 @ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
 @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16
index d5b8a26e33e172cf18177bad5e2b8355ad0a764e..ab3424a759eae8c5fba17957baeac2ed8397de44 100644 (file)
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
+/* Define ifunc resolver function argument. */
+#undef IFUNC_RESOLVER_ARGS
+
 /* Define to 1 if GNU symbol versioning is used for libatomic. */
 #undef LIBAT_GNU_SYMBOL_VERSIONING
 
diff --git a/libatomic/config/linux/aarch64/host-config.h b/libatomic/config/linux/aarch64/host-config.h
new file mode 100644 (file)
index 0000000..08810a9
--- /dev/null
@@ -0,0 +1,36 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This file is part of the GNU Atomic Library (libatomic).
+
+   Libatomic is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#if HAVE_IFUNC
+#include <stdlib.h>
+
+# ifdef HWCAP_ATOMICS
+#  define IFUNC_COND_1 (hwcap & HWCAP_ATOMICS)
+# else
+#  define IFUNC_COND_1 (false)
+# endif
+# define IFUNC_NCOND(N)        (1)
+
+#endif /* HAVE_IFUNC */
+
+#include_next <host-config.h>
index e49313fbf929373f60ee77793a1ecb24fd4a7afa..cbba8347fd5773a3113c9f8e86770c92616a6f04 100755 (executable)
@@ -608,6 +608,8 @@ ARCH_I386_FALSE
 ARCH_I386_TRUE
 ARCH_ARM_LINUX_FALSE
 ARCH_ARM_LINUX_TRUE
+ARCH_AARCH64_LINUX_FALSE
+ARCH_AARCH64_LINUX_TRUE
 HAVE_IFUNC_FALSE
 HAVE_IFUNC_TRUE
 SIZES
@@ -11118,7 +11120,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11121 "configure"
+#line 11123 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11224,7 +11226,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11227 "configure"
+#line 11229 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11526,6 +11528,13 @@ if test -n "$UNSUPPORTED"; then
   as_fn_error "Configuration ${target} is unsupported." "$LINENO" 5
 fi
 
+# Write out the ifunc resolver arg type.
+
+cat >>confdefs.h <<_ACEOF
+#define IFUNC_RESOLVER_ARGS $IFUNC_RESOLVER_ARGS
+_ACEOF
+
+
 # Disable fallbacks to __sync routines from libgcc.  Otherwise we'll
 # make silly decisions about what the cpu can do.
 CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
@@ -15313,6 +15322,14 @@ else
   HAVE_IFUNC_FALSE=
 fi
 
+ if expr "$config_path" : ".* linux/aarch64 .*" > /dev/null; then
+  ARCH_AARCH64_LINUX_TRUE=
+  ARCH_AARCH64_LINUX_FALSE='#'
+else
+  ARCH_AARCH64_LINUX_TRUE='#'
+  ARCH_AARCH64_LINUX_FALSE=
+fi
+
  if expr "$config_path" : ".* linux/arm .*" > /dev/null; then
   ARCH_ARM_LINUX_TRUE=
   ARCH_ARM_LINUX_FALSE='#'
@@ -15503,6 +15520,10 @@ if test -z "${HAVE_IFUNC_TRUE}" && test -z "${HAVE_IFUNC_FALSE}"; then
   as_fn_error "conditional \"HAVE_IFUNC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${ARCH_AARCH64_LINUX_TRUE}" && test -z "${ARCH_AARCH64_LINUX_FALSE}"; then
+  as_fn_error "conditional \"ARCH_AARCH64_LINUX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${ARCH_ARM_LINUX_TRUE}" && test -z "${ARCH_ARM_LINUX_FALSE}"; then
   as_fn_error "conditional \"ARCH_ARM_LINUX\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
index bf7315e78d1b6c3cc26c7fd598e89fe829199418..6b11f21a03eb15d258f0c955b42865aac335b282 100644 (file)
@@ -163,6 +163,10 @@ if test -n "$UNSUPPORTED"; then
   AC_MSG_ERROR([Configuration ${target} is unsupported.])
 fi
 
+# Write out the ifunc resolver arg type.
+AC_DEFINE_UNQUOTED(IFUNC_RESOLVER_ARGS, $IFUNC_RESOLVER_ARGS,
+       [Define ifunc resolver function argument.])
+
 # Disable fallbacks to __sync routines from libgcc.  Otherwise we'll
 # make silly decisions about what the cpu can do.
 CFLAGS="$save_CFLAGS -fno-sync-libcalls $XCFLAGS"
@@ -251,6 +255,8 @@ AC_SUBST(LIBS)
 AC_SUBST(SIZES)
 
 AM_CONDITIONAL(HAVE_IFUNC, test x$libat_cv_have_ifunc = xyes)
+AM_CONDITIONAL(ARCH_AARCH64_LINUX,
+              [expr "$config_path" : ".* linux/aarch64 .*" > /dev/null])
 AM_CONDITIONAL(ARCH_ARM_LINUX,
               [expr "$config_path" : ".* linux/arm .*" > /dev/null])
 AM_CONDITIONAL(ARCH_I386,
index b8af3ab254611e5cb39e4ed01b7b1a2b6d7b6c04..388ae95e6f4570d9b6f04a7ed5ebb12ed3ee81bb 100644 (file)
@@ -40,6 +40,14 @@ case "${target_cpu}" in
   riscv*)              ARCH=riscv ;;
   sh*)                 ARCH=sh ;;
 
+  aarch64*)
+       ARCH=aarch64
+       case "${target}" in
+           aarch64*-*-linux*)
+               try_ifunc=yes
+               ;;
+       esac
+       ;;
   arm*)
        ARCH=arm
        case "${target}" in
@@ -109,6 +117,11 @@ fi
 
 # Other system configury
 case "${target}" in
+  aarch64*-*-linux*)
+       # OS support for atomic primitives.
+       config_path="${config_path} linux/aarch64 posix"
+       ;;
+
   arm*-*-linux*)
        # OS support for atomic primitives.
        config_path="${config_path} linux/arm posix"
@@ -153,3 +166,14 @@ case "${target}" in
        UNSUPPORTED=1
        ;;
 esac
+
+# glibc will pass hwcap to ifunc resolver functions as an argument.
+# The type may be different on different architectures.
+case "${target}" in
+  aarch64*-*-*)
+       IFUNC_RESOLVER_ARGS="uint64_t hwcap"
+       ;;
+  *)
+       IFUNC_RESOLVER_ARGS="void"
+       ;;
+esac
index 2dad4a84d7a8b054b60e25809bb4228ddea0ee0a..2ecc27aa0dfdabce54591b628f7e917672caf7e8 100644 (file)
@@ -240,7 +240,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
 # if IFUNC_NCOND(N) == 1
 #  define GEN_SELECTOR(X)                                      \
        extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN;    \
-       static typeof(C2(libat_,X)) * C2(select_,X) (void)      \
+       static typeof(C2(libat_,X)) * C2(select_,X) (IFUNC_RESOLVER_ARGS) \
        {                                                       \
          if (IFUNC_COND_1)                                     \
            return C3(libat_,X,_i1);                            \
@@ -250,7 +250,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
 #  define GEN_SELECTOR(X)                                      \
        extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN;    \
        extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN;    \
-       static typeof(C2(libat_,X)) * C2(select_,X) (void)      \
+       static typeof(C2(libat_,X)) * C2(select_,X) (IFUNC_RESOLVER_ARGS) \
        {                                                       \
          if (IFUNC_COND_1)                                     \
            return C3(libat_,X,_i1);                            \
@@ -263,7 +263,7 @@ bool libat_is_lock_free (size_t, void *) MAN(is_lock_free);
        extern typeof(C2(libat_,X)) C3(libat_,X,_i1) HIDDEN;    \
        extern typeof(C2(libat_,X)) C3(libat_,X,_i2) HIDDEN;    \
        extern typeof(C2(libat_,X)) C3(libat_,X,_i3) HIDDEN;    \
-       static typeof(C2(libat_,X)) * C2(select_,X) (void)      \
+       static typeof(C2(libat_,X)) * C2(select_,X) (IFUNC_RESOLVER_ARGS) \
        {                                                       \
          if (IFUNC_COND_1)                                     \
            return C3(libat_,X,_i1);                            \