On Tue, Jan 13, 2015 at 11:27 AM, Jeff Law <l...@redhat.com> wrote: > On 01/13/15 05:54, H.J. Lu wrote: >> >> On Mon, Jan 12, 2015 at 03:04:20PM -0700, Jeff Law wrote: >>> >>> On 01/12/15 14:51, Magnus Granberg wrote: >>>> >>>> måndag 12 januari 2015 12.11.17 skrev H.J. Lu: >>>>> >>>>> On Mon, Jan 12, 2015 at 12:03 PM, Jeff Law <l...@redhat.com> wrote: >>>>>> >>>>>> On 01/12/15 12:59, H.J. Lu wrote: >>>>>>> >>>>>>> I don't know if -pg will work PIE on any targets. For Linux/x86 >>>>>>> the choices of crt1.o are >>>>>>> >>>>>>> %{!shared: %{pg|p|profile:gcrt1.o%s;pie:Scrt1.o%s;:crt1.o%s}} >>>>>>> >>>>>>> -shared, -pg and -pie are mutually exclusive. Those crt1 files are >>>>>>> only crt1 files provided by glibc. You can't even try -pg -pie on >>>>>>> Linux without changing glibc. >>>>>> >>>>>> >>>>>> You're totally missing the point. What I care about is *why*. >>>>>> >>>> With -pg it use gcrt1.o object file and that file is not compile with >>>> -fPIC. >>>> When you build a shared lib on x86_64 all the objects files need to be >>>> buiit >>>> with -fPIC else you get a error like that one abow and it is the same >>>> problems >>>> when you build bin with -fPIE and linke with -pie. >>>> Glibc do not provide one that is compile with -fPIC >>> >>> Is there some reason why glibc could not provide gcrt1.o compiled with >>> -fPIC? >>> >>> >> >> Here is a patch to check if -pg is available. If -pg doesn't link, >> profiling isn't available. OK for trunk? > > OK with a suitable ChangeLog entry. >
Unfortunately it doesn't work with make check-gcc RUNTESTFLAGS="--target_board='unix{-m32,-m64}' since check_profiling_available result is cached. It is wrong to use the cached result from -m32 for -m64. Here is the updated patch. Tested with RUNTESTFLAGS="--target_board='unix{-m32,-m64}'. OK for trunk? Thanks. -- H.J. ---- * lib/target-supports.exp (check_profiling_available): Check if -pg links. --- gcc/testsuite/lib/target-supports.exp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 0ac9646..61bff53 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -549,7 +549,16 @@ proc check_profiling_available { test_what } { } } - return $profiling_available_saved + # -pg link test result can't be cached since it may change between + # runs. + set profiling_working $profiling_available_saved + if { $profiling_available_saved == 1 + && ![check_no_compiler_messages_nocache profiling executable { + int main() { return 0; } } "-pg"] } { + set profiling_working 0 + } + + return $profiling_working } # Check to see if a target is "freestanding". This is as per the definition -- 1.9.3