Skip to contentSkip to conversation

Don't add symlink in srctree when using an objtree

PATCH Superseded Loïc Minier 3 participants 4 messages Dec 5, 2010 – Jan 3, 2011 1 message not in the archive Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't add symlink in srctree when using an objtree

When building with srctree != objtree, the build creates arch/soc/cpu specific symlinks in the source tree. This means that the same source tree can't be used for multiple builds at the same time. Also, these symlinks in the source tree are only cleaned up if one passes the same O= to distclean.

When srctree != objtree, mkconfig creates an $objtree/include2 directory in the objtree to host the asm -> arch/$arch/include/asm symlink so that "#include <asm>" can be used. But it also creates another identical symlink in $objtree/include.

Then, mkconfig creates two symlinks:
$objtree/include/asm/arch -> arch/$arch/include/asm/arch-$cpu (or $soc) $objtree/include/asm/proc -> arch/$arch/include/asm/proc-armv (on arm) but because $objtree/include/asm points at $srctree already, the two symlinks are created under $srctree.

To fix this, create a real $objtree/include/asm directory, instead of a symlink. Update cleanup code accordingly.

---
 Makefile |    4 +++-
 mkconfig |    3 +--
 2 files changed, 4 insertions(+), 3 deletions(-)
Makefile +3 -1
index 87a383d..8a3f3e0 100644
@@ -1246,7 +1246,9 @@ clobber:	clean
 	@rm -f $(obj)u-boot.imx
 	@rm -f $(obj)tools/{env/crc32.c,inca-swap-bytes}
 	@rm -f $(obj)arch/powerpc/cpu/mpc824x/bedbug_603e.c
-	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
+	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch
+	@[ ! -h $(obj)include/asm ] || rm -f $(obj)include/asm
+	@[ ! -d $(obj)include/asm ] || rmdir $(obj)include/asm
 	@rm -fr $(obj)include/generated
 	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
 	@[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type l -print | xargs rm -f
mkconfig +1 -2
index 2fda1d4..1408b53 100755
@@ -98,8 +98,7 @@ if [ "$SRCTREE" != "$OBJTREE" ] ; then
 	ln -s ${SRCTREE}/arch/${arch}/include/asm asm
 	LNPREFIX=${SRCTREE}/arch/${arch}/include/asm/
 	cd ../include
-	rm -f asm
-	ln -s ${SRCTREE}/arch/${arch}/include/asm asm
+	mkdir -p asm
 else
 	cd ./include
 	rm -f asm
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/1 Don't add symlink in srctree when using an objtree

Dear =?UTF-8?q?Lo=C3=AFc=20Minier?=,

Quoted 11 lines · In message <[email protected]> you wrote:

When building with srctree != objtree, the build creates arch/soc/cpu specific symlinks in the source tree. This means that the same source tree can't be used for multiple builds at the same time. Also, these symlinks in the source tree are only cleaned up if one passes the same O= to distclean.

When srctree != objtree, mkconfig creates an $objtree/include2 directory in the objtree to host the asm -> arch/$arch/include/asm symlink so that "#include <asm>" can be used. But it also creates another identical symlink in $objtree/include.

Quoted 8 lines

Then, mkconfig creates two symlinks:
$objtree/include/asm/arch -> arch/$arch/include/asm/arch-$cpu (or $soc) $objtree/include/asm/proc -> arch/$arch/include/asm/proc-armv (on arm) but because $objtree/include/asm points at $srctree already, the two symlinks are created under $srctree.

To fix this, create a real $objtree/include/asm directory, instead of a symlink. Update cleanup code accordingly.

Thanks for the fix. A tiny change request, though:

Makefile clobber: clean · line 1251

Quoted 4 lines
Makefile +3 -1
-	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
+	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch
+	@[ ! -h $(obj)include/asm ] || rm -f $(obj)include/asm
+	@[ ! -d $(obj)include/asm ] || rmdir $(obj)include/asm

Don't make it that complicated. Just change the line into

	@rm -fr$(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm

Also a question: how has this change been tested?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
A girl with a future avoids the man with a past.
                                   -- Evan Esar, "The Humor of Humor"

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw

PATCH 1/1 Don't add symlink in srctree when using an objtree

Quoted 8 lines · Wolfgang Denk

Thanks for the fix. A tiny change request, though:

Makefile clobber: clean · line 1251

Quoted 4 lines
Makefile +3 -1
-	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
+	@rm -f $(obj)include/asm/proc $(obj)include/asm/arch
+	@[ ! -h $(obj)include/asm ] || rm -f $(obj)include/asm
+	@[ ! -d $(obj)include/asm ] || rmdir $(obj)include/asm

Don't make it that complicated. Just change the line into

	@rm -fr$(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm

I think I had this in my first version, but had an issue with it; I will retest

Quoted 1 line

Also a question: how has this change been tested?

I did something like:
a) start fresh:
git clean -x -d
b) configure with or without objdir
make CROSS_COMPILE=arm-linux-gnueabi- O=$PWD/obj omap3_beagle_config
c) build (with or without objdir)
d) distclean (with or without objdir)

and tested combinations like a-d-d, a-b-d-d, a-b-c-d-d, then checked whether any file remained with git clean -x -d -n

Signature · 1 line
Lo?c Minier
#4 lore raw

PATCH 1/1 Don't add symlink in srctree when using an objtree

Quoted 4 lines · Lo?c Minier
Quoted 2 lines

Don't make it that complicated. Just change the line into

	@rm -fr$(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm

I think I had this in my first version, but had an issue with it; I will retest

This works just fine and is much simpler; thanks. I will send an updated patch to use this

Quoted 1 line
Quoted 1 line

Also a question: how has this change been tested?

I'm attaching a test script which, starting from a clean tree, will try to distclean, to configure + distclean, and finally to configure + build + distclean. It tries both with and without an objdir in all make calls, and checks whether the tree is really clean with:
git clean -d -x -n.

This script uncovered another issue with .boards.depend which was not cleaned up by distclean O=foo because it's created in the srctree.

I will send a separate patch for this issue as well.

Signature · 60 lines
Lo?c Minier
-------------- next part --------------
#!/bin/sh

set -e

self="$(basename "$0")"

do_make() {
    make CROSS_COMPILE=arm-linux-gnueabi- "$@"
}

distclean() {
    do_make distclean "$@"
}

config() {
    do_make omap3_beagle_config "$@"
}

build() {
    do_make -j2 "$@"
}

check_clean() {
    clean_output="$(git clean -x -d -n "$@" 2>&1)"
    if [ -n "$clean_output" ]; then
        echo "Expected a clean tree but got: $clean_output" >&2
        exit 1
    fi
}

objdir=""
cleanup() {
    if [ -n "$objdir" ]; then
        rm -rf "$objdir"
    fi
}
trap "cleanup" 0 1 2 3 9 11 13 15

objdir="$(mktemp -dt)"

# this will stop the test if the tree isn't clean to start with
check_clean

for with_objdir in yes no; do
    echo "I: objdir: $with_objdir" >&2
    for seq in "distclean" "config distclean" "config build distclean"; do
        echo "I: sequence: $seq" >&2
        for step in $seq; do
            echo "I: step: $step" >&2
            if [ "$with_objdir" = yes ]; then
                $step "O=$objdir" >/dev/null 2>&1
            else
                $step >/dev/null 2>&1
            fi
        done
        check_clean
    done
done