diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2013-12-03 09:43:15 +0100 |
commit | 64d2a7c8945ba05af859901f5e248f1befdd8621 (patch) | |
tree | 013fcb7e9e3296ecdda876012252c36bd6bcb063 /misc/cgo/testso | |
parent | b901efe83e212f0c34c769c079e41373da12d723 (diff) | |
download | golang-64d2a7c8945ba05af859901f5e248f1befdd8621.tar.gz |
Imported Upstream version 1.2upstream/1.2
Diffstat (limited to 'misc/cgo/testso')
-rw-r--r-- | misc/cgo/testso/cgoso.go | 11 | ||||
-rwxr-xr-x | misc/cgo/testso/test.bash | 20 |
2 files changed, 26 insertions, 5 deletions
diff --git a/misc/cgo/testso/cgoso.go b/misc/cgo/testso/cgoso.go index 216cb1f05..ba6218348 100644 --- a/misc/cgo/testso/cgoso.go +++ b/misc/cgo/testso/cgoso.go @@ -5,7 +5,16 @@ package cgosotest /* -#cgo LDFLAGS: -L. -lcgosotest +// intentionally write the same LDFLAGS differently +// to test correct handling of LDFLAGS. +#cgo linux LDFLAGS: -L. -lcgosotest +#cgo dragonfly LDFLAGS: -L. -l cgosotest +#cgo freebsd LDFLAGS: -L. -l cgosotest +#cgo openbsd LDFLAGS: -L. -l cgosotest +#cgo netbsd LDFLAGS: -L. libcgosotest.so +#cgo darwin LDFLAGS: -L. libcgosotest.dylib +#cgo windows LDFLAGS: -L. libcgosotest.dll + void init(void); void sofunc(void); */ diff --git a/misc/cgo/testso/test.bash b/misc/cgo/testso/test.bash index 5f113d216..f4061c68e 100755 --- a/misc/cgo/testso/test.bash +++ b/misc/cgo/testso/test.bash @@ -1,10 +1,22 @@ -#!/bin/sh +#!/usr/bin/env bash # Copyright 2011 The Go Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. set -e -$(go env CC) $(go env GOGCCFLAGS) -shared -o libcgosotest.so cgoso_c.c + +args= +dyld_envvar=LD_LIBRARY_PATH +ext=so +if [ "$(uname)" == "Darwin" ]; then + args="-undefined suppress -flat_namespace" + dyld_envvar=DYLD_LIBRARY_PATH + ext=dylib +fi + +dylib=libcgosotest.$ext +$(go env CC) $(go env GOGCCFLAGS) -shared $args -o $dylib cgoso_c.c go build main.go -LD_LIBRARY_PATH=. ./main -rm -f libcgosotest.so main + +eval "$dyld_envvar"=. ./main +rm -rf $dylib main *.dSYM |