.gear/rules | 2 + .gear/tags/list | 1 + Makefile | 2 +- README | 4 +- examples/ex1.c | 2 +- examples/ex4.c | 2 +- lib/Makefile | 1 + tcc-0.9.27-alt1.patch | 106 ++++++++++++++++++++++++++++ tcc-doc.texi | 6 +- tcc.spec | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++ tccelf.c | 2 + tccgen.c | 2 +- tests/tcctest.c | 4 ++ tests/tests2/Makefile | 2 +- 14 files changed, 312 insertions(+), 10 deletions(-) diff --git a/.gear/rules b/.gear/rules new file mode 100644 index 0000000..7b01d4c --- /dev/null +++ b/.gear/rules @@ -0,0 +1,2 @@ +diff: upstream/mob:. . +tar: upstream/mob:. diff --git a/.gear/tags/list b/.gear/tags/list new file mode 100644 index 0000000..3050543 --- /dev/null +++ b/.gear/tags/list @@ -0,0 +1 @@ +1432574b2b29ea890ac417ad24cbc47d35f39d9f upstream/mob diff --git a/Makefile b/Makefile index 9d0bc3b..8d967f5 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ ifdef CONFIG_WIN32 NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32) else CFG = -unx - LIBS=-lm -lpthread + LIBS=-pthread ifneq ($(CONFIG_ldl),no) LIBS+=-ldl endif diff --git a/README b/README index 809dd8d..e61be3b 100644 --- a/README +++ b/README @@ -21,7 +21,7 @@ Features: - Compile and execute C source directly. No linking or assembly necessary. Full C preprocessor included. -- C script supported : just add '#!/usr/local/bin/tcc -run' at the first +- C script supported : just add '#!/usr/bin/tcc -run' at the first line of your C source, and execute it directly from the command line. @@ -53,7 +53,7 @@ The include file can be used if you want a small basic libc include support (especially useful for floppy disks). Of course, you can also use standard headers, although they are slower to compile. -You can begin your C script with '#!/usr/local/bin/tcc -run' on the first +You can begin your C script with '#!/usr/bin/tcc -run' on the first line and set its execute bits (chmod a+x your_script). Then, you can launch the C code as a shell or perl script :-) The command line arguments are put in 'argc' and 'argv' of the main functions, as in diff --git a/examples/ex1.c b/examples/ex1.c index 3d2a3e1..d84d2c0 100755 --- a/examples/ex1.c +++ b/examples/ex1.c @@ -1,4 +1,4 @@ -#!/usr/local/bin/tcc -run +#!/usr/bin/tcc -run #include int main() diff --git a/examples/ex4.c b/examples/ex4.c index f92c0da..0f3f87e 100755 --- a/examples/ex4.c +++ b/examples/ex4.c @@ -1,4 +1,4 @@ -#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 +#!/usr/bin/tcc -run -L/usr/X11R6/lib -lX11 #include #include #include diff --git a/lib/Makefile b/lib/Makefile index aefe1fe..60d2a39 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -24,6 +24,7 @@ arm-libtcc1-usegcc ?= no #x86_64-libtcc1-usegcc=yes #i386-libtcc1-usegcc=yes +CFLAGS:=$(CFLAGS) -fno-stack-protector ifeq "$($(T)-libtcc1-usegcc)" "yes" XCC = $(CC) XAR = $(AR) diff --git a/tcc-0.9.27-alt1.patch b/tcc-0.9.27-alt1.patch new file mode 100644 index 0000000..6db23f2 --- /dev/null +++ b/tcc-0.9.27-alt1.patch @@ -0,0 +1,106 @@ +diff --git a/Makefile b/Makefile +index 3ae466f..4790efc 100644 +--- a/Makefile ++++ b/Makefile +@@ -30,7 +30,6 @@ ifdef CONFIG_WIN32 + CFGWIN = -win + NATIVE_TARGET = $(ARCH)-win$(if $(findstring arm,$(ARCH)),ce,32) + else +- LIBS=-lm + ifneq ($(CONFIG_ldl),no) + LIBS+=-ldl + endif +diff --git a/tccgen.c b/tccgen.c +index e0b744e..ddbd2cf 100644 +--- a/tccgen.c ++++ b/tccgen.c +@@ -2207,7 +2207,7 @@ redo: + gen_op(TOK_PDIV); + } else { + /* exactly one pointer : must be '+' or '-'. */ +- if (op != '-' && op != '+') ++ if (op != '-' && op != '+' && op != '&') + tcc_error("cannot use pointers here"); + /* Put pointer as first operand */ + if (bt2 == VT_PTR) { +diff --git a/README b/README +index 3a3f90b..a2ee4ec 100644 +--- a/README ++++ b/README +@@ -21,7 +21,7 @@ Features: + - Compile and execute C source directly. No linking or assembly + necessary. Full C preprocessor included. + +-- C script supported : just add '#!/usr/local/bin/tcc -run' at the first ++- C script supported : just add '#!/usr/bin/tcc -run' at the first + line of your C source, and execute it directly from the command + line. + +@@ -52,7 +52,7 @@ The include file can be used if you want a small basic libc + include support (especially useful for floppy disks). Of course, you + can also use standard headers, although they are slower to compile. + +-You can begin your C script with '#!/usr/local/bin/tcc -run' on the first ++You can begin your C script with '#!/usr/bin/tcc -run' on the first + line and set its execute bits (chmod a+x your_script). Then, you can + launch the C code as a shell or perl script :-) The command line + arguments are put in 'argc' and 'argv' of the main functions, as in +diff --git a/examples/ex1.c b/examples/ex1.c +index 3d2a3e1..d84d2c0 100755 +--- a/examples/ex1.c ++++ b/examples/ex1.c +@@ -1,4 +1,4 @@ +-#!/usr/local/bin/tcc -run ++#!/usr/bin/tcc -run + #include + + int main() +diff --git a/examples/ex4.c b/examples/ex4.c +index f92c0da..0f3f87e 100755 +--- a/examples/ex4.c ++++ b/examples/ex4.c +@@ -1,4 +1,4 @@ +-#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 ++#!/usr/bin/tcc -run -L/usr/X11R6/lib -lX11 + #include + #include + #include +diff --git a/tcc-doc.texi b/tcc-doc.texi +index 5e718a2..c3c1473 100644 +--- a/tcc-doc.texi ++++ b/tcc-doc.texi +@@ -130,10 +130,10 @@ Compile @file{a.c} and @file{b.c}, link them together and generate the object fi + Scripting: + + TCC can be invoked from @emph{scripts}, just as shell scripts. You just +-need to add @code{#!/usr/local/bin/tcc -run} at the start of your C source: ++need to add @code{#!/usr/bin/tcc -run} at the start of your C source: + + @example +-#!/usr/local/bin/tcc -run ++#!/usr/bin/tcc -run + #include + + int main() +@@ -173,7 +173,7 @@ tcc "-run -L/usr/X11R6/lib -lX11" ex4.c + @end example + In a script, it gives the following header: + @example +-#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 ++#!/usr/bin/tcc -run -L/usr/X11R6/lib -lX11 + @end example + + @item -v +diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile +index 190b2d9..7285fbe 100644 +--- a/tests/tests2/Makefile ++++ b/tests/tests2/Makefile +@@ -40,7 +40,7 @@ NORUN = + 42_function_pointer.test : NORUN = true + + # Some tests might need different flags +-FLAGS = ++FLAGS = -lm + 76_dollars_in_identifiers.test : FLAGS += -fdollars-in-identifiers + + # These tests run several snippets from the same file one by one diff --git a/tcc-doc.texi b/tcc-doc.texi index 97b050b..5712bab 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -130,10 +130,10 @@ Compile @file{a.c} and @file{b.c}, link them together and generate the object fi Scripting: TCC can be invoked from @emph{scripts}, just as shell scripts. You just -need to add @code{#!/usr/local/bin/tcc -run} at the start of your C source: +need to add @code{#!/usr/bin/tcc -run} at the start of your C source: @example -#!/usr/local/bin/tcc -run +#!/usr/bin/tcc -run #include int main() @@ -173,7 +173,7 @@ tcc "-run -L/usr/X11R6/lib -lX11" ex4.c @end example In a script, it gives the following header: @example -#!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 +#!/usr/bin/tcc -run -L/usr/X11R6/lib -lX11 @end example @item -v diff --git a/tcc.spec b/tcc.spec new file mode 100644 index 0000000..ddffd83 --- /dev/null +++ b/tcc.spec @@ -0,0 +1,186 @@ +%def_enable static +%def_enable cross +%def_with selinux +%def_without libgcc + +%define Alias TinyCC +%define alias tinycc +%define Name TCC +Name: tcc +%define lname lib%name +Version: 0.9.27 +# git describe upstream/mob --tags +Release: alt3.740.g347c036 +Summary: A small but hyper fast C compiler +Group: Development/C +License: LGPLv2.1+ +URL: http://bellard.org/%name +Source: %name-%version.tar +Patch: %name-%version-%release.patch +Provides: %alias = %version-%release +ExclusiveArch: x86_64 %ix86 aarch64 + +# Automatically added by buildreq on Mon Feb 05 2018 +# optimized out: glibc-kernheaders-generic glibc-kernheaders-x86 perl perl-Encode perl-Pod-Escapes perl-Pod-Simple perl-Text-Unidecode perl-Unicode-EastAsianWidth perl-Unicode-Normalize perl-libintl perl-parent perl-podlators python-base +BuildRequires: makeinfo perl-Pod-Usage +BuildPreReq: perl-podlators + +%description +%Alias (aka %Name) is a small but hyper fast C compiler. Unlike other C +compilers, it is meant to be self-sufficient: you do not need an +external assembler or linker because %Name does that for you. +%Name compiles so fast that even for big projects Makefiles may not be +necessary. +%Name not only supports ANSI C, but also most of the new ISO C99 standard +and many GNUC extensions. +%Name can also be used to make C scripts, i.e. pieces of C source that +you run as a Perl or Python script. Compilation is so fast that your +script will be as fast as if it was an executable. +%Name can also automatically generate memory and bound checks while +allowing all C pointers operations. %Name can do these checks even if non +patched libraries are used. +With %lname, you can use %Name as a backend for dynamic code generation. + +%package -n %lname-devel-static +Summary: %Name backend for static code generation +Group: Development/C +Provides: %lname-devel = %version-%release + +%description -n %lname-devel-static +With %lname, you can use %Name as a backend for static code generation. + + +%package cross +Summary: %Name cross-compilers +Group: Development/C + +%description cross +Cross-compiler suite for %Name. + +%prep +%setup -q +%patch -p1 +#sed -i 's|/usr/local/bin/|%_bindir/|g' README %name-doc.* examples/ex[14].c +#sed -i '/^TCCFLAGS/s/^.*$/& -lm/' tests/tests2/Makefile +#sed -i '/-o tcctest.gcc/s/$/ -fno-pie/' tests/Makefile +%ifarch aarch64 +sed -i 's/-shared -o libtcc2/-r -o libtcc2/g' tests/Makefile +sed -i 's/-shared -D DLL=/-r -D DLL=/g' tests/tests2/Makefile +%endif + +%build +./configure \ + --prefix=%_prefix \ + --libdir=%_libdir \ + --extra-cflags="%optflags" \ + --docdir=%_docdir/%name-%version \ + %{subst_enable static} \ + %{?_enable_cross:--enable-cross} \ + %{?_with_selinux:--with-selinux} \ + %{?_with_libgcc:--with-libgcc} \ + --disable-rpath +%make_build all cross + +%install +%makeinstall_std + +%check +make test + + +%files +%doc README Changelog RELICENSING TODO VERSION examples *html +%_bindir/%name +%_libdir/%name/%{lname}* +%_libdir/%name/*.o +%_libdir/%name/include +%_man1dir/* +%_infodir/* + + +%files cross +%_bindir/*-%name +%_libdir/%name/*-%{lname}* +%_libdir/%name/win32 + + +%files -n %lname-devel-static +%_includedir/* +%_libdir/%lname.a + +%changelog +* Sat Apr 17 2021 Fr. Br. George 0.9.27-alt3.740.g347c036 +- Switch to git origin/mob build +- Update to 2021/04/17 +- Debian patches applied + +* Fri Dec 18 2020 Fr. Br. George 0.9.27-alt2 +- Fix build +- Rename devel to devel-static +- Introduced cross-compilers + +* Mon Feb 05 2018 Fr. Br. George 0.9.27-alt1 +- Resurrect with packaging schheme changed +- Update to 0.9.27 + +* Mon Jul 18 2016 Fr. Br. George 0.9.26.0.727.4134994-alt1 +- Upstream changed to http://repo.or.cz/tinycc.git +- Update to 0.9.26-727-g4134994 + +* Thu Dec 03 2015 Igor Vlasenko 0.9.26-alt1.1 +- NMU: added BR: texinfo + +* Thu Apr 18 2013 Led 0.9.26-alt1 +- 0.9.26 +- Makefile: + + don't strip binaries when install + + dont' link with libm +- updated BuildRequires +- cleaned up spec +- build with default %%_optlevel +- added %%check section + +* Wed Mar 23 2011 Eugeny A. Rostovtsev (REAL) 0.9.25-alt4 +- Really rebuilt for debuginfo + +* Tue Mar 22 2011 Eugeny A. Rostovtsev (REAL) 0.9.25-alt3 +- Rebuilt for debuginfo + +* Tue Nov 16 2010 Eugeny A. Rostovtsev (REAL) 0.9.25-alt2 +- Fixed build + +* Sun Nov 15 2009 Led 0.9.25-alt2 +- warning instead error for unsupported linker options + +* Tue Jun 02 2009 Led 0.9.25-alt1 +- 0.9.25 +- updated URL +- cleaned up spec +- updated description and summary +- fixed License + +* Thu Feb 22 2007 Led 0.9.23-alt4 +- added ExclusiveArch: %%ix86 +- fixed %%files + +* Thu Oct 12 2006 Led 0.9.23-alt3 +- added %name-0.9.23-union-abstract.patch for parse unnamed unions +- added %name-0.9.23-linker-error.patch +- added %name-0.9.23-linker-lib_search_order.patch +- updated %name-0.9.23-linker-group_as_needed.patch +- added %%optflags for compile + +* Wed Oct 04 2006 Led 0.9.23-alt2 +- fixed linker: added %name-0.9.23-linker-defined_twice.patch +- added %name-0.9.23-linker-group_as_needed.patch (fixed by Kim Lux) +- added %name-0.9.23-pointer-operators.patch + +* Tue Oct 03 2006 Led 0.9.23-alt1 +- 0.9.23 +- cleaned up spec + +* Wed Dec 29 2004 Alexey Tourbin 0.9.22-alt1 +- 0.9.20 -> 0.9.22 + +* Mon Nov 10 2003 Alexey Tourbin 0.9.20-alt1 +- initial revision diff --git a/tccelf.c b/tccelf.c index ddbce88..cd49d71 100644 --- a/tccelf.c +++ b/tccelf.c @@ -1034,6 +1034,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr) int sym_index = ELFW(R_SYM)(rel->r_info); int type = ELFW(R_TYPE)(rel->r_info); switch(type) { +#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) #if defined(TCC_TARGET_I386) case R_386_32: if (!get_sym_attr(s1, sym_index, 0)->dyn_index @@ -1080,6 +1081,7 @@ static int prepare_dynamic_rel(TCCState *s1, Section *sr) if (get_sym_attr(s1, sym_index, 0)->dyn_index) count++; break; +#endif default: break; } diff --git a/tccgen.c b/tccgen.c index c36032a..c24ad0b 100644 --- a/tccgen.c +++ b/tccgen.c @@ -3493,7 +3493,7 @@ redo: gen_op(TOK_PDIV); } else { /* exactly one pointer : must be '+' or '-'. */ - if (op != '-' && op != '+') + if (op != '-' && op != '+' && op != '&') tcc_error("cannot use pointers here"); /* Put pointer as first operand */ if (bt2 == VT_PTR) { diff --git a/tests/tcctest.c b/tests/tcctest.c index eef1c4a..05c68bb 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -3357,6 +3357,7 @@ void override_func2 (void) printf ("asmc: override2\n"); } +#ifndef __i386__ /* This checks a construct used by the linux kernel to encode references to strings by PC relative references. */ extern int bug_table[] __attribute__((section("__bug_table"))); @@ -3396,6 +3397,7 @@ char * get_asm_string (void) return (char *) "A string"; #endif } +#endif /* This checks another constructs with local labels. */ extern unsigned char alld_stuff[]; @@ -3687,7 +3689,9 @@ void asm_test(void) the global one, not the local decl from this function. */ asm volatile(".weak override_func3\n.set override_func3, base_func"); override_func3(); +#ifndef __i386__ printf("asmstr: %s\n", get_asm_string()); +#endif asm_local_label_diff(); #endif asm_local_statics(); diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 5f32cbc..bae00c4 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -67,7 +67,7 @@ NORUN = 42_function_pointer.test : NORUN = true # Some tests might need different flags -FLAGS = +FLAGS = -lm 76_dollars_in_identifiers.test : FLAGS += -fdollars-in-identifiers # These tests run several snippets from the same file one by one