Skip to content

elf-loader does not build on Windows #1

@cr1901

Description

@cr1901

When attempting to use iverilog with fusesoc, compiling the elf-loader, compilation of the VPI module fails due to missing <gelf.h>:

../src/elf-loader_1.0/elf-loader.c:26:18: fatal error: gelf.h: No such file or directory
compilation terminated.
../src/elf-loader_1.0/vpi_wrapper.c: In function 'setup_reset_callbacks':
../src/elf-loader_1.0/vpi_wrapper.c:184:3: warning: missing initializer for field 'high' of 's_vpi_time {aka struct t_vpi_time}' [-Wmissing-field-initializers]
   static s_vpi_time time_s = {vpiScaledRealTime};
   ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:95:18: note: 'high' declared here
       PLI_UINT32 high;
                  ^
../src/elf-loader_1.0/vpi_wrapper.c:185:3: warning: missing initializer for field 'value' of 's_vpi_value {aka struct t_vpi_value}' [-Wmissing-field-initializers]
   static s_vpi_value value_s = {vpiBinStrVal};
   ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:128:9: note: 'value' declared here
       } value;
         ^
../src/elf-loader_1.0/vpi_wrapper.c:193:5: warning: missing initializer for field 'index' of 's_cb_data {aka struct t_cb_data}' [-Wmissing-field-initializers]
     };
     ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:461:17: note: 'index' declared here
       PLI_INT32 index;
                 ^
../src/elf-loader_1.0/vpi_wrapper.c: In function 'setup_endofcompile_callbacks':
../src/elf-loader_1.0/vpi_wrapper.c:219:3: warning: missing initializer for field 'high' of 's_vpi_time {aka struct t_vpi_time}' [-Wmissing-field-initializers]
   static s_vpi_time time_s = {vpiScaledRealTime};
   ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:95:18: note: 'high' declared here
       PLI_UINT32 high;
                  ^
../src/elf-loader_1.0/vpi_wrapper.c:220:3: warning: missing initializer for field 'value' of 's_vpi_value {aka struct t_vpi_value}' [-Wmissing-field-initializers]
   static s_vpi_value value_s = {vpiBinStrVal};
   ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:128:9: note: 'value' declared here
       } value;
         ^
../src/elf-loader_1.0/vpi_wrapper.c:228:5: warning: missing initializer for field 'index' of 's_cb_data {aka struct t_cb_data}' [-Wmissing-field-initializers]
     };
     ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:461:17: note: 'index' declared here
       PLI_INT32 index;
                 ^
../src/elf-loader_1.0/vpi_wrapper.c: In function 'setup_finish_callbacks':
../src/elf-loader_1.0/vpi_wrapper.c:251:3: warning: missing initializer for field 'high' of 's_vpi_time {aka struct t_vpi_time}' [-Wmissing-field-initializers]
   static s_vpi_time time_s = {vpiScaledRealTime};
   ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:95:18: note: 'high' declared here
       PLI_UINT32 high;
                  ^
../src/elf-loader_1.0/vpi_wrapper.c:252:3: warning: missing initializer for field 'value' of 's_vpi_value {aka struct t_vpi_value}' [-Wmissing-field-initializers]
   static s_vpi_value value_s = {vpiBinStrVal};
   ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:128:9: note: 'value' declared here
       } value;
         ^
../src/elf-loader_1.0/vpi_wrapper.c:260:5: warning: missing initializer for field 'index' of 's_cb_data {aka struct t_cb_data}' [-Wmissing-field-initializers]
     };
     ^
In file included from ../src/elf-loader_1.0/vpi_wrapper.c:21:0:
C:/msys64/mingw32/include/iverilog/vpi_user.h:461:17: note: 'index' declared here
       PLI_INT32 index;

On msys2 installations, libelf headers are provided under /mingw{32,64}/include/libelf. For now, I hardcoded the icarus simulator to search that path.

When that issue is taken care of, I tickle what I suspect is a bug in iverilog-vpi (have not currently checked if it was reported, too busy), so I had to compile to object files manually and pass in the object files to iverilog-vpi (since I cannot customize how VPI modules are build in fusesoc).

gcc -c -Wall -Wextra -Wshadow   -g -O2 -I"C:\msys64\mingw32\\include\\iverilog" -I/mingw32/include/libelf vpi_wrapper.c
gcc -c -Wall -Wextra -Wshadow   -g -O2 -I"C:\msys64\mingw32\\include\\iverilog" -I/mingw32/include/libelf elf-loader.c
iverilog-vpi -lelf --name=elf-loader_1.0 -I/mingw32/include/libelf vpi_wrapper.o elf-loader.o

Even after all that, compiling the elf-loader failed because it appears my libelf is too new (which is the one provided by msys2):

elf-loader.o: In function `dump_program_data':
C:\msys64\home\William\src\ymsoc2\build\ymsoc2_0\src\elf-loader_1.0/elf-loader.c:64: undefined reference to `elf_getdata_rawchunk'
collect2.exe: error: ld returned 1 exit status

At the moment, I am unsure how to proceed, but the consequence is that iverilog simulation does not work at all since (AFAICT) the elf loader is a prerequisite. This is a placeholder issue for now. I currently don't have the time to try and fix this myself :(.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions