aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja
diff options
context:
space:
mode:
Diffstat (limited to 'backend/ninja')
-rw-r--r--backend/ninja/Ninja.cpp42
1 files changed, 41 insertions, 1 deletions
diff --git a/backend/ninja/Ninja.cpp b/backend/ninja/Ninja.cpp
index c66907c..802ffd8 100644
--- a/backend/ninja/Ninja.cpp
+++ b/backend/ninja/Ninja.cpp
@@ -379,6 +379,37 @@ namespace backend
return {};
}
+ static ninja::NinjaArg getCompilerCpuFlag(const SibsConfig &config)
+ {
+ // TODO: Also use -mcpu=native on non x86 systems
+ switch(config.getCompiler()) {
+ case Compiler::GCC:
+ case Compiler::MINGW_W64: {
+ switch(config.cpu) {
+ case sibs::CPU_INVALID:
+ case sibs::CPU_BASELINE:
+ return {};
+ case sibs::CPU_NATIVE:
+ return ninja::NinjaArg::createRaw("-march=native");
+ }
+ break;
+ }
+ case Compiler::MSVC: {
+ // msvc doesn't have any equivalent to gcc -march=native.
+ // TODO: Detect features at runtime here to manually add the cpu feature flags instead
+ switch(config.cpu) {
+ case sibs::CPU_INVALID:
+ case sibs::CPU_BASELINE:
+ return {};
+ case sibs::CPU_NATIVE:
+ return ninja::NinjaArg::createRaw("-march=native");
+ }
+ break;
+ }
+ }
+ return {};
+ }
+
static vector<ninja::NinjaArg> getCompilerOptimizationFlags(const SibsConfig &config)
{
switch (config.getCompiler())
@@ -1017,6 +1048,10 @@ namespace backend
allLinkerFlags += " " + optFlag.arg;
}
+ ninja::NinjaArg cpuFlag = getCompilerCpuFlag(config);
+ if(cpuFlag.type != ninja::NinjaArg::Type::NONE)
+ compileCCommand.push_back(std::move(cpuFlag));
+
ninja::NinjaArg sanitizerFlag = getCompilerSanitizerFlag(config);
if(sanitizerFlag.type != ninja::NinjaArg::Type::NONE)
compileCCommand.push_back(std::move(sanitizerFlag));
@@ -1075,6 +1110,10 @@ namespace backend
allLinkerFlags += " " + optFlag.arg;
}
+ ninja::NinjaArg cpuFlag = getCompilerCpuFlag(config);
+ if(cpuFlag.type != ninja::NinjaArg::Type::NONE)
+ compileCCommand.push_back(std::move(cpuFlag));
+
ninja::NinjaArg sanitizerFlag = getCompilerSanitizerFlag(config);
if(sanitizerFlag.type != ninja::NinjaArg::Type::NONE)
compileCCommand.push_back(std::move(sanitizerFlag));
@@ -1764,7 +1803,8 @@ namespace backend
SibsTestConfig sibsTestConfig(config.getCompiler(), testSourceDirNative.data, config.getOptimizationLevel());
sibsTestConfig.platform = config.platform;
sibsTestConfig.setSanitize(config.getSanitize());
- sibsTestConfig.zigTestFiles = move(config.zigTestFiles);
+ sibsTestConfig.cpu = config.cpu;
+ sibsTestConfig.zigTestFiles = config.zigTestFiles;
sibsTestConfig.zigTestAllFiles = config.zigTestAllFiles;
sibsTestConfig.cVersion = config.cVersion;
sibsTestConfig.cppVersion = config.cppVersion;