2017-08-26 01:34:03 +02:00
|
|
|
//
|
|
|
|
// OCCAM
|
|
|
|
//
|
|
|
|
// Copyright (c) 2017, SRI International
|
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright notice, this
|
|
|
|
// list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
// this list of conditions and the following disclaimer in the documentation
|
|
|
|
// and/or other materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// * Neither the name of SRI International nor the names of its contributors may
|
|
|
|
// be used to endorse or promote products derived from this software without
|
|
|
|
// specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
//
|
|
|
|
|
2017-07-11 19:52:05 +02:00
|
|
|
package shared
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
|
|
//ELFSectionName is the name of our ELF section of "bitcode paths".
|
|
|
|
ELFSectionName = ".llvm_bc"
|
|
|
|
|
|
|
|
//DarwinSegmentName is the name of our MACH-O segment of "bitcode paths".
|
|
|
|
DarwinSegmentName = "__WLLVM"
|
|
|
|
|
|
|
|
//DarwinSectionName is the name of our MACH-O section of "bitcode paths".
|
|
|
|
DarwinSectionName = "__llvm_bc"
|
|
|
|
)
|
|
|
|
|
|
|
|
//LLVMToolChainBinDir is the user configured directory holding the LLVM binary tools.
|
|
|
|
var LLVMToolChainBinDir string
|
|
|
|
|
|
|
|
//LLVMCCName is the user configured name of the clang compiler.
|
|
|
|
var LLVMCCName string
|
|
|
|
|
|
|
|
//LLVMCXXName is the user configured name of the clang++ compiler.
|
|
|
|
var LLVMCXXName string
|
|
|
|
|
|
|
|
//LLVMARName is the user configured name of the llvm-ar.
|
|
|
|
var LLVMARName string
|
|
|
|
|
|
|
|
//LLVMLINKName is the user configured name of the llvm-link.
|
|
|
|
var LLVMLINKName string
|
|
|
|
|
|
|
|
//LLVMConfigureOnly is the user configured flag indicating a single pass mode is required.
|
|
|
|
var LLVMConfigureOnly string
|
|
|
|
|
|
|
|
//LLVMBitcodeStorePath is the user configured location of the bitcode archive.
|
|
|
|
var LLVMBitcodeStorePath string
|
|
|
|
|
|
|
|
//LLVMLoggingLevel is the user configured logging level: ERROR, WARNING, INFO, DEBUG.
|
|
|
|
var LLVMLoggingLevel string
|
|
|
|
|
|
|
|
//LLVMLoggingFile is the path to the optional logfile (useful when configuring)
|
|
|
|
var LLVMLoggingFile string
|
|
|
|
|
2019-10-23 18:27:24 +02:00
|
|
|
//LLVMObjcopy is the path to the objcopy executable used to attach the bitcode on *nix.
|
|
|
|
var LLVMObjcopy string
|
|
|
|
|
|
|
|
//LLVMLd is the path to the ld executable used to attach the bitcode on OSX.
|
|
|
|
var LLVMLd string
|
|
|
|
|
2017-07-11 22:01:46 +02:00
|
|
|
const (
|
2019-10-23 21:03:01 +02:00
|
|
|
envpath = "LLVM_COMPILER_PATH"
|
|
|
|
envcc = "LLVM_CC_NAME"
|
|
|
|
envcxx = "LLVM_CXX_NAME"
|
|
|
|
envar = "LLVM_AR_NAME"
|
|
|
|
envlnk = "LLVM_LINK_NAME"
|
|
|
|
envcfg = "WLLVM_CONFIGURE_ONLY"
|
|
|
|
envbc = "WLLVM_BC_STORE"
|
|
|
|
envlvl = "WLLVM_OUTPUT_LEVEL"
|
|
|
|
envfile = "WLLVM_OUTPUT_FILE"
|
|
|
|
envld = "GLLVM_LD" //iam: we are deviating from wllvm here.
|
|
|
|
envobjcopy = "GLLVM_OBJCOPY" //iam: we are deviating from wllvm here.
|
2019-10-23 18:27:24 +02:00
|
|
|
//wllvm uses a BINUTILS_TARGET_PREFIX, which seems less general.
|
2017-07-11 22:01:46 +02:00
|
|
|
)
|
|
|
|
|
2017-07-11 19:52:05 +02:00
|
|
|
func init() {
|
|
|
|
|
2017-07-11 22:01:46 +02:00
|
|
|
LLVMToolChainBinDir = os.Getenv(envpath)
|
|
|
|
LLVMCCName = os.Getenv(envcc)
|
|
|
|
LLVMCXXName = os.Getenv(envcxx)
|
|
|
|
LLVMARName = os.Getenv(envar)
|
|
|
|
LLVMLINKName = os.Getenv(envlnk)
|
2017-07-11 19:52:05 +02:00
|
|
|
|
2017-07-11 22:01:46 +02:00
|
|
|
LLVMConfigureOnly = os.Getenv(envcfg)
|
|
|
|
LLVMBitcodeStorePath = os.Getenv(envbc)
|
2017-07-11 19:52:05 +02:00
|
|
|
|
2017-07-11 22:01:46 +02:00
|
|
|
LLVMLoggingLevel = os.Getenv(envlvl)
|
|
|
|
LLVMLoggingFile = os.Getenv(envfile)
|
2017-07-11 19:52:05 +02:00
|
|
|
|
2019-10-23 18:27:24 +02:00
|
|
|
LLVMObjcopy = os.Getenv(envobjcopy)
|
|
|
|
LLVMLd = os.Getenv(envld)
|
2017-07-11 19:52:05 +02:00
|
|
|
}
|
2018-05-03 00:59:34 +02:00
|
|
|
|
|
|
|
func printEnvironment() {
|
2019-10-23 18:27:24 +02:00
|
|
|
vars := []string{envpath, envcc, envcxx, envar, envlnk, envcfg, envbc, envlvl, envfile, envobjcopy, envld}
|
2018-05-03 00:59:34 +02:00
|
|
|
|
2018-05-09 00:11:42 +02:00
|
|
|
informUser("\nLiving in this environment:\n\n")
|
2018-05-03 00:59:34 +02:00
|
|
|
for _, v := range vars {
|
2018-05-09 00:11:42 +02:00
|
|
|
val, defined := os.LookupEnv(v)
|
|
|
|
if defined {
|
|
|
|
informUser("%v = \"%v\"\n", v, val)
|
|
|
|
} else {
|
|
|
|
informUser("%v is NOT defined\n", v)
|
|
|
|
}
|
2018-05-03 00:59:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|