Commit e08f0c18 authored by Gustavo Niemeyer's avatar Gustavo Niemeyer Committed by Russ Cox

goinstall: handle .c files with gc when cgo isn't used

As a data point, this enables goinstall to handle the standard
syscall package almost unchanged (there's one file with the _bsd
extension, and a .c file which isn't supposed to be compiled in).

R=rsc
CC=golang-dev
https://golang.org/cl/4259057
parent 02323c0e
......@@ -52,12 +52,6 @@ func makeMakefile(dir, pkg string) ([]byte, os.Error) {
return nil, err
}
if len(dirInfo.cgoFiles) == 0 && len(dirInfo.cFiles) > 0 {
// When using cgo, .c files are compiled with gcc. Without cgo,
// they may be intended for 6c. Just error out for now.
return nil, os.ErrorString("C files found in non-cgo package")
}
cgoFiles := dirInfo.cgoFiles
isCgo := make(map[string]bool, len(cgoFiles))
for _, file := range cgoFiles {
......@@ -67,25 +61,31 @@ func makeMakefile(dir, pkg string) ([]byte, os.Error) {
isCgo[file] = true
}
cgoOFiles := make([]string, 0, len(dirInfo.cFiles))
for _, file := range dirInfo.cFiles {
goFiles := make([]string, 0, len(dirInfo.goFiles))
for _, file := range dirInfo.goFiles {
if !safeName(file) {
return nil, os.ErrorString("unsafe name: " + file)
}
cgoOFiles = append(cgoOFiles, file[:len(file)-2]+".o")
if !isCgo[file] {
goFiles = append(goFiles, file)
}
}
goFiles := make([]string, 0, len(dirInfo.goFiles))
for _, file := range dirInfo.goFiles {
oFiles := make([]string, 0, len(dirInfo.cFiles)+len(dirInfo.sFiles))
cgoOFiles := make([]string, 0, len(dirInfo.cFiles))
for _, file := range dirInfo.cFiles {
if !safeName(file) {
return nil, os.ErrorString("unsafe name: " + file)
}
if !isCgo[file] {
goFiles = append(goFiles, file)
// When cgo is in use, C files are compiled with gcc,
// otherwise they're compiled with gc.
if len(cgoFiles) > 0 {
cgoOFiles = append(cgoOFiles, file[:len(file)-2]+".o")
} else {
oFiles = append(oFiles, file[:len(file)-2]+".$O")
}
}
oFiles := make([]string, 0, len(dirInfo.sFiles))
for _, file := range dirInfo.sFiles {
if !safeName(file) {
return nil, os.ErrorString("unsafe name: " + file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment