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
4a8de670
Commit
4a8de670
authored
Jun 15, 2011
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/build: record all cgo intermediate files (fix build)
R=rsc CC=golang-dev
https://golang.org/cl/4613045
parent
db5a4ffc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
12 deletions
+24
-12
build.go
src/pkg/go/build/build.go
+20
-12
build_test.go
src/pkg/go/build/build_test.go
+4
-0
No files found.
src/pkg/go/build/build.go
View file @
4a8de670
...
@@ -48,9 +48,10 @@ func Build(tree *Tree, pkg string, info *DirInfo) (*Script, os.Error) {
...
@@ -48,9 +48,10 @@ func Build(tree *Tree, pkg string, info *DirInfo) (*Script, os.Error) {
if
len
(
info
.
CgoFiles
)
>
0
{
if
len
(
info
.
CgoFiles
)
>
0
{
cgoFiles
:=
b
.
abss
(
info
.
CgoFiles
...
)
cgoFiles
:=
b
.
abss
(
info
.
CgoFiles
...
)
s
.
addInput
(
cgoFiles
...
)
s
.
addInput
(
cgoFiles
...
)
outGo
,
outObj
:=
b
.
cgo
(
cgoFiles
)
out
Inter
,
out
Go
,
outObj
:=
b
.
cgo
(
cgoFiles
)
gofiles
=
append
(
gofiles
,
outGo
...
)
gofiles
=
append
(
gofiles
,
outGo
...
)
ofiles
=
append
(
ofiles
,
outObj
...
)
ofiles
=
append
(
ofiles
,
outObj
...
)
s
.
addIntermediate
(
outInter
...
)
s
.
addIntermediate
(
outGo
...
)
s
.
addIntermediate
(
outGo
...
)
s
.
addIntermediate
(
outObj
...
)
s
.
addIntermediate
(
outObj
...
)
}
}
...
@@ -313,7 +314,7 @@ func (b *build) cc(ofile string, cfiles ...string) {
...
@@ -313,7 +314,7 @@ func (b *build) cc(ofile string, cfiles ...string) {
func
(
b
*
build
)
gccCompile
(
ofile
,
cfile
string
)
{
func
(
b
*
build
)
gccCompile
(
ofile
,
cfile
string
)
{
b
.
add
(
Cmd
{
b
.
add
(
Cmd
{
Args
:
gccArgs
(
b
.
arch
,
"-o"
,
ofile
,
"-c"
,
cfile
),
Args
:
b
.
gccArgs
(
"-o"
,
ofile
,
"-c"
,
cfile
),
Input
:
[]
string
{
cfile
},
Input
:
[]
string
{
cfile
},
Output
:
[]
string
{
ofile
},
Output
:
[]
string
{
ofile
},
})
})
...
@@ -321,42 +322,45 @@ func (b *build) gccCompile(ofile, cfile string) {
...
@@ -321,42 +322,45 @@ func (b *build) gccCompile(ofile, cfile string) {
func
(
b
*
build
)
gccLink
(
ofile
string
,
ofiles
...
string
)
{
func
(
b
*
build
)
gccLink
(
ofile
string
,
ofiles
...
string
)
{
b
.
add
(
Cmd
{
b
.
add
(
Cmd
{
Args
:
append
(
gccArgs
(
b
.
arch
,
"-o"
,
ofile
),
ofiles
...
),
Args
:
append
(
b
.
gccArgs
(
"-o"
,
ofile
),
ofiles
...
),
Input
:
ofiles
,
Input
:
ofiles
,
Output
:
[]
string
{
ofile
},
Output
:
[]
string
{
ofile
},
})
})
}
}
func
gccArgs
(
arch
string
,
args
...
string
)
[]
string
{
func
(
b
*
build
)
gccArgs
(
args
...
string
)
[]
string
{
// TODO(adg): HOST_CC
// TODO(adg): HOST_CC
m
:=
"-m32"
m
:=
"-m32"
if
arch
==
"6"
{
if
b
.
arch
==
"6"
{
m
=
"-m64"
m
=
"-m64"
}
}
return
append
([]
string
{
"gcc"
,
m
,
"-I"
,
"."
,
"-g"
,
"-fPIC"
,
"-O2"
},
args
...
)
return
append
([]
string
{
"gcc"
,
m
,
"-I"
,
b
.
path
,
"-g"
,
"-fPIC"
,
"-O2"
},
args
...
)
}
}
func
(
b
*
build
)
cgo
(
cgofiles
[]
string
)
(
outGo
,
outObj
[]
string
)
{
func
(
b
*
build
)
cgo
(
cgofiles
[]
string
)
(
out
Inter
,
out
Go
,
outObj
[]
string
)
{
// cgo
// cgo
// TODO(adg): CGOPKGPATH
// TODO(adg): CGOPKGPATH
// TODO(adg): CGO_FLAGS
// TODO(adg): CGO_FLAGS
gofiles
:=
[]
string
{
b
.
obj
+
"_cgo_gotypes.go"
}
gofiles
:=
[]
string
{
b
.
obj
+
"_cgo_gotypes.go"
}
cfiles
:=
[]
string
{
b
.
obj
+
"_cgo_main.c"
,
b
.
obj
+
"_cgo_export.c"
}
cfiles
:=
[]
string
{
b
.
obj
+
"_cgo_main.c"
,
b
.
obj
+
"_cgo_export.c"
}
for
_
,
fn
:=
range
cgofiles
{
for
_
,
fn
:=
range
cgofiles
{
fn
=
filepath
.
Base
(
fn
)
f
:=
b
.
obj
+
strings
.
Replace
(
fn
[
:
len
(
fn
)
-
2
],
"/"
,
"_"
,
-
1
)
f
:=
b
.
obj
+
fn
[
:
len
(
fn
)
-
2
]
gofiles
=
append
(
gofiles
,
f
+
"cgo1.go"
)
gofiles
=
append
(
gofiles
,
f
+
"cgo1.go"
)
cfiles
=
append
(
cfiles
,
f
+
"cgo2.c"
)
cfiles
=
append
(
cfiles
,
f
+
"cgo2.c"
)
}
}
defunC
:=
b
.
obj
+
"_cgo_defun.c"
defunC
:=
b
.
obj
+
"_cgo_defun.c"
output
:=
append
([]
string
{
defunC
},
go
files
...
)
output
:=
append
([]
string
{
defunC
},
c
files
...
)
output
=
append
(
output
,
c
files
...
)
output
=
append
(
output
,
go
files
...
)
b
.
add
(
Cmd
{
b
.
add
(
Cmd
{
Args
:
append
([]
string
{
"cgo"
,
"--"
},
cgofiles
...
),
Args
:
append
([]
string
{
"cgo"
,
"--"
},
cgofiles
...
),
Dir
:
b
.
path
,
Input
:
cgofiles
,
Input
:
cgofiles
,
Output
:
output
,
Output
:
output
,
})
})
outGo
=
append
(
outGo
,
gofiles
...
)
outGo
=
append
(
outGo
,
gofiles
...
)
exportH
:=
filepath
.
Join
(
b
.
path
,
"_cgo_export.h"
)
outInter
=
append
(
outInter
,
exportH
,
defunC
,
b
.
obj
+
"_cgo_flags"
)
outInter
=
append
(
outInter
,
cfiles
...
)
// cc _cgo_defun.c
// cc _cgo_defun.c
defunObj
:=
b
.
obj
+
"_cgo_defun."
+
b
.
arch
defunObj
:=
b
.
obj
+
"_cgo_defun."
+
b
.
arch
...
@@ -371,10 +375,13 @@ func (b *build) cgo(cgofiles []string) (outGo, outObj []string) {
...
@@ -371,10 +375,13 @@ func (b *build) cgo(cgofiles []string) (outGo, outObj []string) {
linkobj
=
append
(
linkobj
,
ofile
)
linkobj
=
append
(
linkobj
,
ofile
)
if
!
strings
.
HasSuffix
(
ofile
,
"_cgo_main.o"
)
{
if
!
strings
.
HasSuffix
(
ofile
,
"_cgo_main.o"
)
{
outObj
=
append
(
outObj
,
ofile
)
outObj
=
append
(
outObj
,
ofile
)
}
else
{
outInter
=
append
(
outInter
,
ofile
)
}
}
}
}
dynObj
:=
b
.
obj
+
"_cgo
1
_.o"
dynObj
:=
b
.
obj
+
"_cgo_.o"
b
.
gccLink
(
dynObj
,
linkobj
...
)
b
.
gccLink
(
dynObj
,
linkobj
...
)
outInter
=
append
(
outInter
,
dynObj
)
// cgo -dynimport
// cgo -dynimport
importC
:=
b
.
obj
+
"_cgo_import.c"
importC
:=
b
.
obj
+
"_cgo_import.c"
...
@@ -384,6 +391,7 @@ func (b *build) cgo(cgofiles []string) (outGo, outObj []string) {
...
@@ -384,6 +391,7 @@ func (b *build) cgo(cgofiles []string) (outGo, outObj []string) {
Input
:
[]
string
{
dynObj
},
Input
:
[]
string
{
dynObj
},
Output
:
[]
string
{
importC
},
Output
:
[]
string
{
importC
},
})
})
outInter
=
append
(
outInter
,
importC
)
// cc _cgo_import.ARCH
// cc _cgo_import.ARCH
importObj
:=
b
.
obj
+
"_cgo_import."
+
b
.
arch
importObj
:=
b
.
obj
+
"_cgo_import."
+
b
.
arch
...
...
src/pkg/go/build/build_test.go
View file @
4a8de670
...
@@ -50,4 +50,8 @@ func testBuild(t *testing.T, tree *Tree, pkg string) {
...
@@ -50,4 +50,8 @@ func testBuild(t *testing.T, tree *Tree, pkg string) {
return
return
}
}
}
}
if
err
:=
s
.
Clean
();
err
!=
nil
{
t
.
Errorf
(
"cleaning: %v"
,
err
)
t
.
Logf
(
"Intermediate: %v"
,
s
.
Intermediate
)
}
}
}
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