So in this new session, we continue with the restoring of the NervSeed project started in my previous post. Now it's time to inject some lua magic in there 😋! Or well… a little bit at least… if possible… lol.
$ nvp cmake add class nervland Core app/NervApp
lld-link: error: could not open 'libboost_filesystem-clangw14-mt-x64-1_78.lib': no such file or directory clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
bjam_cmd = [bjam, "--user-config=user-config.jam", "--buildid=clang", "-j", "8", "toolset=clang", "--prefix="+prefix, "--without-mpi", "-sNO_BZIP2=1", "architecture=x86", "variant=release", "link=static", "threading=multi", "address-model=64"]
lld-link: error: /failifmismatch: mismatch detected for 'RuntimeLibrary': >>> msvcprt.lib(locale0_implib.obj) has value MD_DynamicRelease >>> libboost_filesystem-clang14-mt-x64-1_79.lib(operations.obj) has value MT_StaticRelease clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
with open(self.get_path(build_dir, "user-config.jam"), "w", encoding="utf-8") as file: # Note: Should not add the -std=c++11 flag below as this will lead to an error with C files: file.write(f"using clang : {ver_major}.{ver_minor} : {comp_path} : ") if self.is_windows: file.write("cxxstd=17 ") file.write(f"<ranlib>\"{comp_dir}/llvm-ranlib.exe\" ") file.write(f"<archiver>\"{comp_dir}/llvm-ar.exe\" ") file.write("<cxxflags>\"-D_CRT_SECURE_NO_WARNINGS -D_MT -D_DLL -Xclang --dependent-lib=msvcrt\" ") # file.write(f"<cxxflags>-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING ") file.write(";\n") else: file.write(f"<compileflags>\"{cxxflags} -fPIC\" ") file.write(f"<linkflags>\"{linkflags}\" ;\n")
add_definitions(-DBOOST_ALL_STATIC_LINK) add_definitions(-D_CRT_SECURE_NO_WARNINGS) if(WIN32 AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") # MESSAGE(STATUS "Clang version: ${CMAKE_CXX_COMPILER_VERSION}") string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION}) list(GET VERSION_LIST 0 CLANG_MAJOR_VERSION) # list(GET VERSION_LIST 1 CLANG_MINOR_VERSION) # list(GET VERSION_LIST 2 CLANG_PATCH_VERSION) add_definitions(-DBOOST_LIB_TOOLSET="clang${CLANG_MAJOR_VERSION}") endif()
D:\Projects\NervLand\modules\nvCore\src\base/SpinLock.h(41): error C3861: '__builtin_ia32_pause': identifier not found
/
On GCC and clang we can emit the PAUSE instruction using the built-in function \_\_builtin_ia32_pause() and on MSVC using _mm_pause(). Adding this to our spin-wait loop we get:
$ nvp nvl Hello world! [2022-07-23 22:41:48.102] [info] Creating LogManager here. [2022-07-23 22:41:48.103] [info] Setting log level to trace... [2022-07-23 22:41:48.103] [info] Creating LogManager: 42 [2022-07-23 22:41:48.103] [info] Creating NervApp... [2022-07-23 22:41:48.103] [info] Creating NervApp object. [2022-07-23 22:41:48.103] [trace] Creating MemoryManager object. [2022-07-23 22:41:48.103] [info] TODO: should install debug handlers here. [2022-07-23 22:41:48.103] [debug] Creating new pool %d of %d blocks with blocksize=%d [2022-07-23 22:41:48.103] [info] Creating EventHandler object. [2022-07-23 22:41:48.103] [debug] Creating AppComponent ResourceManager [2022-07-23 22:41:48.103] [debug] Creating new pool %d of %d blocks with blocksize=%d [2022-07-23 22:41:48.103] [debug] Creating ResourceManager object. [2022-07-23 22:41:48.103] [trace] Creating ResourceLoader object. [2022-07-23 22:41:48.103] [trace] Adding resource search path: 'D:/Projects/assets/lua/' [2022-07-23 22:41:48.103] [debug] Creating new pool %d of %d blocks with blocksize=%d [2022-07-23 22:41:48.103] [debug] Creating LuaManager object. [2022-07-23 22:41:48.103] [info] Destroying NervApp... [2022-07-23 22:41:48.103] [debug] Uninitializing NervApp object. [2022-07-23 22:41:48.103] [debug] Uninitializing LuaManager... [2022-07-23 22:41:48.103] [debug] Releasing components... [2022-07-23 22:41:48.103] [trace] Uninitializing component: ResourceManager [2022-07-23 22:41:48.103] [debug] Deleting ResourceManager object. [2022-07-23 22:41:48.103] [trace] Deleting ResourceLoader object. [2022-07-23 22:41:48.103] [debug] Deleting AppComponent object ResourceManager [2022-07-23 22:41:48.103] [info] Deleting EventHandler object. [2022-07-23 22:41:48.103] [debug] Unloading dynamic libraries... [2022-07-23 22:41:48.103] [debug] Destroying LuaManager... [2022-07-23 22:41:48.103] [debug] Deleting LuaManager object. [2022-07-23 22:41:48.103] [debug] Deleting NervApp object. [2022-07-23 22:41:48.103] [info] Destroying memory manager. [2022-07-23 22:41:48.103] [trace] Deleting MemoryManager object. Deleted LogManager object. Looking for memory leaks... No memory leak detected. Exiting.
const char*
automatically to nv::String
with SOL, that's a pain, but it also got me thinking, and now I have updated the LuaManager to store the internal maps with StringID keys instead of String: // mapping of Lua script files: // using ScriptMap = Map<StringID, RefPtr<LuaScript>>;
[2022-07-29 08:16:23.198] [debug] Loading resource from file: D:/Projects/NervLand/dist/assets/lua/setup.lua [2022-07-29 08:16:23.198] [debug] Using default root allocator to allocate/free 5713 bytes. [2022-07-29 08:16:23.198] [debug] Using default root allocator to allocate/free 5713 bytes. [2022-07-29 08:16:23.198] [debug] Using default root allocator to allocate/free 5713 bytes. [2022-07-29 08:16:23.198] [debug] Loading resource from file: D:/Projects/NervLand/dist/assets/lua/base/utils.lua [2022-07-29 08:16:23.198] [debug] Using default root allocator to allocate/free 5793 bytes. [2022-07-29 08:16:23.198] [debug] Using default root allocator to allocate/free 5793 bytes. [2022-07-29 08:16:23.198] [debug] Using default root allocator to allocate/free 5793 bytes. [2022-07-29 08:16:23.199] [debug] Loading resource from file: D:/Projects/NervLand/dist/assets/lua/external/serpent.lua [2022-07-29 08:16:23.199] [debug] Using default root allocator to allocate/free 8689 bytes. [2022-07-29 08:16:23.199] [debug] Using default root allocator to allocate/free 8689 bytes. [2022-07-29 08:16:23.199] [debug] Using default root allocator to allocate/free 8689 bytes.
template <typename T, class... Args> auto create_ref_object(Args&&... args) -> RefPtr<T> { // cf. // https://stackoverflow.com/questions/2821223/how-would-one-call-stdforward-on-all-arguments-in-a-variadic-function return MemoryManager::get_root_allocator().create<T>( std::forward<Args>(args)...); }
template <class T, class... Args> auto create(Args&&... args) -> RefPtr<T> { // Allocate the memory void* ptr = allocate(sizeof(T)); CHECK(ptr != nullptr, "Cannot allocate new object."); // Call the class constructor: RefPtr<T> obj(new (ptr) T(args...)); // Assign this allocator to the object: obj->set_allocator(this); // Return the object we just created: return obj; }
auto LuaScriptLoader::load_resource(const char* fullpath) -> RefPtr<RefObject> { CHECK(file_exists(fullpath), "The file {} doesn't exist.", fullpath); // We read the content of the file: String content = read_file(fullpath); logDEBUG("LuaScript source data ptr: {}", (const void*)content.data()); // Create a new LuaScript from that content: auto res = create_ref_object<LuaScript>(std::move(content)); return res; }
llvm-config --cxxflags -ID:\Projects\NervProj\libraries\windows_msvc\LLVM-14.0.6\include -std:c++14 /EHsc /GR -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
llvm-config --ldflags -LIBPATH:D:\Projects\NervProj\libraries\windows_msvc\LLVM-14.0.6\lib
llvm-config --system-libs psapi.lib shell32.lib ole32.lib uuid.lib advapi32.lib zlibstatic.lib
llvm-config --libs LLVMWindowsManifest.lib LLVMXRay.lib LLVMLibDriver.lib LLVMDlltoolDriver.lib LLVMCoverage.lib LLVMLineEditor.lib LLVMX86TargetMCA.lib LLVMX86Disassembler.lib LLVMX86AsmParser.lib LLVMX86CodeGen.lib LLVMX86Desc.lib LLVMX86Info.lib LLVMOrcJIT.lib LLVMMCJIT.lib LLVMJITLink.lib LLVMInterpreter.lib LLVMExecutionEngine.lib LLVMRuntimeDyld.lib LLVMOrcTargetProcess.lib LLVMOrcShared.lib LLVMDWP.lib LLVMSymbolize.lib LLVMDebugInfoPDB.lib LLVMDebugInfoGSYM.lib LLVMOption.lib LLVMObjectYAML.lib LLVMMCA.lib LLVMMCDisassembler.lib LLVMLTO.lib LLVMCFGuard.lib LLVMFrontendOpenACC.lib LLVMExtensions.lib Polly.lib PollyISL.lib LLVMPasses.lib LLVMObjCARCOpts.lib LLVMCoroutines.lib LLVMipo.lib LLVMInstrumentation.lib LLVMVectorize.lib LLVMLinker.lib LLVMFrontendOpenMP.lib LLVMDWARFLinker.lib LLVMGlobalISel.lib LLVMMIRParser.lib LLVMAsmPrinter.lib LLVMDebugInfoMSF.lib LLVMSelectionDAG.lib LLVMCodeGen.lib LLVMIRReader.lib LLVMAsmParser.lib LLVMInterfaceStub.lib LLVMFileCheck.lib LLVMFuzzMutate.lib LLVMTarget.lib LLVMScalarOpts.lib LLVMInstCombine.lib LLVMAggressiveInstCombine.lib LLVMTransformUtils.lib LLVMBitWriter.lib LLVMAnalysis.lib LLVMProfileData.lib LLVMDebugInfoDWARF.lib LLVMObject.lib LLVMTextAPI.lib LLVMMCParser.lib LLVMMC.lib LLVMDebugInfoCodeView.lib LLVMBitReader.lib LLVMCore.lib LLVMRemarks.lib LLVMBitstreamReader.lib LLVMBinaryFormat.lib LLVMTableGen.lib LLVMSupport.lib LLVMDemangle.lib
if(MSVC) if(BUILD_SHARED_LIBS) set_target_properties( LibXml2 PROPERTIES DEBUG_POSTFIX d ) else() set_target_properties( LibXml2 PROPERTIES DEBUG_POSTFIX sd MINSIZEREL_POSTFIX s RELEASE_POSTFIX s RELWITHDEBINFO_POSTFIX s ) endif() endif()
# When compiling with clang on windows we should specify the Host triple: if self.is_windows and self.compiler.is_clang(): flags += ["-DLLVM_HOST_TRIPLE=x86_64-pc-win32"]
self.append_cxxflag("-std=gnu99")
cmd.exe /C "cd . && D:\Projects\NervProj\libraries\windows_msvc\LLVM-14.0.6\bin\clang++.exe -fuse-ld=lld-link -nostartfiles -nostdlib -DLIBXML_STATIC -ID:/Projects/NervProj/libraries/windows_clang/libiconv-1.16/include -ID:/Projects/NervProj/libraries/windows_clang/libxml2-2.9.13/include/libxml2 -Werror=date-time -Werror=unguarded-availability-new -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -LD:/Projects/NervProj/libraries/windows_clang/libxml2-2.9.13/lib -llibxml2s -LD:/Projects/NervProj/libraries/windows_clang/libiconv-1.16/lib -llibiconvStatic -lWs2_32 -Wl,--gc-sections D:/Projects/NervProj/libraries/build/LLVM-14.0.6/build/tools/clang/tools/libclang/libclang.def -shared -o bin\clang.dll -Xlinker /MANIFEST:EMBED -Xlinker /implib:lib\clang.lib -Xlinker /pdb:bin\clang.pdb -Xlinker /version:14.0 @CMakeFiles\libclang.rsp && cd ." lld-link: warning: ignoring unknown argument '--gc-sections' lld-link: error: D:/Projects/NervProj/libraries/build/LLVM-14.0.6/build/tools/clang/tools/libclang/libclang.def: unknown file type clang++: error: linker command failed with exit code 1 (use -v to see invocation)
'cmd.exe' n'est pas reconnu en tant que commande interne
if self.is_clang(): env = {} env["PATH"] = self.get_cxx_dir() # inc_dir = f"{self.root_dir}/include/c++/v1" env["CC"] = self.get_cc_path() env["CXX"] = self.get_cxx_path() # Do not use fPIC on windows: # fpic = " -fPIC" if self.is_linux else "" # env['CXXFLAGS'] = f"-I{inc_dir} {self.cxxflags}{fpic}" # env['CFLAGS'] = f"-I{inc_dir} -w{fpic}" env["LD_LIBRARY_PATH"] = f"{self.libs_path}" # If we are on windows, we also need the library path from the MSVC compiler: if self.is_windows: bman = self.ctx.get_component("builder") msvc_comp = bman.get_compiler("msvc") msvc_env = msvc_comp.get_env() # logger.info("MSVC compiler env: %s", self.pretty_print(msvc_env)) env = self.prepend_env_list(msvc_env["LIB"], env, "LIB") self.comp_env = env
drive = os.getenv("HOMEDRIVE") assert drive is not None, "Invalid HOMEDRIVE variable." orig_env["PATH"] = f"{drive}\\Windows\\System32;{drive}\\Windows"
nvp nvl_build
2022/08/25 08:24:26 [nvp.core.build_manager] INFO: Running automatic setup for LuaJIT Traceback (most recent call last): File "D:\Projects\NervProj\nvp\core\cmake_manager.py", line 647, in <module> comp.run() File "D:\Projects\NervProj\nvp\nvp_component.py", line 93, in run res = self.process_command(cmd) File "D:\Projects\NervProj\nvp\nvp_component.py", line 83, in process_command return self.process_cmd_path(self.ctx.get_command_path()) File "D:\Projects\NervProj\nvp\core\cmake_manager.py", line 39, in process_cmd_path self.build_projects(bprints, dest_dir, rebuild=rebuild) File "D:\Projects\NervProj\nvp\core\cmake_manager.py", line 510, in build_projects self.build_project(proj_name, install_dir, rebuild) File "D:\Projects\NervProj\nvp\core\cmake_manager.py", line 549, in build_project var_val = bman.get_library_root_dir(lib_name) File "D:\Projects\NervProj\nvp\core\build_manager.py", line 185, in get_library_root_dir assert self.dir_exists(dep_dir), f"Library folder {dep_dir} doesn't exist yet." AssertionError: Library folder D:\Projects\NervProj\libraries\windows_clang\LuaJIT-2.1 doesn't exist yet. 2022/08/25 08:24:26 [nvp.nvp_object] ERROR: Subprocess terminated with error code 1 (cmd=['D:\\Projects\\NervProj\\.pyenvs\\min_env\\python.exe', 'D:\\Projects\\NervProj/nvp/core/cmake_manager.py', 'build', 'nervland']) 2022/08/25 08:24:26 [nvp.components.runner] ERROR: Error occured in script command: cmd=['D:\\Projects\\NervProj\\.pyenvs\\min_env\\python.exe', 'D:\\Projects\\NervProj/nvp/core/cmake_manager.py', 'build', 'nervland'] cwd=D:\Projects\NervLand return code=1 lastest outputs: return self.process_cmd_path(self.ctx.get_command_path()) File "D:\Projects\NervProj\nvp\core\cmake_manager.py", line 39, in process_cmd_path self.build_projects(bprints, dest_dir, rebuild=rebuild) File "D:\Projects\NervProj\nvp\core\cmake_manager.py", line 510, in build_projects self.build_project(proj_name, install_dir, rebuild) File "D:\Projects\NervProj\nvp\core\cmake_manager.py", line 549, in build_project var_val = bman.get_library_root_dir(lib_name) File "D:\Projects\NervProj\nvp\core\build_manager.py", line 185, in get_library_root_dir assert self.dir_exists(dep_dir), f"Library folder {dep_dir} doesn't exist yet." AssertionError: Library folder D:\Projects\NervProj\libraries\windows_clang\LuaJIT-2.1 doesn't exist yet.
def check_libraries(self, dep_list, rebuild=False, preview=False, append=False, keep_build=False): """Build all the libraries for NervProj.""" # Iterate on each dependency: logger.debug("Checking libraries:") alldeps = self.config["libraries"] # Ensure we use only lower case for dependency names: dep_list = [dname.lower() for dname in dep_list]
clang++: error: no such file or directory: '/Gw' clang++: error: no such file or directory: '/MD' clang++: error: no such file or directory: '/O2' clang++: error: no such file or directory: '/Ob2'
arg.getAsIntegral().toString(buf); return cxstring::createDup(buf.data());
D:/Projects/NervLand/modules/nvCore/src\lua/sol/sol.hpp:12297:28: error: no matching function for call to object of type 'std::less<>' return stack::push(L, op(detail::deref(l), detail::deref(r))); ^~ D:/Projects/NervLand/modules/nvCore/src\lua/sol/sol.hpp:23333:26: note: in instantiation of function template specialization 'sol::detail::comparsion_operator_wrap<nv::RefPtr<nv::CursorSet>, std::less<>>' requested here lua_CFunction f = &comparsion_operator_wrap<T, std::less<>>;
lld-link: error: undefined symbol: __std_init_once_link_alternate_names_and_abort >>> referenced by LLVMX86CodeGen.lib(X86TargetMachine.cpp.obj):(void __cdecl llvm::initializeX86ExecutionDomainFixPass(class llvm::PassRegistry &)) >>> referenced by LLVMX86CodeGen.lib(X86TargetMachine.cpp.obj):(int `void __cdecl llvm::initializeX86ExecutionDomainFixPass(class initializeX86ExecutionDomainFixPass::PassRegistry &)'::`1'::dtor$7) >>> referenced by LLVMCodeGen.lib(MachineModuleInfo.cpp.obj):(public: __cdecl llvm::MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(class llvm::LLVMTargetMachine const *)) >>> referenced 550 more times clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
"settings": { "clangd.path": "D:/Projects/NervProj/libraries/windows_msvc/LLVM-14.0.6/bin/clangd.exe", "cmake.buildDirectory": "${workspaceFolder}/.cache/cmake" }
SOL_BEGIN_REF_CLASS(clang, "CursorSet", CursorSet) SOL_CLASS_FUNC(contains); SOL_CLASS_FUNC(insert); SOL_CLASS_FUNC(dispose); // SOL_CALL_FACTORIES([]() { return create_ref_object<class_t>(); }); SOL_END_CLASS();
SOL_BEGIN_CLASS(space, "LuaScript", LuaScript) SOL_CALL_FACTORIES([]() { return create_ref_object<class_t>("hello"); }); SOL_END_CLASS()
std::less<>
and std::equal_to<>
classes, I think the issue might be because of the deref() function itself which should return the pointers for RefPtr containers: template <typename T> inline decltype(auto) deref(T&& item) { using Tu = meta::unqualified_t<T>; if constexpr (meta::is_pointer_like_v<Tu>) { return *std::forward<T>(item); } else { return std::forward<T>(item); } }
D:\Softs\VisualStudio\VS2022\VC\Tools\MSVC\14.33.31629\include\xstddef:218:31: note: candidate template ignored: substitution failure [with _Ty1 = nv::LuaScript &, _Ty2 = nv::LuaScript &]: invalid operands to binary expression ('nv::LuaScript' and 'nv::LuaScript') _NODISCARD constexpr auto operator()(_Ty1&& _Left, _Ty2&& _Right) const
namespace sol { template <typename T> struct unique_usertype_traits; template <typename T> struct unique_usertype_traits<nv::RefPtr<T>> { typedef T type; typedef nv::RefPtr<T> actual_type; static const bool value = true; static bool is_null(const actual_type& value) { return value == nullptr; } static type* get(const actual_type& p) { return p.get(); } }; } // namespace sol