Re: [Tinycc-devel] Problem after compiling tiny CC

2021-06-30 Thread Clive Tovero via Tinycc-devel
> No, 'tcc -ar' should behave like 'ar'

This makes sense--looking at it as a link-time problem, rather than an 
archiving problem.  Just to be clear, "ar" is a library archiver, not a linker. 
 Maybe it is best not to conflate them.

In my example with Femtolisp, I added "-ltcc1" when using gcc to link to the 
static low level library ("libllt.a") compiled with tcc and archived with 
either "ar" or "tcc -ar".  The gcc linker resolved the symbols, and the tests 
worked.  Easy enough.  I'm sure there are other corner cases, like creating 
shared libraries using static ones, which are harder.

> The easiest way to achieve this is to compile and link with the same program. 
>   

The easiest way for me was to first understand what I was trying to do. :) This 
topic might make a good FAQ item.  Thanks for your comments.    

arrivederci

-Original Message-
From: Michael Matz 
To: Clive Tovero via Tinycc-devel 
Sent: Wed, Jun 30, 2021 11:30 am
Subject: Re: [Tinycc-devel] Problem after compiling tiny CC

Hello,

On Sat, 26 Jun 2021, Elijah Stone wrote:

> On Sat, 26 Jun 2021, Clive Tovero via Tinycc-devel wrote:
>>  Also watch out for "ar", this will cause the problem too.
>
> Perhaps 'tcc -ar' should add libtcc.a automatically (unless you tell it not 
> to)?  That way it would be possible to compile a static library with tcc and 
> link a gcc app to it.

No, 'tcc -ar' should behave like 'ar' (within the implemented features). 
It can't simply add random objects from random libraries to the output it 
creates.  There's a proposal somewhere to extend the ar format to be able 
to specify dependencies on libraries for the included objects, that would 
be a possible half-solution.  It's only a half-solution because it 
wouldn't specify search paths for the dependencies and hence would require 
putting the support libs into a default lib path forever (i.e. it would 
rules out the possibility to put that support lib in a compiler specific 
path like GCC is doing for e.g. libgcc.a).

The situation is the same as when trying to use gcc to link stuff compiled 
by g++, or to build with icc and link with clang, or when linking with ld 
directly, or the old problem of compiling with -pthread but not also 
linking with it.  If you do that you need to know how to link the 
compilers runtime libs into the result.  The easiest way to achieve this 
is to compile and link with the same program.

(for this specific instance of the problem with __mzerosf we could 
possibly find an alternate solution, but I think we shouldn't bother as 
there are other instances that can't be easily changed).


Ciao,
Michael.

___
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] Problem after compiling tiny CC

2021-06-30 Thread Michael Matz

Hello,

On Sat, 26 Jun 2021, Elijah Stone wrote:


On Sat, 26 Jun 2021, Clive Tovero via Tinycc-devel wrote:

 Also watch out for "ar", this will cause the problem too.


Perhaps 'tcc -ar' should add libtcc.a automatically (unless you tell it not 
to)?  That way it would be possible to compile a static library with tcc and 
link a gcc app to it.


No, 'tcc -ar' should behave like 'ar' (within the implemented features). 
It can't simply add random objects from random libraries to the output it 
creates.  There's a proposal somewhere to extend the ar format to be able 
to specify dependencies on libraries for the included objects, that would 
be a possible half-solution.  It's only a half-solution because it 
wouldn't specify search paths for the dependencies and hence would require 
putting the support libs into a default lib path forever (i.e. it would 
rules out the possibility to put that support lib in a compiler specific 
path like GCC is doing for e.g. libgcc.a).


The situation is the same as when trying to use gcc to link stuff compiled 
by g++, or to build with icc and link with clang, or when linking with ld 
directly, or the old problem of compiling with -pthread but not also 
linking with it.  If you do that you need to know how to link the 
compilers runtime libs into the result.  The easiest way to achieve this 
is to compile and link with the same program.


(for this specific instance of the problem with __mzerosf we could 
possibly find an alternate solution, but I think we shouldn't bother as 
there are other instances that can't be easily changed).



Ciao,
Michael.

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


Re: [Tinycc-devel] Problem after compiling tiny CC

2021-06-28 Thread Clive Tovero via Tinycc-devel
On Sat, 26 Jun 2021 01:52:36 -0700 (PDT) Elijah Stone via Tinycc-devel 
wrote:
> Perhaps 'tcc -ar' should add libtcc.a automatically (unless you tell 
it not to)? That way it would be possible to compile a static library 
with tcc and link a gcc app to it.


Whether opt-in or opt-out, it would be nice to have this in tcc. I guess 
the downside is more complexity in tcc.


I built Femtolisp as a non-trivial mixed test (gcc/tcc):

https://github.com/JeffBezanson/femtolisp

I specified tcc as the compiler for its separate static, low-leve 
library in "../llt/Makefile" and kept gcc in "./Makefile" for the rest.  
I was able to compile and successfully run the test suite with this 
mixed situation, using "ar -M" and a small MRI script to archive the 
low-level library with tcc.  Libtool might have been another (better?) 
option to generate the static library.



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


Re: [Tinycc-devel] Problem after compiling tiny CC

2021-06-26 Thread Elijah Stone

On Sat, 26 Jun 2021, Clive Tovero via Tinycc-devel wrote:

Also watch out for "ar", this will cause the problem too.


Perhaps 'tcc -ar' should add libtcc.a automatically (unless you tell it 
not to)?  That way it would be possible to compile a static library with 
tcc and link a gcc app to it.


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


Re: [Tinycc-devel] Problem after compiling tiny CC

2021-06-25 Thread Clive Tovero via Tinycc-devel

Automatically. :)

Turns out I had an old version of tcc installed.  Removing it and 
installing the latest corrected the problem with tcc.


Also watch out for "ar", this will cause the problem too.

On 6/26/21 1:26 AM, Clive Tovero wrote:

> should be automatically linked

Maybe "semi-automatically"... ;)




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


Re: [Tinycc-devel] Problem after compiling tiny CC

2021-06-25 Thread Clive Tovero via Tinycc-devel

> should be automatically linked

Maybe "semi-automatically"... ;)

clive@akira:~/temp$ tinycc/tcc -v
tcc version 0.9.27 - b5d4b90 (x86_64 Linux)
clive@akira:~/temp$ cat b.c
int b(int x)
{
    float y = x;
    -y; /* generates the reference to __mzerosf */
    return y;
}
clive@akira:~/temp$ tinycc/tcc -c b.c
clive@akira:~/temp$ nm b.o
 T b
 U __mzerosf
clive@akira:~/temp$ gcc -shared -o b.so b.o
clive@akira:~/temp$ ./a
./b.so: undefined symbol: __mzerosf

But I also got the OP's error with tcc:

clive@akira:~/temp$ tinycc/tcc -shared -o b.so b.c
clive@akira:~/temp$ ./a
./b.so: undefined symbol: __mzerosf

On 6/25/21 6:11 PM, Elijah Stone wrote:

On Fri, 25 Jun 2021, LOPEZ OLIVIER wrote:
I actually got an error when I dlopen the library compiled by tcc (no 
error when I compil it with gcc).


The error is : “undefined symbol: __mzerosf”


__mzerosf is part of the tcc runtime library, which should be 
automatically linked in with everything.  If you linked with gcc or l, 
though, it wouldn't know to do that so the symbol wouldn't be 
resolved. Make sure you're linking with tcc.





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


Re: [Tinycc-devel] Problem after compiling tiny CC

2021-06-25 Thread Elijah Stone

On Fri, 25 Jun 2021, LOPEZ OLIVIER wrote:
I actually got an error when I dlopen the library compiled by tcc (no 
error when I compil it with gcc).


The error is : “undefined symbol: __mzerosf”


__mzerosf is part of the tcc runtime library, which should be 
automatically linked in with everything.  If you linked with gcc or l, 
though, it wouldn't know to do that so the symbol wouldn't be resolved. 
Make sure you're linking with tcc.___
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel