From a4bb44e2a004d04cbee3ceb2d90aa7461dabecf4 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 13 Mar 2026 15:09:21 +0100 Subject: [FEAT] Update and add Nectar compliant snippet with CL paradigm in mind. Signed-off-by: Amlal El Mahrouss --- src/CompilerKit/ck-osx-san.json | 5 +++-- src/CompilerKit/ck-osx.json | 3 ++- src/CompilerKit/src/CodeGenerator+AssemblyFactory.cpp | 10 +++++++++- src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cpp | 6 +++--- 4 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/CompilerKit') diff --git a/src/CompilerKit/ck-osx-san.json b/src/CompilerKit/ck-osx-san.json index 7ded2a0..8e09356 100644 --- a/src/CompilerKit/ck-osx-san.json +++ b/src/CompilerKit/ck-osx-san.json @@ -1,9 +1,10 @@ -i{ - "compiler_path": "clang++", +{ + "compiler_path": "g++", "compiler_std": "c++20", "headers_path": [ "../../include/CompilerKit", "../../include/", + "/usr/local/include", "../../include/CompilerKit/src/", "../../include/CompilerKit/src/impl", "/opt/homebrew/Cellar/boost/1.90.0/include" diff --git a/src/CompilerKit/ck-osx.json b/src/CompilerKit/ck-osx.json index 53bdba2..2dd9bbd 100644 --- a/src/CompilerKit/ck-osx.json +++ b/src/CompilerKit/ck-osx.json @@ -1,11 +1,12 @@ { - "compiler_path": "clang++", + "compiler_path": "g++", "compiler_std": "c++20", "headers_path": [ "../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/", "../../include/CompilerKit/src/impl", + "/usr/local/include/", "/opt/homebrew/Cellar/boost/1.90.0/include" ], "sources_path": [ diff --git a/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cpp b/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cpp index 5d8c255..7e9e1af 100644 --- a/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cpp +++ b/src/CompilerKit/src/CodeGenerator+AssemblyFactory.cpp @@ -23,7 +23,15 @@ Int32 AssemblyFactory::Compile(STLString sourceFile, const Int32& arch) { if (!this->fMounted) return NECTAR_UNIMPLEMENTED; if (arch != this->fMounted->Arch()) return NECTAR_INVALID_ARCH; - return this->fMounted->CompileToFormat(sourceFile, arch); + if (!std::filesystem::is_regular_file(sourceFile)) return NECTAR_UNIMPLEMENTED; + + auto compiledUnit = sourceFile + ".ignore"; + + std::filesystem::copy(sourceFile, compiledUnit); + auto ret = this->fMounted->CompileToFormat(compiledUnit, arch); + std::filesystem::remove(compiledUnit); + + return ret; } ///! @brief mount assembly backend. diff --git a/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cpp b/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cpp index 3c19522..f016c6e 100644 --- a/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cpp +++ b/src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cpp @@ -364,10 +364,10 @@ NECTAR_MODULE(DynamicLinker64MachO) { UInt32 dysymtabCmdSize = sizeof(dysymtab_command); UInt32 linkeditCmdSize = sizeof(segment_command_64); // No sections UInt32 dylinkerCmdSize = - (strlen(dylinker_command) + 13 + 1 + 7) & ~7; // "/usr/lib/dyld" + padding to 8-byte align + (13 + 1 + 7) & ~7; // "/usr/lib/dyld" + padding to 8-byte align sizeOfCmds = pageZeroSize + textSegCmdSize + dataSegCmdSize + buildCmdSize + uuidCmdSize + - symtabCmdSize + dysymtabCmdSize + linkeditCmdSize + dylinkerCmdSize; + symtabCmdSize + dysymtabCmdSize + linkeditCmdSize; if (!kIsDylib) sizeOfCmds += mainCmdSize; @@ -515,7 +515,7 @@ NECTAR_MODULE(DynamicLinker64MachO) { output_fc.write(reinterpret_cast(&linkeditSegment), sizeof(linkeditSegment)); // Write LC_LOAD_DYLINKER command - constexpr char* dyldPath = "/usr/lib/dyld"; + constexpr const char* dyldPath = "/usr/lib/dyld"; std::vector dylinkerCmd(dylinkerCmdSize, 0); dylinker_command* dylinker = reinterpret_cast(dylinkerCmd.data()); dylinker->cmd = LC_LOAD_DYLINKER; -- cgit v1.2.3