public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2
@ 2011-10-21  2:57 Andi Kleen
  2011-10-25 12:16 ` PING " Andi Kleen
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andi Kleen @ 2011-10-21  2:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andi Kleen

From: Andi Kleen <ak@linux.intel.com>

Slim LTO requires running ar/nm/ranlib with the LTO plugin. The most
convenient way to get this into existing Makefiles is using small
wrappers that pass the plugin. This matches how other compilers
(LLVM, icc) do this too.

My previous attempt at using shell scripts for this
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02471.html
was not approved. Here's another attempt using wrappers written
in C.  This adds wrappers add a --plugin argument before calling the
respective binutils utilities.

The logic gcc.c uses to find the files is very complicated. I didn't
try to replicate it 100% and left out some magic. I would be interested
if this simple method works for everyone or if more code needs
to be added. This only needs to support LTO supporting hosts of course.

I didn't add any documentation because the syntax is exactly the same as
the native ar/ranlib/nm.

v2: Address review comments. Makefile follows go now, use own binaries
for each sub program.

Passed bootstrap and test suite on x86_64-linux.

gcc/:
2011-10-19  Andi Kleen  <ak@linux.intel.com>

	* Makefile.in (MOSTLYCLEANFILES): Add gcc-ar/nm/ranlib.
	(native): Add gcc-ar, gcc-nm, gcc-ranlib.
	(AR_LIBS, gcc-ar, gcc-ar.o, gcc-ranlib, gcc-ranlib.o,
         gcc-nm, gcc-nm.o, gcc-ranlib.c, gcc-nm.c): Add.
	(install): Depend on install-gcc-ar.
	(install-gcc-ar): Add.
	(uninstall): Uninstall gcc-ar, gcc-nm, gcc-ranlib.
	* gcc-ar.c: Add new file.
---
 gcc/Makefile.in |   71 +++++++++++++++++++++++++++++++++++++++--
 gcc/gcc-ar.c    |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 164 insertions(+), 3 deletions(-)
 create mode 100644 gcc/gcc-ar.c

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 6b28ef5..1b9987a 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1545,7 +1545,8 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
  genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \
  xgcc$(exeext) cpp$(exeext) cc1$(exeext) $(EXTRA_PASSES) \
  $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
- $(SPECS) collect2$(exeext) lto-wrapper$(exeext) \
+ $(SPECS) collect2$(exeext) gcc-ar$(exeext) gcc-nm$(exeext) \
+ gcc-ranlib$(exeext) \
  gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
  gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
  libcommon-target.a libcommon.a libgcc.mk
@@ -1791,7 +1792,8 @@ rest.encap: lang.rest.encap
 # This is what is made with the host's compiler
 # whether making a cross compiler or not.
 native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
-	$(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext)
+	$(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext) \
+	gcc-ar$(exeext) gcc-nm$(exeext) gcc-ranlib$(exeext)
 
 ifeq ($(enable_plugin),yes)
 native: gengtype$(exeext)
@@ -2049,6 +2051,46 @@ sbitmap.o: sbitmap.c sbitmap.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(BASIC_BLOCK
 ebitmap.o: ebitmap.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(EBITMAP_H)
 sparseset.o: sparseset.c $(SYSTEM_H) sparseset.h $(CONFIG_H)
 
+AR_LIBS = @COLLECT2_LIBS@
+
+gcc-ar$(exeext): gcc-ar.o $(LIBDEPS)
+	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) gcc-ar.o -o $@ \
+		$(LIBS) $(AR_LIBS)
+
+gcc-nm$(exeext): gcc-nm.o $(LIBDEPS)
+	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) gcc-nm.o -o $@ \
+		$(LIBS) $(AR_LIBS)
+
+gcc-ranlib$(exeext): gcc-ranlib.o $(LIBDEPS)
+	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) gcc-ranlib.o -o $@ \
+		$(LIBS) $(AR_LIBS)
+
+CFLAGS-gcc-ar.o += $(DRIVER_DEFINES) \
+	-DTARGET_MACHINE=\"$(target_noncanonical)\" \
+	@TARGET_SYSTEM_ROOT_DEFINE@ -DPERSONALITY=\"ar\"
+
+gcc-ar.o: gcc-ar.c $(CONFIG_H) $(SYSTEM_H) $(LIBIBERTY_H)
+
+CFLAGS-gcc-ranlib.o += $(DRIVER_DEFINES) \
+	-DTARGET_MACHINE=\"$(target_noncanonical)\" \
+	@TARGET_SYSTEM_ROOT_DEFINE@ -DPERSONALITY=\"ranlib\"
+
+gcc-ranlib.o: gcc-ranlib.c $(CONFIG_H) $(SYSTEM_H) $(LIBIBERTY_H)
+
+CFLAGS-gcc-nm.o += $(DRIVER_DEFINES) \
+	-DTARGET_MACHINE=\"$(target_noncanonical)\" \
+	@TARGET_SYSTEM_ROOT_DEFINE@ -DPERSONALITY=\"nm\"
+
+gcc-nm.o: gcc-nm.c $(CONFIG_H) $(SYSTEM_H) $(LIBIBERTY_H)
+
+# ??? the implicit rules dont trigger if the source file has a different name
+# so copy instead
+gcc-ranlib.c: gcc-ar.c
+	cp $^ $@
+
+gcc-nm.c: gcc-ar.c
+	cp $^ $@
+
 COLLECT2_OBJS = collect2.o collect2-aix.o tlink.o
 COLLECT2_LIBS = @COLLECT2_LIBS@
 collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
@@ -4576,7 +4618,7 @@ maintainer-clean:
 # broken is small.
 install: install-common $(INSTALL_HEADERS) \
     install-cpp install-man install-info install-@POSUB@ \
-    install-driver install-lto-wrapper
+    install-driver install-lto-wrapper install-gcc-ar
 
 ifeq ($(enable_plugin),yes)
 install: install-plugin
@@ -4901,6 +4943,23 @@ install-collect2: collect2 installdirs
 install-lto-wrapper: lto-wrapper$(exeext)
 	$(INSTALL_PROGRAM) lto-wrapper$(exeext) $(DESTDIR)$(libexecsubdir)/lto-wrapper$(exeext)
 
+install-gcc-ar:
+	set -e ; \
+	for i in ar nm ranlib ; do \
+	  install_name=`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ;\
+	  target_install_name=$(target_noncanonical)-`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ; \
+	  binname=gcc-$$i$(exeext) ; \
+	  rm -f $(DESTDIR)$(bindir)/$$install_name ; \
+	  rm -f $(DESTDIR)$(bindir)/$$target_install_name ; \
+	  $(INSTALL_PROGRAM) $$binname $(DESTDIR)$(bindir)/$$install_name ;\
+	  if test -f $(DESTDIR)$(bindir)$$target_install_name ; then \
+	    :; \
+	  else \
+	    ( cd $(DESTDIR)$(bindir) && \
+	      $(LN) $$install_name $$target_install_name ) ; \
+	  fi ; \
+	done
+
 # Cancel installation by deleting the installed files.
 uninstall: lang.uninstall
 	-rm -rf $(DESTDIR)$(libsubdir)
@@ -4915,6 +4974,12 @@ uninstall: lang.uninstall
 	-rm -rf $(DESTDIR)$(man1dir)/cpp$(man1ext)
 	-rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
 	-rm -f $(DESTDIR)$(infodir)/cppinternals.info* $(DESTDIR)$(infodir)/gccint.info*
+	for i in ar nm ranlib ; do \
+	  install_name=`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ;\
+	  target_install_name=$(target_noncanonical)-`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ; \
+	  rm -f $(DESTDIR)$(bindir)/$$install_name ; \
+	  rm -f $(DESTDIR)$(bindir)/$$target_install_name ; \
+	done
 #\f
 # These targets are for the dejagnu testsuites. The file site.exp
 # contains global variables that all the testsuites will use.
diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c
new file mode 100644
index 0000000..fc7e4a2
--- /dev/null
+++ b/gcc/gcc-ar.c
@@ -0,0 +1,96 @@
+/* Wrapper for ar/ranlib/nm to pass the LTO plugin.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Contributed by Andi Kleen.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include "config.h"
+#include "system.h"
+#include "libiberty.h"
+
+#ifndef PERSONALITY
+#error "Please set personality"
+#endif
+
+static const char standard_libexec_prefix[] = STANDARD_LIBEXEC_PREFIX;
+static const char standard_bin_prefix[] = STANDARD_BINDIR_PREFIX;
+
+static const char dir_separator[] = { DIR_SEPARATOR, 0 };
+
+int 
+main(int ac, char **av)
+{
+  const char *nprefix;
+  const char *exe_name;
+  char *plugin;
+  int k, status, err;
+  const char *err_msg;
+  const char **nargv;
+  bool is_ar = !strcmp (PERSONALITY, "ar");
+
+  exe_name = PERSONALITY;
+#ifdef CROSS_DIRECTORY_STRUCTURE
+  exe_name = concat (target_machine, "-", exe_name, NULL);
+#endif
+
+  /* Find plugin */
+  /* XXX implement more magic from gcc.c? */
+  nprefix = getenv ("GCC_EXEC_PREFIX");
+  if (!nprefix)
+    nprefix = standard_libexec_prefix;
+
+  nprefix = make_relative_prefix (av[0], 
+				  standard_bin_prefix, 
+				  nprefix);
+  plugin = concat (nprefix,
+		   dir_separator,
+                   DEFAULT_TARGET_MACHINE, 
+		   dir_separator,
+		   DEFAULT_TARGET_VERSION,
+	           dir_separator,
+		   LTOPLUGINSONAME,
+		   NULL);
+  if (access (plugin, X_OK))
+    {
+      fprintf (stderr, "%s: Cannot find plugin %s\n", av[0], plugin);
+      exit (1);
+    }
+
+  /* Create new command line with plugin */
+  nargv = XCNEWVEC (const char *, ac + 4);
+  nargv[0] = exe_name;
+  nargv[1] = "--plugin";
+  nargv[2] = plugin;
+  if (is_ar && av[1] && av[1][0] != '-')
+    av[1] = concat("-", av[1], NULL);
+  for (k = 1; k < ac; k++)
+    nargv[2 + k] = av[k];
+  nargv[2 + k] = NULL;
+
+  /* Run utility */
+  /* ??? the const is misplaced in pex_one's argv? */
+  err_msg = pex_one (PEX_LAST|PEX_SEARCH, 
+		     exe_name, 
+		     CONST_CAST2 (char * const *, const char **, nargv),
+		     concat("gcc-", exe_name, NULL), 
+		     NULL,NULL,  &status, &err);
+  if (err_msg) 
+    fprintf(stderr, "Error running %s: %s\n", exe_name, err_msg);
+
+  return err;
+}
-- 
1.7.5.4

^ permalink raw reply	[flat|nested] 8+ messages in thread

* PING [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2
  2011-10-21  2:57 [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2 Andi Kleen
@ 2011-10-25 12:16 ` Andi Kleen
  2011-10-25 15:49   ` Diego Novillo
  2011-10-28 11:43 ` Richard Guenther
  2011-10-29  9:04 ` Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2" Hans-Peter Nilsson
  2 siblings, 1 reply; 8+ messages in thread
From: Andi Kleen @ 2011-10-25 12:16 UTC (permalink / raw)
  To: gcc-patches

Andi Kleen <andi@firstfloor.org> writes:

> From: Andi Kleen <ak@linux.intel.com>
>
> Slim LTO requires running ar/nm/ranlib with the LTO plugin. The most
> convenient way to get this into existing Makefiles is using small
> wrappers that pass the plugin. This matches how other compilers
> (LLVM, icc) do this too.

Ping. Could someone please review
http://permalink.gmane.org/gmane.comp.gcc.patches/249338

Thanks,

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: PING [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2
  2011-10-25 12:16 ` PING " Andi Kleen
@ 2011-10-25 15:49   ` Diego Novillo
  0 siblings, 0 replies; 8+ messages in thread
From: Diego Novillo @ 2011-10-25 15:49 UTC (permalink / raw)
  To: Andi Kleen; +Cc: gcc-patches

On 11-10-25 01:23 , Andi Kleen wrote:
> Andi Kleen<andi@firstfloor.org>  writes:
>
>> From: Andi Kleen<ak@linux.intel.com>
>>
>> Slim LTO requires running ar/nm/ranlib with the LTO plugin. The most
>> convenient way to get this into existing Makefiles is using small
>> wrappers that pass the plugin. This matches how other compilers
>> (LLVM, icc) do this too.
>
> Ping. Could someone please review
> http://permalink.gmane.org/gmane.comp.gcc.patches/249338

In my review queue.  Will try to get to it shortly.


Diego.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2
  2011-10-21  2:57 [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2 Andi Kleen
  2011-10-25 12:16 ` PING " Andi Kleen
@ 2011-10-28 11:43 ` Richard Guenther
  2011-10-29  9:04 ` Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2" Hans-Peter Nilsson
  2 siblings, 0 replies; 8+ messages in thread
From: Richard Guenther @ 2011-10-28 11:43 UTC (permalink / raw)
  To: Andi Kleen; +Cc: gcc-patches, Andi Kleen

On Fri, Oct 21, 2011 at 1:55 AM, Andi Kleen <andi@firstfloor.org> wrote:
> From: Andi Kleen <ak@linux.intel.com>
>
> Slim LTO requires running ar/nm/ranlib with the LTO plugin. The most
> convenient way to get this into existing Makefiles is using small
> wrappers that pass the plugin. This matches how other compilers
> (LLVM, icc) do this too.
>
> My previous attempt at using shell scripts for this
> http://gcc.gnu.org/ml/gcc-patches/2010-10/msg02471.html
> was not approved. Here's another attempt using wrappers written
> in C.  This adds wrappers add a --plugin argument before calling the
> respective binutils utilities.
>
> The logic gcc.c uses to find the files is very complicated. I didn't
> try to replicate it 100% and left out some magic. I would be interested
> if this simple method works for everyone or if more code needs
> to be added. This only needs to support LTO supporting hosts of course.
>
> I didn't add any documentation because the syntax is exactly the same as
> the native ar/ranlib/nm.
>
> v2: Address review comments. Makefile follows go now, use own binaries
> for each sub program.
>
> Passed bootstrap and test suite on x86_64-linux.

Ok.

We can improve/fix things if there is a need to as followup.

Thanks,
Richard.

> gcc/:
> 2011-10-19  Andi Kleen  <ak@linux.intel.com>
>
>        * Makefile.in (MOSTLYCLEANFILES): Add gcc-ar/nm/ranlib.
>        (native): Add gcc-ar, gcc-nm, gcc-ranlib.
>        (AR_LIBS, gcc-ar, gcc-ar.o, gcc-ranlib, gcc-ranlib.o,
>         gcc-nm, gcc-nm.o, gcc-ranlib.c, gcc-nm.c): Add.
>        (install): Depend on install-gcc-ar.
>        (install-gcc-ar): Add.
>        (uninstall): Uninstall gcc-ar, gcc-nm, gcc-ranlib.
>        * gcc-ar.c: Add new file.
> ---
>  gcc/Makefile.in |   71 +++++++++++++++++++++++++++++++++++++++--
>  gcc/gcc-ar.c    |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 164 insertions(+), 3 deletions(-)
>  create mode 100644 gcc/gcc-ar.c
>
> diff --git a/gcc/Makefile.in b/gcc/Makefile.in
> index 6b28ef5..1b9987a 100644
> --- a/gcc/Makefile.in
> +++ b/gcc/Makefile.in
> @@ -1545,7 +1545,8 @@ MOSTLYCLEANFILES = insn-flags.h insn-config.h insn-codes.h \
>  genrtl.h gt-*.h gtype-*.h gtype-desc.c gtyp-input.list \
>  xgcc$(exeext) cpp$(exeext) cc1$(exeext) $(EXTRA_PASSES) \
>  $(EXTRA_PARTS) $(EXTRA_PROGRAMS) gcc-cross$(exeext) \
> - $(SPECS) collect2$(exeext) lto-wrapper$(exeext) \
> + $(SPECS) collect2$(exeext) gcc-ar$(exeext) gcc-nm$(exeext) \
> + gcc-ranlib$(exeext) \
>  gcov-iov$(build_exeext) gcov$(exeext) gcov-dump$(exeext) \
>  gengtype$(exeext) *.[0-9][0-9].* *.[si] *-checksum.c libbackend.a \
>  libcommon-target.a libcommon.a libgcc.mk
> @@ -1791,7 +1792,8 @@ rest.encap: lang.rest.encap
>  # This is what is made with the host's compiler
>  # whether making a cross compiler or not.
>  native: config.status auto-host.h build-@POSUB@ $(LANGUAGES) \
> -       $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext)
> +       $(EXTRA_PASSES) $(EXTRA_PROGRAMS) $(COLLECT2) lto-wrapper$(exeext) \
> +       gcc-ar$(exeext) gcc-nm$(exeext) gcc-ranlib$(exeext)
>
>  ifeq ($(enable_plugin),yes)
>  native: gengtype$(exeext)
> @@ -2049,6 +2051,46 @@ sbitmap.o: sbitmap.c sbitmap.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(BASIC_BLOCK
>  ebitmap.o: ebitmap.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(EBITMAP_H)
>  sparseset.o: sparseset.c $(SYSTEM_H) sparseset.h $(CONFIG_H)
>
> +AR_LIBS = @COLLECT2_LIBS@
> +
> +gcc-ar$(exeext): gcc-ar.o $(LIBDEPS)
> +       +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) gcc-ar.o -o $@ \
> +               $(LIBS) $(AR_LIBS)
> +
> +gcc-nm$(exeext): gcc-nm.o $(LIBDEPS)
> +       +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) gcc-nm.o -o $@ \
> +               $(LIBS) $(AR_LIBS)
> +
> +gcc-ranlib$(exeext): gcc-ranlib.o $(LIBDEPS)
> +       +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) gcc-ranlib.o -o $@ \
> +               $(LIBS) $(AR_LIBS)
> +
> +CFLAGS-gcc-ar.o += $(DRIVER_DEFINES) \
> +       -DTARGET_MACHINE=\"$(target_noncanonical)\" \
> +       @TARGET_SYSTEM_ROOT_DEFINE@ -DPERSONALITY=\"ar\"
> +
> +gcc-ar.o: gcc-ar.c $(CONFIG_H) $(SYSTEM_H) $(LIBIBERTY_H)
> +
> +CFLAGS-gcc-ranlib.o += $(DRIVER_DEFINES) \
> +       -DTARGET_MACHINE=\"$(target_noncanonical)\" \
> +       @TARGET_SYSTEM_ROOT_DEFINE@ -DPERSONALITY=\"ranlib\"
> +
> +gcc-ranlib.o: gcc-ranlib.c $(CONFIG_H) $(SYSTEM_H) $(LIBIBERTY_H)
> +
> +CFLAGS-gcc-nm.o += $(DRIVER_DEFINES) \
> +       -DTARGET_MACHINE=\"$(target_noncanonical)\" \
> +       @TARGET_SYSTEM_ROOT_DEFINE@ -DPERSONALITY=\"nm\"
> +
> +gcc-nm.o: gcc-nm.c $(CONFIG_H) $(SYSTEM_H) $(LIBIBERTY_H)
> +
> +# ??? the implicit rules dont trigger if the source file has a different name
> +# so copy instead
> +gcc-ranlib.c: gcc-ar.c
> +       cp $^ $@
> +
> +gcc-nm.c: gcc-ar.c
> +       cp $^ $@
> +
>  COLLECT2_OBJS = collect2.o collect2-aix.o tlink.o
>  COLLECT2_LIBS = @COLLECT2_LIBS@
>  collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
> @@ -4576,7 +4618,7 @@ maintainer-clean:
>  # broken is small.
>  install: install-common $(INSTALL_HEADERS) \
>     install-cpp install-man install-info install-@POSUB@ \
> -    install-driver install-lto-wrapper
> +    install-driver install-lto-wrapper install-gcc-ar
>
>  ifeq ($(enable_plugin),yes)
>  install: install-plugin
> @@ -4901,6 +4943,23 @@ install-collect2: collect2 installdirs
>  install-lto-wrapper: lto-wrapper$(exeext)
>        $(INSTALL_PROGRAM) lto-wrapper$(exeext) $(DESTDIR)$(libexecsubdir)/lto-wrapper$(exeext)
>
> +install-gcc-ar:
> +       set -e ; \
> +       for i in ar nm ranlib ; do \
> +         install_name=`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ;\
> +         target_install_name=$(target_noncanonical)-`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ; \
> +         binname=gcc-$$i$(exeext) ; \
> +         rm -f $(DESTDIR)$(bindir)/$$install_name ; \
> +         rm -f $(DESTDIR)$(bindir)/$$target_install_name ; \
> +         $(INSTALL_PROGRAM) $$binname $(DESTDIR)$(bindir)/$$install_name ;\
> +         if test -f $(DESTDIR)$(bindir)$$target_install_name ; then \
> +           :; \
> +         else \
> +           ( cd $(DESTDIR)$(bindir) && \
> +             $(LN) $$install_name $$target_install_name ) ; \
> +         fi ; \
> +       done
> +
>  # Cancel installation by deleting the installed files.
>  uninstall: lang.uninstall
>        -rm -rf $(DESTDIR)$(libsubdir)
> @@ -4915,6 +4974,12 @@ uninstall: lang.uninstall
>        -rm -rf $(DESTDIR)$(man1dir)/cpp$(man1ext)
>        -rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
>        -rm -f $(DESTDIR)$(infodir)/cppinternals.info* $(DESTDIR)$(infodir)/gccint.info*
> +       for i in ar nm ranlib ; do \
> +         install_name=`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ;\
> +         target_install_name=$(target_noncanonical)-`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ; \
> +         rm -f $(DESTDIR)$(bindir)/$$install_name ; \
> +         rm -f $(DESTDIR)$(bindir)/$$target_install_name ; \
> +       done
>  #
>  # These targets are for the dejagnu testsuites. The file site.exp
>  # contains global variables that all the testsuites will use.
> diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c
> new file mode 100644
> index 0000000..fc7e4a2
> --- /dev/null
> +++ b/gcc/gcc-ar.c
> @@ -0,0 +1,96 @@
> +/* Wrapper for ar/ranlib/nm to pass the LTO plugin.
> +   Copyright (C) 2011 Free Software Foundation, Inc.
> +   Contributed by Andi Kleen.
> +
> +This file is part of GCC.
> +
> +GCC is free software; you can redistribute it and/or modify it under
> +the terms of the GNU General Public License as published by the Free
> +Software Foundation; either version 3, or (at your option) any later
> +version.
> +
> +GCC is distributed in the hope that it will be useful, but WITHOUT ANY
> +WARRANTY; without even the implied warranty of MERCHANTABILITY or
> +FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
> +for more details.
> +
> +You should have received a copy of the GNU General Public License
> +along with GCC; see the file COPYING3.  If not see
> +<http://www.gnu.org/licenses/>.  */
> +
> +#include <stdio.h>
> +#include "config.h"
> +#include "system.h"
> +#include "libiberty.h"
> +
> +#ifndef PERSONALITY
> +#error "Please set personality"
> +#endif
> +
> +static const char standard_libexec_prefix[] = STANDARD_LIBEXEC_PREFIX;
> +static const char standard_bin_prefix[] = STANDARD_BINDIR_PREFIX;
> +
> +static const char dir_separator[] = { DIR_SEPARATOR, 0 };
> +
> +int
> +main(int ac, char **av)
> +{
> +  const char *nprefix;
> +  const char *exe_name;
> +  char *plugin;
> +  int k, status, err;
> +  const char *err_msg;
> +  const char **nargv;
> +  bool is_ar = !strcmp (PERSONALITY, "ar");
> +
> +  exe_name = PERSONALITY;
> +#ifdef CROSS_DIRECTORY_STRUCTURE
> +  exe_name = concat (target_machine, "-", exe_name, NULL);
> +#endif
> +
> +  /* Find plugin */
> +  /* XXX implement more magic from gcc.c? */
> +  nprefix = getenv ("GCC_EXEC_PREFIX");
> +  if (!nprefix)
> +    nprefix = standard_libexec_prefix;
> +
> +  nprefix = make_relative_prefix (av[0],
> +                                 standard_bin_prefix,
> +                                 nprefix);
> +  plugin = concat (nprefix,
> +                  dir_separator,
> +                   DEFAULT_TARGET_MACHINE,
> +                  dir_separator,
> +                  DEFAULT_TARGET_VERSION,
> +                  dir_separator,
> +                  LTOPLUGINSONAME,
> +                  NULL);
> +  if (access (plugin, X_OK))
> +    {
> +      fprintf (stderr, "%s: Cannot find plugin %s\n", av[0], plugin);
> +      exit (1);
> +    }
> +
> +  /* Create new command line with plugin */
> +  nargv = XCNEWVEC (const char *, ac + 4);
> +  nargv[0] = exe_name;
> +  nargv[1] = "--plugin";
> +  nargv[2] = plugin;
> +  if (is_ar && av[1] && av[1][0] != '-')
> +    av[1] = concat("-", av[1], NULL);
> +  for (k = 1; k < ac; k++)
> +    nargv[2 + k] = av[k];
> +  nargv[2 + k] = NULL;
> +
> +  /* Run utility */
> +  /* ??? the const is misplaced in pex_one's argv? */
> +  err_msg = pex_one (PEX_LAST|PEX_SEARCH,
> +                    exe_name,
> +                    CONST_CAST2 (char * const *, const char **, nargv),
> +                    concat("gcc-", exe_name, NULL),
> +                    NULL,NULL,  &status, &err);
> +  if (err_msg)
> +    fprintf(stderr, "Error running %s: %s\n", exe_name, err_msg);
> +
> +  return err;
> +}
> --
> 1.7.5.4
>
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2"
  2011-10-21  2:57 [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2 Andi Kleen
  2011-10-25 12:16 ` PING " Andi Kleen
  2011-10-28 11:43 ` Richard Guenther
@ 2011-10-29  9:04 ` Hans-Peter Nilsson
  2011-10-29 12:44   ` Andi Kleen
  2 siblings, 1 reply; 8+ messages in thread
From: Hans-Peter Nilsson @ 2011-10-29  9:04 UTC (permalink / raw)
  To: andi; +Cc: gcc-patches, ak

> From: Andi Kleen <andi@firstfloor.org>
> Date: Fri, 21 Oct 2011 01:55:48 +0200

> 2011-10-19  Andi Kleen  <ak@linux.intel.com>
> 
> 	* Makefile.in (MOSTLYCLEANFILES): Add gcc-ar/nm/ranlib.
> 	(native): Add gcc-ar, gcc-nm, gcc-ranlib.
> 	(AR_LIBS, gcc-ar, gcc-ar.o, gcc-ranlib, gcc-ranlib.o,
>          gcc-nm, gcc-nm.o, gcc-ranlib.c, gcc-nm.c): Add.
> 	(install): Depend on install-gcc-ar.
> 	(install-gcc-ar): Add.
> 	(uninstall): Uninstall gcc-ar, gcc-nm, gcc-ranlib.
> 	* gcc-ar.c: Add new file.

This broke cross to cris-elf and I guess many other targets
with TOT binutils, as follows:

mv -f Tlto-wrapper lto-wrapper
gcc -c  -DSTANDARD_STARTFILE_PREFIX=\"../../../\" -DSTANDARD_EXEC_PREFIX=\"/tmp/hpautotest-gcc1/cris-elf/pre/lib/gcc/\" -DSTANDARD_LIBEXEC_PREFIX=\"/tmp/hpautotest-gcc1/cris-elf/pre/libexec/gcc/\" -DDEFAULT_TARGET_VERSION=\"4.7.0\" -DDEFAULT_TARGET_MACHINE=\"cris-elf\" -DSTANDARD_BINDIR_PREFIX=\"/tmp/hpautotest-gcc1/cris-elf/pre/bin/\" -DTOOLDIR_BASE_PREFIX=\"../../../../\"  `test "X${SHLIB_LINK}" = "X" || test "yes" != "yes" || echo "-DENABLE_SHARED_LIBGCC"` -DCONFIGURE_SPECS="\"\"" -DTARGET_MACHINE=\"cris-elf\" -DPERSONALITY=\"ar\" -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-format-attribute -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Wold-style-definition -Wc++-compat -fno-common  -DHAVE_CONFIG_H -I. -I. -I/tmp/hpautotest-gcc1/gcc/gcc -I/tmp/hpautotest-gcc1/gcc/gcc/. -I/tmp/hpautotest-gcc1/gcc/gcc/../include -I/tmp/hpautotest-gcc1/gcc/gcc/../libcpp/include -I
 /tmp/hpautotest-gcc1/cris-elf/gccobj/./gmp -I/tmp/hpautotest-gcc1/gcc/gmp -I/tmp/hpautotest-gcc1/cris-elf/gccobj/./mpfr -I/tmp/hpautotest-gcc1/gcc/mpfr -I/tmp/hpautotest-gcc1/gcc/mpc/src  -I/tmp/hpautotest-gcc1/gcc/gcc/../libdecnumber -I/tmp/hpautotest-gcc1/gcc/gcc/../libdecnumber/dpd -I../libdecnumber    /tmp/hpautotest-gcc1/gcc/gcc/gcc-ar.c -o gcc-ar.o
/tmp/hpautotest-gcc1/gcc/gcc/gcc-ar.c: In function 'main':
/tmp/hpautotest-gcc1/gcc/gcc/gcc-ar.c:48: error: 'target_machine' undeclared (first use in this function)
/tmp/hpautotest-gcc1/gcc/gcc/gcc-ar.c:48: error: (Each undeclared identifier is reported only once
/tmp/hpautotest-gcc1/gcc/gcc/gcc-ar.c:48: error: for each function it appears in.)
make[2]: *** [gcc-ar.o] Error 1

brgds, H-P

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2"
  2011-10-29  9:04 ` Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2" Hans-Peter Nilsson
@ 2011-10-29 12:44   ` Andi Kleen
  2011-10-29 13:02     ` Andi Kleen
  2011-10-29 13:45     ` Hans-Peter Nilsson
  0 siblings, 2 replies; 8+ messages in thread
From: Andi Kleen @ 2011-10-29 12:44 UTC (permalink / raw)
  To: Hans-Peter Nilsson; +Cc: andi, gcc-patches, ak

> This broke cross to cris-elf and I guess many other targets
> with TOT binutils, as follows:
> 
> mv -f Tlto-wrapper lto-wrapper

Oops.  Can you please confirm this patch fixes it?

-Andi

diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c
index fc7e4a2..1e86d20 100644
--- a/gcc/gcc-ar.c
+++ b/gcc/gcc-ar.c
@@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.  If not see
 
 static const char standard_libexec_prefix[] = STANDARD_LIBEXEC_PREFIX;
 static const char standard_bin_prefix[] = STANDARD_BINDIR_PREFIX;
+static const char *const target_machine = TARGET_MACHINE;
 
 static const char dir_separator[] = { DIR_SEPARATOR, 0 };
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2"
  2011-10-29 12:44   ` Andi Kleen
@ 2011-10-29 13:02     ` Andi Kleen
  2011-10-29 13:45     ` Hans-Peter Nilsson
  1 sibling, 0 replies; 8+ messages in thread
From: Andi Kleen @ 2011-10-29 13:02 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Hans-Peter Nilsson, gcc-patches, ak

On Sat, Oct 29, 2011 at 10:09:48AM +0200, Andi Kleen wrote:
> > This broke cross to cris-elf and I guess many other targets
> > with TOT binutils, as follows:
> > 
> > mv -f Tlto-wrapper lto-wrapper
> 
> Oops.  Can you please confirm this patch fixes it?

I committed the patch with ChangeLog as as obvious now, after running
a full test and testing the if path manually.
-Andi

> 
> -Andi
> 
> diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c
> index fc7e4a2..1e86d20 100644
> --- a/gcc/gcc-ar.c
> +++ b/gcc/gcc-ar.c
> @@ -29,6 +29,7 @@ along with GCC; see the file COPYING3.  If not see
>  
>  static const char standard_libexec_prefix[] = STANDARD_LIBEXEC_PREFIX;
>  static const char standard_bin_prefix[] = STANDARD_BINDIR_PREFIX;
> +static const char *const target_machine = TARGET_MACHINE;
>  
>  static const char dir_separator[] = { DIR_SEPARATOR, 0 };
>  
> 

-- 
ak@linux.intel.com -- Speaking for myself only.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2"
  2011-10-29 12:44   ` Andi Kleen
  2011-10-29 13:02     ` Andi Kleen
@ 2011-10-29 13:45     ` Hans-Peter Nilsson
  1 sibling, 0 replies; 8+ messages in thread
From: Hans-Peter Nilsson @ 2011-10-29 13:45 UTC (permalink / raw)
  To: andi; +Cc: hp, andi, gcc-patches, ak

> From: Andi Kleen <andi@firstfloor.org>
> Date: Sat, 29 Oct 2011 10:09:48 +0200

> Oops.  Can you please confirm this patch fixes it?

My autotester is still busy after your commit, but has passed
the point of failure.  Thanks for fixing.

brgds, H-P

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-10-29 12:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-21  2:57 [PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2 Andi Kleen
2011-10-25 12:16 ` PING " Andi Kleen
2011-10-25 15:49   ` Diego Novillo
2011-10-28 11:43 ` Richard Guenther
2011-10-29  9:04 ` Build broken due to "[PATCH] Add gcc-ar/nm/ranlib wrappers for slim LTO v2" Hans-Peter Nilsson
2011-10-29 12:44   ` Andi Kleen
2011-10-29 13:02     ` Andi Kleen
2011-10-29 13:45     ` Hans-Peter Nilsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).