summaryrefslogtreecommitdiffhomepage
path: root/dev/LibCompiler
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-26 08:56:59 +0200
committerAmlal <amlal@nekernel.org>2025-04-26 08:56:59 +0200
commitc791c2de8bdcd89035dd004b73d05217e40e179c (patch)
treeacfb69b173218dbc42f69ef0c0ab9070f88a3411 /dev/LibCompiler
parent7258fbf7c8785a3390441bbbac44d78b2e4facbf (diff)
dev: codebase has been improved in terms of cli and consistency.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/LibCompiler')
-rw-r--r--dev/LibCompiler/AssemblyInterface.h28
-rw-r--r--dev/LibCompiler/Detail/ClUtils.h15
-rw-r--r--dev/LibCompiler/Parser.h5
-rw-r--r--dev/LibCompiler/Version.h4
-rw-r--r--dev/LibCompiler/src/Assembler64x0.cc10
-rw-r--r--dev/LibCompiler/src/AssemblerAMD64.cc14
-rw-r--r--dev/LibCompiler/src/AssemblerARM64.cc10
-rw-r--r--dev/LibCompiler/src/AssemblerPowerPC.cc (renamed from dev/LibCompiler/src/AssemblerPower.cc)10
-rw-r--r--dev/LibCompiler/src/AssemblyFactory.cc2
-rw-r--r--dev/LibCompiler/src/CCompiler64x0.cc2
-rw-r--r--dev/LibCompiler/src/CCompilerARM64.cc2
-rw-r--r--dev/LibCompiler/src/CCompilerPower64.cc2
-rw-r--r--dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc40
-rw-r--r--dev/LibCompiler/src/DynamicLinkerPEF.cc19
14 files changed, 72 insertions, 91 deletions
diff --git a/dev/LibCompiler/AssemblyInterface.h b/dev/LibCompiler/AssemblyInterface.h
index aebd01f..5450f84 100644
--- a/dev/LibCompiler/AssemblyInterface.h
+++ b/dev/LibCompiler/AssemblyInterface.h
@@ -24,7 +24,7 @@ class AssemblyInterface {
/// @brief compile to object file.
/// @note Example C++ -> MASM -> AE object.
- virtual Int32 CompileToFormat(std::string& src, Int32 arch) = 0;
+ virtual Int32 CompileToFormat(std::string src, Int32 arch) = 0;
};
/// @brief Simple assembly factory
@@ -46,7 +46,7 @@ class AssemblyFactory final {
kArchUnknown,
};
- Int32 Compile(std::string& sourceFile, const Int32& arch) noexcept;
+ Int32 Compile(std::string sourceFile, const Int32& arch) noexcept;
void Mount(AssemblyInterface* mountPtr) noexcept;
AssemblyInterface* Unmount() noexcept;
@@ -107,8 +107,8 @@ class EncoderInterface {
LIBCOMPILER_COPY_DEFAULT(EncoderInterface);
- virtual std::string CheckLine(std::string& line, const std::string& file) = 0;
- virtual bool WriteLine(std::string& line, const std::string& file) = 0;
+ virtual std::string CheckLine(std::string line, std::string file) = 0;
+ virtual bool WriteLine(std::string line, std::string file) = 0;
virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) = 0;
};
@@ -121,8 +121,8 @@ class EncoderAMD64 final : public EncoderInterface {
LIBCOMPILER_COPY_DEFAULT(EncoderAMD64);
- virtual std::string CheckLine(std::string& line, const std::string& file) override;
- virtual bool WriteLine(std::string& line, const std::string& file) override;
+ virtual std::string CheckLine(std::string line, std::string file) override;
+ virtual bool WriteLine(std::string line, std::string file) override;
virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
virtual bool WriteNumber16(const std::size_t& pos, std::string& from_what);
@@ -141,8 +141,8 @@ class EncoderARM64 final : public EncoderInterface {
LIBCOMPILER_COPY_DEFAULT(EncoderARM64);
- virtual std::string CheckLine(std::string& line, const std::string& file) override;
- virtual bool WriteLine(std::string& line, const std::string& file) override;
+ virtual std::string CheckLine(std::string line, std::string file) override;
+ virtual bool WriteLine(std::string line, std::string file) override;
virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
};
@@ -157,8 +157,8 @@ class Encoder64x0 final : public EncoderInterface {
LIBCOMPILER_COPY_DEFAULT(Encoder64x0);
- virtual std::string CheckLine(std::string& line, const std::string& file) override;
- virtual bool WriteLine(std::string& line, const std::string& file) override;
+ virtual std::string CheckLine(std::string line, std::string file) override;
+ virtual bool WriteLine(std::string line, std::string file) override;
virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
};
@@ -173,8 +173,8 @@ class Encoder32x0 final : public EncoderInterface {
LIBCOMPILER_COPY_DEFAULT(Encoder32x0);
- virtual std::string CheckLine(std::string& line, const std::string& file) override;
- virtual bool WriteLine(std::string& line, const std::string& file) override;
+ virtual std::string CheckLine(std::string line, std::string file) override;
+ virtual bool WriteLine(std::string line, std::string file) override;
virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
};
@@ -189,8 +189,8 @@ class EncoderPowerPC final : public EncoderInterface {
LIBCOMPILER_COPY_DEFAULT(EncoderPowerPC);
- virtual std::string CheckLine(std::string& line, const std::string& file) override;
- virtual bool WriteLine(std::string& line, const std::string& file) override;
+ virtual std::string CheckLine(std::string line, std::string file) override;
+ virtual bool WriteLine(std::string line, std::string file) override;
virtual bool WriteNumber(const std::size_t& pos, std::string& from_what) override;
};
diff --git a/dev/LibCompiler/Detail/ClUtils.h b/dev/LibCompiler/Detail/ClUtils.h
index f871d4d..1f31be7 100644
--- a/dev/LibCompiler/Detail/ClUtils.h
+++ b/dev/LibCompiler/Detail/ClUtils.h
@@ -7,6 +7,7 @@
#pragma once
#include <LibCompiler/AssemblyInterface.h>
+#include <LibCompiler/ErrorID.h>
#include <LibCompiler/Parser.h>
#define kZero64Section ".zero64"
@@ -34,13 +35,9 @@ namespace Detail {
inline void print_error(std::string reason, std::string file) noexcept {
if (reason[0] == '\n') reason.erase(0, 1);
- kStdErr << kRed << "[ asm ] " << kWhite
- << ((file == "LibCompiler") ? "InternalErrorException: "
- : ("FileException{ " + file + " }: "))
- << kBlank << std::endl;
- kStdErr << kRed << "[ asm ] " << kWhite << reason << kBlank << std::endl;
+ kStdErr << kRed << "drv: " << kWhite << reason << kBlank << std::endl;
- if (kAcceptableErrors > kErrorLimit) std::exit(3);
+ if (kAcceptableErrors > kErrorLimit) std::exit(LIBCOMPILER_EXEC_ERROR);
++kAcceptableErrors;
}
@@ -48,10 +45,6 @@ inline void print_error(std::string reason, std::string file) noexcept {
inline void print_warning(std::string reason, std::string file) noexcept {
if (reason[0] == '\n') reason.erase(0, 1);
- if (!file.empty()) {
- kStdOut << kYellow << "[ asm ] " << kWhite << file << kBlank << std::endl;
- }
-
- kStdOut << kYellow << "[ asm ] " << kWhite << reason << kBlank << std::endl;
+ kStdOut << kYellow << "drv: " << kWhite << reason << kBlank << std::endl;
}
} // namespace Detail \ No newline at end of file
diff --git a/dev/LibCompiler/Parser.h b/dev/LibCompiler/Parser.h
index 04a7fab..64c46d6 100644
--- a/dev/LibCompiler/Parser.h
+++ b/dev/LibCompiler/Parser.h
@@ -109,7 +109,7 @@ struct SyntaxLeafList final {
/// \param haystack base string
/// \param needle the string we search for.
/// \return if we found it or not.
-inline bool find_word(const std::string& haystack, const std::string& needle) noexcept {
+inline bool find_word(std::string haystack, std::string needle) noexcept {
auto index = haystack.find(needle);
// check for needle validity.
@@ -131,8 +131,7 @@ inline bool find_word(const std::string& haystack, const std::string& needle) no
/// \param haystack
/// \param needle
/// \return position of needle.
-inline std::size_t find_word_range(const std::string& haystack,
- const std::string& needle) noexcept {
+inline std::size_t find_word_range(std::string haystack, std::string needle) noexcept {
auto index = haystack.find(needle);
// check for needle validity.
diff --git a/dev/LibCompiler/Version.h b/dev/LibCompiler/Version.h
index a623312..601bb28 100644
--- a/dev/LibCompiler/Version.h
+++ b/dev/LibCompiler/Version.h
@@ -6,8 +6,8 @@
#pragma once
-#define kDistVersion "v1.1.0"
-#define kDistVersionBCD 0x0110
+#define kDistVersion "v0.0.1"
+#define kDistVersionBCD 0x0001
#define ToString(X) Stringify(X)
#define Stringify(X) #X
diff --git a/dev/LibCompiler/src/Assembler64x0.cc b/dev/LibCompiler/src/Assembler64x0.cc
index fe0e8e2..6d4d31a 100644
--- a/dev/LibCompiler/src/Assembler64x0.cc
+++ b/dev/LibCompiler/src/Assembler64x0.cc
@@ -58,7 +58,7 @@ static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
static const std::string kRelocSymbol = ":RuntimeSymbol:";
// \brief forward decl.
-static bool asm_read_attributes(std::string& line);
+static bool asm_read_attributes(std::string line);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -260,7 +260,7 @@ asm_fail_exit:
/////////////////////////////////////////////////////////////////////////////////////////
-static bool asm_read_attributes(std::string& line) {
+static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the ld
// that we need this symbol.
if (LibCompiler::find_word(line, "extern_segment")) {
@@ -395,7 +395,7 @@ static inline bool is_not_alnum_space(char c) {
(c == '_') || (c == ':') || (c == '@') || (c == '.'));
}
-bool is_valid_64x0(const std::string& str) {
+bool is_valid_64x0(std::string str) {
return std::find_if(str.begin(), str.end(), is_not_alnum_space) == str.end();
}
} // namespace Detail::algorithm
@@ -406,7 +406,7 @@ bool is_valid_64x0(const std::string& str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::Encoder64x0::CheckLine(std::string& line, const std::string& file) {
+std::string LibCompiler::Encoder64x0::CheckLine(std::string line, std::string file) {
std::string err_str;
if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
@@ -607,7 +607,7 @@ bool LibCompiler::Encoder64x0::WriteNumber(const std::size_t& pos, std::string&
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::Encoder64x0::WriteLine(std::string& line, const std::string& file) {
+bool LibCompiler::Encoder64x0::WriteLine(std::string line, std::string file) {
if (LibCompiler::find_word(line, "public_segment ")) return true;
for (auto& opcode64x0 : kOpcodes64x0) {
diff --git a/dev/LibCompiler/src/AssemblerAMD64.cc b/dev/LibCompiler/src/AssemblerAMD64.cc
index dd6b7be..f8772b8 100644
--- a/dev/LibCompiler/src/AssemblerAMD64.cc
+++ b/dev/LibCompiler/src/AssemblerAMD64.cc
@@ -75,7 +75,7 @@ static std::vector<std::string> kUndefinedSymbols;
static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
// \brief forward decl.
-static bool asm_read_attributes(std::string& line);
+static bool asm_read_attributes(std::string line);
#include <LibCompiler/Detail/AsmUtils.h>
@@ -334,7 +334,7 @@ asm_fail_exit:
/////////////////////////////////////////////////////////////////////////////////////////
-static bool asm_read_attributes(std::string& line) {
+static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the ld
// that we need this symbol.
if (LibCompiler::find_word(line, "extern_segment")) {
@@ -479,7 +479,7 @@ static inline bool is_not_valid(char c) {
return true;
}
-bool is_valid_amd64(const std::string& str) {
+bool is_valid_amd64(std::string str) {
return std::find_if(str.begin(), str.end(), is_not_valid) == str.end();
}
} // namespace Detail::algorithm
@@ -490,7 +490,7 @@ bool is_valid_amd64(const std::string& str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::EncoderAMD64::CheckLine(std::string& line, const std::string& file) {
+std::string LibCompiler::EncoderAMD64::CheckLine(std::string line, std::string file) {
std::string err_str;
if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
@@ -950,7 +950,7 @@ bool LibCompiler::EncoderAMD64::WriteNumber8(const std::size_t& pos, std::string
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::EncoderAMD64::WriteLine(std::string& line, const std::string& file) {
+bool LibCompiler::EncoderAMD64::WriteLine(std::string line, std::string file) {
if (LibCompiler::find_word(line, "public_segment ")) return true;
struct RegMapAMD64 {
@@ -1135,7 +1135,7 @@ bool LibCompiler::EncoderAMD64::WriteLine(std::string& line, const std::string&
if (line[0] == kAssemblerPragmaSym) {
if (foundInstruction) {
- Detail::print_error("Syntax error: " + line, "LibCompiler");
+ Detail::print_error("Syntax error: " + line, file);
throw std::runtime_error("syntax_err");
}
@@ -1156,7 +1156,7 @@ bool LibCompiler::EncoderAMD64::WriteLine(std::string& line, const std::string&
continue;
} else {
if (kVerbose) {
- kStdOut << "AssemblerAMD64: origin set: " << kOrigin << std::endl;
+ kStdOut << "AssemblerAMD64: Origin Set: " << kOrigin << std::endl;
}
break;
diff --git a/dev/LibCompiler/src/AssemblerARM64.cc b/dev/LibCompiler/src/AssemblerARM64.cc
index 6c651aa..eb3e915 100644
--- a/dev/LibCompiler/src/AssemblerARM64.cc
+++ b/dev/LibCompiler/src/AssemblerARM64.cc
@@ -65,7 +65,7 @@ static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
static const std::string kRelocSymbol = ":RuntimeSymbol:";
// \brief forward decl.
-static bool asm_read_attributes(std::string& line);
+static bool asm_read_attributes(std::string line);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -267,7 +267,7 @@ asm_fail_exit:
/////////////////////////////////////////////////////////////////////////////////////////
-static bool asm_read_attributes(std::string& line) {
+static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the li
// that we need this symbol.
if (LibCompiler::find_word(line, "extern_segment")) {
@@ -401,7 +401,7 @@ static inline bool is_not_alnum_space(char c) {
(c == '_') || (c == ':') || (c == '@') || (c == '.'));
}
-bool is_valid_arm64(const std::string& str) {
+bool is_valid_arm64(std::string str) {
return std::find_if(str.begin(), str.end(), is_not_alnum_space) == str.end();
}
} // namespace Detail::algorithm
@@ -412,7 +412,7 @@ bool is_valid_arm64(const std::string& str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::EncoderARM64::CheckLine(std::string& line, const std::string& file) {
+std::string LibCompiler::EncoderARM64::CheckLine(std::string line, std::string file) {
std::string err_str;
if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
@@ -575,7 +575,7 @@ bool LibCompiler::EncoderARM64::WriteNumber(const std::size_t& pos, std::string&
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::EncoderARM64::WriteLine(std::string& line, const std::string& file) {
+bool LibCompiler::EncoderARM64::WriteLine(std::string line, std::string file) {
if (LibCompiler::find_word(line, "public_segment")) return false;
if (!Detail::algorithm::is_valid_arm64(line)) return false;
diff --git a/dev/LibCompiler/src/AssemblerPower.cc b/dev/LibCompiler/src/AssemblerPowerPC.cc
index 923008c..ffe5c6a 100644
--- a/dev/LibCompiler/src/AssemblerPower.cc
+++ b/dev/LibCompiler/src/AssemblerPowerPC.cc
@@ -65,7 +65,7 @@ static const std::string kUndefinedSymbol = ":UndefinedSymbol:";
static const std::string kRelocSymbol = ":RuntimeSymbol:";
// \brief forward decl.
-static bool asm_read_attributes(std::string& line);
+static bool asm_read_attributes(std::string line);
/////////////////////////////////////////////////////////////////////////////////////////
@@ -267,7 +267,7 @@ asm_fail_exit:
/////////////////////////////////////////////////////////////////////////////////////////
-static bool asm_read_attributes(std::string& line) {
+static bool asm_read_attributes(std::string line) {
// extern_segment is the opposite of public_segment, it signals to the li
// that we need this symbol.
if (LibCompiler::find_word(line, "extern_segment")) {
@@ -401,7 +401,7 @@ static inline bool is_not_alnum_space(char c) {
(c == '_') || (c == ':') || (c == '@') || (c == '.'));
}
-bool is_valid_power64(const std::string& str) {
+bool is_valid_power64(std::string str) {
return std::find_if(str.begin(), str.end(), is_not_alnum_space) == str.end();
}
} // namespace Detail::algorithm
@@ -412,7 +412,7 @@ bool is_valid_power64(const std::string& str) {
/////////////////////////////////////////////////////////////////////////////////////////
-std::string LibCompiler::EncoderPowerPC::CheckLine(std::string& line, const std::string& file) {
+std::string LibCompiler::EncoderPowerPC::CheckLine(std::string line, std::string file) {
std::string err_str;
if (line.empty() || LibCompiler::find_word(line, "extern_segment") ||
@@ -612,7 +612,7 @@ bool LibCompiler::EncoderPowerPC::WriteNumber(const std::size_t& pos, std::strin
/////////////////////////////////////////////////////////////////////////////////////////
-bool LibCompiler::EncoderPowerPC::WriteLine(std::string& line, const std::string& file) {
+bool LibCompiler::EncoderPowerPC::WriteLine(std::string line, std::string file) {
if (LibCompiler::find_word(line, "public_segment")) return false;
if (!Detail::algorithm::is_valid_power64(line)) return false;
diff --git a/dev/LibCompiler/src/AssemblyFactory.cc b/dev/LibCompiler/src/AssemblyFactory.cc
index 4695c63..8fa12a8 100644
--- a/dev/LibCompiler/src/AssemblyFactory.cc
+++ b/dev/LibCompiler/src/AssemblyFactory.cc
@@ -25,7 +25,7 @@
namespace LibCompiler {
///! @brief Compile for specific format (ELF, PEF, ZBIN)
-Int32 AssemblyFactory::Compile(std::string& sourceFile, const Int32& arch) noexcept {
+Int32 AssemblyFactory::Compile(std::string sourceFile, const Int32& arch) noexcept {
if (sourceFile.length() < 1 || !fMounted) return LIBCOMPILER_UNIMPLEMENTED;
return fMounted->CompileToFormat(sourceFile, arch);
diff --git a/dev/LibCompiler/src/CCompiler64x0.cc b/dev/LibCompiler/src/CCompiler64x0.cc
index dea3ebd..6fa05fb 100644
--- a/dev/LibCompiler/src/CCompiler64x0.cc
+++ b/dev/LibCompiler/src/CCompiler64x0.cc
@@ -1054,7 +1054,7 @@ class AssemblyCCInterface final ASSEMBLY_INTERFACE {
[[maybe_unused]] static Int32 Arch() noexcept { return LibCompiler::AssemblyFactory::kArch64x0; }
- Int32 CompileToFormat(std::string& src, Int32 arch) override {
+ Int32 CompileToFormat(std::string src, Int32 arch) override {
if (arch != AssemblyCCInterface::Arch()) return 1;
if (kCompilerFrontend == nullptr) return 1;
diff --git a/dev/LibCompiler/src/CCompilerARM64.cc b/dev/LibCompiler/src/CCompilerARM64.cc
index 7339840..b2f36e9 100644
--- a/dev/LibCompiler/src/CCompilerARM64.cc
+++ b/dev/LibCompiler/src/CCompilerARM64.cc
@@ -1054,7 +1054,7 @@ class AssemblyCCInterface final ASSEMBLY_INTERFACE {
return LibCompiler::AssemblyFactory::kArchAARCH64;
}
- Int32 CompileToFormat(std::string& src, Int32 arch) override {
+ Int32 CompileToFormat(std::string src, Int32 arch) override {
if (arch != AssemblyCCInterface::Arch()) return 1;
if (kCompilerFrontend == nullptr) return 1;
diff --git a/dev/LibCompiler/src/CCompilerPower64.cc b/dev/LibCompiler/src/CCompilerPower64.cc
index 42c4a0a..ee9c5a4 100644
--- a/dev/LibCompiler/src/CCompilerPower64.cc
+++ b/dev/LibCompiler/src/CCompilerPower64.cc
@@ -1074,7 +1074,7 @@ class AssemblyMountpointCLang final ASSEMBLY_INTERFACE {
return LibCompiler::AssemblyFactory::kArchPowerPC;
}
- Int32 CompileToFormat(std::string& src, Int32 arch) override {
+ Int32 CompileToFormat(std::string src, Int32 arch) override {
if (arch != AssemblyMountpointCLang::Arch()) return 1;
if (kCompilerFrontend == nullptr) return 1;
diff --git a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
index a227f75..e58e4f6 100644
--- a/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
+++ b/dev/LibCompiler/src/CPlusPlusCompilerAMD64.cc
@@ -14,11 +14,6 @@
#define kExitOK (EXIT_SUCCESS)
#define kExitNO (EXIT_FAILURE)
-#define kSplashCxx() \
- kPrintF(kWhite "%s\n", \
- "NeKernel Optimized C++ Compiler Driver, (c) 2024-2025 Amlal El Mahrouss, All rights " \
- "reserved.")
-
// extern_segment, @autodelete { ... }, fn foo() -> auto { ... }
#include <LibCompiler/Backend/Amd64.h>
@@ -392,14 +387,15 @@ Boolean CompilerFrontendCPlusPlus::Compile(std::string text, const std::string f
if (ch == ' ' || ch == '\t') {
if (fnName[indexFnName - 1] != ')')
Detail::print_error("Invalid function name: " + fnName, file);
-
- if ((indexFnName + 1) != fnName.size())
- Detail::print_error("Extra characters after function name: " + fnName, file);
}
++indexFnName;
}
+ if (fnName.find("(") != LibCompiler::String::npos) {
+ fnName.erase(fnName.find("("));
+ }
+
syntax_tree.fUserValue = "public_segment .code64 __LIBCOMPILER_" + fnName + "\n";
++kFunctionEmbedLevel;
@@ -760,7 +756,7 @@ class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE {
[[maybe_unused]] static Int32 Arch() noexcept { return LibCompiler::AssemblyFactory::kArchAMD64; }
- Int32 CompileToFormat(std::string& src, Int32 arch) override {
+ Int32 CompileToFormat(std::string src, Int32 arch) override {
if (arch != AssemblyCPlusPlusInterface::Arch()) return 1;
if (kCompilerFrontend == nullptr) return 1;
@@ -850,12 +846,6 @@ class AssemblyCPlusPlusInterface final ASSEMBLY_INTERFACE {
/////////////////////////////////////////////////////////////////////////////////////////
-static void cxx_print_help() {
- kSplashCxx();
- kPrintF("%s", "No help available, see:\n");
- kPrintF("%s", "nekernel.org/docs/cxxdrv\n");
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
#define kExtListCxx \
@@ -949,30 +939,19 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
continue;
}
- if (strcmp(argv[index], "-version") == 0) {
- kSplashCxx();
- return kExitOK;
- }
-
if (strcmp(argv[index], "-cxx-verbose") == 0) {
kState.fVerbose = true;
continue;
}
- if (strcmp(argv[index], "-h") == 0) {
- cxx_print_help();
-
- return kExitOK;
- }
-
if (strcmp(argv[index], "-cxx-dialect") == 0) {
if (kCompilerFrontend) std::cout << kCompilerFrontend->Language() << "\n";
return kExitOK;
}
- if (strcmp(argv[index], "-max-err") == 0) {
+ if (strcmp(argv[index], "-cxx-max-err") == 0) {
try {
kErrorLimit = std::strtol(argv[index + 1], nullptr, 10);
}
@@ -1016,9 +995,12 @@ LIBCOMPILER_MODULE(CompilerCPlusPlusAMD64) {
return 1;
}
- std::cout << "CPlusPlusCompilerAMD64: Building: " << argv[index] << std::endl;
+ kStdOut << "CPlusPlusCompilerAMD64: Building: " << argv[index] << std::endl;
- if (kFactory.Compile(argv_i, kMachine) != kExitOK) return 1;
+ if (kFactory.Compile(argv_i, kMachine) != kExitOK) {
+ kStdOut << "CPlusPlusCompilerAMD64: Failed to build: " << argv[index] << std::endl;
+ return kExitNO;
+ }
}
return kExitOK;
diff --git a/dev/LibCompiler/src/DynamicLinkerPEF.cc b/dev/LibCompiler/src/DynamicLinkerPEF.cc
index 09e0396..fb2403f 100644
--- a/dev/LibCompiler/src/DynamicLinkerPEF.cc
+++ b/dev/LibCompiler/src/DynamicLinkerPEF.cc
@@ -15,6 +15,8 @@
//! Toolchain Kit.
#include <LibCompiler/Defines.h>
+
+//! Error ID
#include <LibCompiler/ErrorID.h>
//! Assembler Kit
@@ -22,6 +24,8 @@
//! Preferred Executable Format
#include <LibCompiler/PEF.h>
+
+//! UUID header.
#include <LibCompiler/UUID.h>
//! Release macros.
@@ -30,9 +34,12 @@
//! Advanced Executable Object Format.
#include <LibCompiler/AE.h>
-#define kLinkerVersionStr \
- "\e[0;97m NeKernel 64-Bit Linker (Preferred Executable Format) %s, (c) Amlal El Mahrouss " \
- "2024-2025, " \
+//! Format header.
+#include <format>
+
+#define kLinkerVersionStr \
+ "NeKernel 64-Bit Linker (Preferred Executable Format) {}, (c) Amlal El Mahrouss " \
+ "2024-2025 " \
"all rights reserved.\n"
#define MemoryCopy(DST, SRC, SZ) memcpy(DST, SRC, SZ)
@@ -45,10 +52,10 @@
#define kLinkerDefaultOrigin kPefBaseOrigin
#define kLinkerId (0x5046FF)
-#define kLinkerAbiContainer "Container:ABI:"
+#define kLinkerAbiContainer "__PEFContainer:ABI:"
#define kPrintF printf
-#define kLinkerSplash() kPrintF(kLinkerVersionStr, kDistVersion)
+#define kLinkerSplash() kStdOut << std::format(kLinkerVersionStr, kDistVersion)
/// @brief PEF stack size symbol.
#define kLinkerStackSizeSymbol "__PEFSizeOfReserveStack"
@@ -101,7 +108,7 @@ LIBCOMPILER_MODULE(DynamicLinker64PEF) {
kStdOut << "-version: Show linker version.\n";
kStdOut << "-help: Show linker help.\n";
kStdOut << "-ld-verbose: Enable linker trace.\n";
- kStdOut << "-dylib: Output as a Dyanmic PEF.\n";
+ kStdOut << "-dylib: Output as a Dynamic PEF.\n";
kStdOut << "-fat: Output as a FAT PEF.\n";
kStdOut << "-32k: Output as a 32x0 PEF.\n";
kStdOut << "-64k: Output as a 64x0 PEF.\n";