# Redistribute Compiler for Windows 7 as standalone zip

**URL:** <https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959>\
**Category:** HiFive Unleashed\
**Created:** [December 31, 2022, 5:55pm UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959 "2022-12-31T17:55:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rupy](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@rupy](https://forums.sifive.com/u/rupy)\
**Post date:** [December 31, 2022, 5:55pm UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959/1 "2022-12-31T17:55:42Z")

</div>

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

> **[Releases · xpack-dev-tools/riscv-none-elf-gcc-xpack](https://github.com/xpack-dev-tools/riscv-none-elf-gcc-xpack/releases)**
>
> A binary xPack with the GNU RISC-V Embedded GCC toolchain - xpack-dev-tools/riscv-none-elf-gcc-xpack

I’m thinking just these files:

libiconv-2.dll  
libwinpthread-1.dll  
riscv-none-elf-gcc.exe

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?

---

<div class="post-metadata">

**Author:** ![ilg](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/ilg/32/871_2.png) [@ilg](https://forums.sifive.com/u/ilg)\
**Post date:** [January 1, 2023, 8:12pm UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959/2 "2023-01-01T20:12:21Z")

</div>

> [@rupy](#):
>
> Or is anything else needed to compile?

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

---

<div class="post-metadata">

**Author:** ![rupy](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@rupy](https://forums.sifive.com/u/rupy)\
**Post date:** [January 1, 2023, 8:25pm UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959/3 "2023-01-01T20:25:05Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![tgm](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tgm](https://forums.sifive.com/u/tgm)\
**Post date:** [January 3, 2023, 11:38pm UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959/4 "2023-01-03T23:38:01Z")

</div>

> 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/abi`s then that can be achieved easily enough.

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

---

<div class="post-metadata">

**Author:** ![rupy](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@rupy](https://forums.sifive.com/u/rupy)\
**Post date:** [January 4, 2023, 10:30am UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959/5 "2023-01-04T10:30:27Z")

</div>

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?

[http://move.rupy.se/file/test.bin](http://move.rupy.se/file/test.bin)  
[http://move.rupy.se/file/test\_.bin](http://move.rupy.se/file/test_.bin)

Edit:

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?

---

<div class="post-metadata">

**Author:** ![jrtc27](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.sifive.com/jrtc27/32/1352_2.png) [@jrtc27](https://forums.sifive.com/u/jrtc27)\
**Post date:** [January 7, 2023, 8:21am UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959/6 "2023-01-07T08:21:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rupy](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@rupy](https://forums.sifive.com/u/rupy)\
**Post date:** [January 7, 2023, 10:44am UTC](https://forums.sifive.com/t/redistribute-compiler-for-windows-7-as-standalone-zip/5959/7 "2023-01-07T10:44:47Z")

</div>

> [@rupy](#):
>
> bin\riscv-none-elf-gcc.exe -S test.c

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!
