首页 > 解决方案 > glibc 编译错误:错误:'__EI___errno_location' 指定的限制属性低于其目标'

问题描述

帮我找出我尝试编译 glibc 2.24 的错误,我有以下错误:

 ./../include/libc-symbols.h:413:26: error: '__EI___errno_location' specifies less restrictive attributes than its target '__errno_location': 'const', 'nothrow' [-Werror=missing-attributes]
|   413 |   extern __typeof (name) __EI_##name \
|       |                          ^~~~~
| ./../include/libc-symbols.h:417:29: note: in expansion of macro '__hidden_ver1'
|   417 | #  define hidden_def(name)  __hidden_ver1(__GI_##name, name, name);
|       |                             ^~~~~~~~~~~~~
| ./../include/libc-symbols.h:468:32: note: in expansion of macro 'hidden_def'
|   468 | # define libc_hidden_def(name) hidden_def (name)
|       |                                ^~~~~~~~~~
| errno-loc.c:28:1: note: in expansion of macro 'libc_hidden_def'
|    28 | libc_hidden_def (__errno_location)
|       | ^~~~~~~~~~~~~~~
| errno-loc.c:24:1: note: '__EI___errno_location' target declared here
|    24 | __errno_location (void)
|       | ^~~~~~~~~~~~~~~~

我尝试通过以下方式解决此错误:

diff -Naur glibc_orig/include/libc-symbols.h glibc/include/libc-symbols.h
--- glibc_orig/include/libc-symbols.h   2021-08-26 10:16:34.327141852 +0300
+++ glibc/include/libc-symbols.h    2021-08-26 12:08:13.654205932 +0300
@@ -388,6 +388,7 @@
    versioned_symbol (libc, __real_foo, foo, GLIBC_2_1);
    libc_hidden_ver (__real_foo, foo)  */
 
+
 #if defined SHARED && !defined NO_HIDDEN
 # ifndef __ASSEMBLER__
 #  define __hidden_proto_hiddenattr(attrs...) \
@@ -403,6 +404,10 @@
   __hidden_asmname1 (__USER_LABEL_PREFIX__, name)
 #  define __hidden_asmname1(prefix, name) __hidden_asmname2(prefix, name)
 #  define __hidden_asmname2(prefix, name) #prefix name
+
+   #pragma GCC diagnostic push
+   #pragma GCC diagnostic ignored "-Wmissing-attributes"
+
 #  define __hidden_ver1(local, internal, name) \
   extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
   extern __typeof (name) __EI_##name \
@@ -759,5 +764,6 @@
 #else
 # define inhibit_loop_to_libcall
 #endif
+#pragma GCC diagnostic pop
 
 #endif /* libc-symbols.h */

但是编译时重复报错,告诉我如何解决这个错误?

标签: cgccglibcpragma

解决方案


它解决了./configure --disable-werror


推荐阅读