kill include symlinks for sh?
Hi Paul.
Now that kbuild has proper support forinclude/$ARCH/* maybe this is a good time
to kill the use of symlinks for sh?
The idea is to do the following:
1) move all cpu specific directories to:
arch/sh/include/$CPU/cpu
then we can continue to use "#include <cpu/foo.h>" if we just tell gcc to pick up include
files in the correct directory.
2) move all mach specific directories to:
arch/sh/$ARCH/mach
then we can continue to use "#include <mach/foo.h> But this does NOT address the mach's that relied on the mach symlink that pointed one level below. I do not know how big his issue is.
3) move remaining header files to
arch/sh/include/asm
4) adjust arch/sh/Makefile
Test and enjoy....
I do not have sh toolchina on this box so I have not tried to do a full patch myself. And the mach stuff obviously worries me with the link to the parent directory.
But apart form this is is simple. See below for my take on it. You can put an
or
as you like on the final patch.
Questions / comments are welcome.
PS. sparc is the first to use arch/$ARCH/include and will hit -linus soon,
Sam
To complete step 1) to 3) the following script can be used:
# CPU dirs
mkdir -p arch/sh/include/cpu-sh2/cpu
mkdir -p arch/sh/include/cpu-sh2a/cpu mkdir -p arch/sh/include/cpu-sh3/cpu
mkdir -p arch/sh/include/cpu-sh4/cpu
mkdir -p arch/sh/include/cpu-sh5/cpu
git mv include/asm-sh/cpu-sh2 arch/sh/include/cpu-sh2/cpu git mv include/asm-sh/cpu-sh2a arch/sh/include/cpu-sh2a/cpu git mv include/asm-sh/cpu-sh3 arch/sh/include/cpu-sh3/cpu git mv include/asm-sh/cpu-sh4 arch/sh/include/cpu-sh4/cpu git mv include/asm-sh/cpu-sh5 arch/sh/include/cpu-sh5/cpu
# mach dirs mkdir -p arch/sh/include/dreamcast/mach mkdir -p arch/sh/include/landisk/mach mkdir -p arch/sh/include/hd64465/mach mkdir -p arch/sh/include/sh03/mach
git mv include/asm-sh/dreamcast arch/sh/include/dreamcast/mach git mv include/asm-sh/landisk arch/sh/include/landisk/mach git mv include/asm-sh/hd64465 arch/sh/include/hd64465/mach git mv include/asm-sh/sh03 arch/sh/include/sh03/mach
# asm-sh header files mkdir -p arch/sh/include/asm git mv include/asm-sh arch/sh/include/asm
Step 4) is the following patch:
arch/sh/Makefile +3 -48
@@ -156,52 +156,8 @@ drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/ boot := arch/sh/boot -ifneq ($(KBUILD_SRC),) -incdir-prefix := $(srctree)/include/asm-sh/ -else -incdir-prefix := -endif - -# Update machine arch and proc symlinks if something which affects -# them changed. We use .arch and .mach to indicate when they were -# updated last, otherwise make uses the target directory mtime. - -include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) \ - include/config/auto.conf FORCE - @echo ' SYMLINK include/asm-sh/cpu -> include/asm-sh/$(cpuincdir-y)' - $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi - $(Q)ln -fsn $(incdir-prefix)$(cpuincdir-y) include/asm-sh/cpu - @touch $@ - -# Most boards have their own mach directories. For the ones that -# don't, just reference the parent directory so the semantics are -# kept roughly the same. -# -# When multiple boards are compiled in at the same time, preference -# for the mach link is given to whichever has a directory for its -# headers. However, this is only a workaround until platforms that -# can live in the same kernel image back away from relying on the -# mach link. - -include/asm-sh/.mach: $(wildcard include/config/sh/*.h) \ - include/config/auto.conf FORCE - $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi - $(Q)rm -f include/asm-sh/mach - $(Q)for i in $(incdir-y); do \ - if [ -d $(srctree)/include/asm-sh/$$i ]; then \ - echo -n ' SYMLINK include/asm-sh/mach -> '; \ - echo -e "include/asm-sh/$$i"; \ - ln -fsn $(incdir-prefix)$$i \ - include/asm-sh/mach; \ - else \ - if [ ! -d include/asm-sh/mach ]; then \ - echo -n ' SYMLINK include/asm-sh/mach -> '; \ - echo -e 'include/asm-sh'; \ - ln -fsn $(incdir-prefix)../asm-sh include/asm-sh/mach; \ - fi; \ - fi; \ - done - @touch $@ +KBUILD_CFLAGS += -Iarch/sh/include/$(cpuincdir-y) +KBUILD_CFLAGS += $(foreach d, $(incdir-y), -Iarch/sh/include/$(d)) PHONY += maketools FORCE
@@ -215,8 +171,7 @@ zImage uImage uImage.srec vmlinux.srec: vmlinux compressed: zImage -archprepare: include/asm-sh/.cpu include/asm-sh/.mach maketools \ - arch/sh/lib64/syscalltab.h +archprepare: maketools arch/sh/lib64/syscalltab.h archclean: $(Q)$(MAKE) $(clean)=$(boot)
Hi Sam,
Quoted 4 lines · Sam Ravnborg
Now that kbuild has proper support for
include/$ARCH/*maybe this is a good time
to kill the use of symlinks for sh?
Good idea, I just saw the sparc change go by earlier today and remembered we had talked about this before.
Quoted 4 lines
I do not have sh toolchina on this box so I have not tried to do a full patch myself. And the mach stuff obviously worries me with the link to the parent directory.
This didn't end up being _too_ painful, though it did take a bit of time to hunt down all of the guilty parties. I've pushed out what I have now, which you can see at:
It's been holding up to all of the random builds I've thrown at it so far, so there shouldn't be any really nasty surprises left over.
I'm glad git supports renames.. :-)
Hi Paul
Quoted 8 lines
This didn't end up being _too_ painful, though it did take a bit of time to hunt down all of the guilty parties. I've pushed out what I have now, which you can see at:
It's been holding up to all of the random builds I've thrown at it so far, so there shouldn't be any really nasty surprises left over.
I took a quick look at it and the header re-org looks good. I like that you added the 'mach-' prefix to the directory names.
But I also noticed several changes like this:
-#include <asm/landisk/iodata_landisk.h>
+#include <mach/iodata_landisk.h>
In this case you _know_ that this is a landisk so the less magic option would have been the longer include form like this:
+#include <mach-landisk/mach/iodata_landisk.h>
It would be preferable that we use the gcc -I
directive:
-Iarch/sh/include/mach-$MACH
only to automagically select between identical named files for the different platforms and not like the above where we use it simply to cut off the include path a little.
Another note is that you decided to move the generated file over to arch/sh/include too.
I really do not know if I think this is the right approach. What I like is that we some day end up with generated files in a common place. But I have not really thought it through and thus I have no final idea how to do it.
So in other words - keep it as is and lets re-visit it should we one day decide to do this in a common way across architectures.
Thanks for looking into this so quickly!
Sam
Quoted 26 lines · Sam Ravnborg
Hi Paul
Quoted 8 lines
This didn't end up being _too_ painful, though it did take a bit of time to hunt down all of the guilty parties. I've pushed out what I have now, which you can see at:
It's been holding up to all of the random builds I've thrown at it so far, so there shouldn't be any really nasty surprises left over.
I took a quick look at it and the header re-org looks good. I like that you added the 'mach-' prefix to the directory names.
But I also noticed several changes like this:
(quoted diff) +1
-1-#include <asm/landisk/iodata_landisk.h> +#include <mach/iodata_landisk.h>In this case you _know_ that this is a landisk so the less magic option would have been the longer include form like this:
+#include <mach-landisk/mach/iodata_landisk.h>It would be preferable that we use the gcc -I
directive:
Quoted 7 lines
-Iarch/sh/include/mach-$MACH
only to automagically select between identical named files for the different platforms and not like the above where we use it simply to cut off the include path a little.
Yes, I had thought about that as well. We certainly need to go this route if we are building multiple mach types at the same time. Fortunately the vast majority of mach types do not have their own include structure, so it's not been something that's popped up yet as a real problem.
Quoted 3 lines
Another note is that you decided to move the generated file over to
arch/sh/includetoo.
I really do not know if I think this is the right approach.
This was before I realized that asm-offsets.h was being placed in include/asm-sh anyways, despite the directory not existing until Kbuild created it. I don't have any problems with moving it back, I just thought the idea of multiple include directories for the same asm/ prefix seemed non-intuitive.