diff mbox

Go patch committed: Pass -t to native linker on Solaris

Message ID yddfvj5i0mc.fsf@lokon.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth June 16, 2014, 10:56 a.m. UTC
Ian Lance Taylor <iant@google.com> writes:

> This patch changes the gccgo driver to pass -t to the native linker on
> Solaris.  This avoids warnings like
>
> ld: warning: symbol 'go$zerovalue' has differing sizes:
>         (file hello.o value=0x8; file
> i386-pc-solaris2.11/libgo/.libs/libgo.so value=0x800);
>         hello.o definition taken and updated with larger size
>
> The symbol go$zerovalue is a common symbol and it's normal for it to
> have different sizes in different object files and shared libraries.
> The linker should take the larger size, which is what it does.
> Unfortunately, by default, it emits a warning, which in this case is
> useless.  This patch passes the -t option to disable the warning.
>
> Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
> Bootstrapped and ran a few tests on x86_64-sun-solaris.  Committed to
> mainline.

Works fine, thanks.  Just before your patch arrived, I meant to test the
following, slightly more general patch.  Perhaps it's an option to
handle other quirks like this?

	Rainer


2014-06-13  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc/go:
	PR go/61496
	* gospec.c (lang_specific_driver) [TARGET_GO_LINK_OPTIONS]: Pass
	target specific link options.

	gcc:
	PR go/61496
	* config/sol2.h [!USE_GLD] (TARGET_GO_LINK_OPTIONS): Define.

Comments

Ian Lance Taylor June 16, 2014, 1:58 p.m. UTC | #1
On Mon, Jun 16, 2014 at 3:56 AM, Rainer Orth
<ro@cebitec.uni-bielefeld.de> wrote:
>
> Works fine, thanks.  Just before your patch arrived, I meant to test the
> following, slightly more general patch.  Perhaps it's an option to
> handle other quirks like this?

This approach is fine with me, but the target macro should be
documented somwhere.  We need to document that multiple options have
to be separated with commas, not spaces.

Ian
Ian Lance Taylor June 16, 2014, 2:59 p.m. UTC | #2
On Mon, Jun 16, 2014 at 6:58 AM, Ian Lance Taylor <iant@google.com> wrote:
> On Mon, Jun 16, 2014 at 3:56 AM, Rainer Orth
> <ro@cebitec.uni-bielefeld.de> wrote:
>>
>> Works fine, thanks.  Just before your patch arrived, I meant to test the
>> following, slightly more general patch.  Perhaps it's an option to
>> handle other quirks like this?
>
> This approach is fine with me, but the target macro should be
> documented somwhere.  We need to document that multiple options have
> to be separated with commas, not spaces.

Also I think it would be better to write it along the lines of the
following, to allow runtime determination of whether the option is
needed.


#ifdef TARGET_GO_LINK_OPTIONS
  /* Pass target specific linker options if present.  */
  {
    const char *p = TARGET_GO_LINK_OPTIONS;
    if (p != NULL && *p != '\0')
      generate_option (OPT_Wl_, TARGET_GO_LINK_OPTIONS, 1, CL_DRIVER,
		       &new_decoded_options[j++]);
  }
#endif


Ian
diff mbox

Patch

# HG changeset patch
# Parent 59e0e6f1eecd53ddab49b2cd5015be221b5e505a
Suppress Solaris ld warnings about go$zerovalue sizes (PR go/61496)

diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -303,6 +303,12 @@  along with GCC; see the file COPYING3.  
 /* collect2.c can only parse GNU nm -n output.  Solaris nm needs -png to
    produce the same format.  */
 #define NM_FLAGS "-png"
+
+#ifndef USE_GLD
+/* Solaris ld warns about common symbols of differing sizes, which Go uses
+   for go$zerovalue.  Pass -t to suppress that warning.  */
+#define TARGET_GO_LINK_OPTIONS "-t"
+#endif
 
 /* The system headers under Solaris 2 are C++-aware since 2.0.  */
 #define NO_IMPLICIT_EXTERN_C
diff --git a/gcc/go/gospec.c b/gcc/go/gospec.c
--- a/gcc/go/gospec.c
+++ b/gcc/go/gospec.c
@@ -395,6 +395,12 @@  lang_specific_driver (struct cl_decoded_
     }
 #endif
 
+#ifdef TARGET_GO_LINK_OPTIONS
+  /* Pass target specific linker options if present.  */
+  generate_option (OPT_Wl_, TARGET_GO_LINK_OPTIONS, 1, CL_DRIVER,
+		   &new_decoded_options[j++]);
+#endif
+
   *in_decoded_options_count = j;
   *in_decoded_options = new_decoded_options;
   *in_added_libraries = added_libraries;