An introduction to GCC and GCC’s plugins

1. Brief introduction to GNU’s GCC The GNU toolchain is a collection of tools and libraries produced in the context of the GNU project. In 1983, Richard Stallman announced the GNU project. Its goal was to give the community freedom and control in their use of computing devices by developing (collaboratively) free software and letting users modify, copy, and distribute it freely. The GNU toolchain was part of that software and today includes some of the most widespread tools used to develop and compile application such as: GNU make:…

How to run a program with commandline arguments using GDB within a Bash script?

Run gdb with --args parameter: gdb --args executablename arg1 arg2 arg3 If you are doing this often (e.g. when running GDB from a script), you might want to consider the following arguments to automate things further. First, you can place your GDB commands (such as 'run') in a text file and provide the filename to the -x argument. Second, you can have GDB exit after running your commands by providing the --batch argument. A full example: gdb -x commands.txt --batch --args executablename arg1 arg2 arg3

Lima Ubuntu VM setup on Mac

Homebrew Installation /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" Uninstallation /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/HomebrewUninstall.sh)" Lima  launches Linux virtual machines with automatic file sharing and port forwarding (similar to WSL2). # Install brew install lima # Create VM limactl create --cpus=8 --memory=8 --name=default template://ubuntu limactl list # Start && Enter limactl start default limactl shell default # Stop limactl stop default # Delete limactl delete default # Protect && Unprotect limactl protect default limactl unprotect default # Copy # Host -> VM limactl cp ~/Downloads/test.png default:/tmp # VM -> Host…

Everything I know about GNU toolchain

As mainly an LLVM person, I occasionally contribute to GNU toolchain projects. This is sometimes for fun, sometimes for investigating why an (usually ancient) feature works in a particular way, sometimes for pushing forward a toolchain feature with the mind of both communities, or sometimes just for getting sense of how things work with mailing list+GNU make. For a debug build, I normally place my build directory out/debug directly under the project root. Dependency chain of a port: GCC needs binutils. Linux kernel needs GCC. glibc needs Linux kernel. binutils…

How to compile coreutils / binutils for aarch64 in x64

Dockcross git clone https://github.com/dockcross/dockcross.git cd dockcross docker run --rm dockcross/linux-arm64> ./dockcross-linux-arm64 chmod +x ./dockcross-linux-arm64 mv ./dockcross-linux-arm64 ~/bin/ Coreutils / Binutils //Go to the repository diretory dockcross-linux-arm64 bash //In the docker work diretory ./bootstrap(only for coreutils) mkdir aarch64 cd aarch64 ../configure make make check(run official test) Building GDB Natively Ever since the GDB and the binutils repositories were integrated (due to the git migration), it has become a bit more complex to build GDB. Of course, you can still do a simple ./configure && make, but you might actually want to disable…

Installing & Building RISC-V Toolchain

Prerequisites Several standard packages are needed to build the toolchain $ sudo apt-get install autoconf automake autotools-dev curl python3 python3-pip libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev ninja-build git cmake libglib2.0-dev libslirp-dev Create a directory and clone $ mkdir ~/riscv && cd ~/riscv $ git clone https://github.com/riscv/riscv-gnu-toolchain Configure and make $ mkdir /opt/riscv $ ./configure --prefix=/opt/riscv $ make linux Your tool will be available on /opt/riscv/bin Add /opt/riscv/bin to PATH Edit the ~/.bashrc file $ sudo vim ~/.bashrc Add below at the end of the file and…