Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compiler_flags setting take precedence over the compiler flag env var #622

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/occa/internal/modes/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ namespace occa {
compiler = "nvcc";
}

if (env::var("OCCA_CUDA_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_CUDA_COMPILER_FLAGS");
} else if (kernelProps.get<std::string>("compiler_flags").size()) {
if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (env::var("OCCA_CUDA_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_CUDA_COMPILER_FLAGS");
} else {
compilerFlags = "-O3";
}
Expand Down
8 changes: 4 additions & 4 deletions src/occa/internal/modes/dpcpp/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ namespace occa
void setCompilerFlags(occa::json &dpcpp_properties) noexcept
{
std::string compiler_flags;
if (env::var("OCCA_DPCPP_COMPILER_FLAGS").size())
if (dpcpp_properties.has("compiler_flags"))
{
compiler_flags = env::var("OCCA_DPCPP_COMPILER_FLAGS");
compiler_flags = dpcpp_properties["compiler_flags"].toString();
}
else if (dpcpp_properties.has("compiler_flags"))
else if (env::var("OCCA_DPCPP_COMPILER_FLAGS").size())
{
compiler_flags = dpcpp_properties["compiler_flags"].toString();
compiler_flags = env::var("OCCA_DPCPP_COMPILER_FLAGS");
}
dpcpp_properties["compiler_flags"] = compiler_flags;
}
Expand Down
6 changes: 3 additions & 3 deletions src/occa/internal/modes/hip/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ namespace occa {
compiler = "hipcc";
}

if (env::var("OCCA_HIP_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_HIP_COMPILER_FLAGS");
} else if (kernelProps.get<std::string>("compiler_flags").size()) {
if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (env::var("OCCA_HIP_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_HIP_COMPILER_FLAGS");
} else {
compilerFlags = "-O3";
}
Expand Down
6 changes: 3 additions & 3 deletions src/occa/internal/modes/opencl/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ namespace occa {
std::string compilerFlags;

// Use "-cl-opt-disable" for debug-mode
if (env::var("OCCA_OPENCL_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_OPENCL_COMPILER_FLAGS");
} else if (kernelProps.has("compiler_flags")) {
if (kernelProps.has("compiler_flags")) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (env::var("OCCA_OPENCL_COMPILER_FLAGS").size()) {
compilerFlags = env::var("OCCA_OPENCL_COMPILER_FLAGS");
}

std::string ocl_c_ver = "2.0";
Expand Down
6 changes: 3 additions & 3 deletions src/occa/internal/modes/serial/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ namespace occa {
#endif
}

if (compilerLanguageFlag == sys::language::CPP && env::var("OCCA_CXXFLAGS").size()) {
if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (compilerLanguageFlag == sys::language::CPP && env::var("OCCA_CXXFLAGS").size()) {
compilerFlags = env::var("OCCA_CXXFLAGS");
} else if (compilerLanguageFlag == sys::language::C && env::var("OCCA_CFLAGS").size()) {
compilerFlags = env::var("OCCA_CFLAGS");
} else if (kernelProps.get<std::string>("compiler_flags").size()) {
compilerFlags = (std::string) kernelProps["compiler_flags"];
} else if (compilerLanguageFlag == sys::language::CPP && env::var("CXXFLAGS").size()) {
compilerFlags = env::var("CXXFLAGS");
} else if (compilerLanguageFlag == sys::language::C && env::var("CFLAGS").size()) {
Expand Down