While building and running Clarinet on a 64-bit Linux system, I encountered two issues:
- Simulator warnings are treated as fatal errors
elf_to_hex build fails due to large global/static memory allocations
Problem 1: Verilator fatal warnings
When running make simulator, some warnings cause the build to fail.
Proposed fix:
Append the flag --Wno-fatal to Verilator:
make simulator VERILATOR_FLAGS+=" --Wno-fatal"
This prevents warnings from stopping the simulation build.
Problem 2: elf_to_hex fails on 64-bit Linux
The elf_to_hex.c file defines a very large static buffer:
#define MAX_MEM_SIZE ((uint64_t) 0x90000000)
uint8_t mem_buf[MAX_MEM_SIZE]; // ~2.4 GB
On 64-bit Linux, the default PIE executable uses R_X86_64_PC32 relocations, which cannot address such a large global. The linker fails with:
relocation truncated to fit
Proposed fixes:
- Disable PIE:
gcc -g -no-pie -o elf_to_hex elf_to_hex.c -lelf
- Use the large memory model for globals > 2 GB:
gcc -g -mcmodel=large -o elf_to_hex elf_to_hex.c -lelf
- Or combine both:
gcc -g -mcmodel=large -no-pie -o elf_to_hex elf_to_hex.c -lelf
Steps to reproduce manually:
# Build elf_to_hex first
cd Tests/elf_to_hex
make clean
gcc -g -mcmodel=large -no-pie -o elf_to_hex elf_to_hex.c -lelf
# Then build tests in Verilator
cd ../../builds/RV32ACDFIMSU_verilator
make test
Conclusion:
Applying these fixes allows the project to build successfully on modern 64-bit Linux systems and prevents trivial warnings from breaking the simulation build.
While building and running Clarinet on a 64-bit Linux system, I encountered two issues:
elf_to_hexbuild fails due to large global/static memory allocationsProblem 1: Verilator fatal warnings
When running
make simulator, some warnings cause the build to fail.Proposed fix:
Append the flag
--Wno-fatalto Verilator:make simulator VERILATOR_FLAGS+=" --Wno-fatal"This prevents warnings from stopping the simulation build.
Problem 2:
elf_to_hexfails on 64-bit LinuxThe
elf_to_hex.cfile defines a very large static buffer:On 64-bit Linux, the default PIE executable uses
R_X86_64_PC32relocations, which cannot address such a large global. The linker fails with:Proposed fixes:
Steps to reproduce manually:
Conclusion:
Applying these fixes allows the project to build successfully on modern 64-bit Linux systems and prevents trivial warnings from breaking the simulation build.