From 4ff5865d27a3ced44ec8bb1c216117e1baca4139 Mon Sep 17 00:00:00 2001 From: "Ian A. Mason" Date: Mon, 10 Jul 2017 13:11:46 -0700 Subject: [PATCH] stylistic changes, plus still need to track down the SIGSEGV in the llvm-link. --- .travis/test.sh | 3 +++ cmd/gsanity-check/main.go | 7 ------- cmd/gsanity-check/sanity.go | 39 ++++++++++++++----------------------- shared/logging.go | 1 + 4 files changed, 19 insertions(+), 31 deletions(-) diff --git a/.travis/test.sh b/.travis/test.sh index 5be4cac..dc7be1f 100755 --- a/.travis/test.sh +++ b/.travis/test.sh @@ -15,6 +15,9 @@ GLLVM_CONFIGURE_ONLY=1 CC=gclang ./configure --target=LLVM --build=LLVM make +exit $? + + get-bc -b ./lib/libc.a if [ -s "./lib/libc.a.bc" ] diff --git a/cmd/gsanity-check/main.go b/cmd/gsanity-check/main.go index 9bd49d6..21297dd 100644 --- a/cmd/gsanity-check/main.go +++ b/cmd/gsanity-check/main.go @@ -1,13 +1,6 @@ package main -import ( - "os" -) - func main() { - // Parse command line - var args = os.Args - args = args[1:] sanityCheck() diff --git a/cmd/gsanity-check/sanity.go b/cmd/gsanity-check/sanity.go index f8a1925..faed3e3 100644 --- a/cmd/gsanity-check/sanity.go +++ b/cmd/gsanity-check/sanity.go @@ -9,7 +9,7 @@ import ( "strings" ) -const explain_LLVM_CC_NAME = ` +const explainLLVMCCNAME = ` If your clang compiler is not called clang, but something else, then you will need to set the environment variable LLVM_CC_NAME to the @@ -18,7 +18,7 @@ LLVM_CC_NAME should be set to clang-3.5. ` -const explain_LLVM_CXX_NAME = ` +const explainLLVMCXXNAME = ` If your clang++ compiler is not called clang++, but something else, then you will need to set the environment variable LLVM_CXX_NAME to @@ -27,7 +27,7 @@ then LLVM_CC_NAME should be set to ++clang. ` -const explain_LLVM_COMPILER_PATH = ` +const explainLLVMCOMPILERPATH = ` Your compiler should either be in your PATH, or else located where the environment variable LLVM_COMPILER_PATH indicates. It can also be used @@ -36,7 +36,7 @@ llvm-link, and llvm-ar. ` -const explain_LLVM_LINK_NAME = ` +const explainLLVMLINKNAME = ` If your llvm linker is not called llvm-link, but something else, then you will need to set the environment variable LLVM_LINK_NAME to the @@ -45,7 +45,7 @@ LLVM_LINK_NAME should be set to llvm-link-3.5. ` -const explain_LLVM_AR_NAME = ` +const explainLLVMARNAME = ` If your llvm archiver is not called llvm-ar, but something else, then you will need to set the environment variable LLVM_AR_NAME to @@ -54,8 +54,6 @@ then LLVM_AR_NAME should be set to llvm-ar-3.5. ` - - // Performs the environmental sanity check. // // Performs the following checks in order: @@ -69,25 +67,22 @@ func sanityCheck() { checkOS() - if ! checkCompilers() { + if !checkCompilers() { os.Exit(1) } - if ! checkAuxiliaries() { + if !checkAuxiliaries() { os.Exit(1) } checkStore() - } - -func checkOS(){ +func checkOS() { platform := runtime.GOOS - if platform == "darwin" || platform == "linux" || platform == "freebsd" { return } @@ -113,7 +108,6 @@ func checkCompilers() bool { shared.LogWrite("The CXX compiler %s is:\n\n\t%s\n\n", cxx, extractLine(cxxVersion, 0)) } - return ccOK || cxxOK } @@ -124,10 +118,10 @@ func extractLine(version string, n int) string { lines := strings.Split(version, "\n") var line string lenLines := len(lines) - if n < lenLines { + if n < lenLines { line = lines[n] } else { - line = lines[lenLines - 1] + line = lines[lenLines-1] } return strings.TrimSpace(line) @@ -147,7 +141,6 @@ func checkExecutable(cmdExecName string, varg string) (success bool, err error, return } - func checkAuxiliaries() bool { linkerName := shared.LLVMLINKName archiverName := shared.LLVMARName @@ -162,20 +155,18 @@ func checkAuxiliaries() bool { linkerOK, _, linkerVersion := checkExecutable(linkerName, "-version") - - if ! linkerOK { + if !linkerOK { shared.LogError("The bitcode linker %s was not found or not executable.\nBetter not try using get-bc!\n", linkerName) - shared.LogError(explain_LLVM_LINK_NAME) + shared.LogError(explainLLVMLINKNAME) } else { shared.LogWrite("The bitcode linker %s is:\n\n\t%s\n\n", linkerName, extractLine(linkerVersion, 1)) } archiverOK, _, archiverVersion := checkExecutable(archiverName, "-version") - - if ! archiverOK { + if !archiverOK { shared.LogError("The bitcode archiver %s was not found or not executable.\nBetter not try using get-bc!\n", archiverName) - shared.LogError(explain_LLVM_AR_NAME) + shared.LogError(explainLLVMARNAME) } else { shared.LogWrite("The bitcode archiver %s is:\n\n\t%s\n\n", archiverName, extractLine(archiverVersion, 1)) } @@ -192,7 +183,7 @@ func checkStore() { shared.LogError("The bitcode archive %s does not exist!\n\n", storeDir) return } - if ! finfo.Mode().IsDir() { + if !finfo.Mode().IsDir() { shared.LogError("The bitcode archive %s is not a directory!\n\n", storeDir) return } diff --git a/shared/logging.go b/shared/logging.go index 2f7db36..66bcd99 100644 --- a/shared/logging.go +++ b/shared/logging.go @@ -67,4 +67,5 @@ func LogFatal(format string, a ...interface{}) { os.Exit(1) } +//LogWrite writes to the logging stream, irregardless of levels. var LogWrite = makeLogger(-1)