- 
                Notifications
    You must be signed in to change notification settings 
- Fork 36
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Currently we only support c++ 20 based wasm kernel and this flag is passed to our wasm interpreter here
Lines 29 to 33 in dc14222
| void* createInterpreter(const Args &ExtraArgs = {}) { | |
| Args ClangArgs = {/*"-xc++"*/"-v"}; // ? {"-Xclang", "-emit-llvm-only", "-Xclang", "-diagnostic-log-file", "-Xclang", "-", "-xc++"}; | |
| #ifdef EMSCRIPTEN | |
| ClangArgs.push_back("-std=c++20"); | |
| #else | 
This is the only place where essentially we should be hardcoing the version 20 before we start supporting multiple wasm kernels.
Currently get_stdopt is framed like this
    static std::string get_stdopt()
    {
        // We need to find what's the C++ version the interpreter runs with.
#ifndef EMSCRIPTEN
        const char* code = R"(
int __get_cxx_version () {
#if __cplusplus > 202302L
    return 26;
#elif __cplusplus > 202002L
    return 23;
#elif __cplusplus >  201703L
    return 20;
#elif __cplusplus > 201402L
    return 17;
#elif __cplusplus > 201103L || (defined(_WIN32) && _MSC_VER >= 1900)
    return 14;
#elif __cplusplus >= 201103L
   return 11;
#else
  return 0;
#endif
  }
__get_cxx_version ()
      )";
        auto cxx_version = Cpp::Evaluate(code);
        return std::to_string(cxx_version);
#else
        return "20";
#endif
    }
    
But we should simply have
    static std::string get_stdopt()
    {
        // We need to find what's the C++ version the interpreter runs with.
        const char* code = R"(
int __get_cxx_version () {
#if __cplusplus > 202302L
    return 26;
#elif __cplusplus > 202002L
    return 23;
#elif __cplusplus >  201703L
    return 20;
#elif __cplusplus > 201402L
    return 17;
#elif __cplusplus > 201103L || (defined(_WIN32) && _MSC_VER >= 1900)
    return 14;
#elif __cplusplus >= 201103L
   return 11;
#else
  return 0;
#endif
  }
__get_cxx_version()
      )";
        auto cxx_version = Cpp::Evaluate(code);
        return std::to_string(cxx_version);
    }
That is basically run the __get_cxx_version as a first side module and fetch the version through Evaluate rather than hardcode it, cause xeus-cpp-lite should be able to run the code from get_stdopt anyways.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working