Redistribute Compiler for Windows 7 as standalone zip

Hi can I bundle this on whole or in part with my commercial product:

I’m thinking just these files:


Or is anything else needed to compile?

Edit: It says “riscv-none-elf-gcc.exe: fatal error: cannot execute ‘cc1’: CreateProcess: No such file or directory” Is there a way to get all the files needed to compile in a zip?

I tried placing cc1.exe from my MSYS2 install in the folder but no cigarr… I have to run this exe from inside the MSYS2 shell?

Yes, the whole folder structure is needed, as distributed.

Ah, ok!

Any way to make that smaller?

aha libexec!!!

Ok I think I can make it smaller then…

Damn you need riscv-none-elf (1.5GB! Edit so this has 30MB for every permutation of possible RISC-V extensions… hm then I can make it smaller when I know what extensions I will support)

Now I get: test.s:11: Error: can’t have 64-bit ABI on 32-bit ISA

Edit: can somebody explain the 32 vs. 64 bit stuff here I’m a bit confused…

Ok when I edited the command to bin\riscv-none-elf-gcc.exe -Wl,-Ttext=0x0 -nostdlib -march=rv32i -mabi=ilp32 -o test test.s

It worked but warned that no _start was found…

Now I just need to compile my own RISC-V VM!

Edit2: My bin\riscv-none-elf-objcopy.exe output is very different from the one in the example… probably because of the 32-bit thing…

can somebody explain the 32 vs. 64 bit stuff here I’m a bit confused…

I’m not really sure what you’re asking but maybe this will help…

Any RISC-V toolchain (e.g. tool names prefixed with riscv32... or riscv64...) can generate code for both RV32 and RV64 and all ratified/implemented extensions. When the toolchain is configured and built a default arch/abi is specified. Usually this is rv32gc/ilp32d or rv64gc/lp64d. Where toolchain startup code (crt0) and/or system/standard libraries are used these need to be available at link time. For this reason a toolchain that by default supports, say, rv64gc/lp64d may be configured and built to bundle additional multilibs so that linking with crt0/libs works for arch/abis other than the defaults. The set of multilibs built and bundled is determined at toolchain configuration/built time. As far as I recall, @ilg builds a larger set than gets built using the default GCC sources and --enable-multilib. If a toolchain is required for only a specific arch/abi or some specific set of arch/abis then that can be achieved easily enough.

If that doesn’t address your question then please clarify it.

I’m just compiling a test.c file and the result is not the same after applying the objcopy:

bin\riscv-none-elf-gcc.exe -Wl,-Ttext=0x0 -nostdlib -march=rv64i -mabi=lp64 -o test test.s
// This is how I was supposed to compile but I get “can’t have 64-bit ABI on 32-bit ISA”.

Is riscv-none-elf-gcc.exe hardcoded to 32-bit?

bin\riscv-none-elf-gcc.exe -S test.c
bin\riscv-none-elf-gcc.exe -Wl,-Ttext=0x0 -nostdlib -march=rv32i -mabi=ilp32 -o test test.s
bin\riscv-none-elf-objcopy.exe -O binary test test.bin

Here are the bin files… the one with the underscore is the 32-bit one and it’s almost half of the size so makes sense I just don’t know what differs?

Is there a header to these .bin files?


bin/riscv64-unknown-elf-gcc ← so this is hardcoded/default 64-bit
bin\riscv-none-elf-gcc.exe ← and this is hardcoded/default 32-bit?

How do I tell the riscv-none-elf-gcc.exe to make 64-bit stuff?

Pass -march and -mabi to GCC when compiling C to assembly, not just when assembling to an object file; not only is that needed to get the right generated code (think about how void *, size_t, etc vary), the assembly file also includes a .attribute arch directive to specify the ISA it is for, which overrides -march when you come to assemble it (but not -mabi), and so you get the error you see.

So the first line should have bin\riscv-none-elf-gcc.exe -S -march=rv64i -mabi=lp64 test.c

ok, that worked just had to add the m extension (-march=rv64im), thanks alot!

Slowly learning!