LEFT | RIGHT |
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright 2011 The Go Authors. All rights reserved. | 2 # Copyright 2011 The Go Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style | 3 # Use of this source code is governed by a BSD-style |
4 # license that can be found in the LICENSE file. | 4 # license that can be found in the LICENSE file. |
5 | 5 |
6 # This test is not part of the standard test suite, because shared library mode
requires special compilation | 6 # This test is not part of the standard test suite, because shared library mode
requires special compilation |
7 # flags on amd64 and i386. | 7 # flags on amd64 and i386. |
8 # | 8 # |
9 # To enable shared library mode on linux/amd64, build the standard library with | 9 # To enable shared library mode on linux/amd64, build the standard library with |
10 # | 10 # |
11 # GO_GCFLAGS=-largemodel GO_CCFLAGS=-largemodel ./all.bash | 11 # GO_GCFLAGS=-largemodel GO_CCFLAGS=-largemodel ./all.bash |
12 # | 12 # |
13 # and then run this test. | 13 # To enable shared library mode on linux/arm, build the standard library as norm
al. |
14 | 14 |
15 set -e | 15 set -e |
16 | 16 |
17 args= | 17 args= |
18 dyld_envvar=LD_LIBRARY_PATH | 18 dyld_envvar=LD_LIBRARY_PATH |
19 ext=so | 19 ext=so |
20 if [ "$(uname)" == "Darwin" ]; then | 20 if [ "$(uname)" == "Darwin" ]; then |
21 args="-undefined suppress -flat_namespace" | 21 args="-undefined suppress -flat_namespace" |
22 dyld_envvar=DYLD_LIBRARY_PATH | 22 dyld_envvar=DYLD_LIBRARY_PATH |
23 ext=dylib | 23 ext=dylib |
24 fi | 24 fi |
25 | 25 |
26 dylibname=goshared | 26 dylibname=goshared |
| 27 dylibname2=goshared2 |
27 dylib="lib$dylibname.$ext" | 28 dylib="lib$dylibname.$ext" |
28 go build -ldflags "-shared -extldflags -L." -ccflags "-largemodel" -gcflags "-la
rgemodel" -o $dylib shared.go | 29 dylib2="lib$dylibname2.$ext" |
| 30 [ `go env GOARCH` == "amd64" ] && go_flags='-ccflags "-largemodel" -gcflags "-la
rgemodel"' |
| 31 go build -ldflags "-shared -extldflags -L." $go_flags -o $dylib shared.go |
| 32 go build -ldflags "-shared -extldflags -L." $go_flags -o $dylib2 shared2.go |
29 $(go env CC) $(go env GOGCCFLAGS) $args -o main main.c -L. -l$dylibname | 33 $(go env CC) $(go env GOGCCFLAGS) $args -o main main.c -L. -l$dylibname |
30 $(go env CC) $(go env GOGCCFLAGS) $args -o mainadv mainadv.c -ldl -L. -l$dylibna
me | 34 $(go env CC) $(go env GOGCCFLAGS) $args -o mainmult mainmult.c -ldl -L. -l$dylib
name -l$dylibname2 |
| 35 $(go env CC) $(go env GOGCCFLAGS) $args -o mainadv mainadv.c -ldl |
31 | 36 |
32 eval "$dyld_envvar"=. ./main | 37 TEST_ENV=test eval "$dyld_envvar"=. ./main |
33 eval "$dyld_envvar"=. ./mainadv | 38 eval "$dyld_envvar"=. ./mainadv |
34 rm -rf $dylib main mainadv *.dSYM | 39 if eval "$dyld_envvar"=. ./mainmult; then |
| 40 » exit 1; |
| 41 fi |
| 42 rm -rf $dylib $dylib2 mainmult main mainadv *.dSYM |
LEFT | RIGHT |