Replacement for BUILD_BROKEN_PHONY and phony-rebuild in android R

578 views
Skip to first unread message

Sumit Kumar

unread,
Jul 29, 2020, 12:09:17 PM7/29/20
to Android Building
hi all,
    i am trying to build android R but getting the following error in the kernel makefile
       kernel/exynos/AndroidKernel.mk:155: error: writing to readonly directory: "/data/home/sumkumar/work/workspace/R/out/../out/target/product/**/obj/KERNEL_OBJ/arch/arm64/boot/Image"
    this was handled in Android Q by using the flag "BUILD_BROKEN_PHONY_TARGETS=true" but in R this is depreciated hence cannot use the same.

   after looking at following link given for phony rules changes from google for android R 

  i have updated my Makefile as follows by removing the "../" in the erronous path and past the previous error ,
  #KERNEL_OUT ?= $(if $(filter /% ~%,$(TARGET_OUT_INTERMEDIATES)),,$(realpath $(OUT_DIR))/../)$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
KERNEL_OUT ?= $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ

 but now i am getting errors with phony-rebuild as mentioned below
  kernel/exynos/AndroidKernel.mk:139: error: real file "out/target/product/**/obj/KERNEL_OBJ/.config" depends on PHONY target "phony-rebuild"
14:21:04 ckati failed with: exit status 1
  
  
  
   i understood as phony targets are always dirty hence every file will be rebuild which depends on that phony, but in my case this rebuilding is required .
  Attaching a snap of the file depicting the same

KERNEL_CONFIG := $(KERNEL_OUT)/.config

KERNEL_CONFIG := $(KERNEL_OUT)/.config

 

.PHONY: phony-rebuild

 

 

$(KERNEL_CONFIG): phony-rebuild

      $(show) echo "make $(KERNEL_DEFCONFIG)"

      $(MAKE_CONFIG_CMD)

      $(info  MAKE_CONFIG_CMD is $(MAKE_CONFIG_CMD)) 

  Please let me know if there is any way to avoid using phony-rebuild and replace it with an alternate mechanism.

Regards,

Dan Willemsen

unread,
Aug 10, 2020, 5:02:48 PM8/10/20
to Android Building
but in my case this rebuilding is required .

I think this is where we're disconnected. Forcing rebuilds means that incremental builds will nearly never be as fast as they should be, as the entire tree starting from that phony would need to be rebuilt even if you weren't touching anything related to the kernel. Instead, we'd much prefer that the rule depended on what it uses, so it'll only be re-executed when necessary. That list of dependencies may end up being a significant portion of the kernel tree, but that's still better than every build.

This also gets more important as we improve per-action sandboxing to get better incremental builds and remote execution / cross-machine caching of build actions. We're not there yet, but that's the direction we'd like to be heading.

- Dan 

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/786689cd-9816-454d-ba1f-bead4944ce3fo%40googlegroups.com.

احمد الطيب

unread,
Aug 11, 2020, 11:13:40 AM8/11/20
to android-...@googlegroups.com
II

تم الإرسال من هاتف Huawei الخاص بي


-------- الرسالة الأصلية --------
من:‏ 'Dan Willemsen' via Android Building <android-...@googlegroups.com>
التاريخ:‏ الثلاثاء، ١١ آب، ٢٠٢٠ ١٢:٠٢ ص
إلى:‏ Android Building <android-...@googlegroups.com>
الموضوع:‏ Re: [android-building] Replacement for BUILD_BROKEN_PHONY and phony-rebuild in android R

Sumit Kumar

unread,
Aug 11, 2020, 3:07:03 PM8/11/20
to Android Building
HI Dan, 
    Thank for the insight , i was able to get through the phony-rebuild with an alternate mechanism "KERNEL_CONFIG: $(shell find -L $(KERNEL_SRCDIR)" and the build is passing successfully the only issue now i am getting is because of the previous change 

#KERNEL_OUT ?= $(if $(filter /% ~%,$(TARGET_OUT_INTERMEDIATES)),,$(realpath $(OUT_DIR))/../)$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
KERNEL_OUT ?= $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ

all the kernel intermidiates are generated in kernel source  folder as we have removed the realpath $(OUT_DIR) from the equation , generating kernel intermidiates in kernel_source dir is not acceptable, i have tried all diffrent methods of pointing to the real "out/target/product/**"  but with out success,  , 
further please help me with the following querry

      The target is a real file, but it's outside the output directories. All outputs from the build system should be within the output directory, otherwise m clean is unable to clean the build, and future builds may not work properly.
:- Does this mean the path to the target file should start with "out"  because i am not getting readonly error only when the path is specified as out/target/product/**  as mentoined by KERNE_OUT above , but any other real path "/data/home/sumkumar/work/workspace/R/out/target/product/**/obj/KERNEL_OBJ/arch/arm64/boot/Image"  is leading to error thrown ?

Please sugget any alternative for this so that the kernel intermidiates are actually generated in the real out/target/product/**/obj/KERNEL_OBJ directory .

Regards,
Sumit Kumar

Dan Willemsen

unread,
Aug 11, 2020, 7:19:34 PM8/11/20
to Android Building
So the problem here is likely because it's mixing absolute and relative paths. All makefile rules (inputs and outputs) should be using $(OUT_DIR) as is (which is usually "out", but can be an absolute path if the user has changed it). So this would be appropriate:

KERNEL_OUT ?= $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ

But then the rule itself is likely expecting to use that path as an absolute path, since the kernel build system likely uses `cd` to change into a different path, where the relative path is no longer correct. The best solution is to expand it inside those rules, as it keeps absolute paths out of the ninja file (which can preserve the ability to diff between checkouts, and allows moving the source directory without requiring rebuilding everything). This doc section has an example, but it's essentially something like:

$(KERNEL_OUT)/arch/.../zImage: PRIVATE_SRCDIR := $(KERNEL_SRCDIR)
$(KERNEL_OUT)/arch/.../zImage: PRIVATE_OUT := $(KERNEL_OUT)
$(KERNEL_OUT)/arch/.../zImage: $(KERNEL_CONFIG) $(sort $(shell find -L $(KERNEL_SRCDIR) -type f))
    $(MAKE) -C $(PRIVATE_SRCDIR) O=$$(cd $(PRIVATE_OUT); pwd) ...


(If you can guarantee that nothing later in the build will change KERNEL_SRCDIR/KERNEL_OUT, then you wouldn't need to use the PRIVATE_* indirection, but it's generally a good idea to do so to prevent issues in the future)

- Dan

Sumit Kumar

unread,
Aug 18, 2020, 10:29:22 AM8/18/20
to Android Building
Thanks Dan for the descriptive answer, this helped alot in solving the issue.

Regards,
Sumit Kumar 
Reply all
Reply to author
Forward
0 new messages