Hi!

Sorry for the late answer...

On Sat, 19 Sep 2015 14:00:23 +0200, Samuel Thibault <samuel.thiba...@gnu.org> 
wrote:
> On Linux, -p and -pg do not make gcc link against libc_p.a, only
> -profile does (as documented in r11246), and thus people expect -p

(Yo, 20 years ago...)

> and -pg to work without libc_p.a installed (it is actually even not
> available any more in Debian).  We should thus rather make the Hurd port
> do the same to avoid build failures.

Conceptually, ACK.


>       * gcc/config/gnu.h (LIB_SPEC) [-p|-pg]: Link with -lc instead of -lc_p.

> --- gcc/config/gnu.h.orig     2015-09-16 00:43:09.785570853 +0200
> +++ gcc/config/gnu.h  2015-09-16 00:43:12.513550418 +0200
> @@ -25,7 +25,7 @@
>  
>  /* Default C library spec.  */
>  #undef LIB_SPEC
> -#define LIB_SPEC "%{pthread:-lpthread} %{pg|p|profile:-lc_p;:-lc}"
> +#define LIB_SPEC "%{pthread:-lpthread} %{profile:-lc_p;:-lc}"

I guess, we can just drop that custom LIB_SPEC altogether, and will then
use the default (which is also used for x86 GNU/Linux):

    gcc/config/gnu-user.h:#define GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC \
    gcc/config/gnu-user.h-  "%{shared:-lc} \
    gcc/config/gnu-user.h-   %{!shared:%{mieee-fp:-lieee} 
%{profile:-lc_p}%{!profile:-lc}}"
    gcc/config/gnu-user.h-
    gcc/config/gnu-user.h:#define GNU_USER_TARGET_LIB_SPEC \
    gcc/config/gnu-user.h-  "%{pthread:-lpthread} " \
    gcc/config/gnu-user.h:  GNU_USER_TARGET_NO_PTHREADS_LIB_SPEC
    gcc/config/gnu-user.h-
    gcc/config/gnu-user.h:#undef  LIB_SPEC
    gcc/config/gnu-user.h:#define LIB_SPEC GNU_USER_TARGET_LIB_SPEC

I have not tested the -mieee-fp thingy, but I don't expect any issues
there; looke like this on both x86 GNU/Linux and GNU/Hurd:

    $ nm /usr/lib/i386-*gnu/libieee.a
    00000000 D _LIB_VERSION


That said, I think we can also drop our custom CPP_SPEC:

    gcc/config/gnu.h:#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"

..., and instead go with the default:

    gcc/config/i386/gnu-user-common.h:#define CPP_SPEC 
"%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"

(It doesn't matter for GNU/Hurd which is x86-only, but I don't know why
CPP_SPEC is defined in gcc/config/i386/gnu-user-common.h -- and repeated
in a number of other GNU-user and */linux.h files -- instead of putting
it into the generic gcc/config/gnu-user.h?)

I guess getting -D_REENTRANT for -pthread won't do us any harm?


>         * gcc/config/i386/gnu.h (STARTFILE_SPEC) [-p|-pg]: Use gcrt1.o
>         instead of gcrt0.o.

> --- gcc/config/i386/gnu.h.orig        2015-09-17 21:41:13.000000000 +0000
> +++ gcc/config/i386/gnu.h     2015-09-17 23:03:57.000000000 +0000
> @@ -27,11 +27,11 @@
>  #undef       STARTFILE_SPEC
>  #if defined HAVE_LD_PIE
>  #define STARTFILE_SPEC \
> -  "%{!shared: 
> %{pg|p|profile:gcrt0.o%s;pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}} \
> +  "%{!shared: 
> %{pg|p:gcrt1.o%s;profile:gcrt0.o%s;pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}} \
>     crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
>  #else
>  #define STARTFILE_SPEC \
> -  "%{!shared: %{pg|p|profile:gcrt0.o%s;static:crt0.o%s;:crt1.o%s}} \
> +  "%{!shared: %{pg|p:gcrt1.o%s;profile:gcrt0.o%s;static:crt0.o%s;:crt1.o%s}} 
> \
>     crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
>  #endif

I think I understand what you're trying to do (avoid gcrt0.o being used
for -pg or -p, and instead use gcrt1.o), but I'm not sure this is
completely correct.  Which of the several configurations, that is, flags
and their combinations, did you actually test?

In my understanding, the Hurd needs crt0.o for static linking, and crt1.o
for dynamic linking.  Likewise, for -pg or -p, I would assume that we
still need gcrt0.o for static linking, and gcrt1.o for dynamic linking.
Instead you're now suggesting to always use gcrt1.o for -pg or -p, and
gcrt0.o for -profile.


I'm now testing the following patch:

--- gcc/config/gnu.h
+++ gcc/config/gnu.h
@@ -19,14 +19,6 @@ You should have received a copy of the GNU General Public 
License
 along with GCC.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-/* Provide GCC options for standard feature-test macros.  */
-#undef CPP_SPEC
-#define CPP_SPEC "%{posix:-D_POSIX_SOURCE}"
-
-/* Default C library spec.  */
-#undef LIB_SPEC
-#define LIB_SPEC "%{pthread:-lpthread} %{pg|p|profile:-lc_p;:-lc}"
-
 #undef GNU_USER_TARGET_OS_CPP_BUILTINS
 #define GNU_USER_TARGET_OS_CPP_BUILTINS()              \
     do {                                       \
--- gcc/config/i386/gnu.h
+++ gcc/config/i386/gnu.h
@@ -27,11 +27,11 @@ along with GCC.  If not, see <http://www.gnu.org/licenses/>.
 #undef STARTFILE_SPEC
 #if defined HAVE_LD_PIE
 #define STARTFILE_SPEC \
-  "%{!shared: 
%{pg|p|profile:gcrt0.o%s;pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}} \
+  "%{!shared: 
%{pg|p|profile:%{static:gcrt0.o%s;:gcrt1.o%s};pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}}
 \
    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #else
 #define STARTFILE_SPEC \
-  "%{!shared: %{pg|p|profile:gcrt0.o%s;static:crt0.o%s;:crt1.o%s}} \
+  "%{!shared: 
%{pg|p|profile:%{static:gcrt0.o%s;:gcrt1.o%s};static:crt0.o%s;:crt1.o%s}} \
    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
 #endif
 

..., which results in the following spec changes:

@@ -17,7 +17,7 @@
  as %(asm_options) %m.s %A }  }
 
 *cpp:
-%{posix:-D_POSIX_SOURCE}
+%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}
 
 *cpp_options:
 %(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w} 
%{f*} %{g*:%{!g0:%{g*} %{!fno-working-directory:-fworking-directory}}} %{O*} 
%{undef} %{save-temps*:-fpch-preprocess}
@@ -53,7 +53,7 @@
 %{!static:--eh-frame-hdr} -m %(link_emulation) %{shared:-shared}   %{!shared:  
   %{!static:       %{rdynamic:-export-dynamic}       -dynamic-linker 
%(dynamic_linker)}       %{static:-static}}
 
 *lib:
-%{pthread:-lpthread} %{pg|p|profile:-lc_p;:-lc}
+%{pthread:-lpthread} %{shared:-lc}    %{!shared:%{mieee-fp:-lieee} 
%{profile:-lc_p}%{!profile:-lc}}
 
 *link_gomp:
 
@@ -62,7 +62,7 @@
 %{static|static-libgcc:-lgcc 
-lgcc_eh}%{!static:%{!static-libgcc:%{!shared-libgcc:-lgcc --as-needed -lgcc_s 
--no-as-needed}%{shared-libgcc:-lgcc_s%{!shared: -lgcc}}}}
 
 *startfile:
-%{!shared: %{pg|p|profile:gcrt0.o%s;pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}}  
  crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}
+%{!shared: 
%{pg|p|profile:%{static:gcrt0.o%s;:gcrt1.o%s};pie:Scrt1.o%s;static:crt0.o%s;:crt1.o%s}}
    crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}
 
 *cross_compile:
 0


Grüße
 Thomas

Attachment: signature.asc
Description: PGP signature

Reply via email to