Can see compiler exit codes now. Still do not get the same config results as wllvm or clang. Will add more detail to the issue.

This commit is contained in:
Ian A Mason 2017-06-30 14:41:30 -07:00
parent 7c7da225be
commit 698fc9286d
2 changed files with 37 additions and 9 deletions

View File

@ -16,7 +16,13 @@ type bitcodeToObjectLink struct {
objPath string
}
func compile(args []string, compilerName string) {
func compile(args []string, compilerName string) (exitCode int) {
exitCode = 0
//in the configureOnly case we have to know the exit code of the compile
//because that is how configure figures out what it can and cannot do.
var ok bool = true
var compilerExecName = getCompilerExecName(compilerName)
var configureOnly bool
if ConfigureOnly != "" {
@ -26,20 +32,33 @@ func compile(args []string, compilerName string) {
var wg sync.WaitGroup
// If configure only is set, just execute the compiler
if configureOnly {
wg.Add(1)
go execCompile(compilerExecName, pr, &wg)
go execCompile(compilerExecName, pr, &wg, &ok)
wg.Wait()
// Else try to build bitcode as well
if !ok {
exitCode = 1
}
} else {
var bcObjLinks []bitcodeToObjectLink
var newObjectFiles []string
wg.Add(2)
go execCompile(compilerExecName, pr, &wg)
go execCompile(compilerExecName, pr, &wg, &ok)
go buildAndAttachBitcode(compilerExecName, pr, &bcObjLinks, &newObjectFiles, &wg)
wg.Wait()
// When objects and bitcode are builtm we can attach bitcode paths
//grok the exit code
if !ok {
exitCode = 1
}
//FIXME: (if the compile went bad, why are we even trying to do more here)
// When objects and bitcode are built we can attach bitcode paths
// to object files and link
for _, link := range bcObjLinks {
attachBitcodePathToObject(link.bcPath, link.objPath)
@ -48,6 +67,7 @@ func compile(args []string, compilerName string) {
compileTimeLinkFiles(compilerExecName, pr, newObjectFiles)
}
}
return
}
// Compiles bitcode files and mutates the list of bc->obj links to perform + the list of
@ -169,12 +189,13 @@ func buildBitcodeFile(compilerExecName string, pr parserResult, srcFile string,
}
// Tries to build object file
func execCompile(compilerExecName string, pr parserResult, wg *sync.WaitGroup) {
func execCompile(compilerExecName string, pr parserResult, wg *sync.WaitGroup, ok *bool) {
defer (*wg).Done()
success, err := execCmd(compilerExecName, pr.InputList, "")
if !success {
logFatal("Failed to compile using given arguments: %v\n", err)
}
logError("Failed to compile using given arguments: %v\n", err)
*ok = false
}
}
func getCompilerExecName(compilerName string) string {

View File

@ -10,15 +10,22 @@ func main() {
var args = os.Args
_, callerName := path.Split(args[0])
args = args[1:]
var exitCode int
switch callerName {
case "gclang":
compile(args, "clang")
exitCode = compile(args, "clang")
case "gclang++":
compile(args, "clang++")
exitCode = compile(args, "clang++")
case "get-bc":
extract(args)
default:
logError("You should call %s with a valid name.", callerName)
}
logInfo("Calling %v returned %v\n", os.Args, exitCode)
os.Exit(exitCode)
}