Comments (9)
I took some time to investigate. So, the libgcc.a is a part of newlib and consists of object files with the following signature:
ELF 32-bit LSB relocatable, UCB RISC-V, RVE, soft-float ABI, version 1 (SYSV), with debug_info, not stripped
This matches the RV32V003 architecture, which is RV32EC: 32-bit, embedded, with compression support. Note that the RVE line in the object file signatures signifies embedded. The absent is RVC, for compressed instructions. That's a little suboptimal in terms of code size, but otherwise fine.
I've also built libgcc.a from scratch using the following steps:
- Install prerequisites (for Debian-based systems; similar steps for other systems):
sudo apt-get install build-essential autoconf automake autotools-dev curl \
libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo \
gperf libtool patchutils bc zlib1g-dev git
- Checkout sources:
git clone --recursive https://github.com/riscv/riscv-gnu-toolchain.git
cd riscv-gnu-toolchain
- Configure and build:
./configure --prefix $(pwd)/build-ch32v003 --with-arch=rv32ec --with-abi=ilp32e
make -j8
- Enjoy the built libgcc.a:
$ find ./build-ch32v003 -name libgcc.a
./build-ch32v003/lib/gcc/riscv32-unknown-elf/12.2.0/libgcc.a
$ ls -sh ./build-ch32v003/lib/gcc/riscv32-unknown-elf/12.2.0/libgcc.a
<...> 2663918 <...> ./build-ch32v003/lib/gcc/riscv32-unknown-elf/12.2.0/libgcc.a
The new library is 2663918 bytes. That's a little bit smaller than the libgcc.a checked into this repository, which is 2932544 bytes. The reason seems to be because the version I built supports compressed instructions, so they naturally take a bit less space:
ELF 32-bit LSB relocatable, UCB RISC-V, RVC, RVE, soft-float ABI, version 1 (SYSV), with debug_info, not stripped
I've verified that libgcc.a that was built using the instructions links fine with every example I tried, except self_modify_code, but that example seems to be broken with the existing libgcc.a as well, so it's not related.
@cnlohr would you be open to a pull requests that adds a concise version of instructions on how to build libgcc.a near misc/libgcc.a? I will be happy to make one.
Additionally, if you are interested in saving some bytes, I can also include the libgcc.a that has the compressed instructions baked in. Frankly, the savings are likely to be minor (within 10%), but when we only have 16 KB flash, maybe it would actually matter for some people?
from ch32v003fun.
I'm curious why it needs to be provided. I mean, if its part of the toolchain already, shouldn't everyone already have it? I mean, gcc itself, newlib and co - they're not provided, but are assumed to be present
from ch32v003fun.
On the Windows compiler I recommend, there is no -EC libgcc included with it. So I threw it in.
from ch32v003fun.
I would absolutely be up for it!!!! And if your new libgcc is better in (basically any way) then we should use it. I just found a totally random libgcc. I don't even remember where it came from.
Please make the PR, @krasin
from ch32v003fun.
@cnlohr will do! Thank you for the encouragement.
@prosper00 on Linux, it's not needed as gcc-riscv64-linux-gnu package has all/most necessary libgcc.a variants available:
$ find /usr/ -name 'libgcc.a'
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imafc/ilp32f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imf/ilp32f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64ifd/lp64d/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32if/ilp32f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64if/lp64f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imafdc/ilp32d/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64imf/lp64f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64iaf/lp64f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32im/ilp32/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64imafc/lp64f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32emac/ilp32e/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32e/ilp32e/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64i/lp64/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32i/ilp32/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64iac/lp64/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imfd/ilp32d/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64ia/lp64/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64iafd/lp64d/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32iac/ilp32/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32iaf/ilp32f/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32eac/ilp32e/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32iafd/ilp32d/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64im/lp64/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32ea/ilp32e/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32imac/ilp32/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv64imac/lp64/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32ia/ilp32/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32em/ilp32e/libgcc.a
/usr/lib/gcc/riscv64-unknown-elf/12.2.0/rv32ifd/ilp32d/libgcc.a
README.md says: "An extra copy of libgcc so you can use unusual risc-v build chains, located in the misc/libgcc.a", but I hope that @cnlohr can elaborate more about that.
from ch32v003fun.
@cnlohr thank you for merging.
-
It's possible that I've missed something during my testing and that the replacement libgcc.a is "bad" in some way. Please, do not hesitate to rollback my change, if in doubt.
-
@prosper00 raised a good point that bundling libgcc.a is not generally a thing. Would it be possible to give an example, where it's actually needed? This is completely optional, but might serve as a good reference point in the future. Thanks!
from ch32v003fun.
You mention needing to elaborate on that? Do you have a recommendation for what verbage we could use to clarify why one would want to use our build copy of libgcc?
from ch32v003fun.
Hi @cnlohr ,
is there any particular use case / toolchain that you encountered and that's missing an appropriate libgcc.a? In the README.md you mention "unusual risc-v build chains", is there an example of that?
Overall, it's all pretty minor.
Thanks again for working on ch32v003fun!
from ch32v003fun.
I see, thanks.
from ch32v003fun.
Related Issues (20)
- wrong pin diagram on a4m6 HOT 1
- Duplicate readings in `handle_debug_input()` and more.. HOT 9
- Add more examples to.. examples (Si5351) HOT 2
- Reverse engineering the factory bootloader HOT 4
- How to printf a float number? HOT 4
- Why no `-fdata-sections`? HOT 5
- Wrong definition of funPinMode? HOT 2
- FUN_HIGH and FUN_LOW behave reversed for funDigitalWrite HOT 1
- Convoluted UART_BRR calculation HOT 3
- Redundant `blink[_raw].bin` files source controlled in repo? HOT 11
- TODO For new updates
- Configurable RAM sizes for V20x, V30x HOT 8
- Compilation results in no code HOT 1
- Make minichlink print flash amount HOT 1
- Make semihosting printf speed along if it times out.
- Empty LD file on missing build tools HOT 2
- prebuilt blink.bin example doesn't seem to work on a CH32V003 board HOT 1
- PWM 8 KHz 16 bit HOT 11
- Onewire slave
- CH32V003A4M6 SPI? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ch32v003fun.