Patchwork PING^2 [PATCH] Support for AMD64 targets running GNU/kFreeBSD

login
register
mail settings
Submitter Robert Millan
Date May 21, 2011, 11:15 a.m.
Message ID <BANLkTi=toqAbXxt9=XUg_zdwAYX=H5Nbvw@mail.gmail.com>
Download mbox | patch
Permalink /patch/96691/
State New
Headers show

Comments

Robert Millan - May 21, 2011, 11:15 a.m.
Please can this patch be considered? It's several months old (sent in
Jan 2011), and it is critical to use of GCC on GNU/kFreeBSD.

2011/1/26 Robert Millan <rmh@gnu.org>:
> Ping!
>
> 2011/1/18 Robert Millan <rmh@gnu.org>:
>> 2011/1/14 Robert Millan <rmh@gnu.org>:
>>> 2011/1/12 Robert Millan <rmh@gnu.org>:
>>>>> * The headers config/kfreebsd-gnu.h etc. override
>>>>>  GLIBC_DYNAMIC_LINKER.  But the 64-bit configurations
>>>>>  x86_64-*-kfreebsd*-gnu and x86_64-*-knetbsd*-gnu do not appear to
>>>>>  use any header that would override GLIBC_DYNAMIC_LINKER32 and
>>>>>  GLIBC_DYNAMIC_LINKER64, which are what LINK_SPEC in linux64.h
>>>>>  actually uses.  Thus those configurations would use Linux-specific
>>>>>  dynamic linker settings, which seems unlikely to be as intended.
>>>>
>>>> It's not as intended. On amd64 we use /lib/ld.so.1 and
>>>> /lib/ld-kfreebsd-x86-64.so.1.
>>>
>>> It seems x86_64-kfreebsd-gnu has been broken for a while.  I
>>> just realized that I wrote a patch to fix this in 2006 [1], but
>>> somehow it was never merged in GCC (actually I'm not even
>>> sure I submitted it).
>>>
>>> In the meantime Debian GNU/kFreeBSD has been using this
>>> patch to build GCC on their "kfreebsd-amd64" port.
>>>
>>> I can prepare an updated version of this patch (relative to
>>> trunk + your linux.h overhaul [2]).
>>
>> Here is it.
>>
>> --
>> Robert Millan
>>
>
>
>
> --
> Robert Millan
>
Joseph S. Myers - May 21, 2011, 11:45 a.m.
On Sat, 21 May 2011, Robert Millan wrote:

> Please can this patch be considered? It's several months old (sent in
> Jan 2011), and it is critical to use of GCC on GNU/kFreeBSD.

Please send a patch against *current trunk* and CC *relevant target 
architecture maintainers*.  linux*.h headers are no longer used on 
non-Linux targets (since my 2011-04-28 patch - on which I CC:ed you) so 
this patch version is no longer appropriate.  I think you'll want to make 
gnu-user64.h use GNU_USER_LINK_EMULATION32 and GNU_USER_LINK_EMULATION64 
similarly to how gnu-user.h uses GNU_USER_LINK_EMULATION.

Patch

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 168952)
+++ gcc/config.gcc	(working copy)
@@ -1267,7 +1267,7 @@ 
 	case ${target} in
 	x86_64-*-linux*)
 	  default_gnu_indirect_function=glibc-2011 ;;
-	x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h" ;;
+	x86_64-*-kfreebsd*-gnu) tm_file="${tm_file} kfreebsd-gnu.h i386/kfreebsd-gnu.h" ;;
 	x86_64-*-knetbsd*-gnu) tm_file="${tm_file} knetbsd-gnu.h" ;;
 	esac
 	tmake_file="${tmake_file} i386/t-linux64 i386/t-crtstuff i386/t-crtpc i386/t-crtfm t-dfprules"
Index: gcc/config/i386/linux.h
===================================================================
--- gcc/config/i386/linux.h	(revision 168952)
+++ gcc/config/i386/linux.h	(working copy)
@@ -91,7 +91,7 @@ 
    done.  */
 
 /* These macros may be overridden in k*bsd-gnu.h and i386/k*bsd-gnu.h. */
-#define LINK_EMULATION "elf_i386"
+#define LINK_EMULATION(em)	em
 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
 
 #undef  ASM_SPEC
@@ -100,7 +100,7 @@ 
 
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
-  { "link_emulation", LINK_EMULATION },\
+  { "link_emulation", LINK_EMULATION("elf_i386") },\
   { "dynamic_linker", LINUX_DYNAMIC_LINKER }
 
 #undef	LINK_SPEC
Index: gcc/config/i386/kfreebsd-gnu.h
===================================================================
--- gcc/config/i386/kfreebsd-gnu.h	(revision 168952)
+++ gcc/config/i386/kfreebsd-gnu.h	(working copy)
@@ -19,7 +19,15 @@ 
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
-#undef LINK_EMULATION
-#define LINK_EMULATION "elf_i386_fbsd"
+#ifdef GLIBC_DYNAMIC_LINKER32
+#undef GLIBC_DYNAMIC_LINKER32
+#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
+#endif
+
+#ifdef GLIBC_DYNAMIC_LINKER64
+#undef GLIBC_DYNAMIC_LINKER64
+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld-kfreebsd-x86-64.so.1"
+#endif
+
 #undef REG_NAME
 #define REG_NAME(reg) sc_ ## reg
Index: gcc/config/i386/linux64.h
===================================================================
--- gcc/config/i386/linux64.h	(revision 168952)
+++ gcc/config/i386/linux64.h	(working copy)
@@ -75,7 +75,8 @@ 
  %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
 
 #undef	LINK_SPEC
-#define LINK_SPEC "%{" SPEC_64 ":-m elf_x86_64} %{" SPEC_32 ":-m elf_i386} \
+#define LINK_SPEC "%{" SPEC_64 ":-m " LINK_EMULATION("elf_x86_64") "} \
+  %{" SPEC_32 ":-m " LINK_EMULATION("elf_i386") "} \
   %{shared:-shared} \
   %{!shared: \
     %{!static: \
Index: gcc/config/kfreebsd-gnu.h
===================================================================
--- gcc/config/kfreebsd-gnu.h	(revision 168952)
+++ gcc/config/kfreebsd-gnu.h	(working copy)
@@ -35,3 +35,6 @@ 
 #undef GLIBC_DYNAMIC_LINKER
 #define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
 #endif
+
+#undef LINK_EMULATION
+#define LINK_EMULATION(em) em "_fbsd"