From 4b3c6e74aba07d61e91b2e0ba7190483a0f9f000 Mon Sep 17 00:00:00 2001 From: grischka Date: Sun, 23 Jul 2017 21:24:11 +0200 Subject: tccgen: nodata_wanted fix, default ONE_SOURCE, etc... tccgen.c: doubles need to be aligned, on ARM. The section_reserve() in init_putv does not do that. -D ONE_SOURCE: is now the default and not longer needed. Also, tcc.h now sets the default native target. These both make compiling tcc simple as "gcc tcc.c -o tcc -ldl" again. arm-asm.c: enable pseudo asm also for inline asm tests/tests2/Makefile: disable bitfield tests except on windows and x86_64 and don't generate-always tcc.c: fix a loop with -dt on errors configure: print compiler version (as recognized) tccpp.c: actually define symbols for tcc -dt clear static variables (needed for -dt or libtcc usage) 96_nodata_wanted.c: use __label__ instead of asm lib/files: use native symbols (__i386__ etc.) instead of TCC_TARGET_... --- tests/tests2/95_bitfields.c | 9 ++- tests/tests2/95_bitfields.expect | 149 +++++++++++++++++++++++++++++++++++ tests/tests2/95_bitfields_ms.expect | 3 - tests/tests2/96_nodata_wanted.c | 82 ++++++++++--------- tests/tests2/96_nodata_wanted.expect | 21 ++--- tests/tests2/Makefile | 6 +- 6 files changed, 216 insertions(+), 54 deletions(-) create mode 100644 tests/tests2/95_bitfields.expect (limited to 'tests/tests2') diff --git a/tests/tests2/95_bitfields.c b/tests/tests2/95_bitfields.c index 7edbeed..683becf 100644 --- a/tests/tests2/95_bitfields.c +++ b/tests/tests2/95_bitfields.c @@ -87,8 +87,10 @@ # define P #endif +printf("\n\n" + 2*top); #define TEST 1 #include SELF +top = 0; #define TEST 2 #include SELF #define TEST 3 @@ -99,7 +101,6 @@ #include SELF #define TEST 6 #include SELF -printf("\n\n"); #if PACK # pragma pack(pop) @@ -174,7 +175,7 @@ void dump(void *p, int s) #define TEST_STRUCT(v1,v2,v3,v4,v5) { \ struct __s _s, *s = & _s; \ - printf("---- TEST %d%s%s%s ----\n", \ + printf("\n---- TEST %d%s%s%s ----\n" + top, \ TEST, MS_BF?" - MS-BITFIELDS":"", \ PACK?" - PACKED":"", \ ALIGN?" - WITH ALIGN":""); \ @@ -184,7 +185,7 @@ void dump(void *p, int s) s->x = v1, s->y = v2, s->z = v3, s->a += v4, ++s->a, s->b = v5; \ printf("bits as set : "), dump(s, sizeof *s); \ printf("values :"), pv(x), pv(y), pv(z), pv(a), pv(b), printf("\n"); \ - printf("align/size : %d %d\n\n", alignof(struct __s),sizeof(struct __s)); \ + printf("align/size : %d %d\n", alignof(struct __s),sizeof(struct __s)); \ } #ifdef _MSC_VER @@ -203,6 +204,8 @@ void dump(void *p, int s) #define SELF "95_bitfields.c" +int top = 1; + int main() { #define MS_BF MS_BITFIELDS diff --git a/tests/tests2/95_bitfields.expect b/tests/tests2/95_bitfields.expect new file mode 100644 index 0000000..6a8fd9a --- /dev/null +++ b/tests/tests2/95_bitfields.expect @@ -0,0 +1,149 @@ +---- TEST 1 ---- +bits in use : 0000001FFFFFFFFF007F0FFF +bits as set : 000000076055555500440333 +values : 333 44 555555 06 07 +align/size : 4 12 + +---- TEST 2 ---- +bits in use : 000000000000003F7FFFFFFFFFFFFFFF00000000003F0FFF +bits as set : 0000000000000025123456789ABCDEF000000000001E0003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 8 24 + +---- TEST 3 ---- +bits in use : 001F1F1F000003FF +bits as set : 000E0619000002F5 +values : 15 17 19 06 0e +align/size : 4 8 + +---- TEST 4 ---- +bits in use : 0007FFFF00000027 +bits as set : 00078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 4 8 + +---- TEST 5 ---- +bits in use : FFFFFF3FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 007744000000007800000000300000000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 8 24 + +---- TEST 6 ---- +bits in use : 0000007000FFFFFFFFFFFFFF +bits as set : 00000030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 4 12 + + + +---- TEST 1 - PACKED ---- +bits in use : FFFFFFFFFFFFFF +bits as set : 3B02AAAAAC4333 +values : 333 44 555555 06 07 +align/size : 1 7 + +---- TEST 2 - PACKED ---- +bits in use : 7FFFFFFFFFFFFFFFFFFFFF +bits as set : 4A48D159E26AF37BC1E003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 1 11 + +---- TEST 3 - PACKED ---- +bits in use : 7FFF000003FF +bits as set : 38D9000002F5 +values : 15 17 19 06 0e +align/size : 1 6 + +---- TEST 4 - PACKED ---- +bits in use : 07FFFF00000027 +bits as set : 078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 1 7 + +---- TEST 5 - PACKED ---- +bits in use : FFFFFF07FFFFFFFFFFFFFFFF9FFFFFFFFFFF +bits as set : 007744000000000F18000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 1 18 + +---- TEST 6 - PACKED ---- +bits in use : 007000FFFFFFFFFFFFFF +bits as set : 0030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 1 10 + + + +---- TEST 1 - WITH ALIGN ---- +bits in use : 000000000000001FFFFFFFFF007F0FFF +bits as set : 00000000000000076055555500440333 +values : 333 44 555555 06 07 +align/size : 16 16 + +---- TEST 2 - WITH ALIGN ---- +bits in use : 0000000000000000000000000000003F7FFFFFFFFFFFFFFF00000000003F0FFF +bits as set : 00000000000000000000000000000025123456789ABCDEF000000000001E0003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 16 32 + +---- TEST 3 - WITH ALIGN ---- +bits in use : 0000000000000000000000000000001F000000000000000000001F1F000003FF +bits as set : 0000000000000000000000000000000E000000000000000000000619000002F5 +values : 15 17 19 06 0e +align/size : 16 32 + +---- TEST 4 - WITH ALIGN ---- +bits in use : 0007FFFF00000027 +bits as set : 00078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 4 8 + +---- TEST 5 - WITH ALIGN ---- +bits in use : FFFFFF3FFFFFFFFF000000003FFFFFFF00001FFFFFFFFFFF +bits as set : 007744000000007800000000300000000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 8 24 + +---- TEST 6 - WITH ALIGN ---- +bits in use : 0000007000FFFFFFFFFFFFFF +bits as set : 00000030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 4 12 + + + +---- TEST 1 - PACKED - WITH ALIGN ---- +bits in use : 000000000000000000FFFFFFFFFFFFFF +bits as set : 0000000000000000003B02AAAAAC4333 +values : 333 44 555555 06 07 +align/size : 16 16 + +---- TEST 2 - PACKED - WITH ALIGN ---- +bits in use : 3F01FFFFFFFFFFFFFFFFFFFF +bits as set : 250048D159E26AF37BC1E003 +values : 03 1e 123456789abcdef0 05 fffffffe +align/size : 1 12 + +---- TEST 3 - PACKED - WITH ALIGN ---- +bits in use : 1F03FF000003FF +bits as set : 0E00D9000002F5 +values : 15 17 19 06 0e +align/size : 1 7 + +---- TEST 4 - PACKED - WITH ALIGN ---- +bits in use : 07FFFF00000027 +bits as set : 078F0F00000023 +values : 03 ffffffff 0f fffffff8 78 +align/size : 1 7 + +---- TEST 5 - PACKED - WITH ALIGN ---- +bits in use : FFFFFF07FFFFFFFFFFFFFFFF9FFFFFFFFFFF +bits as set : 007744000000000F18000000000123456789 +values : 0000000123456789 f0000000 0000000000000078 44 77 +align/size : 1 18 + +---- TEST 6 - PACKED - WITH ALIGN ---- +bits in use : 007000FFFFFFFFFFFFFF +bits as set : 0030002001FD00000004 +values : 01 02 03 04 fffffffd +align/size : 1 10 diff --git a/tests/tests2/95_bitfields_ms.expect b/tests/tests2/95_bitfields_ms.expect index 6b5c3f9..8ccafb7 100644 --- a/tests/tests2/95_bitfields_ms.expect +++ b/tests/tests2/95_bitfields_ms.expect @@ -147,6 +147,3 @@ bits in use : 00000000700000FFFFFFFFFFFFFF bits as set : 000000003000002001FD00000004 values : 01 02 03 04 fffffffd align/size : 1 14 - - - diff --git a/tests/tests2/96_nodata_wanted.c b/tests/tests2/96_nodata_wanted.c index 1f022c9..b594938 100644 --- a/tests/tests2/96_nodata_wanted.c +++ b/tests/tests2/96_nodata_wanted.c @@ -25,50 +25,60 @@ void foo() { short w = &foo; /* 2 cast warnings */ } -#elif defined test_data_suppression -#include +#elif defined test_data_suppression_off || defined test_data_suppression_on -#define ASMLABELS(s) \ - __asm__(".global d"#s",t"#s"\n.data\nd"#s":\n.text\nt"#s":\n") +#if defined test_data_suppression_on +# define SKIP 1 +#else +# define SKIP 0 +#endif -#define PROG \ - static void *p = (void*)&main;\ - static char cc[] = "static string";\ - static double d = 8.0;\ - static struct __attribute__((packed)) {\ - unsigned x : 12;\ - unsigned char y : 7;\ - unsigned z : 28, a: 4, b: 5;\ - } s = { 0x333,0x44,0x555555,6,7 };\ - printf(" static data: %d - %.1f - %.1f - %s - %s\n",\ - sizeof 8.0, 8.0, d, __FUNCTION__, cc);\ - printf(" static bitfields: %x %x %x %x %x\n", s.x, s.y, s.z, s.a, s.b); +#include +/* some gcc headers #define __attribute__ to empty if it's not gcc */ +#undef __attribute__ int main() { - extern char ds1[],ts1[]; - extern char ds2[],ts2[]; - extern char de1[],te1[]; - extern char de2[],te2[]; + __label__ ts0, te0, ts1, te1; + int tl, dl; - printf("suppression off\n"); - if (1) { - ASMLABELS(s1); - PROG - ASMLABELS(e1); - } - printf(" data length is %s\n", de1 - ds1 ? "not 0":"0"); - printf(" text length is %s\n", te1 - ts1 ? "not 0":"0"); + static char ds0 = 0; + static char de0 = 0; + /* get reference size of empty jmp */ +ts0:; + if (!SKIP) {} +te0:; + dl = -(&de0 - &ds0); + tl = -(&&te0 - &&ts0); - printf("suppression on\n"); - if (0) { - ASMLABELS(s2); - PROG - ASMLABELS(e2); + /* test data and code suppression */ + static char ds1 = 0; +ts1:; + if (!SKIP) { + static void *p = (void*)&main; + static char cc[] = "static string"; + static double d = 8.0; + + static struct __attribute__((packed)) { + unsigned x : 12; + unsigned char y : 7; + unsigned z : 28, a: 4, b: 5; + } s = { 0x333,0x44,0x555555,6,7 }; + + printf("data:\n"); + printf(" %d - %.1f - %.1f - %s - %s\n", + sizeof 8.0, 8.0, d, __FUNCTION__, cc); + printf(" %x %x %x %x %x\n", + s.x, s.y, s.z, s.a, s.b); } - printf(" data length is %x\n", de2 - ds2); - printf(" text length is %X\n", te2 - ts2); - return 0; +te1:; + static char de1 = 0; + + dl += &de1 - &ds1; + tl += &&te1 - &&ts1; + printf("size of data/text:\n %s/%s\n", + dl ? "non-zero":"zero", tl ? "non-zero":"zero"); + printf("# %d/%d\n", dl, tl); } #endif diff --git a/tests/tests2/96_nodata_wanted.expect b/tests/tests2/96_nodata_wanted.expect index 9fd35ca..6e54f24 100644 --- a/tests/tests2/96_nodata_wanted.expect +++ b/tests/tests2/96_nodata_wanted.expect @@ -11,12 +11,15 @@ 96_nodata_wanted.c:25: warning: assignment makes integer from pointer without a cast 96_nodata_wanted.c:25: warning: nonportable conversion from pointer to char/short -[test_data_suppression] -suppression off - static data: 8 - 8.0 - 8.0 - main - static string - static bitfields: 333 44 555555 6 7 - data length is not 0 - text length is not 0 -suppression on - data length is 0 - text length is 0 +[test_data_suppression_off] +data: + 8 - 8.0 - 8.0 - main - static string + 333 44 555555 6 7 +size of data/text: + non-zero/non-zero +# 111/193 + +[test_data_suppression_on] +size of data/text: + zero/zero +# 0/0 diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 4dd1591..c75db8c 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -24,7 +24,7 @@ ifeq (-$(findstring gcc,$(CC))-,--) SKIP += $(patsubst %.expect,%.test,$(GEN-ALWAYS)) endif ifeq (-$(CONFIG_WIN32)-$(CONFIG_i386)$(CONFIG_arm)-,--yes-) - SKIP += 95_bitfields_ms.test # type_align is differnt on 32bit-non-windows + SKIP += 95_bitfields%.test # type_align is differnt on 32bit-non-windows endif # Some tests might need arguments @@ -46,7 +46,7 @@ FLAGS = # Always generate certain .expects (don't put these in the GIT), GEN-ALWAYS = -GEN-ALWAYS += 95_bitfields.expect +# GEN-ALWAYS += 95_bitfields.expect # does not work # using the ms compiler for the really ms-compatible bitfields 95_bitfields_ms.test : GEN = $(GEN-MSC) @@ -67,7 +67,7 @@ all test tests2.all: $(filter-out $(SKIP),$(TESTS)) ; T1 = $(TCC) $(FLAGS) $< -o a.exe && ./a.exe $(ARGS) T2 = $(TCC) $(FLAGS) -run $< $(ARGS) T3 = $(FILTER) >$*.output 2>&1 || true \ - && diff -Nbu $(filter %.expect,$^) $*.output \ + && diff -Nbu -I "^\#" $(filter %.expect,$^) $*.output \ && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS)) # run single test and update .expect file, e.g. "make tests2.37+" -- cgit v1.3.1