Fix archive issues in cli
This commit is contained in:
@@ -1,8 +1,19 @@
|
||||
// c
|
||||
extern func puts(text: cstring)
|
||||
|
||||
struct Human {
|
||||
name: cstring
|
||||
age: u32
|
||||
}
|
||||
|
||||
func main(args: []cstring): i64
|
||||
{
|
||||
puts("Hello, World")
|
||||
let x: Human = struct {
|
||||
name = "Oliver"
|
||||
age = 23
|
||||
}
|
||||
|
||||
puts(x.name)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="assets\libruntime_x64.a" />
|
||||
<EmbeddedResource Include="assets\libruntime_x64.a" />
|
||||
<None Remove="assets\runtime.o" />
|
||||
<EmbeddedResource Include="assets\runtime.o" />
|
||||
<None Remove="assets\x64.o" />
|
||||
<EmbeddedResource Include="assets\x64.o" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -124,20 +124,25 @@ for (var i = 0; i < typedSyntaxTrees.Count; i++)
|
||||
objectFiles.Add(objFilePath);
|
||||
}
|
||||
|
||||
const string runtimeName = "libruntime_x64.a";
|
||||
|
||||
var resources = Assembly.GetExecutingAssembly().GetManifestResourceNames();
|
||||
var runtime = resources.First(r => r.EndsWith(runtimeName));
|
||||
|
||||
await using var reader = Assembly.GetExecutingAssembly().GetManifestResourceStream(runtime);
|
||||
string[] runtimeObjects = ["runtime.o", "x64.o"];
|
||||
|
||||
foreach (var runtimeObject in runtimeObjects)
|
||||
{
|
||||
var runtime = resources.First(r => r.EndsWith(runtimeObject));
|
||||
|
||||
await using var reader = Assembly
|
||||
.GetExecutingAssembly()
|
||||
.GetManifestResourceStream(runtime);
|
||||
|
||||
if (reader == null)
|
||||
{
|
||||
Console.Error.WriteLine($"Cannot open stream to '{runtimeName}'");
|
||||
Console.Error.WriteLine($"Cannot open read stream to '{runtimeObject}'");
|
||||
return 1;
|
||||
}
|
||||
|
||||
var runtimePath = Path.Combine("build", "runtime", runtimeName);
|
||||
var runtimePath = Path.Combine("build", "runtime", runtimeObject);
|
||||
var runtimeDir = Path.GetDirectoryName(runtimePath);
|
||||
if (!string.IsNullOrEmpty(runtimeDir))
|
||||
{
|
||||
@@ -149,6 +154,7 @@ await using var writer = new FileStream(runtimePath, FileMode.Create);
|
||||
reader.CopyTo(writer);
|
||||
|
||||
objectFiles.Add(runtimePath);
|
||||
}
|
||||
|
||||
var outPath = options.OutputPath ?? Path.Combine("build", "out.a");
|
||||
var outDir = Path.GetDirectoryName(outPath);
|
||||
@@ -163,4 +169,5 @@ if (!archiveResult)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
Binary file not shown.
BIN
src/compiler/NubLang.CLI/assets/x64.o
Normal file
BIN
src/compiler/NubLang.CLI/assets/x64.o
Normal file
Binary file not shown.
@@ -939,7 +939,7 @@ public class QBEGenerator
|
||||
{
|
||||
destination = TmpName();
|
||||
var size = SizeOf(structInitializer.StructType);
|
||||
_writer.Indented($"{destination} =l alloc8 {size}");
|
||||
_writer.Indented($"{destination} =l call $malloc(l {size})");
|
||||
}
|
||||
|
||||
foreach (var field in structDef.Fields)
|
||||
|
||||
3
src/runtime/.gitignore
vendored
3
src/runtime/.gitignore
vendored
@@ -1,2 +1 @@
|
||||
bin
|
||||
bin-int
|
||||
build
|
||||
|
||||
@@ -3,14 +3,12 @@ TARGET ?= x64
|
||||
|
||||
CFLAGS = -Wall -Werror -Wextra -g
|
||||
|
||||
libruntime: bin-int/runtime.o
|
||||
$(CC) $(CFLAGS) -c targets/$(TARGET).s -o bin-int/$(TARGET).o
|
||||
mkdir -p bin
|
||||
ar rcs bin/libruntime_$(TARGET).a bin-int/runtime.o bin-int/$(TARGET).o
|
||||
libruntime: build/runtime.o
|
||||
$(CC) $(CFLAGS) -c targets/$(TARGET).s -o build/$(TARGET).o
|
||||
|
||||
bin-int/runtime.o: runtime/runtime.c
|
||||
mkdir -p bin-int
|
||||
$(CC) $(CFLAGS) -c runtime/runtime.c -o bin-int/runtime.o
|
||||
build/runtime.o: runtime/runtime.c
|
||||
mkdir -p build
|
||||
$(CC) $(CFLAGS) -c runtime/runtime.c -o build/runtime.o
|
||||
|
||||
clean:
|
||||
rm -r bin bin-int
|
||||
rm -r build
|
||||
|
||||
Reference in New Issue
Block a user