Skip to content

Commit

Permalink
Add static lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Dec 27, 2024
1 parent 08e8c9b commit 291b26f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ jobs:
./a.out
../../../build/c3c compile-run test.c3 -L . -l add -z -Wl,-rpath=.
- name: Compile and run staticlib-test
run: |
cd resources/examples/staticlib-test
../../../build/c3c -vv static-lib add.c3
mv add.a libadd.a
cc test.c -L. -ladd
./a.out
../../../build/c3c compile-run test.c3 -L . -l add
- name: Compile run unit tests
run: |
cd test
Expand Down
19 changes: 19 additions & 0 deletions resources/examples/staticlib-test/add.c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module add;
import std;
struct Foo(Printable)
{
int a;
}

fn usz! Foo.to_format(&self, Formatter* f) @dynamic
{
return f.printf("Foo[%d]", self.a);
}

fn int add(int a, int b) @export("adder")
{
io::printn("In adder");
Foo x = { a };
io::printfn("Print foo: %s", x);
return a + b;
}
8 changes: 8 additions & 0 deletions resources/examples/staticlib-test/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <stdio.h>
extern int adder(int a, int b);

int main()
{
printf("%d\n", adder(1, 4));
return 0;
}
9 changes: 9 additions & 0 deletions resources/examples/staticlib-test/test.c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module add;
import std;
extern fn int adder(int a, int b);

fn int main()
{
io::printn(adder(1, 4));
return 0;
}
3 changes: 1 addition & 2 deletions test/test_suite/initialize/initialize_finalize.c3t
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ entry:
call void @puts(ptr @.str.4)
ret void
}

define void @.__c3_atexit_test.shutdown() {
define weak void @.__c3_atexit_test.shutdown() comdat {
entry:
call void @atexit(ptr @test.shutdown)
ret void
Expand Down

0 comments on commit 291b26f

Please sign in to comment.