This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Define GEN_AS_CONST_HEADERS when generating header files [BZ #22792]


Glibc build generates header files to define constants from special .sym
files.  If a .sym file includes the same header file which it generates,
it leads to circular dependency.  Define GEN_AS_CONST_HEADERS when
generating header files to avoid circular dependency.

<tcb-offsets.h> is needed for i686 and it isn't needed for x86-64 at
least since glibc 2.23.

Tested on i686 and x86-64.

OK for trunk?

H.J.
---
	[BZ #22792]
	* Makerules ($(common-objpfx)%.h): Pass -DGEN_AS_CONST_HEADERS
	to $(CC).
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h: Include
	<tcb-offsets.h> only if GEN_AS_CONST_HEADERS isn't defined.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h: Don't include
	<tcb-offsets.h>.
---
 Makerules                                     | 4 +++-
 sysdeps/unix/sysv/linux/i386/lowlevellock.h   | 4 +++-
 sysdeps/unix/sysv/linux/x86_64/lowlevellock.h | 1 -
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makerules b/Makerules
index ef6abeac6d..10a2e83468 100644
--- a/Makerules
+++ b/Makerules
@@ -276,10 +276,12 @@ ifdef gen-as-const-headers
 # Generating headers for assembly constants.
 # We need this defined early to get into before-compile before
 # it's used in sysd-rules, below.
+# Define GEN_AS_CONST_HEADERS to avoid circular dependency [BZ #22792].
 $(common-objpfx)%.h $(common-objpfx)%.h.d: $(..)scripts/gen-as-const.awk \
 					   %.sym $(common-before-compile)
 	$(AWK) -f $< $(filter %.sym,$^) \
-	| $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) -x c - \
+	| $(CC) -S -o $(@:.h.d=.h)T3 $(CFLAGS) $(CPPFLAGS) \
+		-DGEN_AS_CONST_HEADERS -x c - \
 		-MD -MP -MF $(@:.h=.h.d)T -MT '$(@:.h=.h.d) $(@:.h.d=.h)'
 	sed -n 's/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$$/#define \1 \2/p' \
 		$(@:.h.d=.h)T3 > $(@:.h.d=.h)T
diff --git a/sysdeps/unix/sysv/linux/i386/lowlevellock.h b/sysdeps/unix/sysv/linux/i386/lowlevellock.h
index fb59b57934..9f081e8a05 100644
--- a/sysdeps/unix/sysv/linux/i386/lowlevellock.h
+++ b/sysdeps/unix/sysv/linux/i386/lowlevellock.h
@@ -26,7 +26,9 @@
 # include <sys/param.h>
 # include <bits/pthreadtypes.h>
 # include <kernel-features.h>
-# include <tcb-offsets.h>
+# ifndef GEN_AS_CONST_HEADERS
+#  include <tcb-offsets.h>
+# endif
 
 # ifndef LOCK_INSTR
 #  ifdef UP
diff --git a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
index a8bcfbe4a3..eedb6fc990 100644
--- a/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
+++ b/sysdeps/unix/sysv/linux/x86_64/lowlevellock.h
@@ -26,7 +26,6 @@
 # include <sys/param.h>
 # include <bits/pthreadtypes.h>
 # include <kernel-features.h>
-# include <tcb-offsets.h>
 
 # ifndef LOCK_INSTR
 #  ifdef UP
-- 
2.14.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]