[Bug go/46986] Go is not supported on Darwin

2012-02-18 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #33 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-18 14:07:03 UTC ---
Created attachment 26699
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26699
gcc-darwin_libgo.patch


[Bug go/46986] Go is not supported on Darwin

2012-02-18 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #34 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-18 14:08:26 UTC ---
There is the other big change needed, which is to prefix all the asm names
with USER_LABEL_PREFIX (_) so that they will actually link properly later.


[Bug go/46986] Go is not supported on Darwin

2012-02-18 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #35 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-18 14:15:28 UTC ---
At least it compiles again, after adding asm prefix and ptrace/sysctl...
Hacked it in for now, but needs a better patch for runtime and syscall.

Still fails to actually run, but I guess that is due to something else:
panic: runtime error: invalid memory address or nil pointer dereference


[Bug go/46986] Go is not supported on Darwin

2012-02-16 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #32 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-16 19:28:22 UTC ---
Then it's more about fixing library issues, like the macros used
for TIOCNOTTY/TIOCSCTTY or st_atime/st_mtime/st_ctime and sysctl.


[Bug go/46986] Go is not supported on Darwin

2012-02-16 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #31 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-16 19:22:52 UTC ---
Created attachment 26683
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26683
gcc-darwin_goc2c.patch


[Bug go/46986] Go is not supported on Darwin

2012-02-16 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #30 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-16 19:22:25 UTC ---
Created attachment 26682
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26682
gcc-gox_import.diff


[Bug go/46986] Go is not supported on Darwin

2012-02-16 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #29 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-16 19:21:45 UTC ---
It still needs to generate the extra underscore for Darwin,
and it still needs to fix the bug mentioned in Comment #12.


[Bug go/46986] Go is not supported on Darwin

2012-02-15 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #19 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-15 22:08:59 UTC ---
(In reply to comment #17)
 I think that now the only thing which will need to change in the Go frontend
 proper is using otool instead of objcopy in libgo/Makefile.am.

The otool was simple enough, but the other go_export issues still remain.
And there are some new issues with ucontext being deprecated on Mac OS X.


[Bug go/46986] Go is not supported on Darwin

2012-02-15 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #22 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-15 22:16:41 UTC ---
Created attachment 26670
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26670
gcc-ucontext.diff

ucontext is deprecated on Mac OS X 10.5-10.6, including ucontext.h gives error:

In file included from ../../../gcc/libgo/runtime/runtime.h:20:0,
 from ../../../gcc/libgo/runtime/go-main.c:21:
/usr/include/ucontext.h:42:2: error: #error ucontext routines are deprecated,
and require _XOPEN_SOURCE to be defined

ucontext is missing altogether from Mac OS X 10.7, but there is no TLS either:

error: thread-local storage not supported for this target


[Bug go/46986] Go is not supported on Darwin

2012-02-15 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #21 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-15 22:12:24 UTC ---
Created attachment 26669
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26669
gcc-go_export.diff

Need to give both segment and section for export on Darwin:

/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Expected comma
after segment-name
/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Rest of line
ignored. 1st junk character valued 32 ( ).
/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Junk character
92 (\).
/var/folders/SU/SU8yve9tFP4OXneVoY+KsU+++TI/-Tmp-//ccWicBIX.s:3:Rest of line
ignored. 1st junk character valued 49 (1).


[Bug go/46986] Go is not supported on Darwin

2012-02-15 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #20 from Anders F Björklund afb at users dot sourceforge.net 
2012-02-15 22:10:09 UTC ---
Created attachment 26668
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=26668
updated patch for trunk


[Bug go/46986] Go is not supported on Darwin

2011-09-05 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

Anders F Björklund afb at users dot sourceforge.net changed:

   What|Removed |Added

  Attachment #25177|0   |1
is obsolete||

--- Comment #16 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-05 14:01:36 UTC ---
Created attachment 25196
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=25196
import-export.diff

Here's an updated portable version. Using otool if LIBGO_IS_DARWIN.

Used a shell function instead of a shell script, for gengox tool...


[Bug go/46986] Go is not supported on Darwin

2011-09-04 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #15 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-04 18:14:48 UTC ---
The whole patch is Darwin-centric, in that it's only applied on Darwin.
You are right that it first needs to be conditionalized to go upstream.

afaik, $(OTOOL) would be something like missing-otool on e.g. Linux ?
(just as we now get $(OBJCOPY) set to missing-objcopy on Mac OS X...)


[Bug go/46986] Go is not supported on Darwin

2011-09-02 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #9 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-02 06:40:28 UTC ---
(In reply to comment #8)
  hello world tests OK on Snow Leopard, with patch
 
 This patch fails on darwin11 when applied to gcc-4_6-branch...

Seems like the patch worked (= didn't fail to apply),
but that the build failed due to missing dependencies ?

 f=`echo sort/sort.lo | sed -e 's/.lo$/.o/'`; missing-objcopy -j
 __GNU_GO.__go_export $f sort.gox.tmp  mv -f sort.gox.tmp sort.gox
 /bin/sh: missing-objcopy: command not found
 make[4]: *** [sort.gox] Error 127
 make[4]: *** Waiting for unfinished jobs
 
 It seems to required binutils to be installed (which we really want to avoid).

Yes, it requires OBJCOPY=gobjcopy. Maybe this requirement
should be replaced with some custom gox-extract tool ?

Since the .go_export section name had to be changed, anyway:
http://golang.org/doc/gccgo_install.html#Imports


[Bug go/46986] Go is not supported on Darwin

2011-09-02 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #10 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-02 08:45:22 UTC ---

Here's my attempt at a native version.
(of that gox-extract shell script)

Instead of the default variant:
OBJCOPY=${OBJCOPY:-objcopy}
$OBJCOPY -j .go_export $1 $2

The Darwin version could be this:
OTOOL=${OTOOL:-otool}
$OTOOL -s __GNU_GO __go_export $1 |
grep -v ^$1: | grep -v Contents of (__GNU_GO,__go_export) section |
cut -f 2- | tr -d ' ' | xxd -r -p - $2

It doesn't include the objcopy header,
but I believe that is skipped anyway ?


[Bug go/46986] Go is not supported on Darwin

2011-09-02 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #11 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-02 09:06:25 UTC ---
 OTOOL=${OTOOL:-otool}
 $OTOOL -s __GNU_GO __go_export $1 |
 grep -v ^$1: | grep -v Contents of (__GNU_GO,__go_export) section |
 cut -f 2- | tr -d ' ' | xxd -r -p - $2

Apparently -X avoids that header text:
$OTOOL -s __GNU_GO __go_export -X $1 | cut -f 2- | tr -d ' ' | xxd -r -p - $2


[Bug go/46986] Go is not supported on Darwin

2011-09-02 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #12 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-02 11:07:33 UTC ---
 It doesn't include the objcopy header,
 but I believe that is skipped anyway ?

Or at least it was *supposed* to ignore it,
but the Stream_from_file was horribly buggy.
(apparently has a dyslectic problem with
comparisons, aggrevated by copy/paste ?)

It always returned  instead of any data,
so failed to provide the required magic...
(or any other data beyond that, if asked)
Fixing that class, and it works just fine:

Index: gcc/go/gofrontend/import.cc
===
--- gcc/go/gofrontend/import.cc(revision 178444)
+++ gcc/go/gofrontend/import.cc(working copy)
@@ -836,7 +836,7 @@
 bool
 Stream_from_file::do_peek(size_t length, const char** bytes)
 {
-  if (this-data_.length() = length)
+  if (this-data_.length() = length)
 {
   *bytes = this-data_.data();
   return true;
@@ -854,7 +854,7 @@
   return false;
 }

-  if (lseek(this-fd_, - got, SEEK_CUR) != 0)
+  if (lseek(this-fd_, - got, SEEK_CUR)  0)
 {
   if (!this-saw_error())
 error(lseek failed: %m);
@@ -876,7 +876,7 @@
 void
 Stream_from_file::do_advance(size_t skip)
 {
-  if (lseek(this-fd_, skip, SEEK_CUR) != 0)
+  if (lseek(this-fd_, skip, SEEK_CUR)  0)
 {
   if (!this-saw_error())
 error(lseek failed: %m);

That bug should affect any other platform too,
if trying to use naked .gox (without object) ?


[Bug go/46986] Go is not supported on Darwin

2011-09-02 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #13 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-02 11:10:51 UTC ---
Created attachment 25177
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=25177
import-export.diff

Just the import/export changes, i.e. outside libgo directory.


[Bug go/46986] Go is not supported on Darwin

2011-09-01 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

--- Comment #6 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-01 18:09:02 UTC ---
Created attachment 25168
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=25168
updated patch for 4.6.1

hello world tests OK on Snow Leopard, with patch


[Bug go/46986] Go is not supported on Darwin

2011-09-01 Thread afb at users dot sourceforge.net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

Anders F Björklund afb at users dot sourceforge.net changed:

   What|Removed |Added

 CC||afb at users dot
   ||sourceforge.net

--- Comment #7 from Anders F Björklund afb at users dot sourceforge.net 
2011-09-01 18:11:32 UTC ---
Another problem is that the -static-libgo flag doesn't work, because the static
library has the same name and location as the dynamic lib and therefore darwin
will always prefer the dynamic library. It probably needs to be renamed (to
something like libgo_static.a), since otherwise the -Wl,-search_paths_first
flag is needed to avoid picking up libgo.dylib even if it comes later in the
paths...