Re: [Tinycc-devel] .fill .rept broken by "Clean up 64bit immediate support"

2016-05-14 Thread Michael Matz

Hi,

[request for testing a patch below]

On Sat, 14 May 2016, Sergey Korshunoff wrote:


It might also simply be that your libc headers are incompatible with a 64bit 
compilation (e.g. if
you miss any WORDSIZE support from ). In that case we might 
have to do
more hackery, but generally it won't be possible on such a system to build much 
software cross > (to 64bit) at all.


My glibc on host is quite old (2.9) Is the new glibc on i386 allow to
compile 64 bit code? How about muslim or uclibc headers? I think we
must use a tcc headers for lib/* compilation

PS: on my host /usr/include/bits/wordsize.h is
#define __WORDSIZE  32


I see.  Well, you will have multiple problems with that and building 64bit 
software, because your system headers aren't 64bit capabable.  OTOH for 
building something cross the correct target heades are a preliminarity 
anyway, so you need some from somewhere else, for instance musl libc.


The idea of using only tcc headers for lib/* compilation might sound good 
at first, but tcc doesn't provide all standard headers (and shouldn't 
because it's not a full toolchain with C library); it really relies on the 
existence of working/compatible target headers that also the lib/* 
implementation can use.


OTOH, for the particular problem you got there might be two solutions 
inside tcc itself.  You got incompatible definitions of 'intptr_t' and 
'ssize_t', those come from TCCs stddef.h.  Now, a ISO c99 stddef.h 
shouldn't even define those two types, OTOH invalid sources might expect 
it to.


Second, at least glibc defines intptr_t and ssize_t on 32bit platforms in 
terms of 'int', not in terms of 'long', but TCC uses the latter, and from 
that the incompatible definitions result.


So, I offer two patches for you to try.  The first (removing the typedefs 
from stddef.h) is more correct, and the second might be more compatible 
with current behaviour.


If somebody could please test the _first_ patch on other systems than 
linux/x86_64 (in particular on windows) on compilation of some random 
software, I would be grateful.  It's the more correct thing to do and I'd 
like to apply it.



Ciao,
Michael.diff --git a/include/stddef.h b/include/stddef.h
index 791ba31..0033bb6 100644
--- a/include/stddef.h
+++ b/include/stddef.h
@@ -2,10 +2,8 @@
 #define _STDDEF_H
 
 typedef __SIZE_TYPE__ size_t;
-typedef __PTRDIFF_TYPE__ ssize_t;
 typedef __WCHAR_TYPE__ wchar_t;
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
-typedef __PTRDIFF_TYPE__ intptr_t;
 typedef __SIZE_TYPE__ uintptr_t;
 
 #ifndef __int8_t_defined
diff --git a/libtcc.c b/libtcc.c
index d63b86f..63b25ce 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1146,9 +1146,12 @@ LIBTCCAPI TCCState *tcc_new(void)
 #if defined TCC_TARGET_PE && defined TCC_TARGET_X86_64
 tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long long");
 tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long long");
-#else
+#elif defined(TCC_TARGET_X86_64) || defined(TCC_TARGET_ARM64)
 tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned long");
 tcc_define_symbol(s, "__PTRDIFF_TYPE__", "long");
+#else
+tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned int");
+tcc_define_symbol(s, "__PTRDIFF_TYPE__", "int");
 #endif
 
 #ifdef TCC_TARGET_PE
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Recent asm changes break Windows 64 built

2016-05-14 Thread Michael Matz

Hello,

On Sat, 14 May 2016, Christian Jullien wrote:



F:\tinycc\win64>.\tcc -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c
../lib/alloca86_64.S

../lib/alloca86_64.S:15: error: bad operand with opcode 'and'


You weren't using the most recent [mob] branch.  The above problem was 
fixed in 4f27e21 late last night.



Ciao,
Michael.

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


Re: [Tinycc-devel] tcc compilation on MSYS2

2016-05-14 Thread Chris Marshall
To be more specific, it should be possible to build the mingw version of 
tcc on cygwin (I don't know, haven't had time to try) but what I would 
like is the linux/unix version---if it builds on unix, it should be 
buildable on cygwin---as long as you don't look under the covers to find 
windows.  In my experience, the problem is when you do something like 
check for windows somewhere and then assume it is windows.  If you check 
for and use unix capabilities, you should find them on cygwin.  NOTE: if 
you then check at the end for something windows specific---everything 
breaks again.



--Chris


On 5/14/2016 11:47, David Mertens wrote:

Hello Sergey,

Is this an issue with the standard Makefile, or with the 
Windows-specific build batch (.BAT) file? FWIW, the batch file 
build-process works in at least some of the mingw setups provided by 
Strawberry Perl.


David

On Sat, May 14, 2016 at 3:24 AM, Sergey Korshunoff > wrote:


MSYS2 is current environment for Qt and other software development on
Windows. It is a mingw+cygwin with a package manager (pacman), ported
from ARCH Linux. MSYS2 allow to build
mingw32/mingw64/cygwin32/cygwin64 programs in unix-like environment.
Currenly tcc can not be build on this environment (mix of unix and
windows). I think a system name (uname output) is needed to
select/reject some code in sources of the tcc.

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




--
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan


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


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


Re: [Tinycc-devel] tcc compilation on MSYS2

2016-05-14 Thread David Mertens
Hello Sergey,

Is this an issue with the standard Makefile, or with the Windows-specific
build batch (.BAT) file? FWIW, the batch file build-process works in at
least some of the mingw setups provided by Strawberry Perl.

David

On Sat, May 14, 2016 at 3:24 AM, Sergey Korshunoff  wrote:

> MSYS2 is current environment for Qt and other software development on
> Windows. It is a mingw+cygwin with a package manager (pacman), ported
> from ARCH Linux. MSYS2 allow to build
> mingw32/mingw64/cygwin32/cygwin64 programs in unix-like environment.
> Currenly tcc can not be build on this environment (mix of unix and
> windows). I think a system name (uname output) is needed to
> select/reject some code in sources of the tcc.
>
> ___
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>



-- 
 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] tcc compilation on MSYS2

2016-05-14 Thread Chris Marshall
As someone whose primary development environment is cygwin/win7, I would 
love for tcc to build and run under cygwin.



--Chris


On 5/14/2016 03:24, Sergey Korshunoff wrote:

MSYS2 is current environment for Qt and other software development on
Windows. It is a mingw+cygwin with a package manager (pacman), ported
from ARCH Linux. MSYS2 allow to build
mingw32/mingw64/cygwin32/cygwin64 programs in unix-like environment.
Currenly tcc can not be build on this environment (mix of unix and
windows). I think a system name (uname output) is needed to
select/reject some code in sources of the tcc.

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



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


[Tinycc-devel] Recent asm changes break Windows 64 built

2016-05-14 Thread Christian Jullien
F:\tinycc\win64>.\tcc -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c
../lib/alloca86_64.S

../lib/alloca86_64.S:15: error: bad operand with opcode 'and'

 

F:\tinycc\win64>tiny_libmaker lib/libtcc1.a libtcc1.o alloca86_64.o crt1.o
wincrt1.o dllcrt1.o dllmain.o chkstk.o

Can't open file alloca86_64.o

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


[Tinycc-devel] tcc compilation on MSYS2

2016-05-14 Thread Sergey Korshunoff
MSYS2 is current environment for Qt and other software development on
Windows. It is a mingw+cygwin with a package manager (pacman), ported
from ARCH Linux. MSYS2 allow to build
mingw32/mingw64/cygwin32/cygwin64 programs in unix-like environment.
Currenly tcc can not be build on this environment (mix of unix and
windows). I think a system name (uname output) is needed to
select/reject some code in sources of the tcc.

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