lkml.org 
[lkml]   [1999]   [Jan]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectFix for 2.2.0-final Makefile problems
Date
Hi!

Below is a patch which should fix some bugs in current Makefiles, especially
related to symbol versioning.
- It adds proper dependencies for the .ver files (they not only depend on
the related .c file, but also on all its dependencies).
- It remakes .ver files and if they changed also modversions.h always when
it is needed, unlike current kernel Makefiles, where you can e.g. change
CONFIG_SMP in make config and nothing but make mrproper will fix module
versioning.
- It adds .depend and .hdepend special targets - for two reasons:
if you do Ctrl-C right in the middle of making it, it won't cause you
problems, and, as .depend depends just on *.[chS] and local Makefile, adds
that dependency (so that if you e.g. patch kernel and do a make dep, it does
not compute dependencies where it is not needed).
- It makes mkdep aware of the special role of modversions.h. They have been
explicitely used in the Makefiles even before this patch, but at the same
time have been generated by mkdep in .hdepend, so any file which included
module.h (there are many, you all know) depended on modversions.h and
version.h only because it is used in EXPORT_SYMTAB case. So this patch makes
only modules dependent on modversions.h. Actually, there are three cases for
module versioning now: during make dep, it checks dependencies of all
EXPORT_SYMTAB objects and if any of them changed, rebuilds modversions.h
(and .depend files as well if needed). During make vmlinux/zImage/etc.
nothing depends on modversions.h, but if make enters a directory where a
EXPORT_SYMTAB object changed (or any header it depends on), then
modversions.h is updated and the object which exports the symbols is
recompiled (as its dependencies must have changed as well). As EXPORT_SYMTAB
non-module objects are interested only in versioning info they export, this
is completely sufficient. For make modules, this cannot be solved this way,
so make modules will only check if .ver files have changed and if they have,
then exits with an error telling the user he must redo make dep. I think it
is a much better solution than what we have so far: if make modules
discovered a .ver file changed (it is likely it will not discover it
although it should), then it will update modversions.h and thus some modules
will be compiled with new versioning information and some with the old, so
to be sure one has to do make modules twice.
- I have special cased version.h in module.h as well, so that whenever Linus
updates a kernel version one does not have to recompile half of static
(in-kernel) objects just because version changed. In module.h, version.h is
used only for modules, so the patch adds that dependency to every module.

Please test this as much as you can, especially in make -j X builds and tell
me if you find any problems. This patch is intended to be as short as
possible, so that it can be included in 2.2.X to fix the bugs described
above.I hope 2.3 will bring fresh ideas to our Makefile scheme, but that's
completely different matter.


--- ./Rules.make.jj Thu Jan 14 10:42:29 1999
+++ ./Rules.make Mon Jan 25 18:01:09 1999
@@ -102,18 +102,16 @@ endif
#
# This make dependencies quickly
#
-fastdep: dummy
- $(TOPDIR)/scripts/mkdep $(wildcard *.[chS] local.h.master) > .depend
+ifdef _FASTDEP_ALL_SUB_DIRS
+fastdep: dummy .depend
ifdef ALL_SUB_DIRS
$(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
endif

-ifdef _FASTDEP_ALL_SUB_DIRS
$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
$(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
endif

-
#
# A rule to make subdirectories
#
@@ -181,20 +179,19 @@ script:
# Separate the object into "normal" objects and "exporting" objects
# Exporting objects are: all objects that define symbol tables
#
-ifdef CONFIG_MODULES
-
SYMTAB_OBJS = $(LX_OBJS) $(OX_OBJS) $(MX_OBJS) $(MIX_OBJS)
+MODINCL = $(TOPDIR)/include/linux/modules
+
+ifdef CONFIG_MODULES

ifdef CONFIG_MODVERSIONS
ifneq "$(strip $(SYMTAB_OBJS))" ""

-MODINCL = $(TOPDIR)/include/linux/modules
-
# The -w option (enable warnings) for genksyms will return here in 2.1
# So where has it gone?
#
# Added the SMP separator to stop module accidents between uniprocessor
-# and SMP Intel boxes - AC - from bits by Michael Chastain
+# and SMP boxes - AC - from bits by Michael Chastain
#

ifdef CONFIG_SMP
@@ -204,18 +201,28 @@ else
endif

$(MODINCL)/%.ver: %.c
- @if [ ! -r $(MODINCL)/$*.stamp -o $(MODINCL)/$*.stamp -ot $< ]; then \
- echo '$(CC) $(CFLAGS) -E -D__GENKSYMS__ $<'; \
- echo '| $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp'; \
- $(CC) $(CFLAGS) -E -D__GENKSYMS__ $< \
- | $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp; \
- if [ -r $@ ] && cmp -s $@ $@.tmp; then echo $@ is unchanged; rm -f $@.tmp; \
- else echo mv $@.tmp $@; mv -f $@.tmp $@; fi; \
- fi; touch $(MODINCL)/$*.stamp
+ifndef MAKING_MODULES
+ $(CC) $(CFLAGS) -E -D__GENKSYMS__ $< \
+ | $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp
+ @if [ -r $@ ] && cmp -s $@ $@.tmp; then echo $@ is unchanged; else touch $(MODINCL)/.modversions.h.dep; fi
+ mv -f $@.tmp $@
+else
+ $(CC) $(subst -include $(HPATH)/linux/modversions.h,,$(CFLAGS)) -E -D__GENKSYMS__ $< \
+ | $(GENKSYMS) $(genksyms_smp_prefix) -k $(VERSION).$(PATCHLEVEL).$(SUBLEVEL) > $@.tmp
+ @if [ -r $@ ] && cmp -s $@ $@.tmp; then echo $@ is unchanged; else \
+ rm -f $@.tmp; \
+ echo "*** Module versions in $@ changed."; \
+ echo "*** Please rerun make dep before doing make modules."; \
+ exit 1; fi
+ rm -f $@.tmp
+endif

$(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver)): $(TOPDIR)/include/linux/autoconf.h

-$(TOPDIR)/include/linux/modversions.h: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver))
+$(MODINCL)/.modversions.h.dep: $(addprefix $(MODINCL)/,$(SYMTAB_OBJS:.o=.ver))
+ @if [ ! -r $@ ]; then touch $@; fi
+
+$(TOPDIR)/include/linux/modversions.h: $(MODINCL)/.modversions.h.dep
@echo updating $(TOPDIR)/include/linux/modversions.h
@(echo "#ifndef _LINUX_MODVERSIONS_H";\
echo "#define _LINUX_MODVERSIONS_H"; \
@@ -225,15 +232,18 @@ $(TOPDIR)/include/linux/modversions.h: $
if [ -f $$f ]; then echo "#include <linux/modules/$${f}>"; fi; \
done; \
echo "#endif"; \
- ) > $@
+ ) > $(TOPDIR)/include/linux/modversions.h
+
+$(MODINCL)/.modversions.upd: $(TOPDIR)/include/linux/modversions.h
+ @if [ ! -r $@ ]; then touch $@; fi

dep fastdep: $(TOPDIR)/include/linux/modversions.h

endif # SYMTAB_OBJS

-$(M_OBJS): $(TOPDIR)/include/linux/modversions.h
+$(M_OBJS): $(TOPDIR)/include/linux/modversions.h $(TOPDIR)/include/linux/version.h
ifdef MAKING_MODULES
-$(O_OBJS) $(L_OBJS): $(TOPDIR)/include/linux/modversions.h
+$(O_OBJS) $(L_OBJS): $(TOPDIR)/include/linux/modversions.h $(TOPDIR)/include/linux/version.h
endif

else
@@ -241,10 +251,13 @@ else
$(TOPDIR)/include/linux/modversions.h:
@echo "#include <linux/modsetver.h>" > $@

+$(MODINCL)/.modversions.upd: $(TOPDIR)/include/linux/modversions.h
+ @if [ ! -r $@ ]; then touch $@; fi
+
endif # CONFIG_MODVERSIONS

ifneq "$(strip $(SYMTAB_OBJS))" ""
-$(SYMTAB_OBJS): $(TOPDIR)/include/linux/modversions.h $(SYMTAB_OBJS:.o=.c)
+$(SYMTAB_OBJS): $(MODINCL)/.modversions.upd $(SYMTAB_OBJS:.o=.c)
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB -c $(@:.o=.c)
@ ( \
echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -DEXPORT_SYMTAB)),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@) -DEXPORT_SYMTAB)))' ; \
@@ -255,6 +268,16 @@ endif

endif # CONFIG_MODULES

+#
+# This rule updates the dependencies
+#
+ifdef _FASTDEP_ALL_SUB_DIRS
+.depend: $(wildcard *.[chS] local.h.master) Makefile
+ $(TOPDIR)/scripts/mkdep $(wildcard *.[chS] local.h.master) > .depend
+ifneq "$(strip $(SYMTAB_OBJS))" ""
+ $(TOPDIR)/scripts/mkdep $(SYMTAB_OBJS:.o=.c) | sed 's%^\(.*\)\.o:%$$(MODINCL)/\1.ver:%' >> .depend
+endif
+endif

#
# include dependency files if they exist
--- ./scripts/mkdep.c.jj Thu Jan 14 12:08:45 1999
+++ ./scripts/mkdep.c Fri Jan 22 17:12:26 1999
@@ -48,6 +48,12 @@ int size_config = 0;
int len_config = 0;


+/*
+ * Are we processing linux/module.h?
+ */
+int module_h = 0;
+
+

/*
* Grow the configuration string to a desired length.
@@ -135,6 +141,13 @@ void handle_include(int type, const char

if (len == 14 && !memcmp(name, "linux/config.h", len))
return;
+
+ if (module_h) {
+ if (len == 19 && !memcmp(name, "linux/modversions.h", len))
+ return; /* This is handled in the Makefiles */
+ if (len == 15 && !memcmp(name, "linux/version.h", len))
+ return; /* And this as well. */
+ }

if (len >= 7 && !memcmp(name, "config/", 7))
define_config(0, name+7, len-7-2);
@@ -427,12 +440,16 @@ void do_depend(const char * filename, co
int fd;
struct stat st;
char * map;
+ int len;

fd = open(filename, O_RDONLY);
if (fd < 0) {
perror(filename);
return;
}
+
+ len = strlen(filename);
+ module_h = !strcmp(filename + len - 14, "linux/module.h");

fstat(fd, &st);
if (st.st_size == 0) {
--- ./Makefile.jj Fri Jan 22 10:17:56 1999
+++ ./Makefile Mon Jan 25 17:30:06 1999
@@ -398,11 +398,18 @@ sums:
find . -type f -print | sort | xargs sum > .SUMS

dep-files: scripts/mkdep archdep include/linux/version.h
- scripts/mkdep init/*.c > .depend
- scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend
+ $(MAKE) _FASTDEP_TOPLEVEL=1 .depend .hdepend
# set -e; for i in $(SUBDIRS); do $(MAKE) -C $$i fastdep ;done
# let this be made through the fastdep rule in Rules.make
$(MAKE) $(patsubst %,_sfdep_%,$(SUBDIRS)) _FASTDEP_ALL_SUB_DIRS="$(SUBDIRS)"
+
+ifdef _FASTDEP_TOPLEVEL
+.depend: $(wildcard init/*.c)
+ scripts/mkdep init/*.c > $@
+
+.hdepend: dummy
+ scripts/mkdep `find $(FINDHPATH) -follow -name \*.h ! -name modversions.h -print` > .hdepend
+endif

MODVERFILE :=


Cheers,
Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux | http://ultra.linux.cz/ | http://ultra.penguin.cz/
Linux version 2.2.0-final on a sparc64 machine (3958.37 BogoMips)
___________________________________________________________________
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:50    [W:0.029 / U:0.680 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site