tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Errors using riscv64-tcc with gcc/newlib headers


From: grischka
Subject: Re: [Tinycc-devel] Errors using riscv64-tcc with gcc/newlib headers
Date: Mon, 19 Jul 2021 16:45:41 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

Sam Ellicott wrote:
Hi everyone,
This is my first time using the mailing list/patching an open-source
program, so let me know if I am doing something wrong.

I was trying to build the riscv version of tcc while using the newlib
standard library for riscv provided by GCC and I ran into a couple of
issues. First, I wanted to make the cross compiler use the newlib library
by default and I believe using the `--sysincludepaths`, `--libpaths`, and
`--crtprefix` However, I found when I tried adding these options to the
`./configure` script, they had no effect on the tcc cross compiler.
(Command and output shown below)

Honestly configure was not made to create real working cross-compilers.
cross-compilers as build by default are more or less just for developers
to catch some errors or warnings earlier.

There is however a mechanism with a file "config-extra.mak" included from
Makefile that allows to set paths and flags for cross-compilers individually:

    ROOT-<target> = ... (translated to -DCONFIG_SYSROOT=...)
    CRT-<target>  = ... (translated to -DCONFIG_TCC_CRTPREFIX=...)
    LIB-<target>  = ... (translated to -DCONFIG_TCC_LIBPATHS=...)
    INC-<target>  = ... (translated to -DCONFIG_TCC_SYSINCLUDEPATHS=...)
    DEF-<target>  = ... (translated to -DDEFINES+=...)

So once you did create the file and did add your options, it should just
work without any special further configuration.  At least that is how
it was meant to work.

See also "make help".

As to the integer defs I maybe would not add anything one can find
from anywhere.  TCC is not GCC, so just to have the minimum of what
is required to make it work should be fine as well.

Also, cygwin might not be representative for what a riscv compiler should
have.  You didn't tell what the error with "stdint.h" actually was but
obviously no "stdint.h" seen by tcc so far did require any of these defines.
Therefor it might be just a mistake on the cygwin people's side.

Maybe you can try with files from a real riscv system first?

--- grischka

I put together a small patch that seems to fix the issue
(0001-Update-build-scripts.patch). It changes the `print_mak` function in
the configure script to output these options to the `EXTRA_DEFINES`
variable (a random name I chose) instead of the `NATIVE_DEFINES` variable.
Then the `EXTRA_DEFINES` variable is always appended to the total build
defines, so that is used for cross-compilers as well as the main tcc
compiler. With this change a few other lines could probably be removed from
the Makefile as well, but I wasn't brave enough to do it.

The next issue I ran into was errors when using `stdint.h`, (specifically a
file included by it `_intsup.h`). Many base definitions that are provided
by the gcc riscv compiler were missing (like __INT32_TYPE__) along with
some pointer size definitions. I added in the pointer size definitions
generally, and the other riscv definitions were copied from definitions by
the riscv gcc compiler. This is in
(0002-stdint-base-types-for-riscv-in-tccdef.h.patch).
The file contents for _intsup.h can be found here:
https://www.sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=newlib/libc/include/sys/_intsup.h;h=993121ba890b2208eb83432daf741aa0ba598d30;hb=HEAD

Thanks,
-Sam Ellicott
Soli Deo Gloria



reply via email to

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