Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Mar 2012 10:22:14 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/165771: Fix devel/binutils build with clang, after gold was enabled
Message-ID:  <201203061022.q26AMEB2072701@red.freebsd.org>
Resent-Message-ID: <201203061030.q26AUDBt040254@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         165771
>Category:       ports
>Synopsis:       Fix devel/binutils build with clang, after gold was enabled
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 06 10:30:13 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Dimitry Andric
>Release:        10.0-CURRENT
>Organization:
The FreeBSD Project
>Environment:
FreeBSD vm-dvs-dimtest2.home.andric.com 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r232293M: Wed Feb 29 18:32:49 CET 2012     dim@vm-dvs-dimtest2.home.andric.com:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
After ports/165406, gold got enabled in the devel/binutils ports.
Unfortunately, gold does not cleanly compile with clang, neither the
3.0 release in the base system, nor top-of-trunk clang.

Here is a set of patch files to make gold compile with clang.

>How-To-Repeat:
CC=clang CXX=clang++ CPP=clang-cpp make -C /usr/ports/devel/binutils

>Fix:


Patch attached with submission follows:

Index: devel/binutils/files/patch-gold__archive.h
===================================================================
RCS file: devel/binutils/files/patch-gold__archive.h
diff -N devel/binutils/files/patch-gold__archive.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/binutils/files/patch-gold__archive.h	5 Mar 2012 19:40:52 -0000
@@ -0,0 +1,11 @@
+--- gold/archive.h.orig	2011-06-02 22:13:23.000000000 +0200
++++ gold/archive.h	2012-03-05 18:57:24.000000000 +0100
+@@ -40,7 +40,7 @@ class Input_group;
+ class Layout;
+ class Symbol_table;
+ class Object;
+-class Read_symbols_data;
++struct Read_symbols_data;
+ class Input_file_lib;
+ class Incremental_archive_entry;
+ 
Index: devel/binutils/files/patch-gold__arm.cc
===================================================================
RCS file: devel/binutils/files/patch-gold__arm.cc
diff -N devel/binutils/files/patch-gold__arm.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/binutils/files/patch-gold__arm.cc	5 Mar 2012 19:40:52 -0000
@@ -0,0 +1,40 @@
+--- gold/arm.cc.orig	2011-11-21 10:40:12.000000000 +0100
++++ gold/arm.cc	2012-03-05 20:12:40.000000000 +0100
+@@ -2372,8 +2372,8 @@ class Target_arm : public Sized_target<3
+ 			       unsigned char* preloc_out);
+  
+   // Return whether SYM is defined by the ABI.
+-  bool
+-  do_is_defined_by_abi(Symbol* sym) const
++  virtual bool
++  do_is_defined_by_abi(const Symbol* sym) const
+   { return strcmp(sym->name(), "__tls_get_addr") == 0; }
+ 
+   // Return whether there is a GOT section.
+@@ -7039,7 +7039,7 @@ Stub_addend_reader<elfcpp::SHT_REL, big_
+     const unsigned char* view,
+     const typename Reloc_types<elfcpp::SHT_REL, 32, big_endian>::Reloc&) const
+ {
+-  typedef struct Arm_relocate_functions<big_endian> RelocFuncs;
++  typedef class Arm_relocate_functions<big_endian> RelocFuncs;
+   
+   switch (r_type)
+     {
+@@ -11778,7 +11778,7 @@ Target_arm<big_endian>::scan_span_for_co
+ 	  // Check if we have an offending branch instruction.
+ 	  uint16_t upper_insn = (insn >> 16) & 0xffffU;
+ 	  uint16_t lower_insn = insn & 0xffffU;
+-	  typedef struct Arm_relocate_functions<big_endian> RelocFuncs;
++	  typedef class Arm_relocate_functions<big_endian> RelocFuncs;
+ 
+ 	  if (cortex_a8_reloc != NULL
+ 	      && cortex_a8_reloc->reloc_stub() != NULL)
+@@ -11881,7 +11881,7 @@ Target_arm<big_endian>::apply_cortex_a8_
+   Valtype lower_insn = elfcpp::Swap<16, big_endian>::readval(wv + 1);
+   off_t branch_offset = stub_address - (insn_address + 4);
+ 
+-  typedef struct Arm_relocate_functions<big_endian> RelocFuncs;
++  typedef class Arm_relocate_functions<big_endian> RelocFuncs;
+   switch (stub->stub_template()->type())
+     {
+     case arm_stub_a8_veneer_b_cond:
Index: devel/binutils/files/patch-gold__gc.h
===================================================================
RCS file: devel/binutils/files/patch-gold__gc.h
diff -N devel/binutils/files/patch-gold__gc.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/binutils/files/patch-gold__gc.h	5 Mar 2012 19:40:52 -0000
@@ -0,0 +1,11 @@
+--- gold/gc.h.orig	2011-05-24 23:41:10.000000000 +0200
++++ gold/gc.h	2012-03-05 19:00:49.000000000 +0100
+@@ -40,7 +40,7 @@ template<int size, bool big_endian>
+ class Sized_relobj_file;
+ 
+ template<int sh_type, int size, bool big_endian>
+-class Reloc_types;
++struct Reloc_types;
+ 
+ class Output_section;
+ class General_options;
Index: devel/binutils/files/patch-gold__object.h
===================================================================
RCS file: devel/binutils/files/patch-gold__object.h
diff -N devel/binutils/files/patch-gold__object.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/binutils/files/patch-gold__object.h	5 Mar 2012 19:40:52 -0000
@@ -0,0 +1,11 @@
+--- gold/object.h.orig	2011-08-01 20:25:21.000000000 +0200
++++ gold/object.h	2012-03-05 18:59:19.000000000 +0100
+@@ -47,7 +47,7 @@ class Pluginobj;
+ class Dynobj;
+ class Object_merge_map;
+ class Relocatable_relocs;
+-class Symbols_data;
++struct Symbols_data;
+ 
+ template<typename Stringpool_char>
+ class Stringpool_template;
Index: devel/binutils/files/patch-gold__reloc.h
===================================================================
RCS file: devel/binutils/files/patch-gold__reloc.h
diff -N devel/binutils/files/patch-gold__reloc.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/binutils/files/patch-gold__reloc.h	5 Mar 2012 19:40:52 -0000
@@ -0,0 +1,11 @@
+--- gold/reloc.h.orig	2011-11-21 10:37:51.000000000 +0100
++++ gold/reloc.h	2012-03-05 18:58:15.000000000 +0100
+@@ -37,7 +37,7 @@ namespace gold
+ class General_options;
+ class Object;
+ class Relobj;
+-class Read_relocs_data;
++struct Read_relocs_data;
+ class Symbol;
+ class Layout;
+ class Output_data;
Index: devel/binutils/files/patch-gold__script.cc
===================================================================
RCS file: devel/binutils/files/patch-gold__script.cc
diff -N devel/binutils/files/patch-gold__script.cc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/binutils/files/patch-gold__script.cc	5 Mar 2012 19:40:52 -0000
@@ -0,0 +1,65 @@
+--- gold/script.cc.orig	2011-06-29 23:57:14.000000000 +0200
++++ gold/script.cc	2012-03-05 20:05:49.000000000 +0100
+@@ -2871,7 +2871,7 @@ script_add_search_dir(void* closurev, co
+   else if (!closure->command_line()->options().nostdlib())
+     {
+       std::string s = "-L" + std::string(option, length);
+-      script_parse_option(closurev, s.c_str(), s.size());
++      ::script_parse_option(closurev, s.c_str(), s.size());
+     }
+ }
+ 
+@@ -3011,7 +3011,7 @@ version_script_push_lang(void* closurev,
+       snprintf(buf, langlen + 100,
+ 	       _("unrecognized version script language '%s'"),
+ 	       language.c_str());
+-      yyerror(closurev, buf);
++      ::yyerror(closurev, buf);
+       delete[] buf;
+       code = Version_script_info::LANGUAGE_C;
+     }
+@@ -3165,7 +3165,7 @@ script_string_sort_list_add(String_sort_
+ 			    const struct Wildcard_section* string_sort)
+ {
+   if (pv == NULL)
+-    return script_new_string_sort_list(string_sort);
++    return ::script_new_string_sort_list(string_sort);
+   else
+     {
+       pv->push_back(*string_sort);
+@@ -3189,7 +3189,7 @@ extern "C" String_list_ptr
+ script_string_list_push_back(String_list_ptr pv, const char* str, size_t len)
+ {
+   if (pv == NULL)
+-    return script_new_string_list(str, len);
++    return ::script_new_string_list(str, len);
+   else
+     {
+       pv->push_back(std::string(str, len));
+@@ -3261,7 +3261,7 @@ script_phdr_string_to_type(void* closure
+     if (namelen == phdr_type_names[i].namelen
+ 	&& strncmp(name, phdr_type_names[i].name, namelen) == 0)
+       return phdr_type_names[i].val;
+-  yyerror(closurev, _("unknown PHDR type (try integer)"));
++  ::yyerror(closurev, _("unknown PHDR type (try integer)"));
+   return elfcpp::PT_NULL;
+ }
+ 
+@@ -3336,7 +3336,7 @@ script_parse_memory_attr(void* closurev,
+       case 'l':
+ 	attributes |= MEM_INITIALIZED; break;
+       default:
+-	yyerror(closurev, _("unknown MEMORY attribute"));
++	::yyerror(closurev, _("unknown MEMORY attribute"));
+       }
+ 
+   if (invert)
+@@ -3349,7 +3349,7 @@ extern "C" void
+ script_include_directive(void* closurev, const char*, size_t)
+ {
+   // FIXME: Implement ?
+-  yyerror (closurev, _("GOLD does not currently support INCLUDE directives"));
++  ::yyerror (closurev, _("GOLD does not currently support INCLUDE directives"));
+ }
+ 
+ // Functions for memory regions.
Index: devel/binutils/files/patch-gold__target.h
===================================================================
RCS file: devel/binutils/files/patch-gold__target.h
diff -N devel/binutils/files/patch-gold__target.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ devel/binutils/files/patch-gold__target.h	5 Mar 2012 19:40:52 -0000
@@ -0,0 +1,11 @@
+--- gold/target.h.orig	2011-07-09 00:48:08.000000000 +0200
++++ gold/target.h	2012-03-05 18:52:40.000000000 +0100
+@@ -49,7 +49,7 @@ template<int size, bool big_endian>
+ class Sized_relobj_file;
+ class Relocatable_relocs;
+ template<int size, bool big_endian>
+-class Relocate_info;
++struct Relocate_info;
+ class Reloc_symbol_changes;
+ class Symbol;
+ template<int size>


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203061022.q26AMEB2072701>