[uClibc] [buildroot] Strange error when STAGING_DIR already exists

Thomas Petazzoni thomas.petazzoni at enix.org
Thu Sep 16 07:47:28 UTC 2004


Hello,

Yesterday, I tried to change the default STAGING_DIR (inside the main
Makefile), to generate the cross-compilation toolchain in a separate
directory, so that other users can use it. (If you just copy
build_*/staging_dir/ somewhere else, it won't work, because gcc will be
compiled to search files in your $HOME directory).

But when I did that, compilation failed during compilation of ldd (in
uClibc/utils), because ld couldn't find crt1.o. After some search, I
discovered that gcc tells ld that crt1.o is in the current directory,
which isn't true. And gcc -print-file-name=crt1.o returns "crt1.o"
instead of "/the/path/to/the/tool/chain/lib/crt1.o". Something was wrong
...

It took me a couple of hours, and after many discussions with Manuel
Novoa to find the problem. If the STAGING_DIR (for example
/opt/something/) already exists, then it will fail. If STAGING_DIR
doesn't exist, it will be OK.

In my opinion, this is something that may happen to other buildroot
users, and which is quite annoying (a big waste of time). I think a fix
should be made to avoid this.

The problem is in the $(STAGING_DIR) target at the very bottom of the
Makefile :

$(STAGING_DIR):
        rm -rf $(STAGING_DIR)
        mkdir -p $(STAGING_DIR)/lib
        mkdir -p $(STAGING_DIR)/include
        mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
        ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib

If STAGING_DIR already exists, then the rules aren't executed, and
subdirs and symlinks won't be created. I think this Makefile rule is
wrong : the rules not only create the target, but also other things
inside the target. I think rules should limit to actions that allow to
create the target, nothing more.

I'm not a Makefile expert, but maybe something like

setup_staging_dir: $(STAGING_DIR)
        mkdir -p $(STAGING_DIR)/lib
        mkdir -p $(STAGING_DIR)/include
        mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
        ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib

$(STAGING_DIR):
	rm -rf $(STAGING_DIR)
	mkdir -p $(STAGING_DIR)

would make sure everything is created inside the STAGING_DIR.

What do you think about it ?

BTW, Manuel, did you had time to look at my patch concerning libstdc++
installation inside the root filesystem ?

Thanks,

Thomas
-- 
PETAZZONI Thomas - thomas.petazzoni at enix.org 
http://thomas.enix.org - Jabber: kos_tom at sourcecode.de
KOS: http://kos.enix.org/ - Lolut: http://lolut.utbm.info
Fingerprint : 0BE1 4CF3 CEA4 AC9D CC6E  1624 F653 CB30 98D3 F7A7



More information about the uClibc mailing list