* [PATCH v2 1/4] Add declare_object_symbol_alias for assembly codes (BZ #28128)
2022-05-12 12:59 [PATCH v2 0/4] Remove fno_unit_at_a_time configure check Adhemerval Zanella
@ 2022-05-12 12:59 ` Adhemerval Zanella
2022-05-12 16:52 ` Fangrui Song
2022-05-12 12:59 ` [PATCH v2 2/4] stdio: Remove the usage of $(fno-unit-at-a-time) for errlist.c Adhemerval Zanella
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 12:59 UTC (permalink / raw)
To: libc-alpha, Fangrui Song
From: "H.J. Lu" <hjl.tools@gmail.com>
There are 2 problems in:
#define declare_symbol_alias(symbol, original, type, size) \
declare_symbol_alias_1 (symbol, original, type, size)
#ifdef __ASSEMBLER__
# define declare_symbol_alias_1(symbol, original, type, size) \
strong_alias (original, symbol); \
.type C_SYMBOL_NAME (symbol), %##type; \
.size C_SYMBOL_NAME (symbol), size
1. .type and .size are substituted by arguments.
2. %##type is expanded to "% type" due to the GCC bug:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101613
But assembler doesn't support "% type".
Workaround BZ #28128 by
1. Don't define declare_symbol_alias for assembly codes.
2. Define declare_object_symbol_alias for assembly codes.
---
include/libc-symbols.h | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index 662bd118b1..4bb3d8c7ba 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -324,14 +324,16 @@ for linking")
This is only necessary when defining something in assembly, or playing
funny alias games where the size should be other than what the compiler
thinks it is. */
-#define declare_symbol_alias(symbol, original, type, size) \
- declare_symbol_alias_1 (symbol, original, type, size)
#ifdef __ASSEMBLER__
-# define declare_symbol_alias_1(symbol, original, type, size) \
- strong_alias (original, symbol); \
- .type C_SYMBOL_NAME (symbol), %##type; \
- .size C_SYMBOL_NAME (symbol), size
+# define declare_object_symbol_alias(symbol, original, size) \
+ declare_object_symbol_alias_1 (symbol, original, size)
+# define declare_object_symbol_alias_1(symbol, original, s_size) \
+ strong_alias (original, symbol) ASM_LINE_SEP \
+ .type C_SYMBOL_NAME (symbol), %object ASM_LINE_SEP \
+ .size C_SYMBOL_NAME (symbol), s_size ASM_LINE_SEP
#else /* Not __ASSEMBLER__. */
+# define declare_symbol_alias(symbol, original, type, size) \
+ declare_symbol_alias_1 (symbol, original, type, size)
# define declare_symbol_alias_1(symbol, original, type, size) \
asm (".globl " __SYMBOL_PREFIX #symbol \
"\n\t" declare_symbol_alias_1_alias (symbol, original) \
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/4] Add declare_object_symbol_alias for assembly codes (BZ #28128)
2022-05-12 12:59 ` [PATCH v2 1/4] Add declare_object_symbol_alias for assembly codes (BZ #28128) Adhemerval Zanella
@ 2022-05-12 16:52 ` Fangrui Song
0 siblings, 0 replies; 11+ messages in thread
From: Fangrui Song @ 2022-05-12 16:52 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha, H.J. Lu
On 2022-05-12, Adhemerval Zanella wrote:
>From: "H.J. Lu" <hjl.tools@gmail.com>
>
>There are 2 problems in:
>
> #define declare_symbol_alias(symbol, original, type, size) \
> declare_symbol_alias_1 (symbol, original, type, size)
> #ifdef __ASSEMBLER__
> # define declare_symbol_alias_1(symbol, original, type, size) \
> strong_alias (original, symbol); \
> .type C_SYMBOL_NAME (symbol), %##type; \
> .size C_SYMBOL_NAME (symbol), size
>
>1. .type and .size are substituted by arguments.
>2. %##type is expanded to "% type" due to the GCC bug:
>
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101613
>
>But assembler doesn't support "% type".
>
>Workaround BZ #28128 by
>
>1. Don't define declare_symbol_alias for assembly codes.
>2. Define declare_object_symbol_alias for assembly codes.
Interesting. clang -E can expand
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101613
correctly.
Reviewed-by: Fangrui Song <maskray@google.com>
>---
> include/libc-symbols.h | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
>diff --git a/include/libc-symbols.h b/include/libc-symbols.h
>index 662bd118b1..4bb3d8c7ba 100644
>--- a/include/libc-symbols.h
>+++ b/include/libc-symbols.h
>@@ -324,14 +324,16 @@ for linking")
> This is only necessary when defining something in assembly, or playing
> funny alias games where the size should be other than what the compiler
> thinks it is. */
>-#define declare_symbol_alias(symbol, original, type, size) \
>- declare_symbol_alias_1 (symbol, original, type, size)
> #ifdef __ASSEMBLER__
>-# define declare_symbol_alias_1(symbol, original, type, size) \
>- strong_alias (original, symbol); \
>- .type C_SYMBOL_NAME (symbol), %##type; \
>- .size C_SYMBOL_NAME (symbol), size
>+# define declare_object_symbol_alias(symbol, original, size) \
>+ declare_object_symbol_alias_1 (symbol, original, size)
>+# define declare_object_symbol_alias_1(symbol, original, s_size) \
>+ strong_alias (original, symbol) ASM_LINE_SEP \
>+ .type C_SYMBOL_NAME (symbol), %object ASM_LINE_SEP \
>+ .size C_SYMBOL_NAME (symbol), s_size ASM_LINE_SEP
> #else /* Not __ASSEMBLER__. */
>+# define declare_symbol_alias(symbol, original, type, size) \
>+ declare_symbol_alias_1 (symbol, original, type, size)
> # define declare_symbol_alias_1(symbol, original, type, size) \
> asm (".globl " __SYMBOL_PREFIX #symbol \
> "\n\t" declare_symbol_alias_1_alias (symbol, original) \
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/4] stdio: Remove the usage of $(fno-unit-at-a-time) for errlist.c
2022-05-12 12:59 [PATCH v2 0/4] Remove fno_unit_at_a_time configure check Adhemerval Zanella
2022-05-12 12:59 ` [PATCH v2 1/4] Add declare_object_symbol_alias for assembly codes (BZ #28128) Adhemerval Zanella
@ 2022-05-12 12:59 ` Adhemerval Zanella
2022-05-12 17:03 ` Fangrui Song
2022-05-12 12:59 ` [PATCH v2 3/4] stdio: Remove the usage of $(fno-unit-at-a-time) for siglist.c Adhemerval Zanella
2022-05-12 12:59 ` [PATCH v2 4/4] Remove configure fno_unit_at_a_time Adhemerval Zanella
3 siblings, 1 reply; 11+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 12:59 UTC (permalink / raw)
To: libc-alpha, Fangrui Song
The errlist.c is build with -fno-toplevel-reorder to avoid compiler to
reorder the compat assembly directives due a static linker issue [1]
(fixed on 2.39).
This patch removes the compiler flags by split the compat symbol
generation in two phases. First the _sys_errlist_internal internal
without any compat symbol directive is preprocessed to generate an
assembly source code. This generate assembly is then used as input
on a platform agnostic errlist-data.S which then creates the compat
definitions. This prevents compiler to move any compat directive
prior the _sys_errlist_internal definition itself.
Checked on a make check run-built-tests=no on all affected ABIs.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=29012
---
Makeconfig | 3 +-
include/stdio.h | 1 +
stdio-common/Makefile | 20 ++++++++++-
stdio-common/err_map.h | 24 +++++++++++++
stdio-common/errlist-compat-data.h | 1 +
stdio-common/errlist-compat.c | 1 -
stdio-common/errlist-data-gen.c | 34 +++++++++++++++++++
stdio-common/errlist-data.S | 7 ++++
stdio-common/errlist.c | 20 +++--------
sysdeps/mach/hurd/{errlist.c => err_map.h} | 9 +++--
...errlist-compat.c => errlist-compat-data.h} | 0
...errlist-compat.c => errlist-compat-data.h} | 0
sysdeps/unix/sysv/linux/errlist-compat.h | 33 +++++++++++-------
...errlist-compat.c => errlist-compat-data.h} | 0
...errlist-compat.c => errlist-compat-data.h} | 0
...errlist-compat.c => errlist-compat-data.h} | 0
16 files changed, 120 insertions(+), 33 deletions(-)
create mode 100644 stdio-common/err_map.h
create mode 100644 stdio-common/errlist-compat-data.h
delete mode 100644 stdio-common/errlist-compat.c
create mode 100644 stdio-common/errlist-data-gen.c
create mode 100644 stdio-common/errlist-data.S
rename sysdeps/mach/hurd/{errlist.c => err_map.h} (83%)
rename sysdeps/unix/sysv/linux/alpha/{errlist-compat.c => errlist-compat-data.h} (100%)
rename sysdeps/unix/sysv/linux/{errlist-compat.c => errlist-compat-data.h} (100%)
rename sysdeps/unix/sysv/linux/hppa/{errlist-compat.c => errlist-compat-data.h} (100%)
rename sysdeps/unix/sysv/linux/mips/{errlist-compat.c => errlist-compat-data.h} (100%)
rename sysdeps/unix/sysv/linux/sparc/{errlist-compat.c => errlist-compat-data.h} (100%)
diff --git a/Makeconfig b/Makeconfig
index 760f14e92f..b5aa07c4f4 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -1030,7 +1030,8 @@ ifeq (yes,$(build-shared))
# Under --enable-shared, we will build a shared library of PIC objects.
# The PIC object files are named foo.os.
object-suffixes += .os
-CPPFLAGS-.os = -DPIC -DSHARED
+pic-cppflags = -DPIC -DSHARED
+CPPFLAGS-.os = $(pic-cppflags)
CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
libtype.os := lib%_pic.a
# This can be changed by a sysdep makefile
diff --git a/include/stdio.h b/include/stdio.h
index 23b7fd288c..a6f7fd43cb 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -180,6 +180,7 @@ int __vfxprintf (FILE *__fp, const char *__fmt, __gnuc_va_list,
attribute_hidden;
extern const char *const _sys_errlist_internal[] attribute_hidden;
+extern const size_t _sys_errlist_internal_len attribute_hidden;
extern const char *__get_errlist (int) attribute_hidden;
extern const char *__get_errname (int) attribute_hidden;
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index a1603e82fe..08bc998436 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -88,6 +88,7 @@ routines := \
aux := \
errlist \
+ errlist-data \
errname \
fxprintf \
printf-parsemb \
@@ -211,6 +212,10 @@ tests := \
xbug \
# tests
+generated += \
+ errlist-data-aux-shared.S \
+ errlist-data-aux.S \
+ # generated
test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
@@ -246,6 +251,20 @@ tests-special += $(objpfx)tst-errno-manual.out
include ../Rules
+# The errlist.c is built in two phases because compiler might reorder the
+# compat_symbol directive prior the object itself and on binutils older
+# than 2.29 it might generate object sizes different than the expected ones.
+$(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c
+ $(make-target-directory)
+ $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
+
+$(objpfx)errlist-data-aux.S: errlist-data-gen.c
+ $(make-target-directory)
+ $(compile-command.c) $(pie-default) $(no-stack-protector) -S
+
+$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
+$(objpfx)errlist-data.o: $(objpfx)errlist-data-aux.S
+
ifeq ($(run-built-tests),yes)
LOCALES := \
de_DE.ISO-8859-1 \
@@ -334,7 +353,6 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
CFLAGS-isoc99_vscanf.c += -fexceptions
CFLAGS-isoc99_fscanf.c += -fexceptions
CFLAGS-isoc99_scanf.c += -fexceptions
-CFLAGS-errlist.c += $(fno-unit-at-a-time)
CFLAGS-siglist.c += $(fno-unit-at-a-time)
# scanf14a.c and scanf16a.c test a deprecated extension which is no
diff --git a/stdio-common/err_map.h b/stdio-common/err_map.h
new file mode 100644
index 0000000000..6cc3aa3375
--- /dev/null
+++ b/stdio-common/err_map.h
@@ -0,0 +1,24 @@
+/* Internal errno names mapping definition.
+ Copyright (C) 2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _ERR_MAP_H
+#define _ERR_MAP_H
+
+#define ERR_MAP(n) (n)
+
+#endif
diff --git a/stdio-common/errlist-compat-data.h b/stdio-common/errlist-compat-data.h
new file mode 100644
index 0000000000..7c89c9a5a4
--- /dev/null
+++ b/stdio-common/errlist-compat-data.h
@@ -0,0 +1 @@
+/* Empty */
diff --git a/stdio-common/errlist-compat.c b/stdio-common/errlist-compat.c
deleted file mode 100644
index 6e25b021ab..0000000000
--- a/stdio-common/errlist-compat.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Empty. */
diff --git a/stdio-common/errlist-data-gen.c b/stdio-common/errlist-data-gen.c
new file mode 100644
index 0000000000..db4f50e6db
--- /dev/null
+++ b/stdio-common/errlist-data-gen.c
@@ -0,0 +1,34 @@
+/* Internal errno names mapping definition.
+ Copyright (C) 2022 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <array_length.h>
+#include <err_map.h>
+#include <errno.h>
+#include <libintl.h>
+#include <stdio.h>
+
+const char *const _sys_errlist_internal[] =
+ {
+#define _S(n, str) [ERR_MAP(n)] = str,
+#include <errlist.h>
+#undef _S
+ };
+const size_t _sys_errlist_internal_len = array_length (_sys_errlist_internal);
+
+/* Include to get the definitions for sys_nerr/_sys_nerr. */
+#include <errlist-compat-data.h>
diff --git a/stdio-common/errlist-data.S b/stdio-common/errlist-data.S
new file mode 100644
index 0000000000..870b3f40c9
--- /dev/null
+++ b/stdio-common/errlist-data.S
@@ -0,0 +1,7 @@
+#ifdef SHARED
+# include "errlist-data-aux-shared.S"
+#else
+# include "errlist-data-aux.S"
+#endif
+
+#include <errlist-compat-data.h>
diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
index 1c09a31a7a..4c0a0a218d 100644
--- a/stdio-common/errlist.c
+++ b/stdio-common/errlist.c
@@ -16,29 +16,17 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <stdio.h>
+#include <array_length.h>
+#include <err_map.h>
#include <errno.h>
#include <libintl.h>
-#include <array_length.h>
-
-#ifndef ERR_MAP
-# define ERR_MAP(n) n
-#endif
-
-const char *const _sys_errlist_internal[] =
- {
-#define _S(n, str) [ERR_MAP(n)] = str,
-#include <errlist.h>
-#undef _S
- };
+#include <stdio.h>
const char *
__get_errlist (int errnum)
{
int mapped = ERR_MAP (errnum);
- if (mapped >= 0 && mapped < array_length (_sys_errlist_internal))
+ if (mapped >= 0 && mapped < _sys_errlist_internal_len)
return _sys_errlist_internal[mapped];
return NULL;
}
-
-#include <errlist-compat.c>
diff --git a/sysdeps/mach/hurd/errlist.c b/sysdeps/mach/hurd/err_map.h
similarity index 83%
rename from sysdeps/mach/hurd/errlist.c
rename to sysdeps/mach/hurd/err_map.h
index 2d782ffc67..22d21ca9f1 100644
--- a/sysdeps/mach/hurd/errlist.c
+++ b/sysdeps/mach/hurd/err_map.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1998-2022 Free Software Foundation, Inc.
+/* Internal errno names mapping definition. Hurd version.
+ Copyright (C) 2022 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -15,7 +16,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#ifndef _ERR_MAP_H
+#define _ERR_MAP_H
+
#include <mach/error.h>
#define ERR_MAP(value) err_get_code (value)
-#include <stdio-common/errlist.c>
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/errlist-compat.c b/sysdeps/unix/sysv/linux/alpha/errlist-compat-data.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/alpha/errlist-compat.c
rename to sysdeps/unix/sysv/linux/alpha/errlist-compat-data.h
diff --git a/sysdeps/unix/sysv/linux/errlist-compat.c b/sysdeps/unix/sysv/linux/errlist-compat-data.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/errlist-compat.c
rename to sysdeps/unix/sysv/linux/errlist-compat-data.h
diff --git a/sysdeps/unix/sysv/linux/errlist-compat.h b/sysdeps/unix/sysv/linux/errlist-compat.h
index a09b38f243..33008863f8 100644
--- a/sysdeps/unix/sysv/linux/errlist-compat.h
+++ b/sysdeps/unix/sysv/linux/errlist-compat.h
@@ -20,6 +20,7 @@
#define _ERRLIST_COMPAT_H
#include <shlib-compat.h>
+#include <limits.h>
/* Define new compat symbols for symbols _sys_errlist, sys_errlist,
_sys_nerr, and sys_nerr for version VERSION with NUMBERERR times number of
@@ -27,17 +28,25 @@
Both _sys_errlist and sys_errlist alias to _sys_errlist_internal symbol
(defined on errlist.c) while _sys_nerr and sys_nerr created new variable
with the expected size. */
-#define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
- const int __##VERSION##_sys_nerr = NUMBERERR; \
- strong_alias (__##VERSION##_sys_nerr, __##VERSION##__sys_nerr); \
- declare_symbol_alias (__ ## VERSION ## _sys_errlist, _sys_errlist_internal,\
- object, NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \
- declare_symbol_alias (__ ## VERSION ## __sys_errlist, \
- _sys_errlist_internal, object, \
- NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \
- compat_symbol (libc, __## VERSION ## _sys_nerr, sys_nerr, VERSION); \
- compat_symbol (libc, __## VERSION ## __sys_nerr, _sys_nerr, VERSION); \
- compat_symbol (libc, __## VERSION ## _sys_errlist, sys_errlist, VERSION); \
- compat_symbol (libc, __## VERSION ## __sys_errlist, _sys_errlist, VERSION);\
+#ifdef __ASSEMBLER__
+# define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
+ declare_object_symbol_alias (__ ## VERSION ## _sys_errlist, \
+ _sys_errlist_internal, \
+ NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)) \
+ ASM_LINE_SEP \
+ declare_object_symbol_alias (__ ## VERSION ## __sys_errlist, \
+ _sys_errlist_internal, \
+ NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)) \
+ ASM_LINE_SEP \
+ compat_symbol (libc, __## VERSION ## _sys_errlist, sys_errlist, VERSION) \
+ ASM_LINE_SEP \
+ compat_symbol (libc, __## VERSION ## __sys_errlist, _sys_errlist, VERSION)
+#else
+# define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
+ const int __##VERSION##_sys_nerr = NUMBERERR; \
+ strong_alias (__##VERSION##_sys_nerr, __##VERSION##__sys_nerr); \
+ compat_symbol (libc, __## VERSION ## _sys_nerr, sys_nerr, VERSION); \
+ compat_symbol (libc, __## VERSION ## __sys_nerr, _sys_nerr, VERSION);
+#endif
#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/errlist-compat.c b/sysdeps/unix/sysv/linux/hppa/errlist-compat-data.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/hppa/errlist-compat.c
rename to sysdeps/unix/sysv/linux/hppa/errlist-compat-data.h
diff --git a/sysdeps/unix/sysv/linux/mips/errlist-compat.c b/sysdeps/unix/sysv/linux/mips/errlist-compat-data.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/mips/errlist-compat.c
rename to sysdeps/unix/sysv/linux/mips/errlist-compat-data.h
diff --git a/sysdeps/unix/sysv/linux/sparc/errlist-compat.c b/sysdeps/unix/sysv/linux/sparc/errlist-compat-data.h
similarity index 100%
rename from sysdeps/unix/sysv/linux/sparc/errlist-compat.c
rename to sysdeps/unix/sysv/linux/sparc/errlist-compat-data.h
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/4] stdio: Remove the usage of $(fno-unit-at-a-time) for errlist.c
2022-05-12 12:59 ` [PATCH v2 2/4] stdio: Remove the usage of $(fno-unit-at-a-time) for errlist.c Adhemerval Zanella
@ 2022-05-12 17:03 ` Fangrui Song
2022-05-12 20:03 ` Adhemerval Zanella
0 siblings, 1 reply; 11+ messages in thread
From: Fangrui Song @ 2022-05-12 17:03 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On 2022-05-12, Adhemerval Zanella wrote:
>The errlist.c is build with -fno-toplevel-reorder to avoid compiler to
>reorder the compat assembly directives due a static linker issue [1]
>(fixed on 2.39).
From https://sourceware.org/pipermail/libc-alpha/2022-May/138657.html
s/build/built
s/static linker/assembler/
Otherwise looks good.
Reviewed-by: Fangrui Song <maskray@google.com>
>This patch removes the compiler flags by split the compat symbol
>generation in two phases. First the _sys_errlist_internal internal
>without any compat symbol directive is preprocessed to generate an
>assembly source code. This generate assembly is then used as input
>on a platform agnostic errlist-data.S which then creates the compat
>definitions. This prevents compiler to move any compat directive
>prior the _sys_errlist_internal definition itself.
>
>Checked on a make check run-built-tests=no on all affected ABIs.
>
>[1] https://sourceware.org/bugzilla/show_bug.cgi?id=29012
>---
> Makeconfig | 3 +-
> include/stdio.h | 1 +
> stdio-common/Makefile | 20 ++++++++++-
> stdio-common/err_map.h | 24 +++++++++++++
> stdio-common/errlist-compat-data.h | 1 +
> stdio-common/errlist-compat.c | 1 -
> stdio-common/errlist-data-gen.c | 34 +++++++++++++++++++
> stdio-common/errlist-data.S | 7 ++++
> stdio-common/errlist.c | 20 +++--------
> sysdeps/mach/hurd/{errlist.c => err_map.h} | 9 +++--
> ...errlist-compat.c => errlist-compat-data.h} | 0
> ...errlist-compat.c => errlist-compat-data.h} | 0
> sysdeps/unix/sysv/linux/errlist-compat.h | 33 +++++++++++-------
> ...errlist-compat.c => errlist-compat-data.h} | 0
> ...errlist-compat.c => errlist-compat-data.h} | 0
> ...errlist-compat.c => errlist-compat-data.h} | 0
> 16 files changed, 120 insertions(+), 33 deletions(-)
> create mode 100644 stdio-common/err_map.h
> create mode 100644 stdio-common/errlist-compat-data.h
> delete mode 100644 stdio-common/errlist-compat.c
> create mode 100644 stdio-common/errlist-data-gen.c
> create mode 100644 stdio-common/errlist-data.S
> rename sysdeps/mach/hurd/{errlist.c => err_map.h} (83%)
> rename sysdeps/unix/sysv/linux/alpha/{errlist-compat.c => errlist-compat-data.h} (100%)
> rename sysdeps/unix/sysv/linux/{errlist-compat.c => errlist-compat-data.h} (100%)
> rename sysdeps/unix/sysv/linux/hppa/{errlist-compat.c => errlist-compat-data.h} (100%)
> rename sysdeps/unix/sysv/linux/mips/{errlist-compat.c => errlist-compat-data.h} (100%)
> rename sysdeps/unix/sysv/linux/sparc/{errlist-compat.c => errlist-compat-data.h} (100%)
>
>diff --git a/Makeconfig b/Makeconfig
>index 760f14e92f..b5aa07c4f4 100644
>--- a/Makeconfig
>+++ b/Makeconfig
>@@ -1030,7 +1030,8 @@ ifeq (yes,$(build-shared))
> # Under --enable-shared, we will build a shared library of PIC objects.
> # The PIC object files are named foo.os.
> object-suffixes += .os
>-CPPFLAGS-.os = -DPIC -DSHARED
>+pic-cppflags = -DPIC -DSHARED
>+CPPFLAGS-.os = $(pic-cppflags)
> CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
> libtype.os := lib%_pic.a
> # This can be changed by a sysdep makefile
>diff --git a/include/stdio.h b/include/stdio.h
>index 23b7fd288c..a6f7fd43cb 100644
>--- a/include/stdio.h
>+++ b/include/stdio.h
>@@ -180,6 +180,7 @@ int __vfxprintf (FILE *__fp, const char *__fmt, __gnuc_va_list,
> attribute_hidden;
>
> extern const char *const _sys_errlist_internal[] attribute_hidden;
>+extern const size_t _sys_errlist_internal_len attribute_hidden;
> extern const char *__get_errlist (int) attribute_hidden;
> extern const char *__get_errname (int) attribute_hidden;
>
>diff --git a/stdio-common/Makefile b/stdio-common/Makefile
>index a1603e82fe..08bc998436 100644
>--- a/stdio-common/Makefile
>+++ b/stdio-common/Makefile
>@@ -88,6 +88,7 @@ routines := \
>
> aux := \
> errlist \
>+ errlist-data \
> errname \
> fxprintf \
> printf-parsemb \
>@@ -211,6 +212,10 @@ tests := \
> xbug \
> # tests
>
>+generated += \
>+ errlist-data-aux-shared.S \
>+ errlist-data-aux.S \
>+ # generated
>
> test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
>
>@@ -246,6 +251,20 @@ tests-special += $(objpfx)tst-errno-manual.out
>
> include ../Rules
>
>+# The errlist.c is built in two phases because compiler might reorder the
>+# compat_symbol directive prior the object itself and on binutils older
>+# than 2.29 it might generate object sizes different than the expected ones.
>+$(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c
>+ $(make-target-directory)
>+ $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
>+
>+$(objpfx)errlist-data-aux.S: errlist-data-gen.c
>+ $(make-target-directory)
>+ $(compile-command.c) $(pie-default) $(no-stack-protector) -S
Thanks for fixing the extension name (o->S) in v2.
>+$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
>+$(objpfx)errlist-data.o: $(objpfx)errlist-data-aux.S
>+
> ifeq ($(run-built-tests),yes)
> LOCALES := \
> de_DE.ISO-8859-1 \
>@@ -334,7 +353,6 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
> CFLAGS-isoc99_vscanf.c += -fexceptions
> CFLAGS-isoc99_fscanf.c += -fexceptions
> CFLAGS-isoc99_scanf.c += -fexceptions
>-CFLAGS-errlist.c += $(fno-unit-at-a-time)
> CFLAGS-siglist.c += $(fno-unit-at-a-time)
>
> # scanf14a.c and scanf16a.c test a deprecated extension which is no
>diff --git a/stdio-common/err_map.h b/stdio-common/err_map.h
>new file mode 100644
>index 0000000000..6cc3aa3375
>--- /dev/null
>+++ b/stdio-common/err_map.h
>@@ -0,0 +1,24 @@
>+/* Internal errno names mapping definition.
>+ Copyright (C) 2022 Free Software Foundation, Inc.
>+ This file is part of the GNU C Library.
>+
>+ The GNU C Library is free software; you can redistribute it and/or
>+ modify it under the terms of the GNU Lesser General Public
>+ License as published by the Free Software Foundation; either
>+ version 2.1 of the License, or (at your option) any later version.
>+
>+ The GNU C Library 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
>+ Lesser General Public License for more details.
>+
>+ You should have received a copy of the GNU Lesser General Public
>+ License along with the GNU C Library; if not, see
>+ <https://www.gnu.org/licenses/>. */
>+
>+#ifndef _ERR_MAP_H
>+#define _ERR_MAP_H
>+
>+#define ERR_MAP(n) (n)
>+
>+#endif
>diff --git a/stdio-common/errlist-compat-data.h b/stdio-common/errlist-compat-data.h
>new file mode 100644
>index 0000000000..7c89c9a5a4
>--- /dev/null
>+++ b/stdio-common/errlist-compat-data.h
>@@ -0,0 +1 @@
>+/* Empty */
>diff --git a/stdio-common/errlist-compat.c b/stdio-common/errlist-compat.c
>deleted file mode 100644
>index 6e25b021ab..0000000000
>--- a/stdio-common/errlist-compat.c
>+++ /dev/null
>@@ -1 +0,0 @@
>-/* Empty. */
>diff --git a/stdio-common/errlist-data-gen.c b/stdio-common/errlist-data-gen.c
>new file mode 100644
>index 0000000000..db4f50e6db
>--- /dev/null
>+++ b/stdio-common/errlist-data-gen.c
>@@ -0,0 +1,34 @@
>+/* Internal errno names mapping definition.
>+ Copyright (C) 2022 Free Software Foundation, Inc.
>+ This file is part of the GNU C Library.
>+
>+ The GNU C Library is free software; you can redistribute it and/or
>+ modify it under the terms of the GNU Lesser General Public
>+ License as published by the Free Software Foundation; either
>+ version 2.1 of the License, or (at your option) any later version.
>+
>+ The GNU C Library 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
>+ Lesser General Public License for more details.
>+
>+ You should have received a copy of the GNU Lesser General Public
>+ License along with the GNU C Library; if not, see
>+ <https://www.gnu.org/licenses/>. */
>+
>+#include <array_length.h>
>+#include <err_map.h>
>+#include <errno.h>
>+#include <libintl.h>
>+#include <stdio.h>
>+
>+const char *const _sys_errlist_internal[] =
>+ {
>+#define _S(n, str) [ERR_MAP(n)] = str,
>+#include <errlist.h>
>+#undef _S
>+ };
>+const size_t _sys_errlist_internal_len = array_length (_sys_errlist_internal);
>+
>+/* Include to get the definitions for sys_nerr/_sys_nerr. */
>+#include <errlist-compat-data.h>
>diff --git a/stdio-common/errlist-data.S b/stdio-common/errlist-data.S
>new file mode 100644
>index 0000000000..870b3f40c9
>--- /dev/null
>+++ b/stdio-common/errlist-data.S
>@@ -0,0 +1,7 @@
>+#ifdef SHARED
>+# include "errlist-data-aux-shared.S"
>+#else
>+# include "errlist-data-aux.S"
>+#endif
>+
>+#include <errlist-compat-data.h>
>diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
>index 1c09a31a7a..4c0a0a218d 100644
>--- a/stdio-common/errlist.c
>+++ b/stdio-common/errlist.c
>@@ -16,29 +16,17 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
>-#include <stdio.h>
>+#include <array_length.h>
>+#include <err_map.h>
> #include <errno.h>
> #include <libintl.h>
>-#include <array_length.h>
>-
>-#ifndef ERR_MAP
>-# define ERR_MAP(n) n
>-#endif
>-
>-const char *const _sys_errlist_internal[] =
>- {
>-#define _S(n, str) [ERR_MAP(n)] = str,
>-#include <errlist.h>
>-#undef _S
>- };
>+#include <stdio.h>
>
> const char *
> __get_errlist (int errnum)
> {
> int mapped = ERR_MAP (errnum);
>- if (mapped >= 0 && mapped < array_length (_sys_errlist_internal))
>+ if (mapped >= 0 && mapped < _sys_errlist_internal_len)
> return _sys_errlist_internal[mapped];
> return NULL;
> }
>-
>-#include <errlist-compat.c>
>diff --git a/sysdeps/mach/hurd/errlist.c b/sysdeps/mach/hurd/err_map.h
>similarity index 83%
>rename from sysdeps/mach/hurd/errlist.c
>rename to sysdeps/mach/hurd/err_map.h
>index 2d782ffc67..22d21ca9f1 100644
>--- a/sysdeps/mach/hurd/errlist.c
>+++ b/sysdeps/mach/hurd/err_map.h
>@@ -1,4 +1,5 @@
>-/* Copyright (C) 1998-2022 Free Software Foundation, Inc.
>+/* Internal errno names mapping definition. Hurd version.
>+ Copyright (C) 2022 Free Software Foundation, Inc.
> This file is part of the GNU C Library.
>
> The GNU C Library is free software; you can redistribute it and/or
>@@ -15,7 +16,11 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
>+#ifndef _ERR_MAP_H
>+#define _ERR_MAP_H
>+
> #include <mach/error.h>
>
> #define ERR_MAP(value) err_get_code (value)
>-#include <stdio-common/errlist.c>
>+
>+#endif
>diff --git a/sysdeps/unix/sysv/linux/alpha/errlist-compat.c b/sysdeps/unix/sysv/linux/alpha/errlist-compat-data.h
>similarity index 100%
>rename from sysdeps/unix/sysv/linux/alpha/errlist-compat.c
>rename to sysdeps/unix/sysv/linux/alpha/errlist-compat-data.h
>diff --git a/sysdeps/unix/sysv/linux/errlist-compat.c b/sysdeps/unix/sysv/linux/errlist-compat-data.h
>similarity index 100%
>rename from sysdeps/unix/sysv/linux/errlist-compat.c
>rename to sysdeps/unix/sysv/linux/errlist-compat-data.h
>diff --git a/sysdeps/unix/sysv/linux/errlist-compat.h b/sysdeps/unix/sysv/linux/errlist-compat.h
>index a09b38f243..33008863f8 100644
>--- a/sysdeps/unix/sysv/linux/errlist-compat.h
>+++ b/sysdeps/unix/sysv/linux/errlist-compat.h
>@@ -20,6 +20,7 @@
> #define _ERRLIST_COMPAT_H
>
> #include <shlib-compat.h>
>+#include <limits.h>
>
> /* Define new compat symbols for symbols _sys_errlist, sys_errlist,
> _sys_nerr, and sys_nerr for version VERSION with NUMBERERR times number of
>@@ -27,17 +28,25 @@
> Both _sys_errlist and sys_errlist alias to _sys_errlist_internal symbol
> (defined on errlist.c) while _sys_nerr and sys_nerr created new variable
> with the expected size. */
>-#define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
>- const int __##VERSION##_sys_nerr = NUMBERERR; \
>- strong_alias (__##VERSION##_sys_nerr, __##VERSION##__sys_nerr); \
>- declare_symbol_alias (__ ## VERSION ## _sys_errlist, _sys_errlist_internal,\
>- object, NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \
>- declare_symbol_alias (__ ## VERSION ## __sys_errlist, \
>- _sys_errlist_internal, object, \
>- NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \
>- compat_symbol (libc, __## VERSION ## _sys_nerr, sys_nerr, VERSION); \
>- compat_symbol (libc, __## VERSION ## __sys_nerr, _sys_nerr, VERSION); \
>- compat_symbol (libc, __## VERSION ## _sys_errlist, sys_errlist, VERSION); \
>- compat_symbol (libc, __## VERSION ## __sys_errlist, _sys_errlist, VERSION);\
>+#ifdef __ASSEMBLER__
>+# define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
>+ declare_object_symbol_alias (__ ## VERSION ## _sys_errlist, \
>+ _sys_errlist_internal, \
>+ NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)) \
>+ ASM_LINE_SEP \
>+ declare_object_symbol_alias (__ ## VERSION ## __sys_errlist, \
>+ _sys_errlist_internal, \
>+ NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)) \
>+ ASM_LINE_SEP \
>+ compat_symbol (libc, __## VERSION ## _sys_errlist, sys_errlist, VERSION) \
>+ ASM_LINE_SEP \
>+ compat_symbol (libc, __## VERSION ## __sys_errlist, _sys_errlist, VERSION)
>+#else
>+# define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
>+ const int __##VERSION##_sys_nerr = NUMBERERR; \
>+ strong_alias (__##VERSION##_sys_nerr, __##VERSION##__sys_nerr); \
>+ compat_symbol (libc, __## VERSION ## _sys_nerr, sys_nerr, VERSION); \
>+ compat_symbol (libc, __## VERSION ## __sys_nerr, _sys_nerr, VERSION);
>+#endif
>
> #endif
>diff --git a/sysdeps/unix/sysv/linux/hppa/errlist-compat.c b/sysdeps/unix/sysv/linux/hppa/errlist-compat-data.h
>similarity index 100%
>rename from sysdeps/unix/sysv/linux/hppa/errlist-compat.c
>rename to sysdeps/unix/sysv/linux/hppa/errlist-compat-data.h
>diff --git a/sysdeps/unix/sysv/linux/mips/errlist-compat.c b/sysdeps/unix/sysv/linux/mips/errlist-compat-data.h
>similarity index 100%
>rename from sysdeps/unix/sysv/linux/mips/errlist-compat.c
>rename to sysdeps/unix/sysv/linux/mips/errlist-compat-data.h
>diff --git a/sysdeps/unix/sysv/linux/sparc/errlist-compat.c b/sysdeps/unix/sysv/linux/sparc/errlist-compat-data.h
>similarity index 100%
>rename from sysdeps/unix/sysv/linux/sparc/errlist-compat.c
>rename to sysdeps/unix/sysv/linux/sparc/errlist-compat-data.h
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 2/4] stdio: Remove the usage of $(fno-unit-at-a-time) for errlist.c
2022-05-12 17:03 ` Fangrui Song
@ 2022-05-12 20:03 ` Adhemerval Zanella
0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 20:03 UTC (permalink / raw)
To: Fangrui Song; +Cc: libc-alpha
On 12/05/2022 14:03, Fangrui Song wrote:
> On 2022-05-12, Adhemerval Zanella wrote:
>> The errlist.c is build with -fno-toplevel-reorder to avoid compiler to
>> reorder the compat assembly directives due a static linker issue [1]
>> (fixed on 2.39).
>
> From https://sourceware.org/pipermail/libc-alpha/2022-May/138657.html
>
> s/build/built
> s/static linker/assembler/
Oops, I though I had these fixed.
>
> Otherwise looks good.
>
> Reviewed-by: Fangrui Song <maskray@google.com>
Thanks.
>
>> This patch removes the compiler flags by split the compat symbol
>> generation in two phases. First the _sys_errlist_internal internal
>> without any compat symbol directive is preprocessed to generate an
>> assembly source code. This generate assembly is then used as input
>> on a platform agnostic errlist-data.S which then creates the compat
>> definitions. This prevents compiler to move any compat directive
>> prior the _sys_errlist_internal definition itself.
>>
>> Checked on a make check run-built-tests=no on all affected ABIs.
>>
>> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=29012
>> ---
>> Makeconfig | 3 +-
>> include/stdio.h | 1 +
>> stdio-common/Makefile | 20 ++++++++++-
>> stdio-common/err_map.h | 24 +++++++++++++
>> stdio-common/errlist-compat-data.h | 1 +
>> stdio-common/errlist-compat.c | 1 -
>> stdio-common/errlist-data-gen.c | 34 +++++++++++++++++++
>> stdio-common/errlist-data.S | 7 ++++
>> stdio-common/errlist.c | 20 +++--------
>> sysdeps/mach/hurd/{errlist.c => err_map.h} | 9 +++--
>> ...errlist-compat.c => errlist-compat-data.h} | 0
>> ...errlist-compat.c => errlist-compat-data.h} | 0
>> sysdeps/unix/sysv/linux/errlist-compat.h | 33 +++++++++++-------
>> ...errlist-compat.c => errlist-compat-data.h} | 0
>> ...errlist-compat.c => errlist-compat-data.h} | 0
>> ...errlist-compat.c => errlist-compat-data.h} | 0
>> 16 files changed, 120 insertions(+), 33 deletions(-)
>> create mode 100644 stdio-common/err_map.h
>> create mode 100644 stdio-common/errlist-compat-data.h
>> delete mode 100644 stdio-common/errlist-compat.c
>> create mode 100644 stdio-common/errlist-data-gen.c
>> create mode 100644 stdio-common/errlist-data.S
>> rename sysdeps/mach/hurd/{errlist.c => err_map.h} (83%)
>> rename sysdeps/unix/sysv/linux/alpha/{errlist-compat.c => errlist-compat-data.h} (100%)
>> rename sysdeps/unix/sysv/linux/{errlist-compat.c => errlist-compat-data.h} (100%)
>> rename sysdeps/unix/sysv/linux/hppa/{errlist-compat.c => errlist-compat-data.h} (100%)
>> rename sysdeps/unix/sysv/linux/mips/{errlist-compat.c => errlist-compat-data.h} (100%)
>> rename sysdeps/unix/sysv/linux/sparc/{errlist-compat.c => errlist-compat-data.h} (100%)
>>
>> diff --git a/Makeconfig b/Makeconfig
>> index 760f14e92f..b5aa07c4f4 100644
>> --- a/Makeconfig
>> +++ b/Makeconfig
>> @@ -1030,7 +1030,8 @@ ifeq (yes,$(build-shared))
>> # Under --enable-shared, we will build a shared library of PIC objects.
>> # The PIC object files are named foo.os.
>> object-suffixes += .os
>> -CPPFLAGS-.os = -DPIC -DSHARED
>> +pic-cppflags = -DPIC -DSHARED
>> +CPPFLAGS-.os = $(pic-cppflags)
>> CFLAGS-.os = $(filter %frame-pointer,$(+cflags)) $(pic-ccflag)
>> libtype.os := lib%_pic.a
>> # This can be changed by a sysdep makefile
>> diff --git a/include/stdio.h b/include/stdio.h
>> index 23b7fd288c..a6f7fd43cb 100644
>> --- a/include/stdio.h
>> +++ b/include/stdio.h
>> @@ -180,6 +180,7 @@ int __vfxprintf (FILE *__fp, const char *__fmt, __gnuc_va_list,
>> attribute_hidden;
>>
>> extern const char *const _sys_errlist_internal[] attribute_hidden;
>> +extern const size_t _sys_errlist_internal_len attribute_hidden;
>> extern const char *__get_errlist (int) attribute_hidden;
>> extern const char *__get_errname (int) attribute_hidden;
>>
>> diff --git a/stdio-common/Makefile b/stdio-common/Makefile
>> index a1603e82fe..08bc998436 100644
>> --- a/stdio-common/Makefile
>> +++ b/stdio-common/Makefile
>> @@ -88,6 +88,7 @@ routines := \
>>
>> aux := \
>> errlist \
>> + errlist-data \
>> errname \
>> fxprintf \
>> printf-parsemb \
>> @@ -211,6 +212,10 @@ tests := \
>> xbug \
>> # tests
>>
>> +generated += \
>> + errlist-data-aux-shared.S \
>> + errlist-data-aux.S \
>> + # generated
>>
>> test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
>>
>> @@ -246,6 +251,20 @@ tests-special += $(objpfx)tst-errno-manual.out
>>
>> include ../Rules
>>
>> +# The errlist.c is built in two phases because compiler might reorder the
>> +# compat_symbol directive prior the object itself and on binutils older
>> +# than 2.29 it might generate object sizes different than the expected ones.
>> +$(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c
>> + $(make-target-directory)
>> + $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
>> +
>> +$(objpfx)errlist-data-aux.S: errlist-data-gen.c
>> + $(make-target-directory)
>> + $(compile-command.c) $(pie-default) $(no-stack-protector) -S
>
> Thanks for fixing the extension name (o->S) in v2.
>
>> +$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
>> +$(objpfx)errlist-data.o: $(objpfx)errlist-data-aux.S
>> +
>> ifeq ($(run-built-tests),yes)
>> LOCALES := \
>> de_DE.ISO-8859-1 \
>> @@ -334,7 +353,6 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
>> CFLAGS-isoc99_vscanf.c += -fexceptions
>> CFLAGS-isoc99_fscanf.c += -fexceptions
>> CFLAGS-isoc99_scanf.c += -fexceptions
>> -CFLAGS-errlist.c += $(fno-unit-at-a-time)
>> CFLAGS-siglist.c += $(fno-unit-at-a-time)
>>
>> # scanf14a.c and scanf16a.c test a deprecated extension which is no
>> diff --git a/stdio-common/err_map.h b/stdio-common/err_map.h
>> new file mode 100644
>> index 0000000000..6cc3aa3375
>> --- /dev/null
>> +++ b/stdio-common/err_map.h
>> @@ -0,0 +1,24 @@
>> +/* Internal errno names mapping definition.
>> + Copyright (C) 2022 Free Software Foundation, Inc.
>> + This file is part of the GNU C Library.
>> +
>> + The GNU C Library is free software; you can redistribute it and/or
>> + modify it under the terms of the GNU Lesser General Public
>> + License as published by the Free Software Foundation; either
>> + version 2.1 of the License, or (at your option) any later version.
>> +
>> + The GNU C Library 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
>> + Lesser General Public License for more details.
>> +
>> + You should have received a copy of the GNU Lesser General Public
>> + License along with the GNU C Library; if not, see
>> + <https://www.gnu.org/licenses/>. */
>> +
>> +#ifndef _ERR_MAP_H
>> +#define _ERR_MAP_H
>> +
>> +#define ERR_MAP(n) (n)
>> +
>> +#endif
>> diff --git a/stdio-common/errlist-compat-data.h b/stdio-common/errlist-compat-data.h
>> new file mode 100644
>> index 0000000000..7c89c9a5a4
>> --- /dev/null
>> +++ b/stdio-common/errlist-compat-data.h
>> @@ -0,0 +1 @@
>> +/* Empty */
>> diff --git a/stdio-common/errlist-compat.c b/stdio-common/errlist-compat.c
>> deleted file mode 100644
>> index 6e25b021ab..0000000000
>> --- a/stdio-common/errlist-compat.c
>> +++ /dev/null
>> @@ -1 +0,0 @@
>> -/* Empty. */
>> diff --git a/stdio-common/errlist-data-gen.c b/stdio-common/errlist-data-gen.c
>> new file mode 100644
>> index 0000000000..db4f50e6db
>> --- /dev/null
>> +++ b/stdio-common/errlist-data-gen.c
>> @@ -0,0 +1,34 @@
>> +/* Internal errno names mapping definition.
>> + Copyright (C) 2022 Free Software Foundation, Inc.
>> + This file is part of the GNU C Library.
>> +
>> + The GNU C Library is free software; you can redistribute it and/or
>> + modify it under the terms of the GNU Lesser General Public
>> + License as published by the Free Software Foundation; either
>> + version 2.1 of the License, or (at your option) any later version.
>> +
>> + The GNU C Library 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
>> + Lesser General Public License for more details.
>> +
>> + You should have received a copy of the GNU Lesser General Public
>> + License along with the GNU C Library; if not, see
>> + <https://www.gnu.org/licenses/>. */
>> +
>> +#include <array_length.h>
>> +#include <err_map.h>
>> +#include <errno.h>
>> +#include <libintl.h>
>> +#include <stdio.h>
>> +
>> +const char *const _sys_errlist_internal[] =
>> + {
>> +#define _S(n, str) [ERR_MAP(n)] = str,
>> +#include <errlist.h>
>> +#undef _S
>> + };
>> +const size_t _sys_errlist_internal_len = array_length (_sys_errlist_internal);
>> +
>> +/* Include to get the definitions for sys_nerr/_sys_nerr. */
>> +#include <errlist-compat-data.h>
>> diff --git a/stdio-common/errlist-data.S b/stdio-common/errlist-data.S
>> new file mode 100644
>> index 0000000000..870b3f40c9
>> --- /dev/null
>> +++ b/stdio-common/errlist-data.S
>> @@ -0,0 +1,7 @@
>> +#ifdef SHARED
>> +# include "errlist-data-aux-shared.S"
>> +#else
>> +# include "errlist-data-aux.S"
>> +#endif
>> +
>> +#include <errlist-compat-data.h>
>> diff --git a/stdio-common/errlist.c b/stdio-common/errlist.c
>> index 1c09a31a7a..4c0a0a218d 100644
>> --- a/stdio-common/errlist.c
>> +++ b/stdio-common/errlist.c
>> @@ -16,29 +16,17 @@
>> License along with the GNU C Library; if not, see
>> <https://www.gnu.org/licenses/>. */
>>
>> -#include <stdio.h>
>> +#include <array_length.h>
>> +#include <err_map.h>
>> #include <errno.h>
>> #include <libintl.h>
>> -#include <array_length.h>
>> -
>> -#ifndef ERR_MAP
>> -# define ERR_MAP(n) n
>> -#endif
>> -
>> -const char *const _sys_errlist_internal[] =
>> - {
>> -#define _S(n, str) [ERR_MAP(n)] = str,
>> -#include <errlist.h>
>> -#undef _S
>> - };
>> +#include <stdio.h>
>>
>> const char *
>> __get_errlist (int errnum)
>> {
>> int mapped = ERR_MAP (errnum);
>> - if (mapped >= 0 && mapped < array_length (_sys_errlist_internal))
>> + if (mapped >= 0 && mapped < _sys_errlist_internal_len)
>> return _sys_errlist_internal[mapped];
>> return NULL;
>> }
>> -
>> -#include <errlist-compat.c>
>> diff --git a/sysdeps/mach/hurd/errlist.c b/sysdeps/mach/hurd/err_map.h
>> similarity index 83%
>> rename from sysdeps/mach/hurd/errlist.c
>> rename to sysdeps/mach/hurd/err_map.h
>> index 2d782ffc67..22d21ca9f1 100644
>> --- a/sysdeps/mach/hurd/errlist.c
>> +++ b/sysdeps/mach/hurd/err_map.h
>> @@ -1,4 +1,5 @@
>> -/* Copyright (C) 1998-2022 Free Software Foundation, Inc.
>> +/* Internal errno names mapping definition. Hurd version.
>> + Copyright (C) 2022 Free Software Foundation, Inc.
>> This file is part of the GNU C Library.
>>
>> The GNU C Library is free software; you can redistribute it and/or
>> @@ -15,7 +16,11 @@
>> License along with the GNU C Library; if not, see
>> <https://www.gnu.org/licenses/>. */
>>
>> +#ifndef _ERR_MAP_H
>> +#define _ERR_MAP_H
>> +
>> #include <mach/error.h>
>>
>> #define ERR_MAP(value) err_get_code (value)
>> -#include <stdio-common/errlist.c>
>> +
>> +#endif
>> diff --git a/sysdeps/unix/sysv/linux/alpha/errlist-compat.c b/sysdeps/unix/sysv/linux/alpha/errlist-compat-data.h
>> similarity index 100%
>> rename from sysdeps/unix/sysv/linux/alpha/errlist-compat.c
>> rename to sysdeps/unix/sysv/linux/alpha/errlist-compat-data.h
>> diff --git a/sysdeps/unix/sysv/linux/errlist-compat.c b/sysdeps/unix/sysv/linux/errlist-compat-data.h
>> similarity index 100%
>> rename from sysdeps/unix/sysv/linux/errlist-compat.c
>> rename to sysdeps/unix/sysv/linux/errlist-compat-data.h
>> diff --git a/sysdeps/unix/sysv/linux/errlist-compat.h b/sysdeps/unix/sysv/linux/errlist-compat.h
>> index a09b38f243..33008863f8 100644
>> --- a/sysdeps/unix/sysv/linux/errlist-compat.h
>> +++ b/sysdeps/unix/sysv/linux/errlist-compat.h
>> @@ -20,6 +20,7 @@
>> #define _ERRLIST_COMPAT_H
>>
>> #include <shlib-compat.h>
>> +#include <limits.h>
>>
>> /* Define new compat symbols for symbols _sys_errlist, sys_errlist,
>> _sys_nerr, and sys_nerr for version VERSION with NUMBERERR times number of
>> @@ -27,17 +28,25 @@
>> Both _sys_errlist and sys_errlist alias to _sys_errlist_internal symbol
>> (defined on errlist.c) while _sys_nerr and sys_nerr created new variable
>> with the expected size. */
>> -#define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
>> - const int __##VERSION##_sys_nerr = NUMBERERR; \
>> - strong_alias (__##VERSION##_sys_nerr, __##VERSION##__sys_nerr); \
>> - declare_symbol_alias (__ ## VERSION ## _sys_errlist, _sys_errlist_internal,\
>> - object, NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \
>> - declare_symbol_alias (__ ## VERSION ## __sys_errlist, \
>> - _sys_errlist_internal, object, \
>> - NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)); \
>> - compat_symbol (libc, __## VERSION ## _sys_nerr, sys_nerr, VERSION); \
>> - compat_symbol (libc, __## VERSION ## __sys_nerr, _sys_nerr, VERSION); \
>> - compat_symbol (libc, __## VERSION ## _sys_errlist, sys_errlist, VERSION); \
>> - compat_symbol (libc, __## VERSION ## __sys_errlist, _sys_errlist, VERSION);\
>> +#ifdef __ASSEMBLER__
>> +# define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
>> + declare_object_symbol_alias (__ ## VERSION ## _sys_errlist, \
>> + _sys_errlist_internal, \
>> + NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)) \
>> + ASM_LINE_SEP \
>> + declare_object_symbol_alias (__ ## VERSION ## __sys_errlist, \
>> + _sys_errlist_internal, \
>> + NUMBERERR * (ULONG_WIDTH / UCHAR_WIDTH)) \
>> + ASM_LINE_SEP \
>> + compat_symbol (libc, __## VERSION ## _sys_errlist, sys_errlist, VERSION) \
>> + ASM_LINE_SEP \
>> + compat_symbol (libc, __## VERSION ## __sys_errlist, _sys_errlist, VERSION)
>> +#else
>> +# define DEFINE_COMPAT_ERRLIST(NUMBERERR, VERSION) \
>> + const int __##VERSION##_sys_nerr = NUMBERERR; \
>> + strong_alias (__##VERSION##_sys_nerr, __##VERSION##__sys_nerr); \
>> + compat_symbol (libc, __## VERSION ## _sys_nerr, sys_nerr, VERSION); \
>> + compat_symbol (libc, __## VERSION ## __sys_nerr, _sys_nerr, VERSION);
>> +#endif
>>
>> #endif
>> diff --git a/sysdeps/unix/sysv/linux/hppa/errlist-compat.c b/sysdeps/unix/sysv/linux/hppa/errlist-compat-data.h
>> similarity index 100%
>> rename from sysdeps/unix/sysv/linux/hppa/errlist-compat.c
>> rename to sysdeps/unix/sysv/linux/hppa/errlist-compat-data.h
>> diff --git a/sysdeps/unix/sysv/linux/mips/errlist-compat.c b/sysdeps/unix/sysv/linux/mips/errlist-compat-data.h
>> similarity index 100%
>> rename from sysdeps/unix/sysv/linux/mips/errlist-compat.c
>> rename to sysdeps/unix/sysv/linux/mips/errlist-compat-data.h
>> diff --git a/sysdeps/unix/sysv/linux/sparc/errlist-compat.c b/sysdeps/unix/sysv/linux/sparc/errlist-compat-data.h
>> similarity index 100%
>> rename from sysdeps/unix/sysv/linux/sparc/errlist-compat.c
>> rename to sysdeps/unix/sysv/linux/sparc/errlist-compat-data.h
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/4] stdio: Remove the usage of $(fno-unit-at-a-time) for siglist.c
2022-05-12 12:59 [PATCH v2 0/4] Remove fno_unit_at_a_time configure check Adhemerval Zanella
2022-05-12 12:59 ` [PATCH v2 1/4] Add declare_object_symbol_alias for assembly codes (BZ #28128) Adhemerval Zanella
2022-05-12 12:59 ` [PATCH v2 2/4] stdio: Remove the usage of $(fno-unit-at-a-time) for errlist.c Adhemerval Zanella
@ 2022-05-12 12:59 ` Adhemerval Zanella
2022-05-12 17:06 ` Fangrui Song
2022-05-12 12:59 ` [PATCH v2 4/4] Remove configure fno_unit_at_a_time Adhemerval Zanella
3 siblings, 1 reply; 11+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 12:59 UTC (permalink / raw)
To: libc-alpha, Fangrui Song
The siglist.c is build with -fno-toplevel-reorder to avoid compiler
to reorder the compat assembly directives due a static linker
issue [1] (fixed on 2.39).
This patch removes the compiler flags by split the compat symbol
generation in two phases. First the __sys_siglist and __sys_sigabbrev
without any compat symbol directive is preprocessed to generate an
assembly source code. This generate assembly is then used as input
on a platform agnostic siglist.S which then creates the compat
definitions. This prevents compiler to move any compat directive
prior the _sys_errlist_internal definition itself.
Checked on a make check run-built-tests=no on all affected ABIs.
---
include/signal.h | 6 ++---
stdio-common/Makefile | 14 +++++++++-
stdio-common/{siglist.c => siglist-gen.c} | 4 ---
stdio-common/siglist.S | 7 +++++
...{siglist-compat.h => siglist-compat-def.h} | 27 ++++++++++---------
sysdeps/generic/siglist-compat.c | 1 -
.../{siglist-compat.c => siglist-compat.h} | 7 +++--
.../{siglist-compat.c => siglist-compat.h} | 7 +++--
8 files changed, 47 insertions(+), 26 deletions(-)
rename stdio-common/{siglist.c => siglist-gen.c} (92%)
create mode 100644 stdio-common/siglist.S
rename sysdeps/generic/{siglist-compat.h => siglist-compat-def.h} (69%)
delete mode 100644 sysdeps/generic/siglist-compat.c
rename sysdeps/mach/hurd/{siglist-compat.c => siglist-compat.h} (86%)
rename sysdeps/unix/sysv/linux/{siglist-compat.c => siglist-compat.h} (87%)
diff --git a/include/signal.h b/include/signal.h
index 2a278697c1..73f18dddd7 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -14,10 +14,8 @@ libc_hidden_proto (__sigpause)
libc_hidden_proto (raise)
libc_hidden_proto (__libc_current_sigrtmin)
libc_hidden_proto (__libc_current_sigrtmax)
-extern const char * const __sys_siglist[_NSIG];
-libc_hidden_proto (__sys_siglist)
-extern const char * const __sys_sigabbrev[_NSIG];
-libc_hidden_proto (__sys_sigabbrev)
+extern const char * const __sys_siglist[_NSIG] attribute_hidden;
+extern const char * const __sys_sigabbrev[_NSIG] attribute_hidden;
/* Now define the internal interfaces. */
extern __sighandler_t __bsd_signal (int __sig, __sighandler_t __handler);
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 08bc998436..cb85e949c0 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -215,6 +215,8 @@ tests := \
generated += \
errlist-data-aux-shared.S \
errlist-data-aux.S \
+ siglist-aux-shared.S \
+ siglist-aux.S \
# generated
test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
@@ -265,6 +267,17 @@ $(objpfx)errlist-data-aux.S: errlist-data-gen.c
$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
$(objpfx)errlist-data.o: $(objpfx)errlist-data-aux.S
+$(objpfx)siglist-aux-shared.S: siglist-gen.c
+ $(make-target-directory)
+ $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
+
+$(objpfx)siglist-aux.S: siglist-gen.c
+ $(make-target-directory)
+ $(compile-command.c) $(pie-default) $(no-stack-protector) -S
+
+$(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
+$(objpfx)siglist.o: $(objpfx)siglist-aux.S
+
ifeq ($(run-built-tests),yes)
LOCALES := \
de_DE.ISO-8859-1 \
@@ -353,7 +366,6 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
CFLAGS-isoc99_vscanf.c += -fexceptions
CFLAGS-isoc99_fscanf.c += -fexceptions
CFLAGS-isoc99_scanf.c += -fexceptions
-CFLAGS-siglist.c += $(fno-unit-at-a-time)
# scanf14a.c and scanf16a.c test a deprecated extension which is no
# longer visible under most conformance levels; see the source files
diff --git a/stdio-common/siglist.c b/stdio-common/siglist-gen.c
similarity index 92%
rename from stdio-common/siglist.c
rename to stdio-common/siglist-gen.c
index bb88d5300f..95441b707d 100644
--- a/stdio-common/siglist.c
+++ b/stdio-common/siglist-gen.c
@@ -26,7 +26,6 @@ const char *const __sys_siglist[NSIG] =
#include <siglist.h>
#undef init_sig
};
-libc_hidden_def (__sys_siglist)
const char *const __sys_sigabbrev[NSIG] =
{
@@ -34,6 +33,3 @@ const char *const __sys_sigabbrev[NSIG] =
#include <siglist.h>
#undef init_sig
};
-libc_hidden_def (__sys_sigabbrev)
-
-#include <siglist-compat.c>
diff --git a/stdio-common/siglist.S b/stdio-common/siglist.S
new file mode 100644
index 0000000000..f84cdac976
--- /dev/null
+++ b/stdio-common/siglist.S
@@ -0,0 +1,7 @@
+#ifdef SHARED
+# include "siglist-aux-shared.S"
+#else
+# include "siglist-aux.S"
+#endif
+
+#include <siglist-compat.h>
diff --git a/sysdeps/generic/siglist-compat.h b/sysdeps/generic/siglist-compat-def.h
similarity index 69%
rename from sysdeps/generic/siglist-compat.h
rename to sysdeps/generic/siglist-compat-def.h
index 05a0d63855..f5a1840dc3 100644
--- a/sysdeps/generic/siglist-compat.h
+++ b/sysdeps/generic/siglist-compat-def.h
@@ -28,20 +28,23 @@
sys_sigabbrev alias to __sys_sigabbrev. Both target alias are
define in siglist.c. */
#define DEFINE_COMPAT_SIGLIST(NUMBERSIG, VERSION) \
- declare_symbol_alias (__ ## VERSION ## _sys_siglist, \
- __sys_siglist, \
- object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
- declare_symbol_alias (__ ## VERSION ## sys_siglist, \
- __sys_siglist, \
- object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
- declare_symbol_alias (__ ## VERSION ## _sys_sigabbrev, \
- __sys_sigabbrev, \
- object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
+ declare_object_symbol_alias (__ ## VERSION ## _sys_siglist, \
+ __sys_siglist, \
+ NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
+ ASM_LINE_SEP \
+ declare_object_symbol_alias (__ ## VERSION ## sys_siglist, \
+ __sys_siglist, \
+ NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
+ ASM_LINE_SEP \
+ declare_object_symbol_alias (__ ## VERSION ## _sys_sigabbrev, \
+ __sys_sigabbrev, \
+ NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
+ ASM_LINE_SEP \
compat_symbol (libc, __## VERSION ## _sys_siglist, _sys_siglist, \
- VERSION); \
+ VERSION) ASM_LINE_SEP \
compat_symbol (libc, __## VERSION ## sys_siglist, sys_siglist, \
- VERSION); \
+ VERSION) ASM_LINE_SEP \
compat_symbol (libc, __## VERSION ## _sys_sigabbrev, sys_sigabbrev, \
- VERSION); \
+ VERSION)
#endif
diff --git a/sysdeps/generic/siglist-compat.c b/sysdeps/generic/siglist-compat.c
deleted file mode 100644
index 6e25b021ab..0000000000
--- a/sysdeps/generic/siglist-compat.c
+++ /dev/null
@@ -1 +0,0 @@
-/* Empty. */
diff --git a/sysdeps/mach/hurd/siglist-compat.c b/sysdeps/mach/hurd/siglist-compat.h
similarity index 86%
rename from sysdeps/mach/hurd/siglist-compat.c
rename to sysdeps/mach/hurd/siglist-compat.h
index 5334b0885b..17bb0401aa 100644
--- a/sysdeps/mach/hurd/siglist-compat.c
+++ b/sysdeps/mach/hurd/siglist-compat.h
@@ -16,12 +16,15 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <siglist-compat.h>
+#include <siglist-compat-def.h>
+/* To get _NSIG definition. */
+#define _SIGNAL_H
+#include <bits/signum-generic.h>
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
DEFINE_COMPAT_SIGLIST (33, GLIBC_2_0)
#endif
#if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_32)
-DEFINE_COMPAT_SIGLIST (NSIG, GLIBC_2_1)
+DEFINE_COMPAT_SIGLIST (_NSIG, GLIBC_2_1)
#endif
diff --git a/sysdeps/unix/sysv/linux/siglist-compat.c b/sysdeps/unix/sysv/linux/siglist-compat.h
similarity index 87%
rename from sysdeps/unix/sysv/linux/siglist-compat.c
rename to sysdeps/unix/sysv/linux/siglist-compat.h
index cbc77289c0..2a9801276d 100644
--- a/sysdeps/unix/sysv/linux/siglist-compat.c
+++ b/sysdeps/unix/sysv/linux/siglist-compat.h
@@ -16,7 +16,10 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#include <siglist-compat.h>
+#include <siglist-compat-def.h>
+/* To get _NSIG definition. */
+#define _SIGNAL_H
+#include <bits/signum-generic.h>
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
DEFINE_COMPAT_SIGLIST (32, GLIBC_2_0)
@@ -27,5 +30,5 @@ DEFINE_COMPAT_SIGLIST (64, GLIBC_2_1)
#endif
#if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_32)
-DEFINE_COMPAT_SIGLIST (NSIG, GLIBC_2_3_3)
+DEFINE_COMPAT_SIGLIST (_NSIG, GLIBC_2_3_3)
#endif
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/4] stdio: Remove the usage of $(fno-unit-at-a-time) for siglist.c
2022-05-12 12:59 ` [PATCH v2 3/4] stdio: Remove the usage of $(fno-unit-at-a-time) for siglist.c Adhemerval Zanella
@ 2022-05-12 17:06 ` Fangrui Song
2022-05-12 20:04 ` Adhemerval Zanella
0 siblings, 1 reply; 11+ messages in thread
From: Fangrui Song @ 2022-05-12 17:06 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On 2022-05-12, Adhemerval Zanella wrote:
>The siglist.c is build with -fno-toplevel-reorder to avoid compiler
>to reorder the compat assembly directives due a static linker
>issue [1] (fixed on 2.39).
This description needs similar changes like the patch for errlist.c.
Reviewed-by: Fangrui Song <maskray@google.com>
>This patch removes the compiler flags by split the compat symbol
>generation in two phases. First the __sys_siglist and __sys_sigabbrev
>without any compat symbol directive is preprocessed to generate an
>assembly source code. This generate assembly is then used as input
>on a platform agnostic siglist.S which then creates the compat
>definitions. This prevents compiler to move any compat directive
>prior the _sys_errlist_internal definition itself.
Typo. _sys_siglist?
>Checked on a make check run-built-tests=no on all affected ABIs.
>---
> include/signal.h | 6 ++---
> stdio-common/Makefile | 14 +++++++++-
> stdio-common/{siglist.c => siglist-gen.c} | 4 ---
> stdio-common/siglist.S | 7 +++++
> ...{siglist-compat.h => siglist-compat-def.h} | 27 ++++++++++---------
> sysdeps/generic/siglist-compat.c | 1 -
> .../{siglist-compat.c => siglist-compat.h} | 7 +++--
> .../{siglist-compat.c => siglist-compat.h} | 7 +++--
> 8 files changed, 47 insertions(+), 26 deletions(-)
> rename stdio-common/{siglist.c => siglist-gen.c} (92%)
> create mode 100644 stdio-common/siglist.S
> rename sysdeps/generic/{siglist-compat.h => siglist-compat-def.h} (69%)
> delete mode 100644 sysdeps/generic/siglist-compat.c
> rename sysdeps/mach/hurd/{siglist-compat.c => siglist-compat.h} (86%)
> rename sysdeps/unix/sysv/linux/{siglist-compat.c => siglist-compat.h} (87%)
>
>diff --git a/include/signal.h b/include/signal.h
>index 2a278697c1..73f18dddd7 100644
>--- a/include/signal.h
>+++ b/include/signal.h
>@@ -14,10 +14,8 @@ libc_hidden_proto (__sigpause)
> libc_hidden_proto (raise)
> libc_hidden_proto (__libc_current_sigrtmin)
> libc_hidden_proto (__libc_current_sigrtmax)
>-extern const char * const __sys_siglist[_NSIG];
>-libc_hidden_proto (__sys_siglist)
>-extern const char * const __sys_sigabbrev[_NSIG];
>-libc_hidden_proto (__sys_sigabbrev)
>+extern const char * const __sys_siglist[_NSIG] attribute_hidden;
>+extern const char * const __sys_sigabbrev[_NSIG] attribute_hidden;
>
> /* Now define the internal interfaces. */
> extern __sighandler_t __bsd_signal (int __sig, __sighandler_t __handler);
>diff --git a/stdio-common/Makefile b/stdio-common/Makefile
>index 08bc998436..cb85e949c0 100644
>--- a/stdio-common/Makefile
>+++ b/stdio-common/Makefile
>@@ -215,6 +215,8 @@ tests := \
> generated += \
> errlist-data-aux-shared.S \
> errlist-data-aux.S \
>+ siglist-aux-shared.S \
>+ siglist-aux.S \
> # generated
>
> test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
>@@ -265,6 +267,17 @@ $(objpfx)errlist-data-aux.S: errlist-data-gen.c
> $(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
> $(objpfx)errlist-data.o: $(objpfx)errlist-data-aux.S
>
>+$(objpfx)siglist-aux-shared.S: siglist-gen.c
>+ $(make-target-directory)
>+ $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
>+
>+$(objpfx)siglist-aux.S: siglist-gen.c
>+ $(make-target-directory)
>+ $(compile-command.c) $(pie-default) $(no-stack-protector) -S
>+
>+$(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
>+$(objpfx)siglist.o: $(objpfx)siglist-aux.S
>+
> ifeq ($(run-built-tests),yes)
> LOCALES := \
> de_DE.ISO-8859-1 \
>@@ -353,7 +366,6 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
> CFLAGS-isoc99_vscanf.c += -fexceptions
> CFLAGS-isoc99_fscanf.c += -fexceptions
> CFLAGS-isoc99_scanf.c += -fexceptions
>-CFLAGS-siglist.c += $(fno-unit-at-a-time)
>
> # scanf14a.c and scanf16a.c test a deprecated extension which is no
> # longer visible under most conformance levels; see the source files
>diff --git a/stdio-common/siglist.c b/stdio-common/siglist-gen.c
>similarity index 92%
>rename from stdio-common/siglist.c
>rename to stdio-common/siglist-gen.c
>index bb88d5300f..95441b707d 100644
>--- a/stdio-common/siglist.c
>+++ b/stdio-common/siglist-gen.c
>@@ -26,7 +26,6 @@ const char *const __sys_siglist[NSIG] =
> #include <siglist.h>
> #undef init_sig
> };
>-libc_hidden_def (__sys_siglist)
>
> const char *const __sys_sigabbrev[NSIG] =
> {
>@@ -34,6 +33,3 @@ const char *const __sys_sigabbrev[NSIG] =
> #include <siglist.h>
> #undef init_sig
> };
>-libc_hidden_def (__sys_sigabbrev)
>-
>-#include <siglist-compat.c>
>diff --git a/stdio-common/siglist.S b/stdio-common/siglist.S
>new file mode 100644
>index 0000000000..f84cdac976
>--- /dev/null
>+++ b/stdio-common/siglist.S
>@@ -0,0 +1,7 @@
>+#ifdef SHARED
>+# include "siglist-aux-shared.S"
>+#else
>+# include "siglist-aux.S"
>+#endif
>+
>+#include <siglist-compat.h>
>diff --git a/sysdeps/generic/siglist-compat.h b/sysdeps/generic/siglist-compat-def.h
>similarity index 69%
>rename from sysdeps/generic/siglist-compat.h
>rename to sysdeps/generic/siglist-compat-def.h
>index 05a0d63855..f5a1840dc3 100644
>--- a/sysdeps/generic/siglist-compat.h
>+++ b/sysdeps/generic/siglist-compat-def.h
>@@ -28,20 +28,23 @@
> sys_sigabbrev alias to __sys_sigabbrev. Both target alias are
> define in siglist.c. */
> #define DEFINE_COMPAT_SIGLIST(NUMBERSIG, VERSION) \
>- declare_symbol_alias (__ ## VERSION ## _sys_siglist, \
>- __sys_siglist, \
>- object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
>- declare_symbol_alias (__ ## VERSION ## sys_siglist, \
>- __sys_siglist, \
>- object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
>- declare_symbol_alias (__ ## VERSION ## _sys_sigabbrev, \
>- __sys_sigabbrev, \
>- object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
>+ declare_object_symbol_alias (__ ## VERSION ## _sys_siglist, \
>+ __sys_siglist, \
>+ NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
>+ ASM_LINE_SEP \
>+ declare_object_symbol_alias (__ ## VERSION ## sys_siglist, \
>+ __sys_siglist, \
>+ NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
>+ ASM_LINE_SEP \
>+ declare_object_symbol_alias (__ ## VERSION ## _sys_sigabbrev, \
>+ __sys_sigabbrev, \
>+ NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
>+ ASM_LINE_SEP \
> compat_symbol (libc, __## VERSION ## _sys_siglist, _sys_siglist, \
>- VERSION); \
>+ VERSION) ASM_LINE_SEP \
> compat_symbol (libc, __## VERSION ## sys_siglist, sys_siglist, \
>- VERSION); \
>+ VERSION) ASM_LINE_SEP \
> compat_symbol (libc, __## VERSION ## _sys_sigabbrev, sys_sigabbrev, \
>- VERSION); \
>+ VERSION)
>
> #endif
>diff --git a/sysdeps/generic/siglist-compat.c b/sysdeps/generic/siglist-compat.c
>deleted file mode 100644
>index 6e25b021ab..0000000000
>--- a/sysdeps/generic/siglist-compat.c
>+++ /dev/null
>@@ -1 +0,0 @@
>-/* Empty. */
>diff --git a/sysdeps/mach/hurd/siglist-compat.c b/sysdeps/mach/hurd/siglist-compat.h
>similarity index 86%
>rename from sysdeps/mach/hurd/siglist-compat.c
>rename to sysdeps/mach/hurd/siglist-compat.h
>index 5334b0885b..17bb0401aa 100644
>--- a/sysdeps/mach/hurd/siglist-compat.c
>+++ b/sysdeps/mach/hurd/siglist-compat.h
>@@ -16,12 +16,15 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
>-#include <siglist-compat.h>
>+#include <siglist-compat-def.h>
>+/* To get _NSIG definition. */
>+#define _SIGNAL_H
>+#include <bits/signum-generic.h>
>
> #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
> DEFINE_COMPAT_SIGLIST (33, GLIBC_2_0)
> #endif
>
> #if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_32)
>-DEFINE_COMPAT_SIGLIST (NSIG, GLIBC_2_1)
>+DEFINE_COMPAT_SIGLIST (_NSIG, GLIBC_2_1)
> #endif
>diff --git a/sysdeps/unix/sysv/linux/siglist-compat.c b/sysdeps/unix/sysv/linux/siglist-compat.h
>similarity index 87%
>rename from sysdeps/unix/sysv/linux/siglist-compat.c
>rename to sysdeps/unix/sysv/linux/siglist-compat.h
>index cbc77289c0..2a9801276d 100644
>--- a/sysdeps/unix/sysv/linux/siglist-compat.c
>+++ b/sysdeps/unix/sysv/linux/siglist-compat.h
>@@ -16,7 +16,10 @@
> License along with the GNU C Library; if not, see
> <https://www.gnu.org/licenses/>. */
>
>-#include <siglist-compat.h>
>+#include <siglist-compat-def.h>
>+/* To get _NSIG definition. */
>+#define _SIGNAL_H
>+#include <bits/signum-generic.h>
>
> #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
> DEFINE_COMPAT_SIGLIST (32, GLIBC_2_0)
>@@ -27,5 +30,5 @@ DEFINE_COMPAT_SIGLIST (64, GLIBC_2_1)
> #endif
>
> #if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_32)
>-DEFINE_COMPAT_SIGLIST (NSIG, GLIBC_2_3_3)
>+DEFINE_COMPAT_SIGLIST (_NSIG, GLIBC_2_3_3)
> #endif
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/4] stdio: Remove the usage of $(fno-unit-at-a-time) for siglist.c
2022-05-12 17:06 ` Fangrui Song
@ 2022-05-12 20:04 ` Adhemerval Zanella
0 siblings, 0 replies; 11+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 20:04 UTC (permalink / raw)
To: Fangrui Song; +Cc: libc-alpha
On 12/05/2022 14:06, Fangrui Song wrote:
> On 2022-05-12, Adhemerval Zanella wrote:
>> The siglist.c is build with -fno-toplevel-reorder to avoid compiler
>> to reorder the compat assembly directives due a static linker
>> issue [1] (fixed on 2.39).
>
> This description needs similar changes like the patch for errlist.c.
Ack.
>
> Reviewed-by: Fangrui Song <maskray@google.com>
>
>> This patch removes the compiler flags by split the compat symbol
>> generation in two phases. First the __sys_siglist and __sys_sigabbrev
>> without any compat symbol directive is preprocessed to generate an
>> assembly source code. This generate assembly is then used as input
>> on a platform agnostic siglist.S which then creates the compat
>> definitions. This prevents compiler to move any compat directive
>> prior the _sys_errlist_internal definition itself.
>
> Typo. _sys_siglist?
Yeap, I will fix it.
>
>> Checked on a make check run-built-tests=no on all affected ABIs.
>> ---
>> include/signal.h | 6 ++---
>> stdio-common/Makefile | 14 +++++++++-
>> stdio-common/{siglist.c => siglist-gen.c} | 4 ---
>> stdio-common/siglist.S | 7 +++++
>> ...{siglist-compat.h => siglist-compat-def.h} | 27 ++++++++++---------
>> sysdeps/generic/siglist-compat.c | 1 -
>> .../{siglist-compat.c => siglist-compat.h} | 7 +++--
>> .../{siglist-compat.c => siglist-compat.h} | 7 +++--
>> 8 files changed, 47 insertions(+), 26 deletions(-)
>> rename stdio-common/{siglist.c => siglist-gen.c} (92%)
>> create mode 100644 stdio-common/siglist.S
>> rename sysdeps/generic/{siglist-compat.h => siglist-compat-def.h} (69%)
>> delete mode 100644 sysdeps/generic/siglist-compat.c
>> rename sysdeps/mach/hurd/{siglist-compat.c => siglist-compat.h} (86%)
>> rename sysdeps/unix/sysv/linux/{siglist-compat.c => siglist-compat.h} (87%)
>>
>> diff --git a/include/signal.h b/include/signal.h
>> index 2a278697c1..73f18dddd7 100644
>> --- a/include/signal.h
>> +++ b/include/signal.h
>> @@ -14,10 +14,8 @@ libc_hidden_proto (__sigpause)
>> libc_hidden_proto (raise)
>> libc_hidden_proto (__libc_current_sigrtmin)
>> libc_hidden_proto (__libc_current_sigrtmax)
>> -extern const char * const __sys_siglist[_NSIG];
>> -libc_hidden_proto (__sys_siglist)
>> -extern const char * const __sys_sigabbrev[_NSIG];
>> -libc_hidden_proto (__sys_sigabbrev)
>> +extern const char * const __sys_siglist[_NSIG] attribute_hidden;
>> +extern const char * const __sys_sigabbrev[_NSIG] attribute_hidden;
>>
>> /* Now define the internal interfaces. */
>> extern __sighandler_t __bsd_signal (int __sig, __sighandler_t __handler);
>> diff --git a/stdio-common/Makefile b/stdio-common/Makefile
>> index 08bc998436..cb85e949c0 100644
>> --- a/stdio-common/Makefile
>> +++ b/stdio-common/Makefile
>> @@ -215,6 +215,8 @@ tests := \
>> generated += \
>> errlist-data-aux-shared.S \
>> errlist-data-aux.S \
>> + siglist-aux-shared.S \
>> + siglist-aux.S \
>> # generated
>>
>> test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
>> @@ -265,6 +267,17 @@ $(objpfx)errlist-data-aux.S: errlist-data-gen.c
>> $(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
>> $(objpfx)errlist-data.o: $(objpfx)errlist-data-aux.S
>>
>> +$(objpfx)siglist-aux-shared.S: siglist-gen.c
>> + $(make-target-directory)
>> + $(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
>> +
>> +$(objpfx)siglist-aux.S: siglist-gen.c
>> + $(make-target-directory)
>> + $(compile-command.c) $(pie-default) $(no-stack-protector) -S
>> +
>> +$(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
>> +$(objpfx)siglist.o: $(objpfx)siglist-aux.S
>> +
>> ifeq ($(run-built-tests),yes)
>> LOCALES := \
>> de_DE.ISO-8859-1 \
>> @@ -353,7 +366,6 @@ CFLAGS-isoc99_vfscanf.c += -fexceptions
>> CFLAGS-isoc99_vscanf.c += -fexceptions
>> CFLAGS-isoc99_fscanf.c += -fexceptions
>> CFLAGS-isoc99_scanf.c += -fexceptions
>> -CFLAGS-siglist.c += $(fno-unit-at-a-time)
>>
>> # scanf14a.c and scanf16a.c test a deprecated extension which is no
>> # longer visible under most conformance levels; see the source files
>> diff --git a/stdio-common/siglist.c b/stdio-common/siglist-gen.c
>> similarity index 92%
>> rename from stdio-common/siglist.c
>> rename to stdio-common/siglist-gen.c
>> index bb88d5300f..95441b707d 100644
>> --- a/stdio-common/siglist.c
>> +++ b/stdio-common/siglist-gen.c
>> @@ -26,7 +26,6 @@ const char *const __sys_siglist[NSIG] =
>> #include <siglist.h>
>> #undef init_sig
>> };
>> -libc_hidden_def (__sys_siglist)
>>
>> const char *const __sys_sigabbrev[NSIG] =
>> {
>> @@ -34,6 +33,3 @@ const char *const __sys_sigabbrev[NSIG] =
>> #include <siglist.h>
>> #undef init_sig
>> };
>> -libc_hidden_def (__sys_sigabbrev)
>> -
>> -#include <siglist-compat.c>
>> diff --git a/stdio-common/siglist.S b/stdio-common/siglist.S
>> new file mode 100644
>> index 0000000000..f84cdac976
>> --- /dev/null
>> +++ b/stdio-common/siglist.S
>> @@ -0,0 +1,7 @@
>> +#ifdef SHARED
>> +# include "siglist-aux-shared.S"
>> +#else
>> +# include "siglist-aux.S"
>> +#endif
>> +
>> +#include <siglist-compat.h>
>> diff --git a/sysdeps/generic/siglist-compat.h b/sysdeps/generic/siglist-compat-def.h
>> similarity index 69%
>> rename from sysdeps/generic/siglist-compat.h
>> rename to sysdeps/generic/siglist-compat-def.h
>> index 05a0d63855..f5a1840dc3 100644
>> --- a/sysdeps/generic/siglist-compat.h
>> +++ b/sysdeps/generic/siglist-compat-def.h
>> @@ -28,20 +28,23 @@
>> sys_sigabbrev alias to __sys_sigabbrev. Both target alias are
>> define in siglist.c. */
>> #define DEFINE_COMPAT_SIGLIST(NUMBERSIG, VERSION) \
>> - declare_symbol_alias (__ ## VERSION ## _sys_siglist, \
>> - __sys_siglist, \
>> - object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
>> - declare_symbol_alias (__ ## VERSION ## sys_siglist, \
>> - __sys_siglist, \
>> - object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
>> - declare_symbol_alias (__ ## VERSION ## _sys_sigabbrev, \
>> - __sys_sigabbrev, \
>> - object, NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)); \
>> + declare_object_symbol_alias (__ ## VERSION ## _sys_siglist, \
>> + __sys_siglist, \
>> + NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
>> + ASM_LINE_SEP \
>> + declare_object_symbol_alias (__ ## VERSION ## sys_siglist, \
>> + __sys_siglist, \
>> + NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
>> + ASM_LINE_SEP \
>> + declare_object_symbol_alias (__ ## VERSION ## _sys_sigabbrev, \
>> + __sys_sigabbrev, \
>> + NUMBERSIG * (ULONG_WIDTH / UCHAR_WIDTH)) \
>> + ASM_LINE_SEP \
>> compat_symbol (libc, __## VERSION ## _sys_siglist, _sys_siglist, \
>> - VERSION); \
>> + VERSION) ASM_LINE_SEP \
>> compat_symbol (libc, __## VERSION ## sys_siglist, sys_siglist, \
>> - VERSION); \
>> + VERSION) ASM_LINE_SEP \
>> compat_symbol (libc, __## VERSION ## _sys_sigabbrev, sys_sigabbrev, \
>> - VERSION); \
>> + VERSION)
>>
>> #endif
>> diff --git a/sysdeps/generic/siglist-compat.c b/sysdeps/generic/siglist-compat.c
>> deleted file mode 100644
>> index 6e25b021ab..0000000000
>> --- a/sysdeps/generic/siglist-compat.c
>> +++ /dev/null
>> @@ -1 +0,0 @@
>> -/* Empty. */
>> diff --git a/sysdeps/mach/hurd/siglist-compat.c b/sysdeps/mach/hurd/siglist-compat.h
>> similarity index 86%
>> rename from sysdeps/mach/hurd/siglist-compat.c
>> rename to sysdeps/mach/hurd/siglist-compat.h
>> index 5334b0885b..17bb0401aa 100644
>> --- a/sysdeps/mach/hurd/siglist-compat.c
>> +++ b/sysdeps/mach/hurd/siglist-compat.h
>> @@ -16,12 +16,15 @@
>> License along with the GNU C Library; if not, see
>> <https://www.gnu.org/licenses/>. */
>>
>> -#include <siglist-compat.h>
>> +#include <siglist-compat-def.h>
>> +/* To get _NSIG definition. */
>> +#define _SIGNAL_H
>> +#include <bits/signum-generic.h>
>>
>> #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
>> DEFINE_COMPAT_SIGLIST (33, GLIBC_2_0)
>> #endif
>>
>> #if SHLIB_COMPAT (libc, GLIBC_2_1, GLIBC_2_32)
>> -DEFINE_COMPAT_SIGLIST (NSIG, GLIBC_2_1)
>> +DEFINE_COMPAT_SIGLIST (_NSIG, GLIBC_2_1)
>> #endif
>> diff --git a/sysdeps/unix/sysv/linux/siglist-compat.c b/sysdeps/unix/sysv/linux/siglist-compat.h
>> similarity index 87%
>> rename from sysdeps/unix/sysv/linux/siglist-compat.c
>> rename to sysdeps/unix/sysv/linux/siglist-compat.h
>> index cbc77289c0..2a9801276d 100644
>> --- a/sysdeps/unix/sysv/linux/siglist-compat.c
>> +++ b/sysdeps/unix/sysv/linux/siglist-compat.h
>> @@ -16,7 +16,10 @@
>> License along with the GNU C Library; if not, see
>> <https://www.gnu.org/licenses/>. */
>>
>> -#include <siglist-compat.h>
>> +#include <siglist-compat-def.h>
>> +/* To get _NSIG definition. */
>> +#define _SIGNAL_H
>> +#include <bits/signum-generic.h>
>>
>> #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
>> DEFINE_COMPAT_SIGLIST (32, GLIBC_2_0)
>> @@ -27,5 +30,5 @@ DEFINE_COMPAT_SIGLIST (64, GLIBC_2_1)
>> #endif
>>
>> #if SHLIB_COMPAT (libc, GLIBC_2_3_3, GLIBC_2_32)
>> -DEFINE_COMPAT_SIGLIST (NSIG, GLIBC_2_3_3)
>> +DEFINE_COMPAT_SIGLIST (_NSIG, GLIBC_2_3_3)
>> #endif
>> --
>> 2.34.1
>>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 4/4] Remove configure fno_unit_at_a_time
2022-05-12 12:59 [PATCH v2 0/4] Remove fno_unit_at_a_time configure check Adhemerval Zanella
` (2 preceding siblings ...)
2022-05-12 12:59 ` [PATCH v2 3/4] stdio: Remove the usage of $(fno-unit-at-a-time) for siglist.c Adhemerval Zanella
@ 2022-05-12 12:59 ` Adhemerval Zanella
2022-05-12 17:07 ` Fangrui Song
3 siblings, 1 reply; 11+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 12:59 UTC (permalink / raw)
To: libc-alpha, Fangrui Song
Since it is not used any longer.
---
config.make.in | 1 -
configure | 32 --------------------------------
configure.ac | 19 -------------------
3 files changed, 52 deletions(-)
diff --git a/config.make.in b/config.make.in
index fff4c78dd0..d7c416cbea 100644
--- a/config.make.in
+++ b/config.make.in
@@ -68,7 +68,6 @@ have-selinux = @have_selinux@
have-libaudit = @have_libaudit@
have-libcap = @have_libcap@
have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
-fno-unit-at-a-time = @fno_unit_at_a_time@
bind-now = @bindnow@
use-default-link = @use_default_link@
have-cxx-thread_local = @libc_cv_cxx_thread_local@
diff --git a/configure b/configure
index 716dc041b6..ff2c406b3b 100755
--- a/configure
+++ b/configure
@@ -620,7 +620,6 @@ libc_cv_cc_loop_to_function
libc_cv_cc_submachine
libc_cv_cc_nofma
libc_cv_mtls_dialect_gnu2
-fno_unit_at_a_time
libc_cv_has_glob_dat
libc_cv_fpie
libc_cv_z_execstack
@@ -6226,37 +6225,6 @@ fi
$as_echo "$libc_cv_has_glob_dat" >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-toplevel-reorder -fno-section-anchors" >&5
-$as_echo_n "checking for -fno-toplevel-reorder -fno-section-anchors... " >&6; }
-if ${libc_cv_fno_toplevel_reorder+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat > conftest.c <<EOF
-int foo;
-EOF
-if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
- conftest.c 1>&5'
- { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }
-then
- libc_cv_fno_toplevel_reorder=yes
-else
- libc_cv_fno_toplevel_reorder=no
-fi
-rm -f conftest*
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_fno_toplevel_reorder" >&5
-$as_echo "$libc_cv_fno_toplevel_reorder" >&6; }
-if test $libc_cv_fno_toplevel_reorder = yes; then
- fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
-else
- fno_unit_at_a_time=-fno-unit-at-a-time
-fi
-
-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -mtls-dialect=gnu2" >&5
$as_echo_n "checking for -mtls-dialect=gnu2... " >&6; }
if ${libc_cv_mtls_dialect_gnu2+:} false; then :
diff --git a/configure.ac b/configure.ac
index d08ad4d64e..eb5bc6a131 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1383,25 +1383,6 @@ fi
rm -f conftest*])
AC_SUBST(libc_cv_has_glob_dat)
-AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
-cat > conftest.c <<EOF
-int foo;
-EOF
-if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
- conftest.c 1>&AS_MESSAGE_LOG_FD])
-then
- libc_cv_fno_toplevel_reorder=yes
-else
- libc_cv_fno_toplevel_reorder=no
-fi
-rm -f conftest*])
-if test $libc_cv_fno_toplevel_reorder = yes; then
- fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
-else
- fno_unit_at_a_time=-fno-unit-at-a-time
-fi
-AC_SUBST(fno_unit_at_a_time)
-
AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
[dnl
cat > conftest.c <<EOF
--
2.34.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 4/4] Remove configure fno_unit_at_a_time
2022-05-12 12:59 ` [PATCH v2 4/4] Remove configure fno_unit_at_a_time Adhemerval Zanella
@ 2022-05-12 17:07 ` Fangrui Song
0 siblings, 0 replies; 11+ messages in thread
From: Fangrui Song @ 2022-05-12 17:07 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On 2022-05-12, Adhemerval Zanella wrote:
>Since it is not used any longer.
Thanks for removing obsoleted GCC option:)
Reviewed-by: Fangrui Song <maskray@google.com>
>---
> config.make.in | 1 -
> configure | 32 --------------------------------
> configure.ac | 19 -------------------
> 3 files changed, 52 deletions(-)
>
>diff --git a/config.make.in b/config.make.in
>index fff4c78dd0..d7c416cbea 100644
>--- a/config.make.in
>+++ b/config.make.in
>@@ -68,7 +68,6 @@ have-selinux = @have_selinux@
> have-libaudit = @have_libaudit@
> have-libcap = @have_libcap@
> have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
>-fno-unit-at-a-time = @fno_unit_at_a_time@
> bind-now = @bindnow@
> use-default-link = @use_default_link@
> have-cxx-thread_local = @libc_cv_cxx_thread_local@
>diff --git a/configure b/configure
>index 716dc041b6..ff2c406b3b 100755
>--- a/configure
>+++ b/configure
>@@ -620,7 +620,6 @@ libc_cv_cc_loop_to_function
> libc_cv_cc_submachine
> libc_cv_cc_nofma
> libc_cv_mtls_dialect_gnu2
>-fno_unit_at_a_time
> libc_cv_has_glob_dat
> libc_cv_fpie
> libc_cv_z_execstack
>@@ -6226,37 +6225,6 @@ fi
> $as_echo "$libc_cv_has_glob_dat" >&6; }
>
>
>-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fno-toplevel-reorder -fno-section-anchors" >&5
>-$as_echo_n "checking for -fno-toplevel-reorder -fno-section-anchors... " >&6; }
>-if ${libc_cv_fno_toplevel_reorder+:} false; then :
>- $as_echo_n "(cached) " >&6
>-else
>- cat > conftest.c <<EOF
>-int foo;
>-EOF
>-if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
>- conftest.c 1>&5'
>- { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
>- (eval $ac_try) 2>&5
>- ac_status=$?
>- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
>- test $ac_status = 0; }; }
>-then
>- libc_cv_fno_toplevel_reorder=yes
>-else
>- libc_cv_fno_toplevel_reorder=no
>-fi
>-rm -f conftest*
>-fi
>-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_fno_toplevel_reorder" >&5
>-$as_echo "$libc_cv_fno_toplevel_reorder" >&6; }
>-if test $libc_cv_fno_toplevel_reorder = yes; then
>- fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
>-else
>- fno_unit_at_a_time=-fno-unit-at-a-time
>-fi
>-
>-
> { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -mtls-dialect=gnu2" >&5
> $as_echo_n "checking for -mtls-dialect=gnu2... " >&6; }
> if ${libc_cv_mtls_dialect_gnu2+:} false; then :
>diff --git a/configure.ac b/configure.ac
>index d08ad4d64e..eb5bc6a131 100644
>--- a/configure.ac
>+++ b/configure.ac
>@@ -1383,25 +1383,6 @@ fi
> rm -f conftest*])
> AC_SUBST(libc_cv_has_glob_dat)
>
>-AC_CACHE_CHECK(for -fno-toplevel-reorder -fno-section-anchors, libc_cv_fno_toplevel_reorder, [dnl
>-cat > conftest.c <<EOF
>-int foo;
>-EOF
>-if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -fno-toplevel-reorder -fno-section-anchors
>- conftest.c 1>&AS_MESSAGE_LOG_FD])
>-then
>- libc_cv_fno_toplevel_reorder=yes
>-else
>- libc_cv_fno_toplevel_reorder=no
>-fi
>-rm -f conftest*])
>-if test $libc_cv_fno_toplevel_reorder = yes; then
>- fno_unit_at_a_time="-fno-toplevel-reorder -fno-section-anchors"
>-else
>- fno_unit_at_a_time=-fno-unit-at-a-time
>-fi
>-AC_SUBST(fno_unit_at_a_time)
>-
> AC_CACHE_CHECK([for -mtls-dialect=gnu2], libc_cv_mtls_dialect_gnu2,
> [dnl
> cat > conftest.c <<EOF
>--
>2.34.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread