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/CommandLine/cppdrv.json | 14 ------------- src/CommandLine/dbg.json | 13 ------------ src/CommandLine/kdbg.json | 13 ------------ src/CommandLine/ld64-osx.json | 13 ------------ src/CommandLine/ld64-posix.json | 13 ------------ src/CommandLine/mld64-osx.json | 13 ------------ src/CommandLine/mld64-posix.json | 13 ------------ src/CommandLine/osx/ld64-osx.json | 13 ++++++++++++ src/CommandLine/osx/mld64-osx.json | 13 ++++++++++++ src/CommandLine/osx/pef-amd64-drv.json | 23 ++++++++++++++++++++++ src/CommandLine/pef-amd64-asm.json | 14 ------------- src/CommandLine/pef-amd64-drv.json | 21 -------------------- src/CommandLine/posix/cppdrv.json | 14 +++++++++++++ src/CommandLine/posix/dbg.json | 13 ++++++++++++ src/CommandLine/posix/kdbg.json | 13 ++++++++++++ src/CommandLine/posix/ld64-posix.json | 13 ++++++++++++ src/CommandLine/posix/mld64-posix.json | 13 ++++++++++++ src/CommandLine/posix/pef-amd64-asm.json | 14 +++++++++++++ src/CommandLine/posix/pef-amd64-drv.json | 21 ++++++++++++++++++++ src/CommandLine/posix/ptx-drv.json | 21 ++++++++++++++++++++ src/CommandLine/ptx-drv.json | 21 -------------------- src/CompilerKit/ck-osx-san.json | 5 +++-- src/CompilerKit/ck-osx.json | 3 ++- .../src/CodeGenerator+AssemblyFactory.cpp | 10 +++++++++- .../src/Linkers/DynamicLinker64+MachO.cpp | 6 +++--- 25 files changed, 188 insertions(+), 155 deletions(-) delete mode 100644 src/CommandLine/cppdrv.json delete mode 100644 src/CommandLine/dbg.json delete mode 100644 src/CommandLine/kdbg.json delete mode 100644 src/CommandLine/ld64-osx.json delete mode 100644 src/CommandLine/ld64-posix.json delete mode 100644 src/CommandLine/mld64-osx.json delete mode 100644 src/CommandLine/mld64-posix.json create mode 100644 src/CommandLine/osx/ld64-osx.json create mode 100644 src/CommandLine/osx/mld64-osx.json create mode 100644 src/CommandLine/osx/pef-amd64-drv.json delete mode 100644 src/CommandLine/pef-amd64-asm.json delete mode 100644 src/CommandLine/pef-amd64-drv.json create mode 100644 src/CommandLine/posix/cppdrv.json create mode 100644 src/CommandLine/posix/dbg.json create mode 100644 src/CommandLine/posix/kdbg.json create mode 100644 src/CommandLine/posix/ld64-posix.json create mode 100644 src/CommandLine/posix/mld64-posix.json create mode 100644 src/CommandLine/posix/pef-amd64-asm.json create mode 100644 src/CommandLine/posix/pef-amd64-drv.json create mode 100644 src/CommandLine/posix/ptx-drv.json delete mode 100644 src/CommandLine/ptx-drv.json (limited to 'src') diff --git a/src/CommandLine/cppdrv.json b/src/CommandLine/cppdrv.json deleted file mode 100644 index ad9761b..0000000 --- a/src/CommandLine/cppdrv.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], - "sources_path": ["cppdrv.cpp"], - "output_name": "cppdrv", - "compiler_flags": ["-L/usr/local/lib", "-lCompilerKit"], - "cpp_macros": [ - "__CPPDRV__=202504", - "__NECTAR__", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/dbg.json b/src/CommandLine/dbg.json deleted file mode 100644 index ecc63e8..0000000 --- a/src/CommandLine/dbg.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include", "../../include/CompilerKit/src/Detail"], - "sources_path": ["dbg.cpp"], - "output_name": "dbg", - "compiler_flags": ["-L/usr/lib", "-lDebuggerKit"], - "cpp_macros": [ - "__DBG__=202401", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/kdbg.json b/src/CommandLine/kdbg.json deleted file mode 100644 index 6099f04..0000000 --- a/src/CommandLine/kdbg.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], - "sources_path": ["kdbg.cpp"], - "output_name": "kdbg", - "compiler_flags": ["-L/usr/lib", "-lDebuggerKit"], - "cpp_macros": [ - "__DBG__=202401", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/ld64-osx.json b/src/CommandLine/ld64-osx.json deleted file mode 100644 index ddd233b..0000000 --- a/src/CommandLine/ld64-osx.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], - "sources_path": ["ld64.cpp"], - "output_name": "ld64", - "compiler_flags": ["-L/usr/local/lib", "-lCompilerKit"], - "cpp_macros": [ - "__LD64__=202601", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/ld64-posix.json b/src/CommandLine/ld64-posix.json deleted file mode 100644 index 0847b41..0000000 --- a/src/CommandLine/ld64-posix.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], - "sources_path": ["ld64.cpp"], - "output_name": "ld64", - "compiler_flags": ["-L/usr/lib", "-lCompilerKit"], - "cpp_macros": [ - "__LD64__=202601", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/mld64-osx.json b/src/CommandLine/mld64-osx.json deleted file mode 100644 index 57f08f0..0000000 --- a/src/CommandLine/mld64-osx.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], - "sources_path": ["mld64.cpp"], - "output_name": "mld64", - "compiler_flags": ["-L/usr/local/lib", "-lCompilerKit"], - "cpp_macros": [ - "__MLD64__=202601", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/mld64-posix.json b/src/CommandLine/mld64-posix.json deleted file mode 100644 index e408cec..0000000 --- a/src/CommandLine/mld64-posix.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], - "sources_path": ["mld64.cpp"], - "output_name": "mld64", - "compiler_flags": ["-L/usr/lib", "-lCompilerKit"], - "cpp_macros": [ - "__MLD64__=202601", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/osx/ld64-osx.json b/src/CommandLine/osx/ld64-osx.json new file mode 100644 index 0000000..ddd233b --- /dev/null +++ b/src/CommandLine/osx/ld64-osx.json @@ -0,0 +1,13 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], + "sources_path": ["ld64.cpp"], + "output_name": "ld64", + "compiler_flags": ["-L/usr/local/lib", "-lCompilerKit"], + "cpp_macros": [ + "__LD64__=202601", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/osx/mld64-osx.json b/src/CommandLine/osx/mld64-osx.json new file mode 100644 index 0000000..57f08f0 --- /dev/null +++ b/src/CommandLine/osx/mld64-osx.json @@ -0,0 +1,13 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], + "sources_path": ["mld64.cpp"], + "output_name": "mld64", + "compiler_flags": ["-L/usr/local/lib", "-lCompilerKit"], + "cpp_macros": [ + "__MLD64__=202601", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/osx/pef-amd64-drv.json b/src/CommandLine/osx/pef-amd64-drv.json new file mode 100644 index 0000000..f9bbfbc --- /dev/null +++ b/src/CommandLine/osx/pef-amd64-drv.json @@ -0,0 +1,23 @@ +{ + "compiler_path": "g++", + "compiler_std": "c++20", + "headers_path": [ + "../include/CompilerKit", + "../../include", + "/usr/local/include/", + "/opt/homebrew/Cellar/boost/1.90.0/include", + "../include/CompilerKit/src/Detail" + ], + "sources_path": [ + "pef-amd64-drv.cpp" + ], + "output_name": "pef-amd64-necdrv", + "compiler_flags": [ + ], + "cpp_macros": [ + "__NECDRV__=202504", + "CK_POSIX", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/pef-amd64-asm.json b/src/CommandLine/pef-amd64-asm.json deleted file mode 100644 index a1b1e1f..0000000 --- a/src/CommandLine/pef-amd64-asm.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compiler_path": "g++", - "compiler_std": "c++20", - "headers_path": ["../../include/CompilerKit", "../../include", "../../include/CompilerKit/src/Detail"], - "sources_path": ["pef-amd64-asm.cpp"], - "output_name": "pef-amd64-asm", - "compiler_flags": ["-L/usr/lib"], - "cpp_macros": [ - "__DRV_ASM__=202601", - "CK_POSIX", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/pef-amd64-drv.json b/src/CommandLine/pef-amd64-drv.json deleted file mode 100644 index 69609ff..0000000 --- a/src/CommandLine/pef-amd64-drv.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": [ - "../include/CompilerKit", - "../../include", - "../include/CompilerKit/src/Detail" - ], - "sources_path": [ - "pef-amd64-drv.cpp" - ], - "output_name": "pef-amd64-necdrv", - "compiler_flags": [ - ], - "cpp_macros": [ - "__NECDRV__=202504", - "CK_POSIX", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - diff --git a/src/CommandLine/posix/cppdrv.json b/src/CommandLine/posix/cppdrv.json new file mode 100644 index 0000000..ad9761b --- /dev/null +++ b/src/CommandLine/posix/cppdrv.json @@ -0,0 +1,14 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], + "sources_path": ["cppdrv.cpp"], + "output_name": "cppdrv", + "compiler_flags": ["-L/usr/local/lib", "-lCompilerKit"], + "cpp_macros": [ + "__CPPDRV__=202504", + "__NECTAR__", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/posix/dbg.json b/src/CommandLine/posix/dbg.json new file mode 100644 index 0000000..ecc63e8 --- /dev/null +++ b/src/CommandLine/posix/dbg.json @@ -0,0 +1,13 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include", "../../include/CompilerKit/src/Detail"], + "sources_path": ["dbg.cpp"], + "output_name": "dbg", + "compiler_flags": ["-L/usr/lib", "-lDebuggerKit"], + "cpp_macros": [ + "__DBG__=202401", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/posix/kdbg.json b/src/CommandLine/posix/kdbg.json new file mode 100644 index 0000000..6099f04 --- /dev/null +++ b/src/CommandLine/posix/kdbg.json @@ -0,0 +1,13 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], + "sources_path": ["kdbg.cpp"], + "output_name": "kdbg", + "compiler_flags": ["-L/usr/lib", "-lDebuggerKit"], + "cpp_macros": [ + "__DBG__=202401", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/posix/ld64-posix.json b/src/CommandLine/posix/ld64-posix.json new file mode 100644 index 0000000..0847b41 --- /dev/null +++ b/src/CommandLine/posix/ld64-posix.json @@ -0,0 +1,13 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], + "sources_path": ["ld64.cpp"], + "output_name": "ld64", + "compiler_flags": ["-L/usr/lib", "-lCompilerKit"], + "cpp_macros": [ + "__LD64__=202601", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/posix/mld64-posix.json b/src/CommandLine/posix/mld64-posix.json new file mode 100644 index 0000000..e408cec --- /dev/null +++ b/src/CommandLine/posix/mld64-posix.json @@ -0,0 +1,13 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include/", "../../include/CompilerKit/src/Detail"], + "sources_path": ["mld64.cpp"], + "output_name": "mld64", + "compiler_flags": ["-L/usr/lib", "-lCompilerKit"], + "cpp_macros": [ + "__MLD64__=202601", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/posix/pef-amd64-asm.json b/src/CommandLine/posix/pef-amd64-asm.json new file mode 100644 index 0000000..a1b1e1f --- /dev/null +++ b/src/CommandLine/posix/pef-amd64-asm.json @@ -0,0 +1,14 @@ +{ + "compiler_path": "g++", + "compiler_std": "c++20", + "headers_path": ["../../include/CompilerKit", "../../include", "../../include/CompilerKit/src/Detail"], + "sources_path": ["pef-amd64-asm.cpp"], + "output_name": "pef-amd64-asm", + "compiler_flags": ["-L/usr/lib"], + "cpp_macros": [ + "__DRV_ASM__=202601", + "CK_POSIX", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/posix/pef-amd64-drv.json b/src/CommandLine/posix/pef-amd64-drv.json new file mode 100644 index 0000000..69609ff --- /dev/null +++ b/src/CommandLine/posix/pef-amd64-drv.json @@ -0,0 +1,21 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": [ + "../include/CompilerKit", + "../../include", + "../include/CompilerKit/src/Detail" + ], + "sources_path": [ + "pef-amd64-drv.cpp" + ], + "output_name": "pef-amd64-necdrv", + "compiler_flags": [ + ], + "cpp_macros": [ + "__NECDRV__=202504", + "CK_POSIX", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/posix/ptx-drv.json b/src/CommandLine/posix/ptx-drv.json new file mode 100644 index 0000000..6372117 --- /dev/null +++ b/src/CommandLine/posix/ptx-drv.json @@ -0,0 +1,21 @@ +{ + "compiler_path": "clang++", + "compiler_std": "c++20", + "headers_path": [ + "../include/CompilerKit", + "../../include", + "../include/CompilerKit/src/Detail" + ], + "sources_path": [ + "ptx-drv.cpp" + ], + "output_name": "ptx-necdrv", + "compiler_flags": [ + ], + "cpp_macros": [ + "__NECDRV__=202504", + "CK_POSIX", + "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" + ] +} + diff --git a/src/CommandLine/ptx-drv.json b/src/CommandLine/ptx-drv.json deleted file mode 100644 index 6372117..0000000 --- a/src/CommandLine/ptx-drv.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "compiler_path": "clang++", - "compiler_std": "c++20", - "headers_path": [ - "../include/CompilerKit", - "../../include", - "../include/CompilerKit/src/Detail" - ], - "sources_path": [ - "ptx-drv.cpp" - ], - "output_name": "ptx-necdrv", - "compiler_flags": [ - ], - "cpp_macros": [ - "__NECDRV__=202504", - "CK_POSIX", - "kDistReleaseBranch=$(git rev-parse --abbrev-ref HEAD)-$(uuidgen)" - ] -} - 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