Upgrade to Pro — share decks privately, control downloads, hide ads and more …

クロスコンパイルについて (GeekSalon#7)

クロスコンパイルについて (GeekSalon#7)

Shintaro Kaneko

May 29, 2015
Tweet

More Decks by Shintaro Kaneko

Other Decks in Programming

Transcript

  1. Copyright © 2009-2015 eureka, Inc. All rights reserved. גࣜձࣾΤ΢ϨΧ ࣄۀ಺༰

    ࣗࣾαʔϏεͷاըɾ։ൃɾӡӦ wΦϯϥΠϯɾσʔςΟϯάɾαʔϏεʮQBJSTʯ wΧοϓϧઐ༻ΞϓϦʮ$PVQMFTʯ ւ֎ڌ఺ w།ྷՈވ㟨༗ݶެ࢘ʢ୆࿷ʣ w&63&,"4(1UF-UEʢγϯΨϙʔϧʣ Copyright © 2009-2015 eureka, Inc. All rights reserved. ΤϯδχΞ ਓ ඇΤϯδχΞ ਓ ࣾһ਺ਓ Πϯλʔϯɾۀ຿ҕୗؚΉ ฏۉ೥ྸࡀ
  2. ύοέʔδͷ֬ೝʢ͓·͚ɿHPFOWʣ [kaneshin] ~ $ go env GOARCH="amd64" GOBIN="" GOCHAR="6" GOEXE=""

    GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="/home/kaneshin/gopath" GORACE="" GOROOT="/usr/local/share/go/default" GOTOOLDIR="/usr/local/share/go/default/pkg/tool/linux_amd64" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"
  3. [kaneshin] ~ $ cd $(go env GOROOT)/src [kaneshin] /path/to/go/src $

    export GOOS=windows $ export GOARCH=amd64 $ ./make.bash —no-clean [kaneshin] /path/to/go/src $ GOOS=windows GOARCH=amd64 ./make.bash --no-clean ύοέʔδͷϏϧυ ͦΕͧΕͷϓϥοτϑΥʔϜ޲͚ʹύοέʔδΛϏϧυ ؀ڥม਺ͷ(004 (0"3$)Λࢦఆͯ͠Ϗϧυ
  4. [kaneshin] ~ $ cd $(go env GOROOT)/src [kaneshin] /path/to/go/src $

    export GOOS=windows $ export GOARCH=amd64 $ ./make.bash --no-clean [kaneshin] /path/to/go/src $ GOOS=windows GOARCH=amd64 ./make.bash --no-clean ύοέʔδͷϏϧυ ͦΕͧΕͷϓϥοτϑΥʔϜ޲͚ʹύοέʔδΛϏϧυ ؀ڥม਺ͷ(004 (0"3$)Λࢦఆͯ͠Ϗϧυ Ͳͬͪ΋ಉ͡ 1 2-1 2-2
  5. ύοέʔδͷϏϧυʢ֬ೝʣ Ϗϧυ͕ऴΘͬͨΒ֬ೝ [kaneshin] ~ $ ls -1 $(go env GOROOT)/pkg

    darwin_amd64/ linux_amd64/ linux_amd64_race/ obj/ tool/ windows_amd64/
  6. ύοέʔδͷϏϧυʢ֬ೝʣ Ϗϧυ͕ऴΘͬͨΒ֬ೝ [kaneshin] ~ $ ls -1 $(go env GOROOT)/pkg

    darwin_amd64/ linux_amd64/ linux_amd64_race/ obj/ tool/ windows_amd64/ ૿͑ͯΔʂ
  7. ύοέʔδͷϏϧυʢ(004ͱ(0"3$)ͷछྨʣ $GOOS $GOARCH freebsd 386 freebsd amd64 freebsd arm linux

    386 linux amd64 linux arm netbsd 386 netbsd amd64 netbsd arm openbsd 386 openbsd amd64 $GOOS $GOARCH darwin 386 darwin amd64 dragonfly 386 dragonfly amd64 plan9 386 plan9 amd64 solaris amd64 windows 386 windows amd64 छྨͷ૊Έ߹Θ͕ͤଘࡏ͢Δ ͭ·Γɺશͯͷ؀ڥͷίϯύΠϥΛ ༻ҙ͢Δʹ͸ճϏϧυ͕ඞཁ
  8. ΫϩείϯύΠϧͷํ๏ [kaneshin] /tmp/giita $ GOOS=darwin GOARCH=amd64 go build -i \

    github.com/kaneshin/giita/cmd/giita $ GOOS=windows GOARCH=amd64 go build -i \ github.com/kaneshin/giita/cmd/giita $ ls -1 giita* giita.exe* ͦΕͧΕͷϓϥοτϑΥʔϜ޲͚ʹϏϧυ͢Δ (004 (0"3$)ͷ؀ڥม਺Λࢦఆͯ͠Ϗϧυ
  9. ΫϩείϯύΠϧͷํ๏ [kaneshin] /tmp/giita $ GOOS=darwin GOARCH=amd64 go build -i \

    github.com/kaneshin/giita/cmd/giita $ GOOS=windows GOARCH=amd64 go build -i \ github.com/kaneshin/giita/cmd/giita $ ls -1 giita* giita.exe* ͦΕͧΕͷϓϥοτϑΥʔϜ޲͚ʹϏϧυ͢Δ (004 (0"3$)ͷ؀ڥม਺Λࢦఆͯ͠Ϗϧυ 8JOEPXT CJU ༻όΠφϦ͕׬੒