mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-17 08:00:32 +00:00
Create integrated assembler for chibicc
All we need now to complete the triforce is an integrated linker. That way Cosmpolitan will let C be a "build anywhere run anywhere" language.
This commit is contained in:
parent
5eddadafbd
commit
81ef162703
6 changed files with 267 additions and 88 deletions
13
third_party/chibicc/chibicc.c
vendored
13
third_party/chibicc/chibicc.c
vendored
|
@ -563,10 +563,15 @@ static void cc1(void) {
|
|||
fclose(out);
|
||||
}
|
||||
|
||||
static int CountArgv(char **argv) {
|
||||
int n = 0;
|
||||
while (*argv++) ++n;
|
||||
return n;
|
||||
}
|
||||
|
||||
static void assemble(char *input, char *output) {
|
||||
char *as = getenv("AS");
|
||||
if (!as || !*as) as = "as";
|
||||
/* as = "o//third_party/chibicc/as.com"; */
|
||||
StringArray arr = {};
|
||||
strarray_push(&arr, as);
|
||||
strarray_push(&arr, "-W");
|
||||
|
@ -579,7 +584,11 @@ static void assemble(char *input, char *output) {
|
|||
strarray_push(&arr, "-o");
|
||||
strarray_push(&arr, output);
|
||||
strarray_push(&arr, NULL);
|
||||
handle_exit(run_subprocess(arr.data));
|
||||
if (1) {
|
||||
Assembler(CountArgv(arr.data), arr.data);
|
||||
} else {
|
||||
handle_exit(run_subprocess(arr.data));
|
||||
}
|
||||
}
|
||||
|
||||
static void run_linker(StringArray *inputs, char *output) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue