diff mbox

[OpenWrt-Devel] kirkwood gcc/binutils woe?

Message ID 20141213212814.GC43547@nwf.oc.ietfng.org
State RFC
Headers show

Commit Message

nwf Dec. 13, 2014, 9:28 p.m. UTC
On Wed, Dec 10, 2014 at 10:12:53PM +0100, Harald Geyer wrote:
> Hi!
> 
> I ran into the same issue just a few days ago on mxs. Probably most,
> if not all arm targets are affected.

Applying your patch does, indeed, get me a little closer to a working
compiler.  However, when I run

$ gcc -v -o hello hello.c
[...]
 /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/collect2 --eh-frame-hdr -dynamic-linker /lib/ld-uClibc.so.0 -X -m armelf_linux_eabi -o hello /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crt1.o /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crti.o /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtbegin.o -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3 -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../.. /tmp/ccjOqw9X.o -lgcc_s -lc -lgcc_s /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtend.o /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtn.o
/usr/bin/ld: cannot find -lgcc
collect2: error: ld returned 1 exit status

Well, yes, that's true...

$ find / -name \*libgcc\*
/lib/libgcc_s.so.1
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so.1
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc.map
/usr/lib/opkg/info/libgcc.list
/usr/lib/opkg/info/libgcc.control

Grepping about at random I find that
/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so contains the
directive 

> GROUP ( libgcc_s.so.1 -lgcc )

So I think the desire to save space expressed in
feeds/packages/devel/gcc/README is well-intentioned but possibly stale, so
maybe the following, too?  Maybe we should be removing libgcc_pic.a but not
libgcc.a?



Thanks for your help so far!
--nwf;
 
> nwf writes:
> > > root@OpenWrt:/tmp# gcc -o hello hello.c 
> > > /usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi
> > > Supported emulations: armelf_linux armelf armelfb armelfb_linux
> > > collect2: error: ld returned 1 exit status
> > 
> > And I'm really not sure what that means or what to do about it.
> 
> Looks like binutils is built for OABI while gcc is built for EABI.
> Since at least mxs is actually using EABI I think gcc is right and
> binutils is wrong.
> 
> Try if the following patch solves the problem. (Don't have my test
> board around right now.)
> 
> diff --git a/package/devel/binutils/Makefile b/package/devel/binutils/Makefile
> index ff968b9..4aefeca 100644
> --- a/package/devel/binutils/Makefile
> +++ b/package/devel/binutils/Makefile
> @@ -48,6 +48,8 @@ endef
>  TARGET_CFLAGS += $(FPIC) -Wno-unused-value
> 
>  CONFIGURE_ARGS += \
> +	--host=$(REAL_GNU_TARGET_NAME) \
> +	--target=$(REAL_GNU_TARGET_NAME) \
>  	--enable-shared \
>  	--enable-install-libiberty \
>  	--enable-install-libbfd
> 
> HTH,
> Harald

Comments

Harald Geyer Dec. 14, 2014, 11:02 a.m. UTC | #1
nwf writes:
> $ gcc -v -o hello hello.c [...]
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/collect2
> --eh-frame-hdr -dynamic-linker /lib/ld-uClibc.so.0
> -X -m armelf_linux_eabi -o hello
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crt1.o
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crti.o
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtbegin.o
> -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3
> -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../..
> /tmp/ccjOqw9X.o -lgcc_s -lc -lgcc_s
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtend.o
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtn.o /usr/bin/ld:
> cannot find -lgcc collect2: error: ld returned 1 exit status
> 
> Well, yes, that's true...
> 
> $ find / -name \*libgcc\* /lib/libgcc_s.so.1
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so.1
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc.map
> /usr/lib/opkg/info/libgcc.list /usr/lib/opkg/info/libgcc.control
> 
> Grepping about at random I find that
> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so contains
> the directive
> 
> > GROUP ( libgcc_s.so.1 -lgcc )

Actually citing libgcc_s.so in full makes things a bit clearer:
$ cat libgcc_s.so
/* GNU ld script
   Use the shared library, but some functions are only in
   the static library.  */
GROUP ( libgcc_s.so.1 -lgcc )

> So I think the desire to save space expressed in
> feeds/packages/devel/gcc/README is well-intentioned but possibly stale,
> so maybe the following, too? Maybe we should be removing libgcc_pic.a
> but not libgcc.a?

Seems reasonable. Since gcc seems to work for Christian as is, this
might be architecture dependent. Christian, any insight on this?

As far as binutils is concerned the patch below seems to work as expected,
so I can now add my
Signed-off-by: Harald Geyer <harald@ccbib.org>

Felix, can you take this as is or should I resend the patch?

Thanks,
Harald

>> diff --git a/package/devel/binutils/Makefile b/package/devel/binutils/Makefile 
>> index ff968b9..4aefeca 100644
>> --- a/package/devel/binutils/Makefile
>> +++ b/package/devel/binutils/Makefile
>> @@ -48,6 +48,8 @@ endef
>>  TARGET_CFLAGS += $(FPIC) -Wno-unused-value
>>
>>  CONFIGURE_ARGS += \
>> +	--host=$(REAL_GNU_TARGET_NAME) \
>> +	--target=$(REAL_GNU_TARGET_NAME) \
>>  	--enable-shared \
>>  	--enable-install-libiberty \
>>  	--enable-install-libbfd
Felix Fietkau Dec. 15, 2014, 3:16 p.m. UTC | #2
On 2014-12-14 12:02, Harald Geyer wrote:
> nwf writes:
>> $ gcc -v -o hello hello.c [...]
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/collect2
>> --eh-frame-hdr -dynamic-linker /lib/ld-uClibc.so.0
>> -X -m armelf_linux_eabi -o hello
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crt1.o
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crti.o
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtbegin.o
>> -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3
>> -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../..
>> /tmp/ccjOqw9X.o -lgcc_s -lc -lgcc_s
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtend.o
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtn.o /usr/bin/ld:
>> cannot find -lgcc collect2: error: ld returned 1 exit status
>> 
>> Well, yes, that's true...
>> 
>> $ find / -name \*libgcc\* /lib/libgcc_s.so.1
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so.1
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc.map
>> /usr/lib/opkg/info/libgcc.list /usr/lib/opkg/info/libgcc.control
>> 
>> Grepping about at random I find that
>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so contains
>> the directive
>> 
>> > GROUP ( libgcc_s.so.1 -lgcc )
> 
> Actually citing libgcc_s.so in full makes things a bit clearer:
> $ cat libgcc_s.so
> /* GNU ld script
>    Use the shared library, but some functions are only in
>    the static library.  */
> GROUP ( libgcc_s.so.1 -lgcc )
> 
>> So I think the desire to save space expressed in
>> feeds/packages/devel/gcc/README is well-intentioned but possibly stale,
>> so maybe the following, too? Maybe we should be removing libgcc_pic.a
>> but not libgcc.a?
> 
> Seems reasonable. Since gcc seems to work for Christian as is, this
> might be architecture dependent. Christian, any insight on this?
> 
> As far as binutils is concerned the patch below seems to work as expected,
> so I can now add my
> Signed-off-by: Harald Geyer <harald@ccbib.org>
> 
> Felix, can you take this as is or should I resend the patch?
Removing libgcc_pic.a and adding libgcc.a makes sense to me.
You could remove libgcc_pic.a by removing 820-libgcc_pic.patch

- Felix
John Crispin Dec. 15, 2014, 3:51 p.m. UTC | #3
On 15/12/2014 16:16, Felix Fietkau wrote:
> On 2014-12-14 12:02, Harald Geyer wrote:
>> nwf writes:
>>> $ gcc -v -o hello hello.c [...]
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/collect2
>>> --eh-frame-hdr -dynamic-linker /lib/ld-uClibc.so.0
>>> -X -m armelf_linux_eabi -o hello
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crt1.o
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crti.o
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtbegin.o
>>> -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3
>>> -L/usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/../../..
>>> /tmp/ccjOqw9X.o -lgcc_s -lc -lgcc_s
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtend.o
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/crtn.o /usr/bin/ld:
>>> cannot find -lgcc collect2: error: ld returned 1 exit status
>>>
>>> Well, yes, that's true...
>>>
>>> $ find / -name \*libgcc\* /lib/libgcc_s.so.1
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so.1
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc.map
>>> /usr/lib/opkg/info/libgcc.list /usr/lib/opkg/info/libgcc.control
>>>
>>> Grepping about at random I find that
>>> /usr/lib/gcc/arm-openwrt-linux-uclibcgnueabi/4.8.3/libgcc_s.so contains
>>> the directive
>>>
>>>> GROUP ( libgcc_s.so.1 -lgcc )
>>
>> Actually citing libgcc_s.so in full makes things a bit clearer:
>> $ cat libgcc_s.so
>> /* GNU ld script
>>    Use the shared library, but some functions are only in
>>    the static library.  */
>> GROUP ( libgcc_s.so.1 -lgcc )
>>
>>> So I think the desire to save space expressed in
>>> feeds/packages/devel/gcc/README is well-intentioned but possibly stale,
>>> so maybe the following, too? Maybe we should be removing libgcc_pic.a
>>> but not libgcc.a?
>>
>> Seems reasonable. Since gcc seems to work for Christian as is, this
>> might be architecture dependent. Christian, any insight on this?
>>
>> As far as binutils is concerned the patch below seems to work as expected,
>> so I can now add my
>> Signed-off-by: Harald Geyer <harald@ccbib.org>
>>
>> Felix, can you take this as is or should I resend the patch?
> Removing libgcc_pic.a and adding libgcc.a makes sense to me.
> You could remove libgcc_pic.a by removing 820-libgcc_pic.patch
> 
> - Felix
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
> 

gcc is in a github feed so please send a PR or open an issue on github
for this. we cannot merge it via the ML


	John
Harald Geyer Dec. 16, 2014, 1:01 p.m. UTC | #4
Felix Fietkau writes:

> > As far as binutils is concerned the patch below seems to work as expected,
> > so I can now add my
> > Signed-off-by: Harald Geyer <harald@ccbib.org>
> > 
> > Felix, can you take this as is or should I resend the patch?
> Removing libgcc_pic.a and adding libgcc.a makes sense to me.
> You could remove libgcc_pic.a by removing 820-libgcc_pic.patch

So what about the patch against binutils package?

TIA,
Harald
diff mbox

Patch

diff --git a/devel/gcc/Makefile b/devel/gcc/Makefile
index c8d8733..8966955 100644
--- a/devel/gcc/Makefile
+++ b/devel/gcc/Makefile
@@ -106,7 +106,6 @@  define Package/gcc/install
 	ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/gcc
 	ln -s $(REAL_GNU_TARGET_NAME)-gcc $(1)/usr/bin/$(REAL_GNU_TARGET_NAME)-gcc-$(PKG_VERSION)
 	cp -ar $(PKG_INSTALL_DIR)/usr/lib/gcc $(1)/usr/lib
-	$(RM) $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)/*.a
 	cp -ar $(TOOLCHAIN_DIR)/include $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
 	cp -a $(TOOLCHAIN_DIR)/lib/*.{o,so*} $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
 	cp -a $(TOOLCHAIN_DIR)/lib/*nonshared*.a  $(1)/usr/lib/$(PKG_NAME)/$(REAL_GNU_TARGET_NAME)/$(PKG_VERSION)
diff --git a/devel/gcc/README b/devel/gcc/README
index 6cbc80d..828bd28 100644
--- a/devel/gcc/README
+++ b/devel/gcc/README
@@ -1,8 +1,5 @@ 
 Native GCC that runs on target.
 
-To save disk space, this GCC only supports dynamic linking on the target box,
-there are no static libraries shipped.
-
 For now, this was only tested on a mips target. Others to be done...
 
-   Christian Beier <cb@shoutrlabs.com>
\ No newline at end of file
+   Christian Beier <cb@shoutrlabs.com>