diff --git a/compiler.go b/compiler.go index 2d0cce3..0e59454 100644 --- a/compiler.go +++ b/compiler.go @@ -20,7 +20,7 @@ type bitcodeToObjectLink struct { func compile(args []string, compilerName string) { var compilerExecName = getCompilerExecName(compilerName) var configureOnly bool - if os.Getenv(envCONFIGUREONLY) != "" { + if ConfigureOnly != "" { configureOnly = true } var pr = parse(args) @@ -123,7 +123,7 @@ func attachBitcodePathToObject(bcFile, objFile string) { _, err = execCmd(attachCmd, attachCmdArgs, "") // Copy bitcode file to store, if necessary - if bcStorePath := os.Getenv(envBCSTOREPATH); bcStorePath != "" { + if bcStorePath := os.Getenv(BitcodeStorePath); bcStorePath != "" { destFilePath := path.Join(bcStorePath, getHashedPath(absBcPath)) in, _ := os.Open(absBcPath) defer in.Close() diff --git a/constants.go b/constants.go index c5249d1..f6c1f19 100644 --- a/constants.go +++ b/constants.go @@ -5,11 +5,6 @@ import ( ) const ( - // Environment variables - envCONFIGUREONLY = "GLLVM_CONFIGURE_ONLY" - envBCSTOREPATH = "GLLVM_BC_STORE" - - // Gllvm functioning (once we have it working we can change the W to G; but for the time being leave it so that extract-bc works) elfSECTIONNAME = ".llvm_bc" darwinSEGMENTNAME = "__WLLVM" darwinSECTIONNAME = "__llvm_bc" @@ -21,12 +16,19 @@ var LLVMCXXName = "" var LLVMARName = "" var LLVMLINKName = "" +var ConfigureOnly = "" +var BitcodeStorePath = "" + func init(){ + LLVMToolChainBinDir = os.Getenv("GLLVM_TOOLS_PATH") LLVMCCName = os.Getenv("GLLVM_CC_NAME") LLVMCXXName = os.Getenv("GLLVM_CXX_NAME") LLVMARName = os.Getenv("GLLVM_AR_NAME") LLVMLINKName = os.Getenv("GLLVM_LINK_NAME") + + ConfigureOnly = os.Getenv("GLLVM_CONFIGURE_ONLY") + BitcodeStorePath = os.Getenv("GLLVM_BC_STORE") } diff --git a/extractor.go b/extractor.go index fe868cf..fb7f4d9 100644 --- a/extractor.go +++ b/extractor.go @@ -286,7 +286,7 @@ func extractSectionUnix(inputFile string) (contents []string) { func resolveBitcodePath(bcPath string) string { if _, err := os.Stat(bcPath); os.IsNotExist(err) { // If the bitcode file does not exist, try to find it in the store - if bcStorePath := os.Getenv(envBCSTOREPATH); bcStorePath != "" { + if bcStorePath := os.Getenv(BitcodeStorePath); bcStorePath != "" { // Compute absolute path hash absBcPath, _ := filepath.Abs(bcPath) storeBcPath := path.Join(bcStorePath, getHashedPath(absBcPath)) diff --git a/logging.go b/logging.go index ab88605..776c297 100644 --- a/logging.go +++ b/logging.go @@ -13,11 +13,6 @@ const ( debugV ) -const ( - loggingLevelEnvVar = "GLLVM_OUTPUT_LEVEL" - loggingFileEnvVar = "GLLVM_OUTPUT_FILE" -) - var loggingLevels = map[string]int{ "ERROR": errorV, "WARNING": warningV, @@ -30,12 +25,12 @@ var level = 0 var filePointer = os.Stderr func init() { - if envLevelStr := os.Getenv(loggingLevelEnvVar); envLevelStr != "" { + if envLevelStr := os.Getenv("GLLVM_OUTPUT_LEVEL"); envLevelStr != "" { if envLevelVal, ok := loggingLevels[envLevelStr]; ok { level = envLevelVal } } - if envFileStr := os.Getenv(loggingFileEnvVar); envFileStr != "" { + if envFileStr := os.Getenv("GLLVM_OUTPUT_FILE"); envFileStr != "" { if loggingFP, err := os.OpenFile(envFileStr, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600); err == nil { filePointer = loggingFP }