Hi,

On Sun, 16 Oct 2016, Christian Jullien wrote:

Ok Michael,
It is defined in sys/cdefs.h as:

#if __GNUC_PREREQ__(2, 7) || defined(__INTEL_COMPILER)
#define __dead2         __attribute__((__noreturn__))
#define __pure2         __attribute__((__const__))
#define __unused        __attribute__((__unused__))
#define __used          __attribute__((__used__))
#define __packed        __attribute__((__packed__))
#define __aligned(x)    __attribute__((__aligned__(x)))
#define __section(x)    __attribute__((__section__(x)))
#endif

Yeah, we gathered this meanwhile from grischkas research. A bug in FreeBSDs header (the bug being that there's no fallback definition of the macros that are nevertheless used unconditionally in standard headers).

Now, I do agree that we'd want to add a work around for this in tcc. I think a better work-around than defining __GNUC__ is to define the above macros instead. __GNUC__ simply has quite some side-effects. (E.g. after the patch you can't compile programs on some versions of glibc anymore because it then uses facilities of GNU C that tcc simply doesn't implement).

-    tcc_define_symbol(s, "__GNUC_MINOR__", "1");
+    tcc_define_symbol(s, "__GNUC_MINOR__", "7");

And it helps a little bit, now I get the same result as if I define
__aligned(x) __attribute__((__aligned__(x))) i.e. code compiles (with
__aligned defined) but std C library is not found.

------------ test3 ------------
../tcc -B.. -I../include -I.. -I.. -DTCC_TARGET_I386 -DONE_SOURCE -run
../tcc.c -B.. -I../include -I.. -I.. -DTCC_TARGET_I386 -DONE_SOURCE -run
../tcc.c -B.. -I../include -I.. -I.. -DTCC_TARGET_I386 -DONE_SOURCE -run
../tcc.c -B.. -I../include -I.. -I.. -run tcctest.c > test.out3
tcc: error: undefined symbol 'memcpy'
...

Yes, I wrote a paragraph about this in my initial answer of how you should start trying to corner this problem.


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to