Bug 5750

Summary: Doing a Buildroot build from /usr doesn't work
Product: buildroot Reporter: rdghx <rdghx>
Component: OtherAssignee: Thomas De Schampheleire <patrickdepinguin>
Status: RESOLVED FIXED    
Severity: major CC: antoine.pierlot-garcin, benstoltz, buildroot, patrickdepinguin
Priority: P5    
Version: unspecified   
Target Milestone: 2014.08   
Hardware: Other   
OS: Linux   
Host: Target:
Build:
Attachments: config file
Patch file
alternative patch

Description rdghx 2012-12-04 23:55:01 UTC
Created attachment 4670 [details]
config file

CC     Sync.lo
  CC     Synchro.lo
  CC     Text16.lo
  CC     Text.lo
  CC     TextExt16.lo
  CC     TextExt.lo
  CC     TextToStr.lo
  CC     TrCoords.lo
  CC     UndefCurs.lo
  CC     UngrabBut.lo
  CC     UngrabKbd.lo
  CC     UngrabKey.lo
  CC     UngrabPtr.lo
  CC     UngrabSvr.lo
  CC     UninsCmap.lo
  CC     UnldFont.lo
  CC     UnmapSubs.lo
  CC     UnmapWin.lo
  CC     VisUtil.lo
  CC     WarpPtr.lo
  CC     Window.lo
  CC     WinEvent.lo
  CC     Withdraw.lo
  CC     WMGeom.lo
  CC     WMProps.lo
  CC     WrBitF.lo
  CC     xcb_disp.lo
  CC     xcb_io.lo
  CC     XlibAsync.lo
  CC     XlibInt.lo
  CC     Xrm.lo
XlibInt.c: In function '_XPrintDefaultError':
XlibInt.c:1433:5: warning: format not a string literal, argument types not checked
XlibInt.c:1453:2: warning: format not a string literal, argument types not checked
XlibInt.c:1485:6: warning: format not a string literal, argument types not checked
XlibInt.c:1513:2: warning: format not a string literal, argument types not checked
XlibInt.c:1519:5: warning: format not a string literal, argument types not checked
XlibInt.c:1523:5: warning: format not a string literal, argument types not checked
  CC     x11_xcb.lo
  CCLD   libX11.la
libtool: link: warning: library `/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libxcb.la' was moved.
/bin/grep: /usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libXau.la: No such file or directory
/bin/sed: can't read /usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libXau.la: No such file or directory
libtool: link: `/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/work/buildroot/buildroot-2012.11/output/host/usr/arm-buildroot-linux-gnueabi/sysroot/usr/lib/libXau.la' is not a valid libtool archive
make[4]: *** [libX11.la] Error 1
make[4]: Leaving directory `/usr/work/buildroot/buildroot-2012.11/output/build/xlib_libX11-1.4.2/src'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/usr/work/buildroot/buildroot-2012.11/output/build/xlib_libX11-1.4.2/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/usr/work/buildroot/buildroot-2012.11/output/build/xlib_libX11-1.4.2/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/work/buildroot/buildroot-2012.11/output/build/xlib_libX11-1.4.2'
make: *** [/usr/work/buildroot/buildroot-2012.11/output/build/xlib_libX11-1.4.2/.stamp_built] Error 2
Comment 1 Thomas Petazzoni 2012-12-05 07:59:54 UTC
For some complicated reason, using Buildroot in a directory stored under /usr doesn't work. We will work on fixing that, but in the mean time, please build from /home/something, /opt or anything else, but not from a subdirectory of /usr.
Comment 2 Thomas Petazzoni 2013-05-26 11:01:51 UTC
*** Bug 5222 has been marked as a duplicate of this bug. ***
Comment 3 Thomas Petazzoni 2013-05-26 14:23:16 UTC
*** Bug 5228 has been marked as a duplicate of this bug. ***
Comment 4 Thomas Petazzoni 2014-02-13 13:10:24 UTC
*** Bug 6470 has been marked as a duplicate of this bug. ***
Comment 5 Antoine Pierlot-Garcin 2014-05-13 15:56:57 UTC
*** Bug 7082 has been marked as a duplicate of this bug. ***
Comment 6 Thomas De Schampheleire 2014-05-14 07:57:38 UTC
During the 2014.02 stabilization cycle, I started looking into this bug.
See some info here: http://lists.busybox.net/pipermail/buildroot/2014-February/089291.html

After that I didn't continue further, yet, but my plan is to take this up again and hopefully close the bug by 2014.08.
Comment 7 Ben Stoltz 2014-05-15 17:31:12 UTC
This fixes the problem for me.

Ben Stoltz <benstoltz@gmail.com>

diff --git a/package/pkg-autotools.mk b/package/pkg-autotools.mk
index a66ecd4..74c90dd 100644
--- a/package/pkg-autotools.mk
+++ b/package/pkg-autotools.mk
@@ -249,8 +249,12 @@ ifndef $(2)_INSTALL_STAGING_CMDS
 define $(2)_INSTALL_STAGING_CMDS
 	$$(TARGET_MAKE_ENV) $$($$(PKG)_MAKE_ENV) $$($$(PKG)_MAKE) $$($$(PKG)_INSTALL_STAGING_OPT) -C $$($$(PKG)_SRCDIR)
 	for i in $$$$(find $(STAGING_DIR)/usr/lib* -name "*.la"); do \
-		cp -f $$$$i $$$$i~; \
-		$$(SED) "s:\(['= ]\)/usr:\\1$(STAGING_DIR)/usr:g" $$$$i; \
+		cp -n $$$$i $$$$i~; \
+		$$(SED) "s,$(BASE_DIR),@BASE_DIR@,g" \
+			-e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \
+			-e "s,@STAGING_DIR@,$(STAGING_DIR),g" \
+			-e "s,@BASE_DIR@,$(BASE_DIR),g" \
+			$$$$i; \
 	done
 endef
 endif
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 1b99c2a..af3675a 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -195,9 +195,12 @@ $(BUILD_DIR)/%/.stamp_staging_installed:
 	$(foreach hook,$($(PKG)_POST_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep))
 	$(Q)if test -n "$($(PKG)_CONFIG_SCRIPTS)" ; then \
 		$(call MESSAGE,"Fixing package configuration files") ;\
-			$(SED)  "s,^\(exec_\)\?prefix=.*,\1prefix=$(STAGING_DIR)/usr,g" \
-				-e "s,-I/usr/,-I$(STAGING_DIR)/usr/,g" \
-				-e "s,-L/usr/,-L$(STAGING_DIR)/usr/,g" \
+			$(SED)  's,$(BASE_DIR),@BASE_DIR@,g' \
+				-e "s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
+				-e "s,-I/usr/,-I@STAGING_DIR@/usr/,g" \
+				-e "s,-L/usr/,-L@STAGING_DIR@/usr/,g" \
+				-e 's,@STAGING_DIR@,$(STAGING_DIR),g' \
+				-e 's,@BASE_DIR@,$(BASE_DIR),g' \
 				$(addprefix $(STAGING_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ;\
 	fi
 	$(Q)touch $@
diff --git a/package/pkgconf/pkgconf.mk b/package/pkgconf/pkgconf.mk
index f3f6526..536c967 100644
--- a/package/pkgconf/pkgconf.mk
+++ b/package/pkgconf/pkgconf.mk
@@ -19,8 +19,10 @@ endef
 define HOST_PKGCONF_INSTALL_WRAPPER
 	$(INSTALL) -m 0755 -D package/pkgconf/pkg-config.in \
 		$(HOST_DIR)/usr/bin/pkg-config
-	$(SED) 's,@PKG_CONFIG_LIBDIR@,$(STAGING_DIR)/usr/lib/pkgconfig:$(STAGING_DIR)/usr/share/pkgconfig,' \
-		-e 's,@STAGING_DIR@,$(STAGING_DIR),' \
+	$(SED)  's,$(BASE_DIR),@BASE_DIR@,g' \
+		-e 's,@PKG_CONFIG_LIBDIR@,@STAGING_DIR@/usr/lib/pkgconfig:@STAGING_DIR@/usr/share/pkgconfig,' \
+		-e 's,@STAGING_DIR@,$(STAGING_DIR),g' \
+		-e 's,@BASE_DIR@,$(BASE_DIR),g' \
 		$(HOST_DIR)/usr/bin/pkg-config
 endef
Comment 8 Thomas De Schampheleire 2014-05-15 19:18:48 UTC
(In reply to comment #7)
> This fixes the problem for me.

Thanks, I will definitely test this out!
Comment 9 Ben Stoltz 2014-05-15 20:05:53 UTC
Created attachment 5384 [details]
Patch file

Cut and paste errors at end of line on previous submission.
Comment 10 Thomas De Schampheleire 2014-06-14 19:43:00 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > This fixes the problem for me.
> 
> Thanks, I will definitely test this out!

It seems that the result is similar to the patch I was using until now (attached). It works fine too, but if you grep in output/staging you will find still occurrences of /usr/path/to/buildroot/.../sysroot/usr/path/to/buildroot, caused by pkgconfig, as mentioned in http://lists.busybox.net/pipermail/buildroot/2014-February/089866.html.
While this seems to do no harm, I intend to track down this issue further.
Comment 11 Thomas De Schampheleire 2014-06-14 19:43:43 UTC
Created attachment 5450 [details]
alternative patch
Comment 12 Thomas De Schampheleire 2014-06-20 19:14:07 UTC
Patches fixing this issue submitted at:
http://patchwork.ozlabs.org/patch/362322/
http://patchwork.ozlabs.org/patch/362324/
http://patchwork.ozlabs.org/patch/362323/
Comment 14 Thomas Petazzoni 2014-06-29 13:19:56 UTC
(In reply to comment #13)

> Hooray for closing this very old bug!

Yes, thanks a _lot_ for working on this problem!