Skip to contentSkip to conversation

ustr: Makefile fixes for link failures

PATCH New Clayton Shotwell 2 participants 4 messages May 25, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ustr: Makefile fixes for link failures

The ustr package is failing sometimes in the autobuilder at a target install link step. This is an attempt to fix the issue by not allowing make to ignore a failed remove call to remove the link before it is created.

http://autobuild.buildroot.org/results/9e1/9e13c9779a84312bcb094604acfa6ec626697aa7
http://autobuild.buildroot.org/results/ceb/cebfd7e29a6521ae7ba4c229586a3ef662aa9de1

---
 package/ustr/0001-Makefile-force-removes.patch | 39 ++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 package/ustr/0001-Makefile-force-removes.patch
package/ustr/0001-Makefile-force-removes.patch new file +39 -0
new file mode 100644
index 0000000..f244ca7
@@ -0,0 +1,39 @@
+Allowing the makefile to ignore remove failures is masking an issues on some
+builds that causes the subsequent link call to fail. This patch makes the
+remove a required step in an attempt to uncover the real issue. Either way
+the removes should be required since they should never fail with the -f flag.
+
+Signed-off-by: Clayton Shotwell <[email protected]>
+
+--- a/Makefile.in	2016-05-23 08:46:46.337481574 -0500
++++ b/Makefile.in	2016-05-23 08:45:12.327380457 -0500
+@@ -425,11 +425,11 @@
+ 		@echo Installing files
+ 		install -m 644 -t $(DESTDIR)$(libdir) $(OPT_LIB_STATIC)
+ 		install -m 755 -t $(DESTDIR)$(libdir) $(OPT_LIB_SHARED)
+-		-rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)
++		rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)
+ 		ln -s $(OPT_LIB_SHARED) $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)
+-		-rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV)
++		rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV)
+ 		ln -s $(OPT_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV)
+-		-rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV_BSO)
++		rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV_BSO)
+ 		ln -s $(OPT_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV_BSO)
+ 		$(LDCONFIG) -n $(DESTDIR)$(libdir)
+ 		install -pm 644 -t $(DESTDIR)$(libdir)/pkgconfig ustr.pc
+@@ -438,11 +438,11 @@
+ 		@echo Installing files
+ 		install -m 644 -t $(DESTDIR)$(libdir) $(DBG_LIB_STATIC)
+ 		install -m 755 -t $(DESTDIR)$(libdir) $(DBG_LIB_SHARED)
+-		-rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHARED_NAME)
++		rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHARED_NAME)
+ 		ln -s $(DBG_LIB_SHARED) $(DESTDIR)$(libdir)/$(DBG_LIB_SHARED_NAME)
+-		-rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV)
++		rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV)
+ 		ln -s $(DBG_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV)
+-		-rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV_BSO)
++		rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV_BSO)
+ 		ln -s $(DBG_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV_BSO)
+ 		$(LDCONFIG) -n $(DESTDIR)$(libdir)
+ 		install -pm 644 -t $(DESTDIR)$(libdir)/pkgconfig ustr-debug.pc
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 ustr: Makefile fixes for link failures

Hello,

package/ustr/0001-Makefile-force-removes.patch line 15

Quoted 8 lines · Clayton Shotwell

+--- a/Makefile.in 2016-05-23 08:46:46.337481574 -0500
++++ b/Makefile.in 2016-05-23 08:45:12.327380457 -0500
+@@ -425,11 +425,11 @@

package/ustr/0001-Makefile-force-removes.patch new file +5 -0
+ 		@echo Installing files
+ 		install -m 644 -t $(DESTDIR)$(libdir) $(OPT_LIB_STATIC)
+ 		install -m 755 -t $(DESTDIR)$(libdir) $(OPT_LIB_SHARED)
+-		-rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)
++		rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)

Just changing this cannot fix the failures. The "-" at the beginning of the line is not about whether is mandatory or not, it is about ignoring the return value or not.

Normally, make aborts as soon as one command returns a non-zero value. When you prefix the command with "-", it will ignore the return value and continue executing the rest.

But like you said, since the command is "rm -f", it returns 0 regardless of whether the file to be removed existed or not, or if the removal was possible or not.

Hence, I believe your patch is a no-op and cannot fix the original problem.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 ustr: Makefile fixes for link failures

Thomas,

Quoted 21 lines · Thomas Petazzoni

Hello,

package/ustr/0001-Makefile-force-removes.patch line 15

Quoted 8 lines · Clayton Shotwell
+--- a/Makefile.in    2016-05-23 08:46:46.337481574 -0500
++++ b/Makefile.in    2016-05-23 08:45:12.327380457 -0500

+@@ -425,11 +425,11 @@

package/ustr/0001-Makefile-force-removes.patch new file +5 -0
+             @echo Installing files
+             install -m 644 -t $(DESTDIR)$(libdir) $(OPT_LIB_STATIC)
+             install -m 755 -t $(DESTDIR)$(libdir) $(OPT_LIB_SHARED)
+-            -rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)
++            rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)

Just changing this cannot fix the failures. The "-" at the beginning of the line is not about whether is mandatory or not, it is about ignoring the return value or not.

Normally, make aborts as soon as one command returns a non-zero value. When you prefix the command with "-", it will ignore the return value and continue executing the rest.

Quoted 6 lines

But like you said, since the command is "rm -f", it returns 0 regardless of whether the file to be removed existed or not, or if the removal was possible or not.

Hence, I believe your patch is a no-op and cannot fix the original problem.

I completely agree with your assessment but I am unfortunately out of ideas on what could be causing the build failures.

Thanks,
Clayton

Clayton Shotwell
Senior Software Engineer, Rockwell Collins
clayton.shotwell at rockwellcollins.com

#3 lore raw

PATCH 1/1 ustr: Makefile fixes for link failures

Hello,

Quoted 2 lines · Clayton Shotwell

I completely agree with your assessment but I am unfortunately out of ideas on what could be causing the build failures.

Inspecting the log and looking at the makefile, I believe I have a possible interpretation.

Here is the relevant part of the Makefile:

"""
install: install-opt install-dbg

install-opt: install-dirs install-opt-lib install-common

install-dbg: install-dirs install-dbg-lib install-common

install-opt-lib: $(OPT_LIB_STATIC) $(OPT_LIB_SHARED) ustr.pc

                @echo Installing files
                install -m 644 -t $(DESTDIR)$(libdir) $(OPT_LIB_STATIC)
                install -m 755 -t $(DESTDIR)$(libdir) $(OPT_LIB_SHARED)
                -rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)
                ln -s $(OPT_LIB_SHARED) $(DESTDIR)$(libdir)/$(OPT_LIB_SHARED_NAME)
                -rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV)
                ln -s $(OPT_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV)
                -rm -f $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV_BSO)
                ln -s $(OPT_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(OPT_LIB_SHAREDEV_BSO)
                $(LDCONFIG) -n $(DESTDIR)$(libdir)
                install -pm 644 -t $(DESTDIR)$(libdir)/pkgconfig ustr.pc

install-dbg-lib: $(DBG_LIB_STATIC) $(DBG_LIB_SHARED) ustr-debug.pc

                @echo Installing files
                install -m 644 -t $(DESTDIR)$(libdir) $(DBG_LIB_STATIC)
                install -m 755 -t $(DESTDIR)$(libdir) $(DBG_LIB_SHARED)
                -rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHARED_NAME)
                ln -s $(DBG_LIB_SHARED) $(DESTDIR)$(libdir)/$(DBG_LIB_SHARED_NAME)
                -rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV)
                ln -s $(DBG_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV)
                -rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV_BSO)
                ln -s $(DBG_LIB_SHARED_NAME) $(DESTDIR)$(libdir)/$(DBG_LIB_SHAREDEV_BSO)
                $(LDCONFIG) -n $(DESTDIR)$(libdir)
                install -pm 644 -t $(DESTDIR)$(libdir)/pkgconfig ustr-debug.pc

"""

Since install-opt-lib and install-dbg-lib don't have any dependency on each other, they can execute concurrently.

What is important to realize is that $(LDCONFIG) -n $(DESTDIR)$(libdir) will create the symbolic links to the libraries if they don't exist. So, if you have the following sequence of step:

[1] The install-dbg-lib installs its libraries and removes its

     symbolic link:

     install -m 644 -t $(DESTDIR)$(libdir) $(DBG_LIB_STATIC)
     install -m 755 -t $(DESTDIR)$(libdir) $(DBG_LIB_SHARED)
     -rm -f $(DESTDIR)$(libdir)/$(DBG_LIB_SHARED_NAME)

[2] The install-opt-lib runs its LDCONFIG

     $(LDCONFIG) -n $(DESTDIR)$(libdir)

[3] The install-dbg-lib continues its work and creates symlinks:

     ln -s $(DBG_LIB_SHARED) $(DESTDIR)$(libdir)/$(DBG_LIB_SHARED_NAME)

Then, when [3] will run, the symbolic link will already have been created by step [2], and [3] will therefore fail. Of course, there is only a very short window of time between the "rm" and the "ln", but it might be sufficient for the ldconfig to create the symbolic link during this, causing the failure.

Possible solutions:

(1) Get rid of ldconfig by passing LDCONFIG=/bin/true in the environment. Probably the easiest.

(2) Add -f in the option to ln to not fail if the link already exists.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com