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

go-lxc fails with gccgo #33

Closed
stgraber opened this issue Feb 12, 2015 · 2 comments · Fixed by #34
Closed

go-lxc fails with gccgo #33

stgraber opened this issue Feb 12, 2015 · 2 comments · Fixed by #34

Comments

@stgraber
Copy link
Member

I'm looking into gccgo as a way to build LXD for ppc64el and arm64 where gc doesn't work.

So far it looks like most of our code is fine, but go-lxc itself fails when building using gccgo5.

Here's as simple an example as I could come up with:

ubuntu@lantea:~/go/gopkg.in/lxc/go-lxc.v2/examples$ go install -v console.go 
gopkg.in/lxc/go-lxc.v2
command-line-arguments

ubuntu@lantea:~/go/gopkg.in/lxc/go-lxc.v2/examples$ rm -Rf $GOBIN
ubuntu@lantea:~/go/gopkg.in/lxc/go-lxc.v2/examples$ sudo update-alternatives --config go
There are 2 choices for the alternative go (providing /usr/bin/go).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/golang-go   10        auto mode
  1            /usr/bin/gccgo-go    5         manual mode
  2            /usr/bin/golang-go   10        manual mode

Press enter to keep the current choice[*], or type selection number: 1
update-alternatives: using /usr/bin/gccgo-go to provide /usr/bin/go (go) in manual mode

ubuntu@lantea:~/go/gopkg.in/lxc/go-lxc.v2/examples$ go install -v console.go 
command-line-arguments
# command-line-arguments
./console.go:13:24: error: redefinition of ‘lxc’
  "gopkg.in/lxc/go-lxc.v2"
                        ^
./console.go:13:24: note: previous definition of ‘lxc’ was here
@stgraber
Copy link
Member Author

ok, so the main failure can be fixed with the following changes:

  • rename lxc.c to lxc-binding.c
  • rename lxc.h to lxc-binding.h
  • rename lxc.go to lxc-binding.go
  • update include in container.go
  • update include in lxc-binding.go

I'm now getting:

ubuntu@lantea:~/lxd-0.0$ gccgo-go install -v github.com/lxc/lxd/lxc
github.com/lxc/lxd/lxc
# github.com/lxc/lxd/lxc
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:37: error: undefined reference to 'list_active_containers'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:43: error: undefined reference to 'list_all_containers'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:49: error: undefined reference to 'list_defined_containers'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:55: error: undefined reference to 'lxc_container_get'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:61: error: undefined reference to 'lxc_container_new'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:67: error: undefined reference to 'lxc_container_put'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:73: error: undefined reference to 'lxc_get_global_config_item'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.go:79: error: undefined reference to 'lxc_get_version'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.c:232: error: undefined reference to 'lxc_attach_run_shell'
/home/ubuntu/lxd-0.0/dist/src/gopkg.in/lxc/go-lxc.v2/lxc-binding.c:236: error: undefined reference to 'lxc_wait_for_pid_status'
collect2: error: ld returned 1 exit status

Which to me looks like -llxc wasn't passed through to ld somehow.

@stgraber
Copy link
Member Author

Apparently that's because gccgo ignores or fails to parse the pkg-config line, manually setting LDFLAGS fixes it... I'll send a branch with both changes.

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

Successfully merging a pull request may close this issue.

1 participant