Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gospeccy wont compile on OS X #31

Open
jonnosan opened this issue Nov 22, 2010 · 18 comments
Open

gospeccy wont compile on OS X #31

jonnosan opened this issue Nov 22, 2010 · 18 comments

Comments

@jonnosan
Copy link

gospeccy has a dependency on Go-PerfEvents, which looks to be linux only.
As a result, I can't compile (and thus can't execute) gospeccy on my Mac :-(

@remogatto
Copy link
Owner

Yeah, it's a known issue that I never had the time to document and fix. Thank you very much for reporting it. We'll try to fix it as soon as possible.

@ghost
Copy link

ghost commented Nov 22, 2010

The package should now compile on a 32-bit Mac. [https://github.com/0xe2-0x9a-0x9b/Go-PerfEvents/commit/16bb5a901c1b16a6f89198de7344cd21a3ceae37]

64-bit Mac will gain support when somebody generates "types.6.go" file on 64-bit Linux and submits a request to push it into my repository.

@remogatto
Copy link
Owner

Thanks for the fix! I'll generate types.6.go for you as soon as possible

@jonnosan, any success compiling gospeccy after the fix? Feedback would be greatly appreciated! Thanks

@jonnosan
Copy link
Author

I still can't compile Perf-Events:
<----- snip ----->
make -C /Users/jonnosan/src/go/src/pkg/github.com/0xe2-0x9a-0x9b/Go-PerfEvents install
6g -o go.6 src/perf.go src/perf_darwin_amd64.go src/types.6.go
src/perf.go:11: undefined: Attr
src/perf.go:17: undefined: Attr
src/perf.go:17: unknown PerfCounter field 'attr' in struct literal
src/perf.go:17: unknown PerfCounter field 'fd' in struct literal
src/perf.go:20: undefined: Attr
src/perf.go:21: undefined: TYPE_HARDWARE
src/perf.go:22: undefined: ATTR_SIZE
src/perf.go:27: undefined: FLAG_EXCLUDE_USER
src/perf.go:37: undefined: Attr
src/perf_darwin_amd64.go:5: undefined: Attr
src/perf.go:27: too many errors
make[1]: *** [go.6] Error 1
make: *** [/Users/jonnosan/src/go/pkg/darwin_amd64/⚛perf.a] Error 2
<----- snip ----->

This is the first time I've used go, so am not completely sure I've got a working installation of that, nor how to troubleshoot

@jonnosan
Copy link
Author

whoops - I closed this by mistake, can't work out how to reopen

@remogatto
Copy link
Owner

I've generated a struct.6.go file on my Go-PerfEvents and sent pull request 0xe2-0x9a-0x9b/Go-PerfEvents#1. We will wait for the author to merge.

@jonnosan meanwhile, you can try the following:

git clone http://github.com/remogatto/Go-PerfEvents.git
cd Go-PerfEvents
make install

Then go to the gospeccy source dir and issue:

git pull
goam install

You may also need to install the goam build tool that, unfortunately, is currently broken for your platform :) BTW, I've got a trivial fix for it and you can just goinstall it from my fork:

goinstall github.com/remogatto/goam
cd $GOROOT/src/pkg/github.com/remogatto/goam
make install

After the author of Goam and Go-PerfEvents will merge from my repos, I'd suggest you to rearrange your environment to be in sync with her/his repositories. Waiting for your feedback! Thanks.

@ghost
Copy link

ghost commented Nov 27, 2010

@jonnosan: I just merged the fix to the main Go-PerfEvents repository. No need for you to perform the stuff mentioned in the previous message sent be remogatto.

@jonnosan
Copy link
Author

I installed goam per your above instructions, but it seems to be having issues:

Jonathan-Downess-MacBook-Pro:gospeccy jonnosan$ goam install
failed to extract [Go compiler version] from string "6g version 6745+"

@remogatto
Copy link
Owner

This is because goam is not able to extract version numbers that are not numbers (note the + character at the end of the string). I uploaded a naive fix that just trim right any plus character from the version number string.

http://github.com/remogatto/goam

BTW, it seems you're running an "old" version of the 6g compiler. Latest release version number is 6787. Please, consider updating since GoSpeccy lives on the bleeding edge and it usually needs an updated toolchain to build. Hopefully, this is the last issue you encountered before successfully compile and run gospeccy on your mac :) Thanks for your feedback.

@jonnosan
Copy link
Author

I refreshed my go install, and also updated goam.
Looks like it got further down the runway, still not taking off though :-)

Jonathan-Downess-MacBook-Pro:gospeccy jonnosan$ goam install
Installing remote package "0xe2-0x9a-0x9b/Go-SDL"
make -C sdl install
Makefile:18: warning: overriding commands for target `_cgo_defun.c'
/Users/jonnosan/src/go//src/Make.pkg:116: warning: ignoring old commands for target `_cgo_defun.c'
CGOPKGPATH= cgo -- `pkg-config --cflags sdl` sdl.go
Error running gcc:
$ gcc -m64 -E -dM -xc - -D_GNU_SOURCE=1 -D_THREAD_SAFE -I/opt/local/include/SDL <<EOF

typedef struct { char *p; int n; } _GoString_;
_GoString_ GoString(char *p);
_GoString_ GoStringN(char *p, int l);
char *CString(_GoString_);
struct private_hwdata{};
struct SDL_BlitMap{};
#define map _map

#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
static void SetError(const char* description){SDL_SetError("%s",description);}

EOF
<stdin>:10:21: error: SDL/SDL.h: No such file or directory
<stdin>:11:27: error: SDL/SDL_image.h: No such file or directory
make[1]: *** [_cgo_defun.c] Error 2
make: *** [install] Error 2
command "make install" run in directory "/Users/jonnosan/src/go/src/pkg/github.com/0xe2-0x9a-0x9b/Go-SDL" returned an error

@jonnosan
Copy link
Author

So I made a few hacks & got a bit further:
In order to get <SDL/SDL.h> resolved when gcc is called with -I/opt/local/include/SDL, I went to /opt/local/include/SDL and ran ' sudo ln -s . SDL'

Then I got an error "sed: --in-place: No such file or directory" so In the sdl Makefile I changed "sed s/cgo_sdl/cgo_⚛sdl/ --in-place _cgo_defun.c" to "sed s/cgo_sdl/cgo_⚛sdl/ -in-place _cgo_defun.c"

Now I get this:

Jonathan-Downess-MacBook-Pro:gospeccy jonnosan$ goam install
Installing remote package "0xe2-0x9a-0x9b/Go-SDL"
make -C sdl install
Makefile:18: warning: overriding commands for target `_cgo_defun.c'
/Users/jonnosan/src/go//src/Make.pkg:116: warning: ignoring old commands for target `_cgo_defun.c'
make[1]: Nothing to be done for `install'.
make -C sdl/audio install
Makefile:12: warning: overriding commands for target `_cgo_defun.c'
/Users/jonnosan/src/go//src/Make.pkg:116: warning: ignoring old commands for target `_cgo_defun.c'
gcc -m64 -fPIC -O2 -o callback.o -c `pkg-config --cflags sdl` callback.c
callback.c: In function 'get_time':
callback.c:28: error: 'CLOCK_MONOTONIC' undeclared (first use in this function)
callback.c:28: error: (Each undeclared identifier is reported only once
callback.c:28: error: for each function it appears in.)
make[1]: *** [callback.o] Error 1
make: *** [install] Error 2
command "make install" run in directory "/Users/jonnosan/src/go/src/pkg/github.com/0xe2-0x9a-0x9b/Go-SDL" returned an error

@jonnosan
Copy link
Author

So I hacked sdl/audio/callback.c to include an OS X implementation of get_time (cribbed from http://le-depotoir.googlecode.com/svn/trunk/misc/clock_gettime_stub.c )

Then I hacked the sdl/ttf/Makefile to pass -I/opt/local/include to gcc

That got all the SDL package compiling.

In order to get Go-PerfEvents to compile I had to change line 66 in perf.go to use syscall.Getpid instead of syscall.Gettid

I am assuming the PerfEvents is all nopped out on darwin anyway, so was just trying to get to compile.

Now I am finally starting to compile gospeccy proper, and I see there are calls to gettid in z80.go as well, which looks like it's kind of important.

@jonnosan
Copy link
Author

so after further hacking, including :

  • attempting to add gettid to zsyscalls_darwin.go , but failing
  • backing that out, and replacing the gettid calls in z80.go with getpid
  • adding -I/opt/local/include to various Makefiles

I eventually got "goam install" to complete, and had an "a.out" in the src directory

when I tried to run ./a.out, I got "dyld: Library not loaded: @rpath/cgo_sdl.so"

After reading the dyld man page, and poking around on my filesystem, I ended up adding "export DYLD_LIBRARY_PATH=/Users/jonnosan/src/go/pkg/darwin_amd64/:. " to my profile.

Then I discovered that all the "cgo_sdl*.so" files in that folder actually had a weird character in the filenames, e.g. "cgo_⚛sdl_ttf.so"

So I tried to get around that with more "ln -s" hacking. Which got me a little further, but now when I run a.out I get :
Jonathan-Downess-MacBook-Pro:src jonnosan$ ./a.out
dyld: Symbol not found: _rl_catch_sigwinch
Referenced from: /Users/jonnosan/src/gospeccy/src/./a.out
Expected in: flat namespace

Trace/BPT trap

At this point, I think I have butchered so many things (both in my 'go' setup, and in the gospeccy code & dependancies) it's probably going to be impossible to debug, so I'm going to stop swimming against the tide and see if I can get linux running in a VM instead.

@remogatto
Copy link
Owner

Which OSX version are you running? I'll try to setup a development environment for OSX trying to debug the installation issues you got. I'd like to see GoSpeccy running at least on OSX and Linux.

@jonnosan
Copy link
Author

I'm on OS X 10.6.5

I did manage to get ubuntu running under VirtualBox, and got go & gospeccy compiled without any dramas - it even ran the Fire104b demo (which I thought looked familiar - when I read the .nfo I realised I was at the Syntax '09 party where it was released :-)

@remogatto
Copy link
Owner

Unfortunately, I still didn't have the chance to setup a MacOSX dev env... @jonnosan have you tried building gospeccy after the latest big changes in cgo? I'd really appreciate any news about that! Thank you!

@YorkshireKev
Copy link

Hi @remogatto, gospeccy seems to compile on MacOSX without issues (go 1.6.2). It also appears to run without any errors too but unfortunately it does not display the GUI window so you can't actually see the spectrum running.

@bigianb
Copy link

bigianb commented Dec 27, 2017

PR #62 adds the build flags so that the output shows on OSX. You just need to make sure that you have an SDL with X11 compiled in (I added how to do this in the readme)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants