aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/x86/cpu-features.c
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2017-05-23 00:59:16 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2017-06-07 11:11:40 +0530
commit511c5a1087991108118c6e9c9546e83e992bf39c (patch)
treeb3b2d7c31e685fccdc4f94f54287b5bd2a2375a4 /sysdeps/x86/cpu-features.c
parentf82e9672ad89ea1ef40bbe1af71478e255e87c5e (diff)
downloadglibc-511c5a1087991108118c6e9c9546e83e992bf39c.zip
glibc-511c5a1087991108118c6e9c9546e83e992bf39c.tar.gz
glibc-511c5a1087991108118c6e9c9546e83e992bf39c.tar.bz2
Make LD_HWCAP_MASK usable for static binaries
The LD_HWCAP_MASK environment variable was ignored in static binaries, which is inconsistent with the behaviour of dynamically linked binaries. This seems to have been because of the inability of ld_hwcap_mask being read early enough to influence anything but now that it is in tunables, the mask is usable in static binaries as well. This feature is important for aarch64, which relies on HWCAP_CPUID being masked out to disable multiarch. A sanity test on x86_64 shows that there are no failures. Likewise for aarch64. * elf/dl-hwcaps.h [HAVE_TUNABLES]: Always read hwcap_mask. * sysdeps/sparc/sparc32/dl-machine.h [HAVE_TUNABLES]: Likewise. * sysdeps/x86/cpu-features.c (init_cpu_features): Always set up hwcap and hwcap_mask.
Diffstat (limited to 'sysdeps/x86/cpu-features.c')
-rw-r--r--sysdeps/x86/cpu-features.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sysdeps/x86/cpu-features.c b/sysdeps/x86/cpu-features.c
index 4fe58bf..4288001 100644
--- a/sysdeps/x86/cpu-features.c
+++ b/sysdeps/x86/cpu-features.c
@@ -312,17 +312,16 @@ no_cpuid:
cpu_features->model = model;
cpu_features->kind = kind;
-#if IS_IN (rtld)
/* Reuse dl_platform, dl_hwcap and dl_hwcap_mask for x86. */
GLRO(dl_platform) = NULL;
GLRO(dl_hwcap) = 0;
-#if !HAVE_TUNABLES
+#if !HAVE_TUNABLES && defined SHARED
/* The glibc.tune.hwcap_mask tunable is initialized already, so no need to do
this. */
GLRO(dl_hwcap_mask) = HWCAP_IMPORTANT;
#endif
-# ifdef __x86_64__
+#ifdef __x86_64__
if (cpu_features->kind == arch_kind_intel)
{
if (CPU_FEATURES_ARCH_P (cpu_features, AVX512F_Usable)
@@ -352,7 +351,7 @@ no_cpuid:
&& CPU_FEATURES_CPU_P (cpu_features, POPCNT))
GLRO(dl_platform) = "haswell";
}
-# else
+#else
if (CPU_FEATURES_CPU_P (cpu_features, SSE2))
GLRO(dl_hwcap) |= HWCAP_X86_SSE2;
@@ -360,6 +359,5 @@ no_cpuid:
GLRO(dl_platform) = "i686";
else if (CPU_FEATURES_ARCH_P (cpu_features, I586))
GLRO(dl_platform) = "i586";
-# endif
#endif
}