Skip to contentSkip to conversation

sawman: Link using gcc instead of ld

PATCH New Vicente Olivert Riera 3 participants 7 messages Dec 6, 2013 – Dec 10, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sawman: Link using gcc instead of ld

Using ld may cause a link failure due to using the default emulation linker which is configured when building the linker in binutils. Using gcc instead will pass the appropriate -m value because the compiler knows the ABI you are using.

Here is an example of the failure:

ld: .libs/libdirectfbwm_sawman.a.tmp/sawman_wm.o: ABI is incompatible with that of the selected emulation
ld: failed to merge target specific data of file .libs/libdirectfbwm_sawman.a.tmp/sawman_wm.o
ld: Attempt to do relocatable link with elf64-tradbigmips input and elf32-tradbigmips output
ld: .libs/libdirectfbwm_sawman.a.tmp/sawman_wm.o: file class ELFCLASS64 incompatible with ELFCLASS32
ld: final link failed: File in wrong format

Fixes:

http://autobuild.buildroot.net/results/e4b/e4b77681a44626efa2a44627604630697e785086/

---
 .../sawman-001-link-using-gcc-instead-of-ld.patch  |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
 create mode 100644 package/sawman/sawman-001-link-using-gcc-instead-of-ld.patch
package/sawman/sawman-001-link-using-gcc-instead-of-ld.patch new file +20 -0
new file mode 100644
index 0000000..5472651
@@ -0,0 +1,20 @@
+sawman: Link using gcc instead of ld
+
+Using ld may cause a link failure due to using the default emulation
+linker which is configured when building the linker in binutils.  Using
+gcc instead will pass the appropriate -m value because the compiler 
+knows the ABI you are using.
+
+Signed-off-by: Vicente Olivert Riera <[email protected]>
+
+--- SaWMan-1.6.3/wm/sawman/Makefile.in.orig	2013-12-06 14:22:22.675409826 +0000
++++ SaWMan-1.6.3/wm/sawman/Makefile.in	2013-12-06 16:04:03.383752843 +0000
+@@ -622,7 +622,7 @@ uninstall-am: uninstall-wmDATA uninstall
+ 	if test -d $<.tmp; then rmdir $<.tmp; fi
+ 	mkdir $<.tmp
+ 	(cd $<.tmp && $(AR) x ../../$<)
+-	$(LD) -o $@ -r $<.tmp/*.o
++	$(CC) $(LDFLAGS) -nostdlib -o $@ -r $<.tmp/*.o
+ 	rm -f $<.tmp/*.o && rmdir $<.tmp
+ 
+ .PHONY: $(LTLIBRARIES:%.la=.libs/%.a)
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 sawman: Link using gcc instead of ld

Dear Vicente Olivert Riera,

Quoted 2 lines · Vicente Olivert Riera

+--- SaWMan-1.6.3/wm/sawman/Makefile.in.orig 2013-12-06 14:22:22.675409826 +0000
++++ SaWMan-1.6.3/wm/sawman/Makefile.in 2013-12-06 16:04:03.383752843 +0000

Makefile.in is generated from Makefile.am. So we shouldn't be fixing Makefile.in, but instead Makefile.am or the process that generates Makefile.in from Makefile.am.

What happens if you simply add:

SAWMAN_AUTORECONF = YES

?

Best regards,

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 sawman: Link using gcc instead of ld

Quoted 11 lines · Thomas Petazzoni

Dear Vicente Olivert Riera,

Quoted 2 lines · Vicente Olivert Riera

+--- SaWMan-1.6.3/wm/sawman/Makefile.in.orig 2013-12-06 14:22:22.675409826 +0000
++++ SaWMan-1.6.3/wm/sawman/Makefile.in 2013-12-06 16:04:03.383752843 +0000

Makefile.in is generated from Makefile.am. So we shouldn't be fixing Makefile.in, but instead Makefile.am or the process that generates Makefile.in from Makefile.am.

Quoted 5 lines

What happens if you simply add:

SAWMAN_AUTORECONF = YES

?

You still have the same problem.

Quoted 4 lines

Best regards,

Thomas

Signature · 1 line
Vincent
#3 lore raw

PATCH 1/1 sawman: Link using gcc instead of ld

Quoted 14 lines · Vicente Olivert Riera
Quoted 13 lines · Thomas Petazzoni

Dear Vicente Olivert Riera,

Quoted 4 lines · Vicente Olivert Riera

+--- SaWMan-1.6.3/wm/sawman/Makefile.in.orig 2013-12-06
14:22:22.675409826 +0000
++++ SaWMan-1.6.3/wm/sawman/Makefile.in 2013-12-06
16:04:03.383752843 +0000

Makefile.in is generated from Makefile.am. So we shouldn't be fixing Makefile.in, but instead Makefile.am or the process that generates Makefile.in from Makefile.am.

Quoted 14 lines
Quoted 5 lines

What happens if you simply add:

SAWMAN_AUTORECONF = YES

?

You still have the same problem.

Quoted 4 lines

Best regards,

Thomas

Adding:

LD = $(CC) -nostdlib

to Makefile.am and also:

SAWMAN_AUTORECONF = YES

to sawman.mk fixes the problem.

What do you think about this solution?

Signature · 1 line
Vincent
#4 lore raw

PATCH 1/1 sawman: Link using gcc instead of ld

Quoted 34 lines · Vicente Olivert Riera
Quoted 14 lines · Vicente Olivert Riera
Quoted 13 lines · Thomas Petazzoni

Dear Vicente Olivert Riera,

Quoted 4 lines · Vicente Olivert Riera

+--- SaWMan-1.6.3/wm/sawman/Makefile.in.orig 2013-12-06
14:22:22.675409826 +0000
++++ SaWMan-1.6.3/wm/sawman/Makefile.in 2013-12-06
16:04:03.383752843 +0000

Makefile.in is generated from Makefile.am. So we shouldn't be fixing Makefile.in, but instead Makefile.am or the process that generates Makefile.in from Makefile.am.

Quoted 14 lines
Quoted 5 lines

What happens if you simply add:

SAWMAN_AUTORECONF = YES

?

You still have the same problem.

Quoted 4 lines

Best regards,

Thomas

Adding:

LD = $(CC) -nostdlib

Quoted 8 lines

to Makefile.am and also:

SAWMAN_AUTORECONF = YES

to sawman.mk fixes the problem.

What do you think about this solution?

Yes this is preferred. You should patch configure.ac or Makefile.am (if they are available) and run autoreconf as suggested.

Signature · 1 line
markos
#5 lore raw

PATCH 1/1 sawman: Link using gcc instead of ld

Dear Markos Chandras,

Quoted 6 lines · Markos Chandras
Quoted 6 lines

Adding:

LD = $(CC) -nostdlib

to Makefile.am and also:

Quoted 8 lines
Quoted 5 lines

SAWMAN_AUTORECONF = YES

to sawman.mk fixes the problem.

What do you think about this solution?

Yes this is preferred. You should patch configure.ac or Makefile.am (if they are available) and run autoreconf as suggested.

I definitely agree that patching the Makefile.am and using <pkg>_AUTORECONF is the preferred way.

However, I find it weird that we need to add LD = $(CC) -nostdlib in the Makefile.am. There are plenty of other autotools-based packages that generate libraries, including private libraries, and they work just fine. Isn't there a better fix that can hopefully be upstreamed?

Best regards,

Thomas

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

PATCH 1/1 sawman: Link using gcc instead of ld

Quoted 22 lines · Thomas Petazzoni

Dear Markos Chandras,

Quoted 6 lines · Markos Chandras
Quoted 6 lines

Adding:

LD = $(CC) -nostdlib

to Makefile.am and also:

Quoted 8 lines
Quoted 5 lines

SAWMAN_AUTORECONF = YES

to sawman.mk fixes the problem.

What do you think about this solution?

Yes this is preferred. You should patch configure.ac or Makefile.am (if they are available) and run autoreconf as suggested.

I definitely agree that patching the Makefile.am and using <pkg>_AUTORECONF is the preferred way.

Quoted 9 lines

However, I find it weird that we need to add LD = $(CC) -nostdlib in the Makefile.am. There are plenty of other autotools-based packages that generate libraries, including private libraries, and they work just fine. Isn't there a better fix that can hopefully be upstreamed?

Best regards,

Thomas

Hi Thomas,

I am not familiar with the code. I haven't examined the Makefiles to be honest. A better fix would be to identify the direct use of $(LD) in the Makefile for linking and replace it with $(CC). I did something similar for directfb

http://git.buildroot.net/buildroot/tree/package/directfb/directfb-use-gcc-link.patch

Signature · 1 line
markos