occa icon indicating copy to clipboard operation
occa copied to clipboard

`occa::json["compiler_flags"]` should override environment variable

Open MalachiTimothyPhillips opened this issue 3 years ago • 1 comments

e.g., https://github.com/libocca/occa/blob/2e576e69e07627a516b568079e047965a9bd8d24/src/occa/internal/modes/serial/device.cpp#L196


      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()) {
        compilerFlags = env::var("CFLAGS");
      } else {
#if (OCCA_OS & (OCCA_LINUX_OS | OCCA_MACOS_OS))
        compilerFlags = "-O3";
#else
        compilerFlags = " /Ox";
#endif
      }

Why is OCCA_CXXFLAGS used to set the compiler flags, despite kernelProps["compiler_flags"] being set? I would have thought that setting the kernelProps["compiler_flags] should have taken precedence here.

MalachiTimothyPhillips avatar Sep 19 '22 22:09 MalachiTimothyPhillips

To be clear, this logic is also repeated across other backends, e.g. https://github.com/libocca/occa/blob/2e576e69e07627a516b568079e047965a9bd8d24/src/occa/internal/modes/cuda/device.cpp#L53.

MalachiTimothyPhillips avatar Sep 19 '22 22:09 MalachiTimothyPhillips