This commit is contained in:
nub31
2025-06-26 15:15:01 +02:00
parent 9f20e71740
commit 3d06f40516
5 changed files with 41 additions and 18 deletions

View File

@@ -7,7 +7,7 @@ public static class GCC
public static async Task<bool> Assemble(string asmPath, string objPath)
{
using var gccProcess = new Process();
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-c", asmPath, "-o", objPath])
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-nostdlib", "-ffreestanding", "-c", asmPath, "-o", objPath])
{
UseShellExecute = false,
RedirectStandardOutput = true,
@@ -30,7 +30,7 @@ public static class GCC
public static async Task<bool> Link(List<string> objectFiles, string outputPath)
{
using var gccProcess = new Process();
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-nostartfiles", "-o", outputPath, ..objectFiles])
gccProcess.StartInfo = new ProcessStartInfo("gcc", ["-g", "-nostdlib", "-ffreestanding", "-o", outputPath, ..objectFiles])
{
UseShellExecute = false,
RedirectStandardOutput = true,

View File

@@ -24,10 +24,31 @@ if (Directory.Exists(BIN_INT_DIR))
Directory.CreateDirectory(BIN_DIR);
Directory.CreateDirectory(BIN_INT_DIR);
var files = new List<string>();
var compileOnly = false;
string? outPath = null;
foreach (var arg in args)
{
if (arg == "-c")
{
compileOnly = true;
}
else if (arg.StartsWith("-o="))
{
outPath = arg.Substring("-o=".Length);
}
else
{
files.Add(arg);
}
}
var diagnostics = new List<Diagnostic>();
var syntaxTrees = new List<SyntaxTree>();
foreach (var file in args)
foreach (var file in files)
{
if (!File.Exists(file))
{
@@ -36,7 +57,7 @@ foreach (var file in args)
}
}
foreach (var file in args)
foreach (var file in files)
{
var content = File.ReadAllText(file);
var sourceText = new SourceText(file, content);
@@ -78,9 +99,10 @@ if (diagnostics.Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Erro
return 1;
}
var objectFiles = new List<string>();
objectFiles.Add("/home/oliste/repos/nub-lang/src/runtime/runtime.o");
var objectFiles = new List<string>
{
"libruntime.a"
};
foreach (var boundSyntaxTree in boundSyntaxTrees)
{