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