Received: by 10.216.94.4 with SMTP id m4mr15935wef.27.1342505603869;
Mon, 16 Jul 2012 23:13:23 -0700 (PDT)
X-BeenThere: golang-nuts-/***@public.gmane.org
Received: by 10.180.81.71 with SMTP id y7ls180895wix.3.gmail; Mon, 16 Jul 2012
23:13:18 -0700 (PDT)
Received: by 10.180.75.8 with SMTP id y8mr90542wiv.4.1342505598214;
Mon, 16 Jul 2012 23:13:18 -0700 (PDT)
Received: by 10.180.75.8 with SMTP id y8mr90541wiv.4.1342505598203;
Mon, 16 Jul 2012 23:13:18 -0700 (PDT)
Received: from mail-we0-f169.google.com (mail-we0-f169.google.com [74.125.82.169])
by gmr-mx.google.com with ESMTPS id fa8si2920746wid.1.2012.07.16.23.13.17
(version=TLSv1/SSLv3 cipher=OTHER);
Mon, 16 Jul 2012 23:13:17 -0700 (PDT)
Received-SPF: neutral (google.com: 74.125.82.169 is neither permitted nor denied by best guess record for domain of dave-7L4Cwp9BzA+sTnJN9+***@public.gmane.org) client-ip=74.125.82.169;
Received: by weys10 with SMTP id s10so35006wey.28
for <golang-nuts-/***@public.gmane.org>; Mon, 16 Jul 2012 23:13:17 -0700 (PDT)
Received: by 10.216.136.95 with SMTP id v73mr640151wei.2.1342505597715; Mon,
16 Jul 2012 23:13:17 -0700 (PDT)
Received: by 10.223.84.196 with HTTP; Mon, 16 Jul 2012 23:13:17 -0700 (PDT)
In-Reply-To: <09c548aa-130d-450a-b780-129214f1c2aa-/***@public.gmane.org>
X-Gm-Message-State: ALoCoQlmmOW9BehF4cALtS3uORmC6R4z+T9A0LybzMr890Lt5XHOtLbyICC8qfOBJRT8UqG+/tdl
X-Original-Sender: dave-7L4Cwp9BzA+sTnJN9+***@public.gmane.org
X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com:
74.125.82.169 is neither permitted nor denied by best guess record for domain
of dave-7L4Cwp9BzA+sTnJN9+***@public.gmane.org) smtp.mail=dave-7L4Cwp9BzA+sTnJN9+***@public.gmane.org
Precedence: list
Mailing-list: list golang-nuts-/***@public.gmane.org; contact golang-nuts+owners-/***@public.gmane.org
List-ID: <golang-nuts.googlegroups.com>
X-Google-Group-Id: 332403668183
List-Post: <http://groups.google.com/group/golang-nuts/post?hl=en_US>, <mailto:golang-nuts-/***@public.gmane.org>
List-Help: <http://groups.google.com/support/?hl=en_US>, <mailto:golang-nuts+help-/***@public.gmane.org>
List-Archive: <http://groups.google.com/group/golang-nuts?hl=en_US>
Sender: golang-nuts-/***@public.gmane.org
List-Subscribe: <http://groups.google.com/group/golang-nuts/subscribe?hl=en_US>,
<mailto:golang-nuts+subscribe-/***@public.gmane.org>
List-Unsubscribe: <http://groups.google.com/group/golang-nuts/subscribe?hl=en_US>,
<mailto:googlegroups-manage+332403668183+unsubscribe-/***@public.gmane.org>
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.go.general/66129>
Hello,
Reposting to the list.
To cross compile
cd $GOROOT/src
CGO_ENABLED=0 GOARCH=arm GOOS=linux ./make.bash
Assuming you have those three variables exported, then any invocation
of go build will produce a binary that will run on an arm system.
note: subtle application of GOARM={5,6,7} not covered.
The reason you can't currently cross compile with cgo enabled are
1. very few people have the correct set of cross compiling gcc
compilers installed.
2. even if they did, the dist tool and cgo tool don't understand
how to use them anyway.
3. even if both were true, 5l has to have access to the /lib/ld.so.3
library for the target to correctly link.
4. finally, cgo would need access to the headers and -dev packages for the
target arm system to produce a cross compiled, dynamically linked binary.
Cheers
Dave
Post by Daniel SkinnerI haven't played with cgo yet but if I'm not mistaken, the wiki linked to
previously deals with the go toolchain on arm, not necessarily cross
compilation where host arch is not arm. You may need to dig in to that
portion of cgo to see what to do.
Just as an example, for gc cross compilation I have the following to
bootstrap the toolchain (builds 5g and 5l)
export GOOS=linux
export GOARCH=arm
cd ~/local/go/src
./make.bash
and then this to build a source file and link
~/local/go/pkg/tool/linux_amd64/5g "$1".go
~/local/go/pkg/tool/linux_amd64/5l "$1".5
rm "$1".5
mv 5.out "$1"
That produces a binary I can run on the phone, built from my laptop.
I would be interested to hear about cross compilation with cgo, or any other
information related.