diff options
| author | Andre McCurdy <armccurdy@gmail.com> | 2017-11-20 11:40:30 -0800 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-12-11 22:02:59 +0000 |
| commit | 3413d7ac24dafc9ead0247e532400fb9052444fe (patch) | |
| tree | 185271f10346a3d4795cbbff3af4e166c07339e5 | |
| parent | 2c03e1984af7b900bb335e7931f4c66744620f1a (diff) | |
| download | poky-3413d7ac24dafc9ead0247e532400fb9052444fe.tar.gz | |
glibc_2.25: fix building for x86 with -Os (or -fno-omit-frame-pointer)
Glibc 2.25 fails to build for x86 when frame pointers are enabled (ie
when optimised for size or when -fno-omit-frame-pointer is explicitly
included in CFLAGS etc). Backport the upstream fix from glibc 2.26.
https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=3b33d6ed6096c1d20d05a650b06026d673f7399a
(From OE-Core rev: 81ba29c7b9c872d9a9c2efe5f9f8fe6a492af813)
Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/recipes-core/glibc/glibc/0028-Rework-fno-omit-frame-pointer-support-on-i386.patch | 268 | ||||
| -rw-r--r-- | meta/recipes-core/glibc/glibc_2.25.bb | 1 |
2 files changed, 269 insertions, 0 deletions
diff --git a/meta/recipes-core/glibc/glibc/0028-Rework-fno-omit-frame-pointer-support-on-i386.patch b/meta/recipes-core/glibc/glibc/0028-Rework-fno-omit-frame-pointer-support-on-i386.patch new file mode 100644 index 0000000000..7ed2b902da --- /dev/null +++ b/meta/recipes-core/glibc/glibc/0028-Rework-fno-omit-frame-pointer-support-on-i386.patch | |||
| @@ -0,0 +1,268 @@ | |||
| 1 | From 1ea003d4fccc4646fd1848a182405a1c7000ab18 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Adhemerval Zanella <adhemerval.zanella@linaro.org> | ||
| 3 | Date: Sun, 8 Jan 2017 11:38:23 -0200 | ||
| 4 | Subject: [PATCH 28/28] Rework -fno-omit-frame-pointer support on i386 | ||
| 5 | |||
| 6 | Commit 6b1df8b27f fixed the -OS build issue on i386 (BZ#20729) by | ||
| 7 | expliciting disabling frame pointer (-fomit-frame-pointer) on the | ||
| 8 | faulty objects. Although it does fix the issue, it is a subpar | ||
| 9 | workaround that adds complexity in build process (a rule for each | ||
| 10 | object to add the required compiler option and pontentially more | ||
| 11 | rules for objects that call {INLINE,INTERNAL}_SYSCALL) and does not | ||
| 12 | allow the implementations to get all the possible debug/calltrack | ||
| 13 | information possible (used mainly in debuggers and performance | ||
| 14 | measurement tools). | ||
| 15 | |||
| 16 | This patch fixes it by adding an explicit configure check to see | ||
| 17 | if -fno-omit-frame-pointer is set and to act accordingly (set or | ||
| 18 | not OPTIMIZE_FOR_GCC_5). The make rules is simplified and only | ||
| 19 | one is required: to add libc-do-syscall on loader due mmap | ||
| 20 | (which will be empty anyway for default build with | ||
| 21 | -fomit-frame-pointer). | ||
| 22 | |||
| 23 | Checked on i386-linux-gnu with GCC 6.2.1 with CFLAGS sets as | ||
| 24 | '-Os', '-O2 -fno-omit-frame-pointer', and '-O2 -fomit-frame-pointer'. | ||
| 25 | For '-Os' the testsuite issues described by BZ#19463 and BZ#15105 | ||
| 26 | still applied. | ||
| 27 | |||
| 28 | It fixes BZ #21029, although it is marked as duplicated of #20729 | ||
| 29 | (I reopened to track this cleanup). | ||
| 30 | |||
| 31 | [BZ #21029] | ||
| 32 | * config.h.in [CAN_USE_REGISTER_ASM_EBP]: New define. | ||
| 33 | * sysdeps/unix/sysv/linux/i386/Makefile | ||
| 34 | [$(subdir) = elf] (sysdep-dl-routines): Add libc-do-syscall. | ||
| 35 | (uses-6-syscall-arguments): Remove. | ||
| 36 | [$(subdir) = misc] (CFLAGS-epoll_pwait.o): Likewise. | ||
| 37 | [$(subdir) = misc] (CFLAGS-epoll_pwait.os): Likewise. | ||
| 38 | [$(subdir) = misc] (CFLAGS-mmap.o): Likewise. | ||
| 39 | [$(subdir) = misc] (CFLAGS-mmap.os): Likewise. | ||
| 40 | [$(subdir) = misc] (CFLAGS-mmap64.o): Likewise. | ||
| 41 | [$(subdir) = misc] (CFLAGS-mmap64.os): Likewise. | ||
| 42 | [$(subdir) = misc] (CFLAGS-pselect.o): Likewise. | ||
| 43 | [$(subdir) = misc] (cflags-pselect.o): Likewise. | ||
| 44 | [$(subdir) = misc] (cflags-pselect.os): Likewise. | ||
| 45 | [$(subdir) = misc] (cflags-rtld-mmap.os): Likewise. | ||
| 46 | [$(subdir) = sysvipc] (cflags-semtimedop.o): Likewise. | ||
| 47 | [$(subdir) = sysvipc] (cflags-semtimedop.os): Likewise. | ||
| 48 | [$(subdir) = io] (CFLAGS-posix_fadvise64.o): Likewise. | ||
| 49 | [$(subdir) = io] (CFLAGS-posix_fadvise64.os): Likewise. | ||
| 50 | [$(subdir) = io] (CFLAGS-posix_fallocate.o): Likewise. | ||
| 51 | [$(subdir) = io] (CFLAGS-posix_fallocate.os): Likewise. | ||
| 52 | [$(subdir) = io] (CFLAGS-posix_fallocate64.o): Likewise. | ||
| 53 | [$(subdir) = io] (CFLAGS-posix_fallocate64.os): Likewise. | ||
| 54 | [$(subdir) = io] (CFLAGS-sync_file_range.o): Likewise. | ||
| 55 | [$(subdir) = io] (CFLAGS-sync_file_range.os): Likewise. | ||
| 56 | [$(subdir) = io] (CFLAGS-fallocate.o): Likewise. | ||
| 57 | [$(subdir) = io] (CFLAGS-fallocate.os): Likewise. | ||
| 58 | [$(subdir) = io] (CFLAGS-fallocate64.o): Likewise. | ||
| 59 | [$(subdir) = io] (CFLAGS-fallocate64.os): Likewise. | ||
| 60 | [$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrdlock.o): | ||
| 61 | Likewise. | ||
| 62 | [$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrdlock.os): | ||
| 63 | Likewise. | ||
| 64 | [$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrwlock.o): | ||
| 65 | Likewise. | ||
| 66 | [$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrwlock.os): | ||
| 67 | Likewise. | ||
| 68 | [$(subdir) = nptl] (CFLAGS-sem_wait.o): Likewise. | ||
| 69 | [$(subdir) = nptl] (CFLAGS-sem_wait.os): Likewise. | ||
| 70 | [$(subdir) = nptl] (CFLAGS-sem_timedwait.o): Likewise. | ||
| 71 | [$(subdir) = nptl] (CFLAGS-sem_timedwait.os): Likewise. | ||
| 72 | * sysdeps/unix/sysv/linux/i386/configure.ac: Add check if compiler allows | ||
| 73 | ebp on inline assembly. | ||
| 74 | * sysdeps/unix/sysv/linux/i386/configure: Regenerate. | ||
| 75 | * sysdeps/unix/sysv/linux/i386/sysdep.h (OPTIMIZE_FOR_GCC_5): | ||
| 76 | Set if CAN_USE_REGISTER_ASM_EBP is set. | ||
| 77 | (check_consistency): Likewise. | ||
| 78 | |||
| 79 | Upstream-Status: Backport | ||
| 80 | |||
| 81 | https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=3b33d6ed6096c1d20d05a650b06026d673f7399a | ||
| 82 | |||
| 83 | Signed-off-by: Andre McCurdy <armccurdy@gmail.com> | ||
| 84 | --- | ||
| 85 | config.h.in | 4 ++++ | ||
| 86 | sysdeps/unix/sysv/linux/i386/Makefile | 39 +------------------------------ | ||
| 87 | sysdeps/unix/sysv/linux/i386/configure | 39 +++++++++++++++++++++++++++++++ | ||
| 88 | sysdeps/unix/sysv/linux/i386/configure.ac | 17 ++++++++++++++ | ||
| 89 | sysdeps/unix/sysv/linux/i386/sysdep.h | 6 ++--- | ||
| 90 | 5 files changed, 64 insertions(+), 41 deletions(-) | ||
| 91 | |||
| 92 | diff --git a/config.h.in b/config.h.in | ||
| 93 | index 7bfe923..fb2cc51 100644 | ||
| 94 | --- a/config.h.in | ||
| 95 | +++ b/config.h.in | ||
| 96 | @@ -259,4 +259,8 @@ | ||
| 97 | /* Build glibc with tunables support. */ | ||
| 98 | #define HAVE_TUNABLES 0 | ||
| 99 | |||
| 100 | +/* Some compiler options may now allow to use ebp in __asm__ (used mainly | ||
| 101 | + in i386 6 argument syscall issue). */ | ||
| 102 | +#define CAN_USE_REGISTER_ASM_EBP 0 | ||
| 103 | + | ||
| 104 | #endif | ||
| 105 | diff --git a/sysdeps/unix/sysv/linux/i386/Makefile b/sysdeps/unix/sysv/linux/i386/Makefile | ||
| 106 | index 9609752..6aac0df 100644 | ||
| 107 | --- a/sysdeps/unix/sysv/linux/i386/Makefile | ||
| 108 | +++ b/sysdeps/unix/sysv/linux/i386/Makefile | ||
| 109 | @@ -1,47 +1,18 @@ | ||
| 110 | # The default ABI is 32. | ||
| 111 | default-abi := 32 | ||
| 112 | |||
| 113 | -# %ebp is used to pass the 6th argument to system calls, so these | ||
| 114 | -# system calls are incompatible with a frame pointer. | ||
| 115 | -uses-6-syscall-arguments = -fomit-frame-pointer | ||
| 116 | - | ||
| 117 | ifeq ($(subdir),misc) | ||
| 118 | sysdep_routines += ioperm iopl vm86 | ||
| 119 | -CFLAGS-epoll_pwait.o += $(uses-6-syscall-arguments) | ||
| 120 | -CFLAGS-epoll_pwait.os += $(uses-6-syscall-arguments) | ||
| 121 | -CFLAGS-mmap.o += $(uses-6-syscall-arguments) | ||
| 122 | -CFLAGS-mmap.os += $(uses-6-syscall-arguments) | ||
| 123 | -CFLAGS-mmap64.o += $(uses-6-syscall-arguments) | ||
| 124 | -CFLAGS-mmap64.os += $(uses-6-syscall-arguments) | ||
| 125 | -CFLAGS-pselect.o += $(uses-6-syscall-arguments) | ||
| 126 | -CFLAGS-pselect.os += $(uses-6-syscall-arguments) | ||
| 127 | -CFLAGS-rtld-mmap.os += $(uses-6-syscall-arguments) | ||
| 128 | -endif | ||
| 129 | - | ||
| 130 | -ifeq ($(subdir),sysvipc) | ||
| 131 | -CFLAGS-semtimedop.o += $(uses-6-syscall-arguments) | ||
| 132 | -CFLAGS-semtimedop.os += $(uses-6-syscall-arguments) | ||
| 133 | endif | ||
| 134 | |||
| 135 | ifeq ($(subdir),elf) | ||
| 136 | +sysdep-dl-routines += libc-do-syscall | ||
| 137 | sysdep-others += lddlibc4 | ||
| 138 | install-bin += lddlibc4 | ||
| 139 | endif | ||
| 140 | |||
| 141 | ifeq ($(subdir),io) | ||
| 142 | sysdep_routines += libc-do-syscall | ||
| 143 | -CFLAGS-posix_fadvise64.o += $(uses-6-syscall-arguments) | ||
| 144 | -CFLAGS-posix_fadvise64.os += $(uses-6-syscall-arguments) | ||
| 145 | -CFLAGS-posix_fallocate.o += $(uses-6-syscall-arguments) | ||
| 146 | -CFLAGS-posix_fallocate.os += $(uses-6-syscall-arguments) | ||
| 147 | -CFLAGS-posix_fallocate64.o += $(uses-6-syscall-arguments) | ||
| 148 | -CFLAGS-posix_fallocate64.os += $(uses-6-syscall-arguments) | ||
| 149 | -CFLAGS-sync_file_range.o += $(uses-6-syscall-arguments) | ||
| 150 | -CFLAGS-sync_file_range.os += $(uses-6-syscall-arguments) | ||
| 151 | -CFLAGS-fallocate.o += $(uses-6-syscall-arguments) | ||
| 152 | -CFLAGS-fallocate.os += $(uses-6-syscall-arguments) | ||
| 153 | -CFLAGS-fallocate64.o += $(uses-6-syscall-arguments) | ||
| 154 | -CFLAGS-fallocate64.os += $(uses-6-syscall-arguments) | ||
| 155 | endif | ||
| 156 | |||
| 157 | ifeq ($(subdir),nptl) | ||
| 158 | @@ -61,14 +32,6 @@ ifeq ($(subdir),nptl) | ||
| 159 | # pull in __syscall_error routine | ||
| 160 | libpthread-routines += sysdep | ||
| 161 | libpthread-shared-only-routines += sysdep | ||
| 162 | -CFLAGS-pthread_rwlock_timedrdlock.o += $(uses-6-syscall-arguments) | ||
| 163 | -CFLAGS-pthread_rwlock_timedrdlock.os += $(uses-6-syscall-arguments) | ||
| 164 | -CFLAGS-pthread_rwlock_timedwrlock.o += $(uses-6-syscall-arguments) | ||
| 165 | -CFLAGS-pthread_rwlock_timedwrlock.os += $(uses-6-syscall-arguments) | ||
| 166 | -CFLAGS-sem_wait.o += $(uses-6-syscall-arguments) | ||
| 167 | -CFLAGS-sem_wait.os += $(uses-6-syscall-arguments) | ||
| 168 | -CFLAGS-sem_timedwait.o += $(uses-6-syscall-arguments) | ||
| 169 | -CFLAGS-sem_timedwait.os += $(uses-6-syscall-arguments) | ||
| 170 | endif | ||
| 171 | |||
| 172 | ifeq ($(subdir),rt) | ||
| 173 | diff --git a/sysdeps/unix/sysv/linux/i386/configure b/sysdeps/unix/sysv/linux/i386/configure | ||
| 174 | index eb72659..ae2c356 100644 | ||
| 175 | --- a/sysdeps/unix/sysv/linux/i386/configure | ||
| 176 | +++ b/sysdeps/unix/sysv/linux/i386/configure | ||
| 177 | @@ -3,5 +3,44 @@ | ||
| 178 | |||
| 179 | arch_minimum_kernel=2.6.32 | ||
| 180 | |||
| 181 | +# Check if CFLAGS allows compiler to use ebp register in inline assembly. | ||
| 182 | + | ||
| 183 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler flags allows ebp in inline assembly" >&5 | ||
| 184 | +$as_echo_n "checking if compiler flags allows ebp in inline assembly... " >&6; } | ||
| 185 | +if ${libc_cv_can_use_register_asm_ebp+:} false; then : | ||
| 186 | + $as_echo_n "(cached) " >&6 | ||
| 187 | +else | ||
| 188 | + | ||
| 189 | +cat confdefs.h - <<_ACEOF >conftest.$ac_ext | ||
| 190 | +/* end confdefs.h. */ | ||
| 191 | + | ||
| 192 | + void foo (int i) | ||
| 193 | + { | ||
| 194 | + register int reg asm ("ebp") = i; | ||
| 195 | + asm ("# %0" : : "r" (reg)); | ||
| 196 | + } | ||
| 197 | +int | ||
| 198 | +main () | ||
| 199 | +{ | ||
| 200 | + | ||
| 201 | + ; | ||
| 202 | + return 0; | ||
| 203 | +} | ||
| 204 | +_ACEOF | ||
| 205 | +if ac_fn_c_try_compile "$LINENO"; then : | ||
| 206 | + libc_cv_can_use_register_asm_ebp=yes | ||
| 207 | +else | ||
| 208 | + libc_cv_can_use_register_asm_ebp=no | ||
| 209 | +fi | ||
| 210 | +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext | ||
| 211 | + | ||
| 212 | +fi | ||
| 213 | +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_can_use_register_asm_ebp" >&5 | ||
| 214 | +$as_echo "$libc_cv_can_use_register_asm_ebp" >&6; } | ||
| 215 | +if test $libc_cv_can_use_register_asm_ebp = yes; then | ||
| 216 | + $as_echo "#define CAN_USE_REGISTER_ASM_EBP 1" >>confdefs.h | ||
| 217 | + | ||
| 218 | +fi | ||
| 219 | + | ||
| 220 | libc_cv_gcc_unwind_find_fde=yes | ||
| 221 | ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed | ||
| 222 | diff --git a/sysdeps/unix/sysv/linux/i386/configure.ac b/sysdeps/unix/sysv/linux/i386/configure.ac | ||
| 223 | index 1a11da6..1cd632e 100644 | ||
| 224 | --- a/sysdeps/unix/sysv/linux/i386/configure.ac | ||
| 225 | +++ b/sysdeps/unix/sysv/linux/i386/configure.ac | ||
| 226 | @@ -3,5 +3,22 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. | ||
| 227 | |||
| 228 | arch_minimum_kernel=2.6.32 | ||
| 229 | |||
| 230 | +# Check if CFLAGS allows compiler to use ebp register in inline assembly. | ||
| 231 | +AC_CACHE_CHECK([if compiler flags allows ebp in inline assembly], | ||
| 232 | + libc_cv_can_use_register_asm_ebp, [ | ||
| 233 | +AC_COMPILE_IFELSE( | ||
| 234 | + [AC_LANG_PROGRAM([ | ||
| 235 | + void foo (int i) | ||
| 236 | + { | ||
| 237 | + register int reg asm ("ebp") = i; | ||
| 238 | + asm ("# %0" : : "r" (reg)); | ||
| 239 | + }])], | ||
| 240 | + [libc_cv_can_use_register_asm_ebp=yes], | ||
| 241 | + [libc_cv_can_use_register_asm_ebp=no]) | ||
| 242 | +]) | ||
| 243 | +if test $libc_cv_can_use_register_asm_ebp = yes; then | ||
| 244 | + AC_DEFINE(CAN_USE_REGISTER_ASM_EBP) | ||
| 245 | +fi | ||
| 246 | + | ||
| 247 | libc_cv_gcc_unwind_find_fde=yes | ||
| 248 | ldd_rewrite_script=sysdeps/unix/sysv/linux/ldd-rewrite.sed | ||
| 249 | diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h | ||
| 250 | index baf4642..449b23e 100644 | ||
| 251 | --- a/sysdeps/unix/sysv/linux/i386/sysdep.h | ||
| 252 | +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h | ||
| 253 | @@ -44,9 +44,9 @@ | ||
| 254 | /* Since GCC 5 and above can properly spill %ebx with PIC when needed, | ||
| 255 | we can inline syscalls with 6 arguments if GCC 5 or above is used | ||
| 256 | to compile glibc. Disable GCC 5 optimization when compiling for | ||
| 257 | - profiling since asm ("ebp") can't be used to put the 6th argument | ||
| 258 | - in %ebp for syscall. */ | ||
| 259 | -#if __GNUC_PREREQ (5,0) && !defined PROF | ||
| 260 | + profiling or when -fno-omit-frame-pointer is used since asm ("ebp") | ||
| 261 | + can't be used to put the 6th argument in %ebp for syscall. */ | ||
| 262 | +#if __GNUC_PREREQ (5,0) && !defined PROF && CAN_USE_REGISTER_ASM_EBP | ||
| 263 | # define OPTIMIZE_FOR_GCC_5 | ||
| 264 | #endif | ||
| 265 | |||
| 266 | -- | ||
| 267 | 1.9.1 | ||
| 268 | |||
diff --git a/meta/recipes-core/glibc/glibc_2.25.bb b/meta/recipes-core/glibc/glibc_2.25.bb index cf9c4f71b8..0f1ec0c142 100644 --- a/meta/recipes-core/glibc/glibc_2.25.bb +++ b/meta/recipes-core/glibc/glibc_2.25.bb | |||
| @@ -42,6 +42,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \ | |||
| 42 | file://0025-Define-DUMMY_LOCALE_T-if-not-defined.patch \ | 42 | file://0025-Define-DUMMY_LOCALE_T-if-not-defined.patch \ |
| 43 | file://0026-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch \ | 43 | file://0026-elf-dl-deps.c-Make-_dl_build_local_scope-breadth-fir.patch \ |
| 44 | file://0027-locale-fix-hard-coded-reference-to-gcc-E.patch \ | 44 | file://0027-locale-fix-hard-coded-reference-to-gcc-E.patch \ |
| 45 | file://0028-Rework-fno-omit-frame-pointer-support-on-i386.patch \ | ||
| 45 | " | 46 | " |
| 46 | 47 | ||
| 47 | NATIVESDKFIXES ?= "" | 48 | NATIVESDKFIXES ?= "" |
