tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Re : Re: Re : Re: win32: -Wl,-nostdlib: undefined sy


From: Michael Matz
Subject: Re: [Tinycc-devel] Re : Re: Re : Re: win32: -Wl,-nostdlib: undefined symbol 'memset'
Date: Tue, 12 Sep 2023 16:39:11 +0200 (CEST)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,

On Tue, 12 Sep 2023, avih via Tinycc-devel wrote:

> Also, what is "pure machine code"? With neither input nor output it
> couldn't do anything but waste instruction cycles.

A function implemented in machine code, where the input is the
arguments in whatever calling convention the implementation uses,
and the output is the return value and whatever memory side effects.

I was hoping that compiling a C function which does not call other
functions would result in machine code which does not call functions,
except maybe existing internal compiler functions.

In the example above it probably does not call external functions.
But the user can't tell when it does and when it doesn't, which makes
-nostdlib very problematic from a practical point of view.

"Very problematic" seems an exaggeration given that e.g. GCC behaves exactly the same, given the right circumstances. TCC, as GCC, freely emits calls to memcpy, memmove and memset. It did so forever, like GCC. If anything then this is a problem of documentation (not for the command line help). TCCs docu is incomplete in many aspects, and this isn't the biggest problem by far.

Even if these are terrible suggestions, the question remains:
What does the user need to do in order to use -nostdlib?

The user needs to provide a working implementation of memcpy, memmove, memset (and abort).

And maybe also: what is -stdlib good for?

Hmm? It's the opposite of nostdlib. And nostdlib is for exactly the documented purpose: prevent linking with default startup files and C library. If you're asking what _that_ is for, then: developing software that doesn't make use of the usual hosted C environment, like boot loaders or OS kernels. It's a special-case option, not to be used in random software development.


Ciao,
Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]