Add patches for TinyCC

This commit is contained in:
Ziyao 2022-04-03 10:27:48 +08:00
parent 5013f777b5
commit 79593d5689
2 changed files with 42 additions and 2 deletions

10
README
View File

@ -8,7 +8,7 @@ still missing,including:
- Full GNU-style inline assembly support. - Full GNU-style inline assembly support.
The original versions of __syscall4(),__syscall5() and __syscall6() The original versions of __syscall4(),__syscall5() and __syscall6()
don't work.They are replaced by assembly implemention in don't work.They are replaced by assembly implemention in
/src/unistd/x86_64/syscall.S /src/internal/x86_64/syscall.S
- math library is removed momently. - math library is removed momently.
Because some missing floating-point features of TinyCC.I am working Because some missing floating-point features of TinyCC.I am working
on completing. on completing.
@ -25,6 +25,12 @@ To compile,simply run
./configure --target=x86_64 # The script cannot detect the ./configure --target=x86_64 # The script cannot detect the
# platform with tcc because of # platform with tcc because of
# missing option "-dumpmachine" # missing option "-dumpmachine"
make make # I finish my compiling in 10s with
two threads on i7-720QM @ 1.60GHz
All modified and addtional files are under MIT License as well. All modified and addtional files are under MIT License as well.
Some changes are made to my TinyCC (This means I may have a different
version from yours,so if you fail to compile,try to apply the patches
listed in /tcc-patch/,including:
- empty_archive.patch
Enables TinyCC to generate empty ar archive

View File

@ -0,0 +1,34 @@
diff --git a/tcctools.c b/tcctools.c
index 4567b81..7c643dc 100644
--- a/tcctools.c
+++ b/tcctools.c
@@ -61,7 +61,7 @@ static int contains_any(const char *s, const char *list) {
}
static int ar_usage(int ret) {
- fprintf(stderr, "usage: tcc -ar [rcsv] lib file...\n");
+ fprintf(stderr, "usage: tcc -ar [rcsv] lib [file...]\n");
fprintf(stderr, "create library ([abdioptxN] not supported).\n");
return ret;
}
@@ -115,8 +115,9 @@ ST_FUNC int tcc_tool_ar(TCCState *s1, int argc, char **argv)
}
}
- if (!i_obj) // i_obj implies also i_lib. we require both.
+ if (!i_lib) // i_obj implies also i_lib.
ret = 1;
+ i_obj = i_obj ? i_obj : argc; // An empty archive will be generated if no input file is given
if (ret == 1)
return ar_usage(ret);
@@ -242,6 +243,9 @@ ST_FUNC int tcc_tool_ar(TCCState *s1, int argc, char **argv)
hofs++, fpos = 1;
// write header
fwrite("!<arch>\n", 8, 1, fh);
+ // create an empty archive
+ if (!funccnt)
+ goto the_end;
sprintf(stmp, "%-10d", (int)(strpos + (funccnt+1) * sizeof(int)));
memcpy(&arhdr.ar_size, stmp, 10);
fwrite(&arhdr, sizeof(arhdr), 1, fh);