public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Built gcc 4.7.0 on OpenBSD x86_64
@ 2012-03-24  1:24 Kyle Markley
  0 siblings, 0 replies; only message in thread
From: Kyle Markley @ 2012-03-24  1:24 UTC (permalink / raw)
  To: gcc

  Hello,

Following the recommendations on 
http://gcc.gnu.org/install/finalinstall.html, I'm reporting my success 
at building gcc 4.7.0 on amd64-unknown-openbsd4.8 because this platform 
is not listed in http://gcc.gnu.org/buildstat.html.  My build is only 
"mostly" successful; I encountered and worked around several problems 
which I detail below.  Help and suggestions are welcome.

Here's gcc -v:
Using built-in specs.
COLLECT_GCC=gcc-4.7.0
COLLECT_LTO_WRAPPER=/storage/gcc470/usr/local/bin/../libexec/gcc/x86_64-unknown-openbsd4.8/4.7.0/lto-wrapper
Target: x86_64-unknown-openbsd4.8
Configured with: ../gcc/configure --program-suffix=-4.7.0 
--enable-threads --disable-werror
Thread model: posix
gcc version 4.7.0 (GCC)

I have been unable so far to secure a release from my employer to 
contribute patches to GCC.  So I'll just describe what I did as a 
reference for others.

I configured with --disable-werror because on earlier releases of GCC I 
had trouble with the definition of NULL and functions expecting a 
sentinel.  The switch is the easiest workaround, but might not be 
necessary anymore.

I ran into two problems that have open PRs:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39618
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52471

The first problem can be worked around most easily by killing the hung 
process.  I do not have a "good" workaround for the second problem -- I 
bypassed the ICE by disabling some code in gcc/dwarf2cfi.c, which 
hobbles my ability to use a debugger.  See my diffs below.

On my platform I have an issue building libiberty.  In 
libiberty/stack-limit.c I need to #include <sys/time.h> immediately 
before <sys/resource.h>.  I have also built GDB 7.4, which also uses 
libiberty, and it needs the identical workaround.

While building GCC this command is eventually executed, and hangs on my 
system:
   ./gcj-dbtool -n classmap.db || touch classmap.db
The command itself was a sufficient hint that this is optional.  If I 
kill the hung gcj-dbtool process, everything continues nicely.

Later, I get an error compiling ../../../gcc/boehm-gc/misc.c with a 
suggestive error message:
In file included from /usr/include/xmmintrin.h:39:0,
                  from /usr/include/emmintrin.h:34,
                  from ../../../gcc/libitm/config/x86/target.h:77,
                  from ../../../gcc/libitm/libitm_i.h:82,
                  from ../../../gcc/libitm/aatree.cc:28:
/usr/include/mmintrin.h: In function '__m64 _mm_add_si64(__m64, __m64)':
/usr/include/mmintrin.h:312:72: error: cannot convert 'long long int' to 
'__vector(1) long long int' for argument '1' to '__vector(1) long long 
int __builtin_ia32_paddq(__vector(1) long long int, __vector(1) long 
long int)'

Those header files should come from gcc/config/i386, not from 
/usr/include.  If I symlink gcc/config/i386/*intrin.h into the build 
directory (obj/x86_64-unknown-openbsd4.8/libitm) and retry, it works.  
This may point to a bug in makefile generation that goes unnoticed on 
other platforms where the /usr/include headers and the gcc/config/i386 
headers match.

The resulting compiler works.  The only trouble I've noticed so far is 
with std::thread.  Any attempt to create a std::thread throws a 
std::system_error.  I haven't been able to figure out what's wrong 
because the debugger doesn't work very well after my edit to 
gcc/dwarf2cfi.c.

Here are my diffs.  I do not warrant that any of these are correct, but 
they work well enough for me that I can make undebuggable 
single-threaded programs.

Index: boehm-gc/include/private/gcconfig.h
===================================================================
--- boehm-gc/include/private/gcconfig.h (revision 185724)
+++ boehm-gc/include/private/gcconfig.h (working copy)
@@ -330,6 +330,11 @@
  #   define OPENBSD
  #   define mach_type_known
  # endif
+# if defined(__OpenBSD__) && (defined(__x86_64__))
+#   define X86_64
+#   define OPENBSD
+#   define mach_type_known
+# endif
  # if defined(FREEBSD) && (defined(i386) || defined(__i386__))
  #   define I386
  #   define mach_type_known
@@ -2065,6 +2070,12 @@
         extern char etext[];
  #      define SEARCH_FOR_DATA_START
  #   endif
+#   ifdef OPENBSD
+#      define OS_TYPE "OPENBSD"
+#      define HEURISTIC2
+       extern char etext[];
+#      define DATASTART ((ptr_t)(etext))
+#   endif
  #   ifdef SUNOS5
  #      define ELF_CLASS ELFCLASS64
  #      define OS_TYPE "SUNOS5"
Index: libiberty/stack-limit.c
===================================================================
--- libiberty/stack-limit.c     (revision 185724)
+++ libiberty/stack-limit.c     (working copy)
@@ -39,6 +39,7 @@
  #include <stdint.h>
  #endif
  #ifdef HAVE_SYS_RESOURCE_H
+#include <sys/time.h>
  #include <sys/resource.h>
  #endif

Index: libgcc/config.host
===================================================================
--- libgcc/config.host  (revision 185724)
+++ libgcc/config.host  (working copy)
@@ -538,6 +538,8 @@
         ;;
  i[34567]86-*-openbsd*)
         ;;
+x86_64-*-openbsd*)
+       ;;
  i[34567]86-*-linux*)
         extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o 
crtfastmath.o"
         tmake_file="${tmake_file} i386/t-crtpc i386/t-crtfm 
i386/t-crtstuff t-dfprules"
Index: gcc/dwarf2cfi.c
===================================================================
--- gcc/dwarf2cfi.c     (revision 185724)
+++ gcc/dwarf2cfi.c     (working copy)
@@ -2904,9 +2904,11 @@
    create_pseudo_cfg ();

    /* Do the work.  */
+/*
    create_cfi_notes ();
    connect_traces ();
    add_cfis_to_fde ();
+*/

    /* Free all the data we allocated.  */
    {
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc      (revision 185724)
+++ gcc/config.gcc      (working copy)
@@ -1225,6 +1225,13 @@
         gas=yes
         gnu_ld=yes
         ;;
+x86_64-*-openbsd*)
+       tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h"
+       tm_file="${tm_file} openbsd.h openbsd-stdint.h 
openbsd-libpthread.h i386/openbsdelf.h"
+       extra_options="${extra_options} openbsd.opt"
+       gas=yes
+       gnu_ld=yes
+       ;;
  i[34567]86-*-linux* | i[34567]86-*-kfreebsd*-gnu | 
i[34567]86-*-knetbsd*-gnu | i[34567]86-*-gnu* | 
i[34567]86-*-kopensolaris*-gnu)
                         # Intel 80386's running GNU/*
                         # with ELF format using glibc 2

-- 
Kyle Markley

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-03-24  1:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-24  1:24 Built gcc 4.7.0 on OpenBSD x86_64 Kyle Markley

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).