diff --git a/src/occa/internal/modes/cuda/device.cpp b/src/occa/internal/modes/cuda/device.cpp index d99a67f47..0a6c5b7c1 100644 --- a/src/occa/internal/modes/cuda/device.cpp +++ b/src/occa/internal/modes/cuda/device.cpp @@ -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("compiler_flags").size()) { + if (kernelProps.get("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"; } diff --git a/src/occa/internal/modes/dpcpp/utils.cpp b/src/occa/internal/modes/dpcpp/utils.cpp index a9ac6fceb..ab2c9a2f4 100644 --- a/src/occa/internal/modes/dpcpp/utils.cpp +++ b/src/occa/internal/modes/dpcpp/utils.cpp @@ -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; } diff --git a/src/occa/internal/modes/hip/device.cpp b/src/occa/internal/modes/hip/device.cpp index 7b06770ea..390885ab6 100644 --- a/src/occa/internal/modes/hip/device.cpp +++ b/src/occa/internal/modes/hip/device.cpp @@ -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("compiler_flags").size()) { + if (kernelProps.get("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"; } diff --git a/src/occa/internal/modes/opencl/device.cpp b/src/occa/internal/modes/opencl/device.cpp index 16be70241..c5d090751 100644 --- a/src/occa/internal/modes/opencl/device.cpp +++ b/src/occa/internal/modes/opencl/device.cpp @@ -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"; diff --git a/src/occa/internal/modes/serial/device.cpp b/src/occa/internal/modes/serial/device.cpp index ce3df6586..4918265ca 100644 --- a/src/occa/internal/modes/serial/device.cpp +++ b/src/occa/internal/modes/serial/device.cpp @@ -193,12 +193,12 @@ namespace occa { #endif } - if (compilerLanguageFlag == sys::language::CPP && env::var("OCCA_CXXFLAGS").size()) { + if (kernelProps.get("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("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()) {