Skip to contentSkip to conversation

let kbuild mkdir for dir/file.o

PATCH In review 张忠山 2 participants 10 messages Jun 4, 2013 – Jul 4, 2013 Kbuild

lore
Share & tools
lore

张忠山

author
#0 lore raw

PATCH 1/1 let kbuild mkdir for dir/file.o

Last week I send this patch, but no reply.
Now I try to explain it clearly:

When I try to add a file(which in a subdir) to my board's obj-y, the build progress crashed.

for example, I use at91rm9200ek board, and in kernel dir run:

mkdir objtree
make O=objtree at91rm9200-defconfig
mkdir arch/arm/mach-at91/dir
touch arch/arm/mach-at91/dir/file.c

and edit arch/arm/mach-at91/dir/file.c to add some code. then edit arch/arm/mach-at91/Makefile, change the flowwing line:

	obj-$(CONFIG_MACH_AT91RM9200EK)	+= board-rm9200ek.o

to:

	obj-$(CONFIG_MACH_AT91RM9200EK)	+= board-rm9200ek.o dir/file.o

Now build it:

make O=objtree

Then the error appears:

	...
	CC      arch/arm/mach-at91/board-rm9200dk.o
	CC      arch/arm/mach-at91/board-rm9200ek.o
	CC      arch/arm/mach-at91/dir/file.o
	linux-2.6/arch/arm/mach-at91/dir/file.c:5: fatal error: opening dependency file arch/arm/mach-at91/dir/.file.o.d: No such file or directory

Check the objtree:
LANG=en ls objtree/arch/arm/mach-at91/dir
ls: cannot access objtree/arch/arm/mach-at91/dir: No such file or directory

It's appearantly that the target dir not created for file.o

I check kbuild source code. It seems that kbuild create dirs for that in $(obj-dirs). But if the dir need not to create a built-in.o, It should never in $(obj-dirs).

So I make this patch to make sure It in $(obj-dirs)

Anybody Anyidea?

张忠山 (1):
let kbuild mkdir for dir/file.o

 scripts/Makefile.lib |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/1 let kbuild mkdir for dir/file.o

when add a obj with dir to obj-y, like this

    obj-y += dir/file.o

the $(obj)/dir not created, this patch fix this

this bug caused by commit
f5fb976520a53f45f8bbf2e851f16b3b5558d485

---
 scripts/Makefile.lib |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/Makefile.lib +2 -1
index 51bb3de..6bae5a9 100644
@@ -63,7 +63,8 @@ multi-objs   := $(multi-objs-y) $(multi-objs-m)
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 
 # $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
+__subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
+obj-dirs := $(dir $(multi-objs) $(__subdir-obj-y))
 
 # Replace multi-part objects by their individual parts, look at local dir only
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
Signature · 1 line
1.7.9.5
#2 lore raw

Hi,

sorry for the late feedback.

Dne 4.6.2013 10:45, 张忠山 napsal(a):

Quoted 8 lines

when add a obj with dir to obj-y, like this

    obj-y += dir/file.o

the $(obj)/dir not created, this patch fix this

this bug caused by commit
f5fb976520a53f45f8bbf2e851f16b3b5558d485

Please also include the wonderful explanation including the error message that you posted separately
(http://permalink.gmane.org/gmane.linux.kbuild.devel/10050). Also, please CC linux-kernel in addition to linux-kbuild.

Quoted 11 lines
---
 scripts/Makefile.lib |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/Makefile.lib +0 -0
index 51bb3de..6bae5a9 100644

scripts/Makefile.lib multi-objs := $(multi-objs-y) $(multi-objs-m) · line 66

Quoted 5 lines
scripts/Makefile.lib +1 -1
@@ -63,7 +63,8 @@ multi-objs   := $(multi-objs-y) $(multi-objs-m)
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 
 # $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
+__subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))

This complicated filter returns entries from $(obj-y) that contain a slash, is that correct? If so, is it really necessary? Why not simply add whole $(obj-y) to $(obj-dirs) and be done? $(multi-objs) is also added without any filtering.

scripts/Makefile.lib multi-objs := $(multi-objs-y) $(multi-objs-m) · line 67

Quoted 1 line
scripts/Makefile.lib +1 -0
+obj-dirs := $(dir $(multi-objs) $(__subdir-obj-y))

thanks,
Michal

author
#3 lore raw

PATCH 1/1 let kbuild mkdir for dir/file.o

When add a obj with dir to obj-y, like this

    obj-y += dir/file.o

The $(obj)/dir not created, this patch fix this.

When try to add a file(which in a subdir) to my board's obj-y, the build progress crashed.

For example, I use at91rm9200ek board, and in kernel dir run:

mkdir objtree
make O=objtree at91rm9200-defconfig
mkdir arch/arm/mach-at91/dir
touch arch/arm/mach-at91/dir/file.c

and edit arch/arm/mach-at91/dir/file.c to add some code. then edit arch/arm/mach-at91/Makefile, change the following line:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o

to:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o dir/file.o

Now build it:

make O=objtree

Then the error appears:
...

  CC      arch/arm/mach-at91/board-rm9200dk.o
  CC      arch/arm/mach-at91/board-rm9200ek.o
  CC      arch/arm/mach-at91/dir/file.o

linux-2.6/arch/arm/mach-at91/dir/file.c:5:
fatal error: opening dependency file arch/arm/mach-at91/dir/.file.o.d: No such file or directory

Check the objtree:
LANG=en ls objtree/arch/arm/mach-at91/dir
ls: cannot access objtree/arch/arm/mach-at91/dir: No such file or directory

It's apparently that the target dir not created for file.o

Check kbuild source code. It seems that kbuild create dirs for that in $(obj-dirs). But if the dir need not to create a built-in.o, It should never in $(obj-dirs).

So I make this patch to make sure It in $(obj-dirs)

this bug caused by commit
f5fb976520a53f45f8bbf2e851f16b3b5558d485

---
 scripts/Makefile.lib |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/Makefile.lib +2 -1
index 51bb3de..6bae5a9 100644
@@ -63,7 +63,8 @@ multi-objs   := $(multi-objs-y) $(multi-objs-m)
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 
 # $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
+__subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))
+obj-dirs := $(dir $(multi-objs) $(__subdir-obj-y))
 
 # Replace multi-part objects by their individual parts, look at local dir only
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
Signature · 1 line
1.7.9.5
author
#4 lore raw
In reply to Michal Marek
Quoted 10 lines

scripts/Makefile.lib multi-objs := $(multi-objs-y) $(multi-objs-m) · line 66

Quoted 3 lines

# $(obj-dirs) is a list of directories that contain object files

scripts/Makefile.lib +1 -1
-obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
+__subdir-obj-y := $(foreach o,$(obj-y),$(if $(filter-out $(o),$(notdir $(o))),$(o)))

This complicated filter returns entries from $(obj-y) that contain a slash, is that correct? If so, is it really necessary? Why not simply add whole $(obj-y) to $(obj-dirs) and be done? $(multi-objs) is also added without any filtering.

Quoted 1 line

+obj-dirs := $(dir $(multi-objs) $(__subdir-obj-y))

Yes, You are right.
It is enough that just add $(obj-y) to $(obj-dirs) directly. I will resend the patch.

Signature · 2 lines
Best Regards,
zzs
author
#5 lore raw

PATCH 1/1 let kbuild mkdir for dir/file.o

In reply to Michal Marek

When add a obj with dir to obj-y, like this

    obj-y += dir/file.o

The $(obj)/dir not created, this patch fix this.

When try to add a file(which in a subdir) to my board's obj-y, the build progress crashed.

For example, I use at91rm9200ek board, and in kernel dir run:

mkdir objtree
make O=objtree at91rm9200_defconfig
mkdir arch/arm/mach-at91/dir
touch arch/arm/mach-at91/dir/file.c

and edit arch/arm/mach-at91/dir/file.c to add some code. then edit arch/arm/mach-at91/Makefile, change the following line:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o

to:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o dir/file.o

Now build it:

make O=objtree

Then the error appears:
...

  CC      arch/arm/mach-at91/board-rm9200dk.o
  CC      arch/arm/mach-at91/board-rm9200ek.o
  CC      arch/arm/mach-at91/dir/file.o

linux-2.6/arch/arm/mach-at91/dir/file.c:5:
fatal error: opening dependency file arch/arm/mach-at91/dir/.file.o.d: No such file or directory

Check the objtree:
LANG=en ls objtree/arch/arm/mach-at91/dir
ls: cannot access objtree/arch/arm/mach-at91/dir: No such file or directory

It's apparently that the target dir not created for file.o

Check kbuild source code. It seems that kbuild create dirs for that in $(obj-dirs). But if the dir need not to create a built-in.o, It should never in $(obj-dirs).

So I make this patch to make sure It in $(obj-dirs)

this bug caused by commit
f5fb976520a53f45f8bbf2e851f16b3b5558d485

---
 scripts/Makefile.lib |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.lib +1 -1
index 51bb3de..cddd2c9 100644
@@ -63,7 +63,7 @@ multi-objs   := $(multi-objs-y) $(multi-objs-m)
 subdir-obj-y := $(filter %/built-in.o, $(obj-y))
 
 # $(obj-dirs) is a list of directories that contain object files
-obj-dirs := $(dir $(multi-objs) $(subdir-obj-y))
+obj-dirs := $(dir $(multi-objs) $(obj-y))
 
 # Replace multi-part objects by their individual parts, look at local dir only
 real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
Signature · 1 line
1.7.9.5
#6 lore raw

Dne 30.6.2013 11:09, 张忠山 napsal(a):

Quoted 48 lines

When add a obj with dir to obj-y, like this

    obj-y += dir/file.o

The $(obj)/dir not created, this patch fix this.

When try to add a file(which in a subdir) to my board's obj-y, the build progress crashed.

For example, I use at91rm9200ek board, and in kernel dir run:

mkdir objtree
make O=objtree at91rm9200_defconfig
mkdir arch/arm/mach-at91/dir
touch arch/arm/mach-at91/dir/file.c

and edit arch/arm/mach-at91/dir/file.c to add some code. then edit arch/arm/mach-at91/Makefile, change the following line:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o

to:

  obj-$(CONFIG_MACH_AT91RM9200EK) += board-rm9200ek.o dir/file.o

Now build it:

make O=objtree

Then the error appears:
...

  CC      arch/arm/mach-at91/board-rm9200dk.o
  CC      arch/arm/mach-at91/board-rm9200ek.o
  CC      arch/arm/mach-at91/dir/file.o

linux-2.6/arch/arm/mach-at91/dir/file.c:5:
fatal error: opening dependency file arch/arm/mach-at91/dir/.file.o.d: No such file or directory

Check the objtree:
LANG=en ls objtree/arch/arm/mach-at91/dir
ls: cannot access objtree/arch/arm/mach-at91/dir: No such file or directory

It's apparently that the target dir not created for file.o

Check kbuild source code. It seems that kbuild create dirs for that in $(obj-dirs). But if the dir need not to create a built-in.o, It should never in $(obj-dirs).

Quoted 5 lines

So I make this patch to make sure It in $(obj-dirs)

this bug caused by commit
f5fb976520a53f45f8bbf2e851f16b3b5558d485
---

You forgot to sign off this patch, can I add

like you did in the previous versions? Otherwise, the patch looks OK.

Michal

author
#7 lore raw
Quoted 5 lines
Quoted 4 lines

this bug caused by commit
f5fb976520a53f45f8bbf2e851f16b3b5558d485
---

Quoted 7 lines

You forgot to sign off this patch, can I add

like you did in the previous versions? Otherwise, the patch looks OK.

Michal

Of course, you can.

Signature · 2 lines
Best Regards,
zzs
author
#8 lore raw
In reply to 张忠山

Anybody review this path? Why no reply

Am i make a mistake or kbuild not need to make a dir for dir/file.o?

Signature · 2 lines
Best Regards,
zzs
#9 lore raw

Dne 14.6.2013 07:39, zzs napsal(a):

Quoted 3 lines

Anybody review this path? Why no reply

Am i make a mistake or kbuild not need to make a dir for dir/file.o?

The patch is probably fine, but I need to take a closer look. Sorry to keep you waiting.

Michal