[Top][All Lists]

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

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

From: Sam Ellicott
Subject: [Tinycc-devel] Errors using riscv64-tcc with gcc/newlib headers
Date: Sun, 18 Jul 2021 19:18:09 -0400

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)

../configure \
--prefix=$HOME/.local \
--sysincludepaths=/usr/riscv64-elf/include \
--libpaths=/usr/riscv64-elf/lib \
make cross-riscv64

TCC output
./riscv64-tcc -print-search-dirs
install: /home/nebk/.local/lib/tcc

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

-Sam Ellicott
Soli Deo Gloria

Attachment: 0002-stdint-base-types-for-riscv-in-tccdef.h.patch
Description: Text Data

Attachment: 0001-Update-build-scripts.patch
Description: Text Data

reply via email to

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