[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues
From: |
Christian Jullien |
Subject: |
Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues |
Date: |
Sat, 15 Oct 2016 06:52:59 +0200 |
Ok,
The point is that it compiles ROOTB but then a single line program using only
ISO include and std C library fails because of __aligned in a **system** header.
I agree that __aligned is a probably a macro or a gcc FreeBSD specific
extension, but no one wants to change it source file (or Makefile) when he the
switch from gcc to tcc
To be more clear, let me start again from scratch (Don’t miss *Linux* in banner
with -v and -vv)
== MY ENV
$ uname -a
FreeBSD freebsd.eligis.com 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420:
Thu Sep 29 03:40:55 UTC 2016 address@hidden:/usr/obj/usr/src/sys/GENERIC
i386
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc48/gcc/i386-portbld-freebsd11.0/4.8.5/lto-wrapper
Target: i386-portbld-freebsd11.0
Configured with: /wrkdirs/usr/ports/lang/gcc/work/gcc-4.8.5/configure
--disable-multilib --disable-bootstrap --disable-nls
--enable-gnu-indirect-function --libdir=/usr/local/lib/gcc48
--libexecdir=/usr/local/libexec/gcc48 --program-suffix=48
--with-as=/usr/local/bin/as --with-gmp=/usr/local
--with-gxx-include-dir=/usr/local/lib/gcc48/include/c++/
--with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection'
--with-system-zlib --with-ecj-jar=/usr/local/share/java/ecj-4.5.jar
--enable-languages=c,c++,objc,fortran,java --prefix=/usr/local
--localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/info/gcc48
--build=i386-portbld-freebsd11.0
Thread model: posix
gcc version 4.8.5 (FreeBSD Ports Collection)
== GET BRAND NEW VERSION
$ rm -r -f tinycc/
$ git clone git://repo.or.cz/tinycc.git
Cloning into 'tinycc'...
...
== CONFIGURE AND BUILD DEFAULT
$ ./configure
Binary directory /usr/local/bin
TinyCC directory /usr/local/lib/tcc
Library directory /usr/local/lib
Include directory /usr/local/include
Manual directory /usr/local/share/man
Info directory /usr/local/share/info
Doc directory /usr/local/share/doc
Target root prefix
Source path /usr/home/jullien/tinycc
C compiler gcc
Target OS FreeBSD
CPU x86
Big Endian no
gprof enabled no
cross compilers no
use libgcc no
Creating config.mak and config.h
$ gmake
gcc -o tcc.o -c tcc.c -DTCC_TARGET_I386 -Wall -g -O2
-Wdeclaration-after-statement -Wno-deprecated-declarations -Wno-strict-aliasing
-Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -Wno-uninitialized
-fno-strict-aliasing -I.
gcc -o libtcc.o -c libtcc.c -DTCC_TARGET_I386 -Wall -g -O2
-Wdeclaration-after-statement -Wno-deprecated-declarations -Wno-strict-aliasing
-Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -Wno-uninitialized
-fno-strict-aliasing -I.
...
== SANITY CHECK
$ ./tcc -v
tcc version 0.9.26 (i386 Linux)
<<= Linux??? It should be FreeBSD
$ ./tcc -vv
tcc version 0.9.26 (i386 Linux)
install: /usr/local/lib/tcc
include:
/usr/local/lib/tcc/include
/usr/local/include
/usr/include
libraries:
/usr/lib
/lib
/usr/local/lib
crt:
/usr/lib
elfinterp:
/libexec/ld-elf.so.1
== FIRST TEST (A pure ISO C program)
$ cat foo.c
#include <signal.h>
int
main() {
raise(SIGTERM);
}
$ ./tcc foo.c
In file included from foo.c:1:
In file included from /usr/include/signal.h:38:
In file included from /usr/include/sys/signal.h:46:
In file included from /usr/include/machine/signal.h:36:
/usr/include/x86/signal.h:82: error: ',' expected (got "__aligned")
Ditto of course with:
$ tcc -run foo.c
Needless to say it complies with gcc and no specific options
$ gcc foo.c
$
It of course prevents me to use tcc to compile tcc and test.
-----Original Message-----
From: Michael Matz [mailto:address@hidden
Sent: vendredi 14 octobre 2016 18:17
To: Christian JULLIEN; address@hidden
Subject: Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues
Hi,
On Mon, 10 Oct 2016, Christian JULLIEN wrote:
> The problem is perhaps different:
> ./tcc -B. -Iinclude -I. -run tests/tcctest.c Compiles and works well.
> This one ic compiled with GCC
>
> I get this issue only with:
> ../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
>
> If understand well, when tcc is compiled by itself.
>
> It I add:
> tcc_define_symbol(s, "__aligned(n)",
> "__attribute__((aligned(n)))");
TCC shouldn't define __aligned, GCC doesn't either. Some FreeBSD headers
contain the equivalent of the above define, you need to find out which, and you
need to find out why it doesn't get used when using TCC. You could use grep or
"gcc -E -dD" on a file showing the problem. Search for "define.*__aligned" and
take it from there.
> The issue is different, it compiles fine this time but I get:
> ------------ 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 'memmove'
> tcc: error: undefined symbol 'memcpy'
> tcc: error: undefined symbol 'strlen'
> tcc: error: undefined symbol 'memset'
> tcc: error: undefined symbol 'memcmp'
> ....
>
> i.e. no stdlib function is found.
Does this also happen with simpler programs containing a call to e.g.
strlen? Does it only happen with -run, or also when compiling to an
executable? I.e.:
% cat x.c
extern long strlen(const char *);
int main(int argc, char*argv[]) {
return strlen(argv[0]);
}
% tcc x.c
% tcc -run x.c
If the first tcc run already fails the output of "gcc -v x.c" would be
interesting. Otherwise it's something to do with the dynamic linker or the
TCCs link editor itself and would need further investigation.
Ciao,
Michael.
- [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Christian Jullien, 2016/10/10
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Christian JULLIEN, 2016/10/10
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Christian JULLIEN, 2016/10/10
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Michael Matz, 2016/10/14
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Michael Matz, 2016/10/15
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Christian Jullien, 2016/10/16
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Michael Matz, 2016/10/16
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Michael Matz, 2016/10/16
- Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Christian Jullien, 2016/10/17
Re: [Tinycc-devel] [FreeBSD support] __aligned(n) + __pure issues, Christian JULLIEN, 2016/10/17