Skip to content
Permalink
Browse files

Initial intel compiler detection.

  • Loading branch information...
egorpugin committed Oct 2, 2019
1 parent 07b9e58 commit 9c566eee8b86a3442633064ec36d694c253e1f93
@@ -634,6 +634,7 @@ String Command::makeErrorString(const String &e)
boost::replace_all(err.text, "\r", "");
s += "\n" + boost::trim_copy(err.text);
}
boost::trim(s);
s += "\n";
s += e;
boost::trim(s);
@@ -655,7 +656,7 @@ String Command::saveCommand() const

String s;
s += "\n";
s += "pid = " + std::to_string(pid) + "\n";
//s += "pid = " + std::to_string(pid) + "\n";
s += "command is copied to " + p.u8string() + "\n";

return s;
@@ -159,6 +159,14 @@ static sw::TargetSettings compilerTypeFromStringCaseI(const sw::UnresolvedPackag
ts["native"]["program"]["cpp"] = set_with_version("com.Microsoft.VisualStudio.VC.cl");
ts["native"]["program"]["asm"] = set_with_version("com.Microsoft.VisualStudio.VC.ml");
}
else if (compiler.ppath == "intel")
{
ts["native"]["program"]["c"] = set_with_version("com.intel.compiler.c");
ts["native"]["program"]["cpp"] = set_with_version("com.intel.compiler.cpp");
ts["native"]["program"]["asm"] = set_with_version("com.Microsoft.VisualStudio.VC.ml");
ts["native"]["program"]["lib"] = "com.intel.compiler.lib";
ts["native"]["program"]["link"] = "com.intel.compiler.link";
}
else
{
ts["native"]["program"]["c"] = compiler.toString();
@@ -730,7 +730,7 @@ static Strings listWindowsKits()
return kits;
}

void detectWindowsSdk(DETECT_ARGS)
static void detectWindowsSdk(DETECT_ARGS)
{
// ucrt - universal CRT
//
@@ -908,14 +908,14 @@ void detectWindowsSdk(DETECT_ARGS)
}
}

void detectMsvc(DETECT_ARGS)
static void detectMsvc(DETECT_ARGS)
{
detectMsvc15Plus(s);
detectMsvc14AndOlder(s);
detectWindowsSdk(s);
}

void detectWindowsClang(DETECT_ARGS)
static void detectWindowsClang(DETECT_ARGS)
{
// create programs
const path base_llvm_path = path("c:") / "Program Files" / "LLVM";
@@ -1024,13 +1024,111 @@ void detectWindowsClang(DETECT_ARGS)
}
}

void detectWindowsCompilers(DETECT_ARGS)
static void detectIntelCompilers(DETECT_ARGS)
{
// some info at https://gitlab.com/ita1024/waf/blob/master/waflib/Tools/msvc.py#L521

// C, C++

// win
{
auto add_prog_from_path = [&s](const path &name, const String &ppath)
{
auto p = std::make_shared<SimpleProgram>(s);
p->file = resolveExecutable(name);
if (fs::exists(p->file))
{
auto v = getVersion(s, p->file);
addProgram(s, PackageId(ppath, v), p);

// icl/xilib/xilink on win wants VC in PATH
auto &cld = s.getPredefinedTargets();
auto i = cld["com.Microsoft.VisualStudio.VC.cl"].rbegin_releases();
if (i != cld["com.Microsoft.VisualStudio.VC.cl"].rend_releases())
{
if (!i->second.empty())
{
if (auto t = (*i->second.begin())->as<PredefinedProgramTarget *>())
{
path x = t->getProgram().getCommand()->getProgram();
p->getCommand()->addPathDirectory(x.parent_path());
}
}
}
}
return p;
};

add_prog_from_path("icl", "com.intel.compiler.c");
add_prog_from_path("icl", "com.intel.compiler.cpp");
add_prog_from_path("xilib", "com.intel.compiler.lib");
add_prog_from_path("xilink", "com.intel.compiler.link");

// ICPP_COMPILER{VERSION} like ICPP_COMPILER19 etc.
for (int i = 9; i < 23; i++)
{
auto s = "ICPP_COMPILER" + std::to_string(i);
auto v = getenv(s.c_str());
if (!v)
continue;

path root = v;
auto bin = root;
bin /= "bin";
auto arch = "intel64";
bin /= arch;

std::shared_ptr<SimpleProgram> p;
p = add_prog_from_path(bin / "icl", "com.intel.compiler.c");
p->getCommand()->push_back("-I");
p->getCommand()->push_back(root / "compiler" / "include");

p = add_prog_from_path(bin / "icl", "com.intel.compiler.cpp");
p->getCommand()->push_back("-I");
p->getCommand()->push_back(root / "compiler" / "include");

add_prog_from_path(bin / "xilib", "com.intel.compiler.lib");

p = add_prog_from_path(bin / "xilink", "com.intel.compiler.link");
p->getCommand()->push_back("-LIBPATH:" + (root / "compiler" / "lib" / arch).u8string());
p->getCommand()->push_back("libirc.lib");
}

// also registry paths
// HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Intel ...
}

// *nix
{
{
auto p = std::make_shared<SimpleProgram>(s); // new object
p->file = resolveExecutable("icc");
if (fs::exists(p->file))
{
auto v = getVersion(s, p->file);
addProgram(s, PackageId("com.intel.compiler.c", v), p);
}
}

{
auto p = std::make_shared<SimpleProgram>(s); // new object
p->file = resolveExecutable("icpc");
if (fs::exists(p->file))
{
auto v = getVersion(s, p->file);
addProgram(s, PackageId("com.intel.compiler.cpp", v), p);
}
}
}
}

static void detectWindowsCompilers(DETECT_ARGS)
{
detectMsvc(s);
detectWindowsClang(s);
}

void detectNonWindowsCompilers(DETECT_ARGS)
static void detectNonWindowsCompilers(DETECT_ARGS)
{
auto resolve_and_add = [&s](const path &prog, const String &ppath)
{
@@ -1081,6 +1179,7 @@ void detectNativeCompilers(DETECT_ARGS)
}
else
detectNonWindowsCompilers(s);
detectIntelCompilers(s);
}

}
@@ -190,16 +190,21 @@ static void targetSettings2Command(primitives::Command &c, const TargetSetting &
}
}

void NativeCompiledTarget::activateCompiler(const TargetSetting &s, const StringSet &exts)
static auto get_settings_package_id(const TargetSetting &s)
{
bool extended_desc = s.isObject();

UnresolvedPackage id;
if (extended_desc)
id = s["package"].getValue();
else
id = s.getValue();
return id;
}

void NativeCompiledTarget::activateCompiler(const TargetSetting &s, const StringSet &exts)
{
bool extended_desc = s.isObject();
auto id = get_settings_package_id(s);
activateCompiler(s, id, exts, extended_desc);
}

@@ -232,6 +237,10 @@ void NativeCompiledTarget::activateCompiler(const TargetSetting &s, const Unreso
ct = CompilerType::Clang;
else if (id.ppath == "org.LLVM.clangcl")
ct = CompilerType::ClangCl;
else if (id.ppath == "com.intel.compiler.c" || id.ppath == "com.intel.compiler.cpp")
ct = CompilerType::Intel;
//else
//throw SW_RUNTIME_ERROR("Unknown compiler type: " + id.toString());
};

auto c = std::dynamic_pointer_cast<CompilerBaseProgram>(t->getProgram().clone());
@@ -331,6 +340,20 @@ void NativeCompiledTarget::activateCompiler(const TargetSetting &s, const Unreso
throw SW_RUNTIME_ERROR("Unknown arch");
}
}
else if (id.ppath == "com.intel.compiler.c" || id.ppath == "com.intel.compiler.cpp")
{
auto C = std::make_shared<VisualStudioCompiler>(getSolution().getContext());
c = C;
C->ForceSynchronousPDBWrites = false;
if (ts["native"]["stdlib"]["cpp"].getValue() == "com.Microsoft.VisualStudio.VC.libcpp")
{
// take same ver as cl
UnresolvedPackage up(ts["native"]["stdlib"]["cpp"].getValue());
up.range = id.range;
*this += up;
libstdcppset = true;
}
}
else
throw SW_RUNTIME_ERROR("Unknown compiler: " + id.toString());

@@ -342,13 +365,7 @@ void NativeCompiledTarget::activateCompiler(const TargetSetting &s, const Unreso
std::shared_ptr<NativeLinker> NativeCompiledTarget::activateLinker(const TargetSetting &s)
{
bool extended_desc = s.isObject();

UnresolvedPackage id;
if (extended_desc)
id = s["package"].getValue();
else
id = s.getValue();

auto id = get_settings_package_id(s);
return activateLinker(s, id, extended_desc);
}

@@ -379,7 +396,8 @@ std::shared_ptr<NativeLinker> NativeCompiledTarget::activateLinker(const TargetS
targetSettings2Command(*C, s["command"]);
};

if (id.ppath == "com.Microsoft.VisualStudio.VC.lib")
if (0);
else if (id.ppath == "com.Microsoft.VisualStudio.VC.lib")
{
c = std::make_shared<VisualStudioLibrarian>(getSolution().getContext());
c->Type = LinkerType::MSVC;
@@ -457,6 +475,16 @@ std::shared_ptr<NativeLinker> NativeCompiledTarget::activateLinker(const TargetS
//cmd->push_back("-target");
//cmd->push_back(getBuildSettings().getTargetTriplet());
}
else if (id.ppath == "com.intel.compiler.lib")
{
c = std::make_shared<VisualStudioLibrarian>(getSolution().getContext());
c->Type = LinkerType::MSVC;
}
else if (id.ppath == "com.intel.compiler.link")
{
c = std::make_shared<VisualStudioLinker>(getSolution().getContext());
c->Type = LinkerType::MSVC;
}
else
throw SW_RUNTIME_ERROR("Unknown librarian/linker: " + id.toString());

@@ -492,7 +520,7 @@ void NativeCompiledTarget::findCompiler()
activateCompiler(ts["native"]["program"]["c"], { ".c" });

if (ct == CompilerType::UnspecifiedCompiler)
throw SW_RUNTIME_ERROR("Unknown compiler: " + ts.toString());
throw SW_RUNTIME_ERROR("Unknown compiler: " + get_settings_package_id(ts["native"]["program"]["c"]).toString());

if (getBuildSettings().TargetOS.is(OSType::Windows))
{
@@ -133,8 +133,8 @@ std::unordered_map<UnresolvedPackage, LocalPackage> SwManagerContext::install(co

auto &e = getExecutor();
Futures<void> fs;
for (auto &[_,p] : pkgs2)
fs.push_back(e.push([this, &p]{ install(*p); }));
for (auto &p : pkgs2)
fs.push_back(e.push([this, &p]{ install(*p.second); }));
waitAndGet(fs);

// install should be fast enough here
3 sw.cpp
@@ -294,6 +294,9 @@ void build(Solution &s)
}
}

if (client.getBuildSettings().TargetOS.Type != OSType::Windows)
return;

auto &gui = client.addTarget<ExecutableTarget>("gui");
{
gui.PackageDefinitions = true;

0 comments on commit 9c566ee

Please sign in to comment.
You can’t perform that action at this time.