summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2026-03-13 15:09:21 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2026-03-13 15:09:21 +0100
commita4bb44e2a004d04cbee3ceb2d90aa7461dabecf4 (patch)
tree248b956a9fc08c67c0cfeb01f3a0f95c0fd4825f
parentfe55f67bf7a5aeba365d7af1d681cef1d9ed7a3c (diff)
[FEAT] Update and add Nectar compliant snippet with CL paradigm in mind.compiler_kit-osx-tweaks-fixes
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--conanfile.txt2
-rw-r--r--example/example_02_nectar/example.nc19
-rw-r--r--src/CommandLine/osx/ld64-osx.json (renamed from src/CommandLine/ld64-osx.json)0
-rw-r--r--src/CommandLine/osx/mld64-osx.json (renamed from src/CommandLine/mld64-osx.json)0
-rw-r--r--src/CommandLine/osx/pef-amd64-drv.json23
-rw-r--r--src/CommandLine/posix/cppdrv.json (renamed from src/CommandLine/cppdrv.json)0
-rw-r--r--src/CommandLine/posix/dbg.json (renamed from src/CommandLine/dbg.json)0
-rw-r--r--src/CommandLine/posix/kdbg.json (renamed from src/CommandLine/kdbg.json)0
-rw-r--r--src/CommandLine/posix/ld64-posix.json (renamed from src/CommandLine/ld64-posix.json)0
-rw-r--r--src/CommandLine/posix/mld64-posix.json (renamed from src/CommandLine/mld64-posix.json)0
-rw-r--r--src/CommandLine/posix/pef-amd64-asm.json (renamed from src/CommandLine/pef-amd64-asm.json)0
-rw-r--r--src/CommandLine/posix/pef-amd64-drv.json (renamed from src/CommandLine/pef-amd64-drv.json)0
-rw-r--r--src/CommandLine/posix/ptx-drv.json (renamed from src/CommandLine/ptx-drv.json)0
-rw-r--r--src/CompilerKit/ck-osx-san.json5
-rw-r--r--src/CompilerKit/ck-osx.json3
-rw-r--r--src/CompilerKit/src/CodeGenerator+AssemblyFactory.cpp10
-rw-r--r--src/CompilerKit/src/Linkers/DynamicLinker64+MachO.cpp6
17 files changed, 53 insertions, 15 deletions
diff --git a/conanfile.txt b/conanfile.txt
index cb1eb04..e0de5ca 100644
--- a/conanfile.txt
+++ b/conanfile.txt
@@ -1,5 +1,5 @@
[requires]
-boost/1.89.0
+boost/1.90.0
[generators]
CMakeDeps
CMakeToolchain
diff --git a/example/example_02_nectar/example.nc b/example/example_02_nectar/example.nc
index 46cbd25..fdaadcd 100644
--- a/example/example_02_nectar/example.nc
+++ b/example/example_02_nectar/example.nc
@@ -1,10 +1,15 @@
-extern sleep;
-extern putchar;
+extern exit;
-const main() {
- sleep(1);
- putchar(0, '!');
+trait foo {
+ let exit();
+};
+
+let foo.exit() {
+ exit(0);
+}
- let foo := 42;
- return foo;
+const main() {
+ let self := 0;
+ foo.exit();
+ return 0;
}
diff --git a/src/CommandLine/ld64-osx.json b/src/CommandLine/osx/ld64-osx.json
index ddd233b..ddd233b 100644
--- a/src/CommandLine/ld64-osx.json
+++ b/src/CommandLine/osx/ld64-osx.json
diff --git a/src/CommandLine/mld64-osx.json b/src/CommandLine/osx/mld64-osx.json
index 57f08f0..57f08f0 100644
--- a/src/CommandLine/mld64-osx.json
+++ b/src/CommandLine/osx/mld64-osx.json
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/cppdrv.json b/src/CommandLine/posix/cppdrv.json
index ad9761b..ad9761b 100644
--- a/src/CommandLine/cppdrv.json
+++ b/src/CommandLine/posix/cppdrv.json
diff --git a/src/CommandLine/dbg.json b/src/CommandLine/posix/dbg.json
index ecc63e8..ecc63e8 100644
--- a/src/CommandLine/dbg.json
+++ b/src/CommandLine/posix/dbg.json
diff --git a/src/CommandLine/kdbg.json b/src/CommandLine/posix/kdbg.json
index 6099f04..6099f04 100644
--- a/src/CommandLine/kdbg.json
+++ b/src/CommandLine/posix/kdbg.json
diff --git a/src/CommandLine/ld64-posix.json b/src/CommandLine/posix/ld64-posix.json
index 0847b41..0847b41 100644
--- a/src/CommandLine/ld64-posix.json
+++ b/src/CommandLine/posix/ld64-posix.json
diff --git a/src/CommandLine/mld64-posix.json b/src/CommandLine/posix/mld64-posix.json
index e408cec..e408cec 100644
--- a/src/CommandLine/mld64-posix.json
+++ b/src/CommandLine/posix/mld64-posix.json
diff --git a/src/CommandLine/pef-amd64-asm.json b/src/CommandLine/posix/pef-amd64-asm.json
index a1b1e1f..a1b1e1f 100644
--- a/src/CommandLine/pef-amd64-asm.json
+++ b/src/CommandLine/posix/pef-amd64-asm.json
diff --git a/src/CommandLine/pef-amd64-drv.json b/src/CommandLine/posix/pef-amd64-drv.json
index 69609ff..69609ff 100644
--- a/src/CommandLine/pef-amd64-drv.json
+++ b/src/CommandLine/posix/pef-amd64-drv.json
diff --git a/src/CommandLine/ptx-drv.json b/src/CommandLine/posix/ptx-drv.json
index 6372117..6372117 100644
--- a/src/CommandLine/ptx-drv.json
+++ b/src/CommandLine/posix/ptx-drv.json
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<const char*>(&linkeditSegment), sizeof(linkeditSegment));
// Write LC_LOAD_DYLINKER command
- constexpr char* dyldPath = "/usr/lib/dyld";
+ constexpr const char* dyldPath = "/usr/lib/dyld";
std::vector<char> dylinkerCmd(dylinkerCmdSize, 0);
dylinker_command* dylinker = reinterpret_cast<dylinker_command*>(dylinkerCmd.data());
dylinker->cmd = LC_LOAD_DYLINKER;