Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
c276d87c
Commit
c276d87c
authored
Dec 21, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cgo: interpret $CGOPKGDIR as absolute path if rooted
R=dho CC=golang-dev
https://golang.org/cl/180099
parent
fa98cf6e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
Make.pkg
src/Make.pkg
+5
-1
main.go
src/cmd/cgo/main.go
+5
-2
out.go
src/cmd/cgo/out.go
+6
-2
No files found.
src/Make.pkg
View file @
c276d87c
...
...
@@ -23,7 +23,11 @@ endif
TARG_words=$(subst /, ,$(TARG))
elem=$(word $(words $(TARG_words)),$(TARG_words))
dir=$(patsubst %/$(elem),%,./$(TARG))
ifeq ($(elem),$(TARG))
dir=
else
dir=$(patsubst %/$(elem),%,$(TARG))
endif
# ugly hack to deal with whitespaces in $GOROOT
nullstring :=
...
...
src/cmd/cgo/main.go
View file @
c276d87c
...
...
@@ -126,8 +126,11 @@ func main() {
if
nerrors
>
0
{
os
.
Exit
(
2
)
}
p
.
PackagePath
=
os
.
Getenv
(
"CGOPKGPATH"
)
+
"/"
+
p
.
Package
pkg
:=
p
.
Package
if
dir
:=
os
.
Getenv
(
"CGOPKGPATH"
);
dir
!=
""
{
pkg
=
dir
+
"/"
+
pkg
}
p
.
PackagePath
=
pkg
p
.
writeOutput
(
input
)
}
...
...
src/cmd/cgo/out.go
View file @
c276d87c
...
...
@@ -24,6 +24,10 @@ func creat(name string) *os.File {
// (The comments here say 6g and 6c but the code applies to the 8 and 5 tools too.)
func
(
p
*
Prog
)
writeDefs
()
{
pkgroot
:=
os
.
Getenv
(
"GOROOT"
)
+
"/pkg/"
+
os
.
Getenv
(
"GOOS"
)
+
"_"
+
os
.
Getenv
(
"GOARCH"
)
path
:=
p
.
PackagePath
if
!
strings
.
HasPrefix
(
path
,
"/"
)
{
path
=
pkgroot
+
"/"
+
path
}
fgo2
:=
creat
(
"_cgo_gotypes.go"
)
fc
:=
creat
(
"_cgo_defun.c"
)
...
...
@@ -46,7 +50,7 @@ func (p *Prog) writeDefs() {
fmt
.
Fprintf
(
fc
,
cProlog
,
pkgroot
,
pkgroot
,
pkgroot
,
pkgroot
,
p
.
Package
,
p
.
Package
)
for
name
,
def
:=
range
p
.
Vardef
{
fmt
.
Fprintf
(
fc
,
"#pragma dynld %s·_C_%s %s
\"
%s
/%s.so
\"\n
"
,
p
.
Package
,
name
,
name
,
pkgroot
,
p
.
PackageP
ath
)
fmt
.
Fprintf
(
fc
,
"#pragma dynld %s·_C_%s %s
\"
%s
.so
\"\n
"
,
p
.
Package
,
name
,
name
,
p
ath
)
fmt
.
Fprintf
(
fgo2
,
"var _C_%s "
,
name
)
printer
.
Fprint
(
fgo2
,
&
ast
.
StarExpr
{
X
:
def
.
Go
})
fmt
.
Fprintf
(
fgo2
,
"
\n
"
)
...
...
@@ -121,7 +125,7 @@ func (p *Prog) writeDefs() {
// C wrapper calls into gcc, passing a pointer to the argument frame.
// Also emit #pragma to get a pointer to the gcc wrapper.
fmt
.
Fprintf
(
fc
,
"#pragma dynld _cgo_%s _cgo_%s
\"
%s
/%s.so
\"\n
"
,
name
,
name
,
pkgroot
,
p
.
PackageP
ath
)
fmt
.
Fprintf
(
fc
,
"#pragma dynld _cgo_%s _cgo_%s
\"
%s
.so
\"\n
"
,
name
,
name
,
p
ath
)
fmt
.
Fprintf
(
fc
,
"void (*_cgo_%s)(void*);
\n
"
,
name
)
fmt
.
Fprintf
(
fc
,
"
\n
"
)
fmt
.
Fprintf
(
fc
,
"void
\n
"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment