Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elf-loader does not build on Windows #1

Open
cr1901 opened this issue Jan 22, 2017 · 2 comments
Open

elf-loader does not build on Windows #1

cr1901 opened this issue Jan 22, 2017 · 2 comments

Comments

@cr1901
Copy link

cr1901 commented Jan 22, 2017

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 :(.

@olofk
Copy link
Contributor

olofk commented Jan 23, 2017

It seems like you have put in quite some effort to make this work. I tried something similar and eventually gave up. I think one problem is that libelf is too old to work, and has been more or less replace with elfutils. Unfortunately, it seems like no one has ever managed to compile elfutils on Windows.

This is very unfortunate, since elf-loader is a dependency for a lot of the systems in the base library. I've been thinking a lot about how to solve this, and come to the conclusion that I will need to either or both

  1. Build a simple elf parser (based on elfutils or something else) that doesn't have all the complexities of elfutils, and can be easier ported to windows
  2. Make elf-loader an optional dependency, and add an alternative to preload memories from verilog hex files, or similar (I'm working right now on better support for optional dependencies in FuseSoC)

So, for now, all I can say is that I'm sorry that things involving elf-loader doesn't work well on windows. I've had reports that it might work on cygwin, so maybe that could be a workaround.

@Kreijstal
Copy link

maybe elfutils has gotten better nowdays?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants