Re: [Tinycc-devel] Crosscompiling failed

2021-04-14 Thread Vad Rulezz

Hello!

On 4/14/21 3:08 PM, Thomas Stalder wrote:
After a more in-depth analysis it appears that the patch does not 
correct the problem because c2str is not compiled on the correct platform.


The commit 
https://repo.or.cz/tinycc.git/commit/9f6b65230ac6b736698e740c4bc14c6c2f095f13 
seems 
to be blocking cross-compilation.


Do you think it is possible to go back or do you have another idea?

Thank you in advance for your reply.


If you specify --config-predefs=no to configure, c2str will not be built 
and used for compiling tcc. Is it suitable to you?



Vad

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


Re: [Tinycc-devel] Crosscompiling failed

2021-04-14 Thread Thomas Stalder
After a more in-depth analysis it appears that the patch does not
correct the problem because c2str is not compiled on the correct
platform. 

The
commit 
https://repo.or.cz/tinycc.git/commit/9f6b65230ac6b736698e740c4bc14c6c2f095f13
seems to be blocking cross-compilation.

Do you think it is possible to go back or do you have another idea?

Thank you in advance for your reply.

Le 2021-04-14T07:56:49.000+02:00, Thomas Stalder 
a écrit :

> Hello,
> 
> Since
> https://repo.or.cz/tinycc.git/commit/9f6b65230ac6b736698e740c4bc14c6c2f095f13
> cross compiling doesn't work :
> 
> btc:~/vc/a/tinycc-035ae7d/a$ ../configure
> --cross-prefix=arm-cortexa8-linux-gnueabihf- --cpu=armv7l
> 
> 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
> 
> Source path ..
> 
> C compiler  arm-cortexa8-linux-gnueabihf-gcc (0.0)
> 
> Target OS   Linux
> 
> CPU arm
> 
> Creating config.mak and config.h
> 
> btc:~/vc/a/tinycc-035ae7d/a$ make
> 
> arm-cortexa8-linux-gnueabihf-gcc -o tcc.o -c ./../tcc.c
> -DTCC_CPU_VERSION=7 -DTCC_TARGET_ARM-DONE_SOURCE=0
> -DTCC_GIT_HASH="\"modified 997fdc0\"" -Wall -O2
> -Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign
> -Wno-sign-compare -Wno-unused-result -I.
> 
> arm-cortexa8-linux-gnueabihf-gcc -o libtcc.o -c ./../libtcc.c
> -DTCC_CPU_VERSION=7 -DTCC_TARGET_ARM-DONE_SOURCE=0
> -Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing
> -Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.
> 
> arm-cortexa8-linux-gnueabihf-gcc -DC2STR ./../conftest.c -o
> c2str.exe && ./c2str.exe ./../include/tccdefs.h tccdefs_.h
> 
> /bin/sh: 1: ./c2str.exe: Exec format error
> 
> make: *** [Makefile:242: tccdefs_.h] Error 2
> 
> Because c2str is compiled with the target compiler and executed on
> the host.
> 
> To fix this problem I propose the attached patch.
> 
> If it's ok for you, I can commit. Or what if you have another idea?
> 
> Thank you in advance for your return.
> 
> Thomas
> 
> -
> ___ 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] Crosscompiling failed

2021-04-13 Thread Thomas Stalder
Hello,

Since
https://repo.or.cz/tinycc.git/commit/9f6b65230ac6b736698e740c4bc14c6c2f095f13
cross compiling doesn't work :

btc:~/vc/a/tinycc-035ae7d/a$ ../configure
--cross-prefix=arm-cortexa8-linux-gnueabihf- --cpu=armv7l

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

Source path ..

C compiler  arm-cortexa8-linux-gnueabihf-gcc (0.0)

Target OS   Linux

CPU arm

Creating config.mak and config.h

btc:~/vc/a/tinycc-035ae7d/a$ make

arm-cortexa8-linux-gnueabihf-gcc -o tcc.o -c ./../tcc.c
-DTCC_CPU_VERSION=7 -DTCC_TARGET_ARM    -DONE_SOURCE=0
-DTCC_GIT_HASH="\"modified 997fdc0\"" -Wall -O2
-Wdeclaration-after-statement -fno-strict-aliasing -Wno-pointer-sign
-Wno-sign-compare -Wno-unused-result -I.

arm-cortexa8-linux-gnueabihf-gcc -o libtcc.o -c ./../libtcc.c
-DTCC_CPU_VERSION=7 -DTCC_TARGET_ARM    -DONE_SOURCE=0
-Wall -O2 -Wdeclaration-after-statement -fno-strict-aliasing
-Wno-pointer-sign -Wno-sign-compare -Wno-unused-result -I.

arm-cortexa8-linux-gnueabihf-gcc -DC2STR ./../conftest.c -o c2str.exe
&& ./c2str.exe ./../include/tccdefs.h tccdefs_.h

/bin/sh: 1: ./c2str.exe: Exec format error

make: *** [Makefile:242: tccdefs_.h] Error 2

Because c2str is compiled with the target compiler and executed on the
host.

To fix this problem I propose the attached patch.

If it's ok for you, I can commit. Or what if you have another idea?

Thank you in advance for your return.

Thomas



fixcross.patch
Description: Binary data
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Crosscompiling

2014-06-30 Thread Markus Bergholz
On Sun, Jun 29, 2014 at 11:17 PM, grischka gris...@gmx.de wrote:

 Markus Bergholz wrote:

 However, both end up with Mex file entry point it missing.


 __declspec(dllexport) Mex file entry point


This works, thank you!


 -- gr


 Thanks in advanced,
 Markus



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




-- 
icq: 167498924
XMPP|Jabber: marku...@jabber.ccc.de
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Crosscompiling

2014-06-29 Thread Markus Bergholz
On Sat, Jun 28, 2014 at 6:44 PM, Michael Matz matz@frakked.de wrote:



 On Fri, 27 Jun 2014, Markus Bergholz wrote:

Make it clear where “mexPrintf” is defined and why it is not
   effective.


 mexPrintf is defined in /usr/include/octave-3.8.1/octave/mexproto.h
 afaiu.


 That's a declaration, not a definition.  The definition comes from some
 Octave internal library.  On linux you can build shared libraries that
 contain references to undefined symbols (like 'mexPrintf') that will then
 be resolved when loading the library (Octave itself or some library it
 depends on will define that symbol).  That's what happens for your working
 example (your helloworld.mex will actually be an ELF shared library
 containing unresolved references to mexPrintf).

 When you try the same for Windows you'll actually build a DLL.  When it's
 supposed to contain references to external symbols then you at least need a
 .def file that describes which library will provide that symbol later.
 You'll also need to generate a .lib file describing the symbols exported by
 your helloworld.mex (so that octave can load it).

 Generally for Octave the right way to create .mex files seems to be to use
 the helper program/script mkoctfile (with --mex), which presumably contains
 all the right libraries and other link parameters for each platform.  If
 Octave supports external commands on Windows at all.

 This all is not TCC specific, it's a problem in how you use Octaves system
 for C bindings.  You'll probably get better answers asking their developers.



Thanks for your long explanation!

After creating a .def file using tiny_imp M:\R2013b\bin\win64\libmex.dll I
can compile it without any error or warning on Windows

tcc.exe mexample.c libmex.def -IM:\R2013\extern\include\ -shared -o
mexample11.mexw64

and on Linux

x86_64-win32-tcc mexample.c libmex.def -I /usr/include/octave-3.8.1/octave/
-shared -o mexample10.mexw64

However, both end up with Mex file entry point it missing.
Same for
tcc.exe mexample.c -IM:\R2013b\extern\include\ -shared
-LM:\R2013b\bin\win64\ -lmex -o mexample12.mexw64

So I don't understand the library part for Windows systems...can you say a
few more words about it?

Thanks in advanced,
Markus
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Crosscompiling

2014-06-29 Thread grischka

Markus Bergholz wrote:

However, both end up with Mex file entry point it missing.


__declspec(dllexport) Mex file entry point

-- gr



Thanks in advanced,
Markus



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


Re: [Tinycc-devel] Crosscompiling

2014-06-28 Thread Michael Matz



On Fri, 27 Jun 2014, Markus Bergholz wrote:


  Make it clear where “mexPrintf” is defined and why it is not
  effective.


mexPrintf is defined in /usr/include/octave-3.8.1/octave/mexproto.h afaiu.


That's a declaration, not a definition.  The definition comes from some 
Octave internal library.  On linux you can build shared libraries that 
contain references to undefined symbols (like 'mexPrintf') that will then 
be resolved when loading the library (Octave itself or some library it 
depends on will define that symbol).  That's what happens for your working 
example (your helloworld.mex will actually be an ELF shared library 
containing unresolved references to mexPrintf).


When you try the same for Windows you'll actually build a DLL.  When it's 
supposed to contain references to external symbols then you at least need 
a .def file that describes which library will provide that symbol later. 
You'll also need to generate a .lib file describing the symbols exported 
by your helloworld.mex (so that octave can load it).


Generally for Octave the right way to create .mex files seems to be to use 
the helper program/script mkoctfile (with --mex), which presumably 
contains all the right libraries and other link parameters for each 
platform.  If Octave supports external commands on Windows at all.


This all is not TCC specific, it's a problem in how you use Octaves system 
for C bindings.  You'll probably get better answers asking their 
developers.



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


Re: [Tinycc-devel] Crosscompiling

2014-06-27 Thread YX Hao
Have you consider that compiler searches its own header path and header files 
have environment switches.

 

Make it clear where “mexPrintf” is defined and why it is not effective.

 

  _  

From: tinycc-devel-bounces+lifenjoiner=163@nongnu.org 
[mailto:tinycc-devel-bounces+lifenjoiner=163@nongnu.org] On Behalf Of 
Markus Bergholz
Sent: Friday, June 27, 2014 1:16 AM
To: tinycc-devel@nongnu.org
Subject: Re: [Tinycc-devel] Crosscompiling

 

 

 

On Tue, Jun 24, 2014 at 11:25 PM, grischka gris...@gmx.de wrote:

Markus Bergholz wrote:

I'd tried to compile tcc itself with build_cross=yes and tried

 ./x86_64-win32-tcc -nostdinc -I /usr/x86_64-w64-mingw32/include/ 
../helloworld.c -o helloworld-gcc.exe

[...]


/usr/x86_64-w64-mingw32/include//vadefs.h:33: error: #error VARARGS not 
implemented for this compiler


If you love problems I know a lot of options that you can try. ;)

Otherwise

./configure --enabie-cross  make  make install
cd win32/examples
x86_64-win32-tcc -v hello_win.c

did work with 0.9.26.  And still should if it hasn't been broken.

--gr

 

Indeed, this works fine for hello_win.c

But the tcc crosscompiler said that mexprintf is undefined

$ tcc -v -I /usr/include/octave-3.8.1/octave/ -shared mexample.c -o mexample.mex
tcc version 0.9.26 (x86-64 Linux)
- mexample.c
- mexample.mex
$ x86_64-win32-tcc -v -I /usr/include/octave-3.8.1/octave/ -shared mexample.c 
-o mexample.mex
tcc version 0.9.26 (x86-64 Win64)
- mexample.c
tcc: error: undefined symbol 'mexPrintf'
$ x86_64-win32-tcc -v -I ~/R2013a/extern/include/ -shared mexample.c -o 
mexample.mex
tcc version 0.9.26 (x86-64 Win64)
- mexample.c
tcc: error: undefined symbol 'mexPrintf' 

And ideas why this just work with native tcc but not with tcc crosscompiler?

 

 



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




-- 
icq: 167498924
XMPP|Jabber: marku...@jabber.ccc.de 

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


Re: [Tinycc-devel] Crosscompiling

2014-06-27 Thread Markus Bergholz
On Fri, Jun 27, 2014 at 1:30 PM, YX Hao lifenjoi...@163.com wrote:

  Have you consider that compiler searches its own header path and header
 files have environment switches.



 Make it clear where “mexPrintf” is defined and why it is not effective.


mexPrintf is defined in /usr/include/octave-3.8.1/octave/mexproto.h
afaiu. So it is already in the include path. Any ideas?

grep mexPrintf /usr/include/octave-3.8.1/octave/*
/usr/include/octave-3.8.1/octave/mexproto.h:extern OCTINTERP_API int
mexPrintf (const char *fmt, ...);
/usr/include/octave-3.8.1/octave/mexproto.h:  mexPrintf
(Assertion failed: %s, at line %d of file \%s\.\n%s\n, \
/usr/include/octave-3.8.1/octave/mexproto.h:  mexPrintf
(Assertion failed at line %d of file \%s\.\n%s\n, \





   --

 *From:* tinycc-devel-bounces+lifenjoiner=163@nongnu.org [mailto:
 tinycc-devel-bounces+lifenjoiner=163@nongnu.org] *On Behalf Of *Markus
 Bergholz
 *Sent:* Friday, June 27, 2014 1:16 AM
 *To:* tinycc-devel@nongnu.org
 *Subject:* Re: [Tinycc-devel] Crosscompiling







 On Tue, Jun 24, 2014 at 11:25 PM, grischka gris...@gmx.de wrote:

 Markus Bergholz wrote:

 I'd tried to compile tcc itself with build_cross=yes and tried

  ./x86_64-win32-tcc -nostdinc -I /usr/x86_64-w64-mingw32/include/
 ../helloworld.c -o helloworld-gcc.exe

 [...]


 /usr/x86_64-w64-mingw32/include//vadefs.h:33: error: #error VARARGS not
 implemented for this compiler


 If you love problems I know a lot of options that you can try. ;)

 Otherwise

 ./configure --enabie-cross  make  make install
 cd win32/examples
 x86_64-win32-tcc -v hello_win.c

 did work with 0.9.26.  And still should if it hasn't been broken.

 --gr



 Indeed, this works fine for hello_win.c

 But the tcc crosscompiler said that mexprintf is undefined

 $ tcc -v -I /usr/include/octave-3.8.1/octave/ -shared mexample.c -o
 mexample.mex
 tcc version 0.9.26 (x86-64 Linux)
 - mexample.c
 - mexample.mex
 $ x86_64-win32-tcc -v -I /usr/include/octave-3.8.1/octave/ -shared
 mexample.c -o mexample.mex
 tcc version 0.9.26 (x86-64 Win64)
 - mexample.c
 tcc: error: undefined symbol 'mexPrintf'
 $ x86_64-win32-tcc -v -I ~/R2013a/extern/include/ -shared mexample.c -o
 mexample.mex
 tcc version 0.9.26 (x86-64 Win64)
 - mexample.c
 tcc: error: undefined symbol 'mexPrintf'

 And ideas why this just work with native tcc but not with tcc
 crosscompiler?







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




 --
 icq: 167498924
 XMPP|Jabber: marku...@jabber.ccc.de

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




-- 
icq: 167498924
XMPP|Jabber: marku...@jabber.ccc.de
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Crosscompiling

2014-06-27 Thread YX Hao
Hi,

 Markus Bergholz
 Sent: Saturday, June 28, 2014 2:55 AM
 
 On Fri, Jun 27, 2014 at 1:30 PM, YX Hao lifenjoi...@163.com wrote:
 
 
   Have you consider that compiler searches its own header path and header
 files have environment switches.
 
^
Read the whole file and check the switches for preprocess.
For example: #ifdef ..., #ifndef ..., #if ...
TCC's -E option could help.

 
 
   Make it clear where “mexPrintf” is defined and why it is not effective.
 
 
 mexPrintf is defined in /usr/include/octave-3.8.1/octave/mexproto.h afaiu.
 So it is already in the include path. Any ideas?
 
 grep mexPrintf /usr/include/octave-3.8.1/octave/*
 /usr/include/octave-3.8.1/octave/mexproto.h:extern OCTINTERP_API int
 mexPrintf (const char *fmt, ...);
 /usr/include/octave-3.8.1/octave/mexproto.h:  mexPrintf
 (Assertion failed: %s, at line %d of file \%s\.\n%s\n, \
 /usr/include/octave-3.8.1/octave/mexproto.h:  mexPrintf
 (Assertion failed at line %d of file \%s\.\n%s\n, \
 



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


Re: [Tinycc-devel] Crosscompiling

2014-06-26 Thread Markus Bergholz
On Tue, Jun 24, 2014 at 11:25 PM, grischka gris...@gmx.de wrote:

 Markus Bergholz wrote:

 I'd tried to compile tcc itself with build_cross=yes and tried

  ./x86_64-win32-tcc -nostdinc -I /usr/x86_64-w64-mingw32/include/
 ../helloworld.c -o helloworld-gcc.exe
 [...]

 /usr/x86_64-w64-mingw32/include//vadefs.h:33: error: #error VARARGS not
 implemented for this compiler


 If you love problems I know a lot of options that you can try. ;)

 Otherwise

 ./configure --enabie-cross  make  make install
 cd win32/examples
 x86_64-win32-tcc -v hello_win.c

 did work with 0.9.26.  And still should if it hasn't been broken.

 --gr



Indeed, this works fine for hello_win.c

But the tcc crosscompiler said that mexprintf is undefined

$ tcc -v -I /usr/include/octave-3.8.1/octave/ -shared mexample.c -o
mexample.mex
tcc version 0.9.26 (x86-64 Linux)
- mexample.c
- mexample.mex
$ x86_64-win32-tcc -v -I /usr/include/octave-3.8.1/octave/ -shared
mexample.c -o mexample.mex
tcc version 0.9.26 (x86-64 Win64)
- mexample.c
tcc: error: undefined symbol 'mexPrintf'
$ x86_64-win32-tcc -v -I ~/R2013a/extern/include/ -shared mexample.c -o
mexample.mex
tcc version 0.9.26 (x86-64 Win64)
- mexample.c
tcc: error: undefined symbol 'mexPrintf'

And ideas why this just work with native tcc but not with tcc crosscompiler?





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




-- 
icq: 167498924
XMPP|Jabber: marku...@jabber.ccc.de
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


[Tinycc-devel] Crosscompiling

2014-06-24 Thread Markus Bergholz
Hello,
I'd like to crosscompile (from Linux for Windows) Matlab/Octave mex
functions written in C with tcc.
I can compile those files in Linux with

tcc -I/usr/include/octave-3.8.1/octave/ -lm -shared mexample.c -o mexample.mex

They are runable with both, Matlab and Octave without any problems.
But what do I have to do to crosscompile it for windows?
If I tried a simple helloworld.c it ends in an error

tcc -nostdinc -I /usr/x86_64-w64-mingw32/include/ helloworld.c -o
helloworld-tcc.exe
In file included from helloworld.c:1:
In file included from /usr/x86_64-w64-mingw32/include//stdio.h:9:
In file included from /usr/x86_64-w64-mingw32/include//crtdefs.h:10:
/usr/x86_64-w64-mingw32/include//_mingw.h:268: error: #error Only Win32
target is supported!

I'd tried to compile tcc itself with build_cross=yes and tried

 ./x86_64-win32-tcc -nostdinc -I /usr/x86_64-w64-mingw32/include/
../helloworld.c -o helloworld-gcc.exe
In file included from ../helloworld.c:1:
In file included from /usr/x86_64-w64-mingw32/include//stdio.h:9:
In file included from /usr/x86_64-w64-mingw32/include//crtdefs.h:10:
In file included from /usr/x86_64-w64-mingw32/include//_mingw.h:282:
/usr/x86_64-w64-mingw32/include//vadefs.h:33: error: #error VARARGS not
implemented for this compiler

Thanks in advance!
Markus
___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


Re: [Tinycc-devel] Crosscompiling

2014-06-24 Thread grischka

Markus Bergholz wrote:

I'd tried to compile tcc itself with build_cross=yes and tried

 ./x86_64-win32-tcc -nostdinc -I /usr/x86_64-w64-mingw32/include/ 
../helloworld.c -o helloworld-gcc.exe

[...]
/usr/x86_64-w64-mingw32/include//vadefs.h:33: error: #error VARARGS not 
implemented for this compiler


If you love problems I know a lot of options that you can try. ;)

Otherwise

./configure --enabie-cross  make  make install
cd win32/examples
x86_64-win32-tcc -v hello_win.c

did work with 0.9.26.  And still should if it hasn't been broken.

--gr


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