Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 122854 - Patches needed for GCC 3.4.5 specs for FreeBSD
Summary: Patches needed for GCC 3.4.5 specs for FreeBSD
Status: RESOLVED INVALID
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All FreeBSD
: High blocker (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-02-14 15:45 UTC by Diego Elio Pettenò (RETIRED)
Modified: 2006-04-12 10:50 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
specs.diff (specs.diff,720 bytes, patch)
2006-02-14 15:46 UTC, Diego Elio Pettenò (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Elio Pettenò (RETIRED) gentoo-dev 2006-02-14 15:45:38 UTC
As discussed and debugged tonight with az and solar, to let GCC work fine on Gentoo/FreeBSD we need to change the specs for it.

The attached patch between the specs provided and the ones that works allows us to have it working fine finally.

Can someone please update GCC 3.4.5 so that we can use it? It's a blocker bug for Gentoo/FreeBSD 6.0 release.

Thanks :)
Comment 1 Diego Elio Pettenò (RETIRED) gentoo-dev 2006-02-14 15:46:04 UTC
Created attachment 79810 [details, diff]
specs.diff
Comment 2 SpanKY gentoo-dev 2006-02-14 21:42:34 UTC
so you need someone to write a real patch for the gcc-3.4.5 source code ?
Comment 3 Kevin F. Quinn (RETIRED) gentoo-dev 2006-02-14 23:37:31 UTC
Diego, could you supply a description of the problem caused by the original specs?
We should understand why it's a problem here but presumably not for FreeBSD itself.
Comment 4 Diego Elio Pettenò (RETIRED) gentoo-dev 2006-02-15 03:28:13 UTC
Well the problem manifested itself when building things that linked against openssl: libgcc_s was pulled in with a NEEDED line in libcrypto.so and libssl.so, but the linker didn't know where to look for it. When added -lgcc_s to the flags, it was working fine instead. The same happened to openssh.

Basically the same problem would happen on normal FreeBSD system, but there libgcc_s.so is in the search path of the linker (because they load ld's search path using ld.so.conf, or rather the ld-elf.so.hints file). Probably if I was still using binutils 2.15 with the fbsd patch the problem wasn't appearing. That was the reason why we actually added that patch, but it's just a workaround to this problem, I'd say.

With that change to the specs, the linking works right (libgcc_s is pulled in for every binary a happening for original FreeBSD afaict).

And yeah Mike, I have no clue how to change the sources to have that change in the specs :)
Comment 5 SpanKY gentoo-dev 2006-02-19 15:43:34 UTC
ok, that isnt going to happen ... those specs are generated by generic gcc code that has nothing to do with arch/os/etc...

try using --disable-shared
Comment 6 Kevin F. Quinn (RETIRED) gentoo-dev 2006-02-19 16:21:55 UTC
(In reply to comment #4)
> libgcc_s was pulled in with a NEEDED line in libcrypto.so and
> libssl.so, but the linker didn't know where to look for it. When added -lgcc_s
> to the flags, it was working fine instead.

Surely the solution is to add the compiler's support library directory to the library search list in ld.so.conf (or equivalent).  That's what we do on Gentoo Linux.
Comment 7 Diego Elio Pettenò (RETIRED) gentoo-dev 2006-02-19 16:47:45 UTC
I thought that ld doesn't look into that when looking for libraries. If that's not the case yeah I need to forward port the 2.15 patch.
Comment 8 Kevin F. Quinn (RETIRED) gentoo-dev 2006-02-20 00:27:48 UTC
The directory containing libgcc_s.so should be the first place gcc looks for libraries it needs - try "gcc -v <something.c>" to see the options the compiler driver passes to the linker (collect2).


If HAVE_LD_AS_NEEDED is set, gcc/gcc.c (function init_gcc_specs) generates:

default: -lgcc --as-needed -lgcc_s%M --no-as-needed
-static: -lgcc -lgcc_eh
-shared: -lgcc --as-needed -lgcc_s%M --no-as-needed
-shared-libgcc: -lgcc_s%M -lgcc
-shared-libgcc -shared: -lgcc_s%M

whereas if HAVE_LD_AS_NEEDED is not set, you get what you see on FreeBSD:

default: -lgcc -lgcc_eh
-static: -lgcc -lgcc_eh
-shared: -lgcc_s%M
-shared-libgcc: -lgcc_s%M -lgcc
-shared-libgcc -shared: -lgcc_s%M


so the problem is the default configuration which is static on FreeBSD but shared for Linux.  Why provision of AS_NEEDED should make such a difference I'm not sure.

A question therefore; does the binutils you build for FreeBSD support AS_NEEDED?  If so, why did gcc think it didn't?
Comment 9 Kevin F. Quinn (RETIRED) gentoo-dev 2006-02-20 00:29:14 UTC
(btw I meant to say that my comment #6 was rubbish - ignore it :) )
Comment 10 Diego Elio Pettenò (RETIRED) gentoo-dev 2006-02-20 01:22:38 UTC
--as-needed on FreeBSD does not work, I'm not quite sure why, but that's the case.
Regard bug #6... seems like ld does look in the ld.so cache file on Linux, so we should do the same on FreeBSD, and then reappear the binutils patch that broke 2.16...
I've cut it down and trying it now... I'm going to work on it more so that I can make it acceptable on upstream this time, too.
Comment 11 Diego Elio Pettenò (RETIRED) gentoo-dev 2006-02-20 06:37:12 UTC
Okay the actual problem is fixed by the binutils patches I submitted now.

Still, I'm wondering about the way binutils works on glibc/uclibc loader, because I'm now seeing something that might be broken there. I want to check that more before having a false allarm, tho.