OLD | NEW |
1 Native Client | 1 Native Client |
2 ============= | 2 ============= |
3 | 3 |
4 This document outlines the basics of building and developing the Go runtime and
programs in the Native Client (NaCl) environment. | 4 This document outlines the basics of building and developing the Go runtime and
programs in the Native Client (NaCl) environment. |
5 | 5 |
6 Go 1.3 supports two architectures | 6 Go 1.3 supports three architectures |
7 | 7 |
8 * nacl/386 which is standard 386. | 8 * nacl/386 which is standard 386. |
9 * nacl/amd64p32 which is a 64 bit architecture, where the address space is limi
ted to a 4gb window.· | 9 * nacl/amd64p32 which is a 64 bit architecture, where the address space is limi
ted to a 4gb window.· |
| 10 * nacl/arm which is 32-bit ARMv7A architecture with 1GB address space. |
10 | 11 |
11 For background it is recommended that you read http://golang.org/s/go13nacl. | 12 For background it is recommended that you read http://golang.org/s/go13nacl. |
12 | 13 |
13 Prerequisites | 14 Prerequisites |
14 ------------- | 15 ------------- |
15 | 16 |
16 Native Client programs are executed inside a sandbox, the NaCl runtime. This run
time must be installed before you can use NaCl programs. | 17 Native Client programs are executed inside a sandbox, the NaCl runtime. This run
time must be installed before you can use NaCl programs. |
17 | 18 |
18 The NaCl distribution comes with an installer which ensures you have access to t
he latest version of the runtime. The version tracks the Chrome numbering scheme
. | 19 The NaCl distribution comes with an installer which ensures you have access to t
he latest version of the runtime. The version tracks the Chrome numbering scheme
. |
19 | 20 |
20 # Download NaCl | 21 # Download NaCl |
21 | 22 |
22 Download nacl_sdk.zip file from https://developers.google.com/native-client/dev/
sdk/download, and unpack it. I chose /opt/nacl_sdk | 23 Download nacl_sdk.zip file from https://developers.google.com/native-client/dev/
sdk/download, and unpack it. I chose /opt/nacl_sdk |
23 | 24 |
24 # Update | 25 # Update |
25 | 26 |
26 The zip file contains a small skeleton that can be used to download the correct
sdk. These are released every 6-8 weeks, in line with Chrome releases. | 27 The zip file contains a small skeleton that can be used to download the correct
sdk. These are released every 6-8 weeks, in line with Chrome releases. |
27 ········ | 28 ········ |
28 % cd /opt/nacl_sdk | 29 % cd /opt/nacl_sdk |
29 % ./naclsdk update | 30 % ./naclsdk update |
30 | 31 |
31 At this time pepper_33 is the stable version. If naclsdk downloads a later versi
on, please adjust accordingly. | 32 At this time pepper_33 is the stable version. If naclsdk downloads a later versi
on, please adjust accordingly. As of June 2014, only the canary sdk provides sup
port for nacl/arm. |
32 | 33 |
33 The cmd/go helper scripts expect that the runtime loaders, sel_ldr_x86_{32,64} a
re in your path. I find it easiest to make a symlink from the NaCl distribution
to my $GOPATH/bin directory. | 34 The cmd/go helper scripts expect that the runtime loaders, sel_ldr_{x86_{32,64},
arm} and nacl_helper_bootstrap_arm are in your path. I find it easiest to make a
symlink from the NaCl distribution to my $GOPATH/bin directory. |
34 | 35 |
35 % ln -nfs /opt/nacl_sdk/pepper_33/tools/sel_ldr_x86_32 $GOPATH/bin/sel_l
dr_x86_32 | 36 % ln -nfs /opt/nacl_sdk/pepper_33/tools/sel_ldr_x86_32 $GOPATH/bin/sel_l
dr_x86_32 |
36 % ln -nfs /opt/nacl_sdk/pepper_33/tools/sel_ldr_x86_64 $GOPATH/bin/sel_l
dr_x86_64 | 37 % ln -nfs /opt/nacl_sdk/pepper_33/tools/sel_ldr_x86_64 $GOPATH/bin/sel_l
dr_x86_64 |
| 38 % ln -nfs /opt/nacl_sdk/pepper_canary/tools/sel_ldr_arm $GOPATH/bin/sel_
ldr_arm |
| 39 % ln -nfs /opt/nacl_sdk/pepper_canary/tools/nacl_helper_bootstrap_arm $G
OPATH/bin/nacl_helper_bootstrap_arm # only required for NaCl/ARM. |
37 | 40 |
38 Support scripts | 41 Support scripts |
39 --------------- | 42 --------------- |
40 | 43 |
41 Symlink the two scripts in this directory into your $PATH, just as you did with
NaCl sdk above. | 44 Symlink the two scripts in this directory into your $PATH, just as you did with
NaCl sdk above. |
42 | 45 |
43 % ln -nfs $GOROOT/go/misc/nacl/go_nacl_amd64p32_exec $GOPATH/bin/go_nacl
_amd64p32_exec | 46 % ln -nfs $GOROOT/go/misc/nacl/go_nacl_amd64p32_exec $GOPATH/bin/go_nacl
_amd64p32_exec |
44 % ln -nfs $GOROOT/go/misc/nacl/go_nacl_386_exec $GOPATH/bin/go_nacl_386_
exec | 47 % ln -nfs $GOROOT/go/misc/nacl/go_nacl_386_exec $GOPATH/bin/go_nacl_386_
exec |
| 48 % ln -nfs $GOROOT/go/misc/nacl/go_nacl_arm_exec $GOPATH/bin/go_nacl_arm_
exec |
45 | 49 |
46 Building and testing | 50 Building and testing |
47 -------------------- | 51 -------------------- |
48 | 52 |
49 Building for NaCl is similar to cross compiling for other platforms. However, as
it is not possible to ever build in a `native` NaCl environment, the cmd/go too
l has been enhanced to allow the full build, all.bash, to be executed, rather th
an just the compile stage, make.bash. | 53 Building for NaCl is similar to cross compiling for other platforms. However, as
it is not possible to ever build in a `native` NaCl environment, the cmd/go too
l has been enhanced to allow the full build, all.bash, to be executed, rather th
an just the compile stage, make.bash. |
50 | 54 |
51 The cmd/go tool knows that if GOOS is set to `nacl` it should not try to execute
any binaries itself. Instead it passes their execution to a support script whic
h sets up a Native Client environment and invokes the NaCl sandbox. | 55 The cmd/go tool knows that if GOOS is set to `nacl` it should not try to execute
any binaries itself. Instead it passes their execution to a support script whic
h sets up a Native Client environment and invokes the NaCl sandbox. |
52 | 56 |
53 The script's name has a special format, go_$GOOS_$GOARCH_exec, so cmd/go can fin
d it. | 57 The script's name has a special format, go_$GOOS_$GOARCH_exec, so cmd/go can fin
d it. |
54 | 58 |
55 In short, if the support scripts are in place, the cmd/go tool can be used as pe
r normal. | 59 In short, if the support scripts are in place, the cmd/go tool can be used as pe
r normal. |
56 | 60 |
57 # Build and test Go for NaCl | 61 # Build and test Go for NaCl |
58 | 62 |
59 NaCl does not permit direct file system access. Instead, package syscall provide
s a simulated file system served by in-memory data. The script nacltest.bash is
the NaCl equivalent of all.bash. It builds NaCl with an in-memory file system co
ntaining files needed for tests, and then it runs the tests. | 63 NaCl does not permit direct file system access. Instead, package syscall provide
s a simulated file system served by in-memory data. The script nacltest.bash is
the NaCl equivalent of all.bash. It builds NaCl with an in-memory file system co
ntaining files needed for tests, and then it runs the tests. |
60 | 64 |
61 % cd go/src | 65 % cd go/src |
62 % env GOARCH=amd64p32 ./nacltest.bash | 66 % env GOARCH=amd64p32 ./nacltest.bash |
63 | 67 |
OLD | NEW |