syslog icon indicating copy to clipboard operation
syslog copied to clipboard

Issues with cross compiling on Darwin

Open snikch opened this issue 11 years ago • 8 comments

Hey, thanks for the package! We're just working on our deploy process and cross compiling a binary to deploy from a Mac OS Yosemite system is causing build issues which seem quite interesting.

This runs fine:

GOARCH=amd64 GOOS=darwin go build 

This does not:

GOARCH=amd64 GOOS=linux go build 
# github.com/blackjack/syslog
../../../../blackjack/syslog/logmask.go:19: undefined: Priority
../../../../blackjack/syslog/logmask.go:27: undefined: Priority
../../../../blackjack/syslog/writer.go:5: undefined: Priority

Do you have any idea where I should start looking to debug this?

snikch avatar Sep 23 '14 04:09 snikch

Hey snikch. Had the same problem. Was able to cross-compile with https://github.com/davecheney/golang-crosscompile (his blog post is here: http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1) after prodigious chmod'ing. Maybe check out what his scripts are doing and adjust accordingly. It may be a linker problem or something.

jeanbza avatar Sep 23 '14 14:09 jeanbza

Hi, snikch. Can you post output of GOARCH=amd64 GOOS=linux go -x build ?

blackjack avatar Sep 23 '14 14:09 blackjack

@jadekler I originally used Dave Chaney's script to compile the Go versions, and just checked running go-linux-amd64 build and it still failed to run. I should note that when I remove this library I'm able to cross compile successfully.

@blackjack I had to trim some info that was leaking from this, but here's the gist of the output up until the error

➜  app git:(fix-syslog) ✗ GOARCH=amd64 GOOS=linux go build -x
WORK=/var/folders/3c/mjx3m7b90nb17y_zqcv2slg80000gn/T/go-build869521343
mkdir -p $WORK/github.com/spf13/pflag/_obj/
mkdir -p $WORK/github.com/spf13/
cd /Users/mal/Code/src/github.com/spf13/pflag
/usr/local/Cellar/go/1.3/libexec/pkg/tool/darwin_amd64/6g -o $WORK/github.com/spf13/pflag.a -trimpath $WORK -p github.com/spf13/pflag -complete -D _/Users/mal/Code/src/github.com/spf13/pflag -I $WORK -pack ./bool.go ./duration.go ./flag.go ./float32.go ./float64.go ./int.go ./int32.go ./int64.go ./int8.go ./ip.go ./ipmask.go ./string.go ./uint.go ./uint16.go ./uint32.go ./uint64.go ./uint8.go
mkdir -p $WORK/github.com/blackjack/syslog/_obj/
mkdir -p $WORK/github.com/blackjack/
cd /Users/mal/Code/src/github.com/blackjack/syslog
/usr/local/Cellar/go/1.3/libexec/pkg/tool/darwin_amd64/6g -o $WORK/github.com/blackjack/syslog.a -trimpath $WORK -p github.com/blackjack/syslog -complete -D _/Users/mal/Code/src/github.com/blackjack/syslog -I $WORK -pack ./functions.go ./logmask.go ./writer.go
mkdir -p $WORK/github.com/…/pkg/config/_obj/
mkdir -p $WORK/github.com/…/pkg/
cd /Users/mal/Code/src/github.com/…/pkg/config
/usr/local/Cellar/go/1.3/libexec/pkg/tool/darwin_amd64/6g -o $WORK/github.com/…/pkg/config.a -trimpath $WORK -p github.com/…/pkg/config -complete -D _/Users/mal/Code/src/github.com/…/pkg/config -I $WORK -pack ./config.go ./environment.go ./envy.go
mkdir -p $WORK/github.com/go-sql-driver/mysql/_obj/
mkdir -p $WORK/github.com/go-sql-driver/
cd /Users/mal/Code/src/github.com/go-sql-driver/mysql
/usr/local/Cellar/go/1.3/libexec/pkg/tool/darwin_amd64/6g -o $WORK/github.com/go-sql-driver/mysql.a -trimpath $WORK -p github.com/go-sql-driver/mysql -complete -D _/Users/mal/Code/src/github.com/go-sql-driver/mysql -I $WORK -pack ./buffer.go ./collations.go ./connection.go ./const.go ./driver.go ./errors.go ./infile.go ./packets.go ./result.go ./rows.go ./statement.go ./transaction.go ./utils.go
# github.com/blackjack/syslog
../../../../blackjack/syslog/logmask.go:19: undefined: Priority
../../../../blackjack/syslog/logmask.go:27: undefined: Priority
../../../../blackjack/syslog/writer.go:5: undefined: Priority
…

Interestingly running go build -x without the flags doesn't make any mention of of your package.

snikch avatar Sep 23 '14 18:09 snikch

@snikch I'll check it out tonight if you and @blackjack don't get it sorted by then. It may be as simple as changing Priority to int everywhere.

(whoops, logged in as wrong user)

jeanbza avatar Sep 23 '14 18:09 jeanbza

cheers

snikch avatar Sep 23 '14 18:09 snikch

So, long story short, I tried a couple of things, and nothing worked.

Priority is not a reserved word, so switching it to LogPriority did nothing. Changing Priority to just an int fixed the error described by @snikch, but then I started getting:

./functions.go:5: undefined: Syslog
./functions.go:5: undefined: LOG_EMERG
./functions.go:10: undefined: Syslogf
./functions.go:10: undefined: LOG_EMERG
etc

So, it's not importing properly? Next, I tried to cat all the files into the same file, which fixed the above problem, but then it was unable to find the syslog_wrapper header file.

So, in conclusion, I have no idea what the heck is happening. This may be a legitimate bug in the gcc. I'll try and see if I can replicate this on a smaller scale tonight. If so, it may be worth bringing up at https://code.google.com/p/go/issues/list

jeanbza avatar Sep 25 '14 14:09 jeanbza

Thanks for your work! In the meantime I've reverted to using the stdlib log/syslog package :(

snikch avatar Sep 25 '14 21:09 snikch

Still an issue in December 2017.

nugget avatar Dec 07 '17 19:12 nugget