Skip to content

Commit

Permalink
makes shell runnable on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
chibash committed Oct 21, 2024
1 parent 803f63e commit c0e08c4
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion microcontroller/core/src/c-runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
To run on a 64bit machine (for testing/debugging purpose only),
compile with -DTEST64. To include test code, compile with -DTEST.
So,
cc -DTEST -DTEST64 gc.c
cc -DTEST -DTEST64 gc.c -lm
will produce ./a.out that runs test code on a 64bit machine.
Typical usecase:
Expand Down
2 changes: 1 addition & 1 deletion microcontroller/core/test/c-runtime-test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test code
// To cmpile,
// cc -DTEST64 c-runtime-test.c
// cc -DTEST64 c-runtime-test.c -lm

#include <string.h>
#include "../src/c-runtime.c"
Expand Down
2 changes: 1 addition & 1 deletion microcontroller/core/test/c-runtime-test2.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test code for c-runtime.c
// To compile,
// cc -DTEST64 c-runtime-test2.c
// cc -DTEST64 c-runtime-test2.c -lm

#include <stdio.h>
#include "../src/c-runtime.c"
Expand Down
2 changes: 1 addition & 1 deletion microcontroller/core/test/float-test.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Test code for value_to_float and float_to_value functions in c-runtime.c
// To compile,
// cc -DTEST64 float-test.c
// cc -DTEST64 float-test.c -lm

#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 2 additions & 2 deletions server/src/transpiler/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function buildShell() {
const srcdir = 'src/transpiler'
console.log(execSync("pwd").toString())
execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${dir}/c-runtime.so ${cRuntimeC} ${srcdir}/shell-builtins.c`)
execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${srcdir}/shell.c ${dir}/c-runtime.so -ldl`)
execSync(`cc -DTEST64 -O2 -o ${dir}/shell ${srcdir}/shell.c ${dir}/c-runtime.so -lm -ldl`)
}

function makeShell(closer: (code: number) => void) {
Expand Down Expand Up @@ -113,7 +113,7 @@ class Transpiler {
fs.writeFileSync(`${fileName}.c`, prologCcode + src)

// throw an Error when compilation fails.
execSync(`cc -shared -DTEST64 -O2 -o ${fileName}.so ${fileName}.c ${this.libs}`)
execSync(`cc -DTEST64 -O2 -shared -fPIC -o ${fileName}.so ${fileName}.c ${this.libs}`)
this.libs =`${this.libs} ${fileName}.so`
this.sources = `${this.sources} ${fileName}.c`
}
Expand Down

0 comments on commit c0e08c4

Please sign in to comment.