UML kbuild patch

UML kbuild patch

Post by Jeff Dik » Wed, 25 Sep 2002 09:10:05



The UML build needs a few kbuild changes in order to work with the latest
stuff.

Since kbuild now enforces the use of the linker script on the vmlinux build,
UML can't use its old two-stage link, where
        vmlinux is a normal relocatable object file
        which is linked into the linux binary with the linker script

So, in order to fold those into one stage and produce an ELF binary, I need
the vmlinux "linker" to actually be gcc.  This implies I need a
"-Wl,-T,arch/$(ARCH)/vmlinux.lds.s" instead of the usual
"-T arch/$(ARCH)/vmlinux.lds.s".

This is done without breaking the other arches by changing the final link
command to $(LD_vmlinux) which is defaulted to $(LD) if the arch doesn't
define it.

The "-Wl,..." is done similarly by using $(LDFLAGS_vmlinux_default) if
the linker command is anything but gcc and $(LDFLAGS_vmlinux_gcc) if it is
gcc.

The one caveat is that I removed $(LDFLAGS) from the link line - you might
want to add it back.

You can pull bk://jdike.stearns.org/kbuild-2.5.  The patch is also appended.

                                Jeff

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.600   -> 1.602  
#                   Makefile    1.305   -> 1.307  
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------

# Fixes to allow UML to build with the new vmlinux rules.
# --------------------------------------------

# Made the UML Makefile changes work for the other arches.
# --------------------------------------------
#
diff -Nru a/Makefile b/Makefile
--- a/Makefile  Mon Sep 23 19:50:33 2002

 #       we cannot yet know if we will need to relink vmlinux.
 #      So we descend into init/ inside the rule for vmlinux again.

+LD_vmlinux := $(if $(LD_vmlinux),$(LD_vmlinux),$(LD))
+
 vmlinux-objs := $(HEAD) $(INIT) $(CORE_FILES) $(LIBS) $(DRIVERS) $(NETWORKS)




                --start-group \
                $(CORE_FILES) \

        $(NM) vmlinux | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
 endef

-LDFLAGS_vmlinux += -T arch/$(ARCH)/vmlinux.lds.s
+LDFLAGS_vmlinux_default = -T arch/$(ARCH)/vmlinux.lds.s
+LDFLAGS_vmlinux_gcc = -Wl,-T,arch/$(ARCH)/vmlinux.lds.s
+
+vmlinux_base = $(basename $(notdir $(LD_vmlinux)))
+LDFLAGS_vmlinux += $(if $(LDFLAGS_vmlinux_$(vmlinux_base)),$(LDFLAGS_vmlinux_$(vmlinux_base)),$(LDFLAGS_vmlinux_default))

 vmlinux: $(vmlinux-objs) arch/$(ARCH)/vmlinux.lds.s FORCE
        $(call if_changed_rule,link_vmlinux)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

UML kbuild patch

Post by Kai Germaschewsk » Wed, 25 Sep 2002 09:30:10



> The UML build needs a few kbuild changes in order to work with the latest
> stuff.

> Since kbuild now enforces the use of the linker script on the vmlinux build,
> UML can't use its old two-stage link, where
>    vmlinux is a normal relocatable object file
>    which is linked into the linux binary with the linker script

> So, in order to fold those into one stage and produce an ELF binary, I need
> the vmlinux "linker" to actually be gcc.  This implies I need a
> "-Wl,-T,arch/$(ARCH)/vmlinux.lds.s" instead of the usual
> "-T arch/$(ARCH)/vmlinux.lds.s".

> This is done without breaking the other arches by changing the final link
> command to $(LD_vmlinux) which is defaulted to $(LD) if the arch doesn't
> define it.

> The "-Wl,..." is done similarly by using $(LDFLAGS_vmlinux_default) if
> the linker command is anything but gcc and $(LDFLAGS_vmlinux_gcc) if it is
> gcc.

I just thought of another solution, which actually seems cleaner and has
less impact on the top-level (generic) Makefile.

Let's just do the

        LDFLAGS_vmlinux := -T arch/$(ARCH)/vmlinux.lds.s

before including arch/$(ARCH)/Makefile.
Normal archs can then just do

        LDFLAGS_vmlinux += -extra_option

while UML does

        LDFLAGS_vmlinux := -r

The actual executable UML generates is called "linux" anyway, so its
Makefile can have its own rule (as for other archs the boot images) which
builds "linux" from "vmlinux" using gcc and the link script. - I.e. the
same way as UML used to do it earlier, anyway.

The only impact on generic code is basically
s/LDFLAGS_vmlinux :=/LDFLAGS_vmlinux +=/
in arch/*/Makefile, and it makes the UML "linux" build conceptually
similar to other archs' "bzImage" or whatever targets.

What do you think?

--Kai

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

UML kbuild patch

Post by Jeff Dik » Wed, 25 Sep 2002 10:40:04



Quote:> The actual executable UML generates is called "linux" anyway, so its
> Makefile can have its own rule (as for other archs the boot images)
> which  builds "linux" from "vmlinux" using gcc and the link script. -
> I.e. the  same way as UML used to do it earlier, anyway.

I'd actually prefer the one-stage link.  That takes better advantage of
the infrastructure that you've put in place.

Instead of making LDFLAGS_vmlinux available to the arch Makefile, can
you make cmd_link_vmlinux available?  Then I can just rewrite it.

That looks like it has no impact on the global Makefile except for moving
it above the include of the arch Makefile.

                                Jeff

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

UML kbuild patch

Post by Oleg Droki » Wed, 25 Sep 2002 21:20:09


Hello!


> I just thought of another solution, which actually seems cleaner and has
> less impact on the top-level (generic) Makefile.

On a little bit unrelated note, I found that your changes accepted by Linus
broke UML (the ones entitled as 'kbuild: arch/um cleanup / O_TARGET removal')
build for 2.5.38, so that's what I was forced to do to make it to compile:

===== arch/um/Makefile 1.3 vs edited =====
--- 1.3/arch/um/Makefile        Tue Sep 24 15:37:03 2002

 LINK_PROFILE = $(PROFILE) -Wl,--wrap,__monstartup
 endif

-ARCH_SUBDIRS = $(ARCH_DIR)/drivers $(ARCH_DIR)/kernel \
-       $(ARCH_DIR)/sys-$(SUBARCH) $(ARCH_DIR)/os-$(OS)
-
-SUBDIRS += $(ARCH_SUBDIRS)
-
 core-y                 += $(ARCH_DIR)/kernel/           \
-                       += $(ARCH_DIR)/drivers/          \
-                       += $(ARCH_DIR)/sys-$(SUBARCH)/   \
-                       += $(ARCH_DIR)/os-$(OS)/
+                          $(ARCH_DIR)/drivers/          \
+                          $(ARCH_DIR)/sys-$(SUBARCH)/   \
+                          $(ARCH_DIR)/os-$(OS)/

 libs-$(CONFIG_PT_PROXY)        += $(ARCH_DIR)/ptproxy/

        -DELF_ARCH=$(ELF_ARCH) -DELF_FORMAT=\"$(ELF_FORMAT)\"

 LD_vmlinux = $(CC)
-LDFLAGS_vmlinux = $(LINK_PROFILE) $(LINK_WRAPS) -static $(ARCH_DIR)/main.o
+LDFLAGS_vmlinux = $(LINK_PROFILE) $(LINK_WRAPS) -static $(ARCH_DIR)/main.o -L/usr/lib
+
+LIBS += -lutil

 SYMLINK_HEADERS = include/asm-um/archparam.h include/asm-um/system.h \
        include/asm-um/sigcontext.h include/asm-um/processor.h \
===== arch/um/Makefile-os-Linux 1.1 vs edited =====
--- 1.1/arch/um/Makefile-os-Linux       Fri Sep  6 21:29:28 2002

 #

 SUBDIRS += $(ARCH_DIR)/os-$(OS)/drivers
-LIBS += $(ARCH_DIR)/os-$(OS)/drivers/drivers.o
===== arch/um/kernel/Makefile 1.2 vs edited =====
--- 1.2/arch/um/kernel/Makefile Mon Sep 23 03:40:07 2002

        umid.o user_util.o

 obj-$(CONFIG_BLK_DEV_INITRD) += initrd_kern.o initrd_user.o
-endif

 # user_syms.o not included here because Rules.make has its own ideas about
 # building anything in export-objs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. kbuild/kbuild for USB Gadgets (6/6)


                                                     ^^^^^^^^^
with with

          ^^^^^^^^^^^^
Shouldn't the `be' be removed?

                        ^^^^^^^^
supported

Gr{oetje,eeting}s,

                                                Geert

--

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                                            -- Linus Torvalds

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. setting gamma for SiS730?

3. A simple patch for SIS (documentation and kbuild)

4. CPU board serial number

5. [2.5] kbuild-2.5 1/12: patched module.h

6. PCI sound

7. PATCH 2.4.4.3: 3rdparty driver support for kbuild

8. OS2 Warp and Linux

9. uml-patch-2.5.42-2

10. [PATCH] convert UML to new do_fork() API

11. uml-patch-2.5.42-1

12. uml-patch-2.5.52-1

13. uml-patch-2.5.58-1