This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[COMMITTED PATCH] Use -Werror=undef for assembly code.
- From: Roland McGrath <roland at hack dot frob dot com>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Thu, 12 Feb 2015 14:22:06 -0800 (PST)
- Subject: [COMMITTED PATCH] Use -Werror=undef for assembly code.
- Authentication-results: sourceware.org; auth=none
We want the -Wundef goodness for our assembly code (.S files) and
everything else (e.g. %if in various magic files) too.
I first tried to put -Wundef and -Werror into CPPFLAGS rather than
just CFLAGS. That blew up in various ways, so I've backed off to
just adding it for assembly specifically. In the future I think we
should rework things so that -Wundef in CPPFLAGS can work.
I'll describe the issues I ran into here just for future reference:
1. The uses for .v.i files and the like all blew up badly for lack
of -DMODULE_NAME change. I considered trying to make those use
-DMODULE_NAME=nonlib or maybe something new like
-DMODULE_NAME=build so that IS_IN could be principled in those
cases. But it looked like a bootstrapping nightmare or further
kludge-o-rama because those uses are dependencies of
libc-module.h generation, so I tried the far simpler route of
changing libc-symbols.h to define IS_IN to a constant zero if
MODULE_NAME is not defined. That covered the .v.i cases OK, and
would probably suffice in the future if we have -Wundef in
CPPFLAGS.
2. The real killer was that CPPFLAGS comes after CFLAGS, not before.
(That seems like it might be backwards from what you really want,
but it is the established practice in make's default rules and
the like, so it probably should stay as it is.) That meant that
-Werror=undef in CPPFLAGS overrode -Wno-error=undef in CFLAGS. I
think once we have conquered all the -Wundef warnings still
lingering (mostly in test code now), we could safely put
-Werror=undef into CPPFLAGS and not worry about --disable-werror
affecting -Wundef errors.
In the x86_64-linux-gnu build, the only new -Wundef errors were from
generated syscall .S files. The make-syscalls.sh change solves
those. I've verified that no generated code changes.
The sysdeps/arm/Versions change fixes the one real bug that lack of
-Wunder for assembly was causing: the SHLIB_COMPAT clause in
arm-mcount.S was not hitting correctly.
This might cause some new build failures for other machines that I
did not test. If so, those were latent bugs that should be fixed in
the assembly code. Nobody should be working around these by instead
defeating -Wundef.
Thanks,
Roland
* Makeconfig (ASFLAGS): Add -Werror=undef.
* sysdeps/arm/Versions (libc: GLIBC_2.19): New (empty) version set.
* sysdeps/unix/make-syscalls.sh: Always emit #define's for
SYSCALL_CANCELLABLE, SYSCALL_NOERRNO, SYSCALL_ERRVAL, to 1 or 0.
--- a/Makeconfig
+++ b/Makeconfig
@@ -948,7 +948,7 @@ endif
ifndef ASFLAGS
ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))
endif
-ASFLAGS += $(ASFLAGS-config) $(asflags-cpu)
+ASFLAGS += -Werror=undef $(ASFLAGS-config) $(asflags-cpu)
ifndef BUILD_CC
BUILD_CC = $(CC)
--- a/sysdeps/arm/Versions
+++ b/sysdeps/arm/Versions
@@ -17,4 +17,8 @@ libc {
GLIBC_2.8 {
__gnu_mcount_nc;
}
+ GLIBC_2.19 {
+ # This set has to exist in some Versions file so we can use 2.19 in
+ # SHLIB_COMPAT. Since it didn't exist anywhere else, we add it here.
+ }
}
--- a/sysdeps/unix/make-syscalls.sh
+++ b/sysdeps/unix/make-syscalls.sh
@@ -250,14 +250,10 @@ while read file srcfile caller syscall args strong weak; do
\$(make-target-directory)
(echo '#define SYSCALL_NAME $syscall'; \\
echo '#define SYSCALL_NARGS $nargs'; \\
- echo '#define SYSCALL_SYMBOL $strong'; \\"
- [ $cancellable = 0 ] || echo "\
- echo '#define SYSCALL_CANCELLABLE 1'; \\"
- [ $noerrno = 0 ] || echo "\
- echo '#define SYSCALL_NOERRNO 1'; \\"
- [ $errval = 0 ] || echo "\
- echo '#define SYSCALL_ERRVAL 1'; \\"
- echo "\
+ echo '#define SYSCALL_SYMBOL $strong'; \\
+ echo '#define SYSCALL_CANCELLABLE $cancellable'; \\
+ echo '#define SYSCALL_NOERRNO $noerrno'; \\
+ echo '#define SYSCALL_ERRVAL $errval'; \\
echo '#include <syscall-template.S>'; \\"
;;
esac