Skip to content

Commit 09fc5ca

Browse files
committed
feat: add linux linker functionality
1 parent 89c436b commit 09fc5ca

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

.bazelrc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
build --cxxopt=/std:c++20
2-
build --host_cxxopt=/std:c++20
1+
build:linux --cxxopt=-std=c++20
2+
build:linux --host_cxxopt=-std=c++20
3+
4+
build:windows --cxxopt=/std:c++20
5+
build:windows --host_cxxopt=/std:c++20

examples/memory.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ main :: () i32 {
1010
let other: ^Test = &test;
1111

1212
let new: Test = ^other;
13-
io:print("%d\n", new.a);
13+
io:print("%d\n", (^other).a);
1414
return 0;
1515
}

out

14.5 KB
Binary file not shown.

src/generator.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,20 @@ void Generator::generate()
223223
}
224224
else if (llvm::Triple(llvm::sys::getProcessTriple()).isOSLinux())
225225
{
226-
linker = "ld";
226+
linker = "/usr/bin/ld";
227+
228+
args = {linker,
229+
"-o",
230+
"out",
231+
"out.o",
232+
"-L/lib",
233+
"-L/usr/lib",
234+
"-lc",
235+
"/usr/lib/x86_64-linux-gnu/crt1.o",
236+
"/usr/lib/x86_64-linux-gnu/crti.o",
237+
"-dynamic-linker",
238+
"/lib64/ld-linux-x86-64.so.2",
239+
"/usr/lib/x86_64-linux-gnu/crtn.o"};
227240
}
228241
else
229242
{
@@ -238,8 +251,7 @@ void Generator::generate()
238251
}
239252

240253
std::string errMsg;
241-
int result = llvm::sys::ExecuteAndWait(linker, execArgs, std::nullopt, {},
242-
0, 0, &errMsg);
254+
int result = llvm::sys::ExecuteAndWait(linker, execArgs, std::nullopt, {}, 0, 0, &errMsg);
243255

244256
if (result != 0)
245257
{

std/io.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ module "io"
33
printf :: (s: string) i32
44

55
print :: (s: string) void {
6-
printf("%s", s);
7-
}
6+
printf(s);
7+
}

0 commit comments

Comments
 (0)