grub2-rc1-emu under cygwin
Subsystems (2)
Hi,
I'm attempting to build grub2-rc1 -emu under cygwin w/o success.
I've made a fast and dirty patch about the missing stuff (emunet tap), see attachment, but I don't known how to say to the build machine these symbols came from cygwin and should be resolved at last ? see bellow... everything else seems to be ok.
thanks in advance.
build environment => cygwin2 up-to-date w/ gcc4
$ uname -a CYGWIN_NT-6.0 pcvista 1.7.17(0.262/5/3) 2012-10-19 14:39 i686 Cygwin
the configure command I use :
CC=gcc-4 ./configure --with-platform=emu --enable-grub-emu-usb --enable-grub-emu-sdl
and the make command :
make -j 1 -k
-j 1 is to avoid fork failures.
what's wrong is :
cat syminfo.lst | sort | awk -f ./genmoddep.awk > moddep.lst || (rm -f moddep.lst; exit 1) __imp__CloseHandle@4 in emunet is not defined
__imp__CreateEventA@16 in emunet is not defined
__imp__CreateFileA@28 in emunet is not defined
__imp__DeviceIoControl@32 in emunet is not defined
__imp__GetLastError@0 in emunet is not defined __imp__GetOverlappedResult@16 in emunet is not defined
__imp__ReadFile@20 in emunet is not defined
__imp__RegCloseKey@4 in emunet is not defined
__imp__RegEnumKeyExA@32 in emunet is not defined
__imp__RegOpenKeyExA@20 in emunet is not defined
__imp__RegQueryValueExA@24 in emunet is not defined
__imp__ResetEvent@4 in emunet is not defined
__imp__WaitForSingleObject@8 in emunet is not defined
__imp__WriteFile@20 in emunet is not defined_cygwin_attach_handle_to_fd in emunet is not defined_get_osfhandle in emunet is not defined
Makefile:81312: recipe for target `moddep.lst' failed
Regards,
Cyrille Lefevre
Signature · 1 line
mailto:[email protected]
net/drivers/emu/emunet.c renamed from opt/bzr/grub/grub-core/net/drivers/emu/emunet.c +15 -21
@@ -21,8 +21,7 @@#include <sys/socket.h> #include <grub/net.h> #include <sys/types.h> -#include <linux/if.h> -#include <linux/if_tun.h> +#include "emutuntap.h" #include <sys/ioctl.h> #include <fcntl.h> #include <unistd.h>
@@ -31,15 +30,19 @@GRUB_MOD_LICENSE ("GPLv3+" ); -static int fd; +#include "emutuntap.c" -static grub_err_t +/* _xxx to avoid "declaration of 'xxx' shadows a global declaration" warning */ +static char _dev[IFNAMSIZ ]; +static int _fd; + +static grub_err_t send_card_buffer (struct grub_net_card *dev __attribute__ ((unused)),struct grub_net_buff *pack) {ssize_t actual; - actual =write (fd, pack->data, pack->tail - pack->data); + actual =tun_write (_fd, pack->data, pack->tail - pack->data);if (actual <0 )return grub_error (GRUB_ERR_IO ,N_ ("couldn't send network packet" ));
@@ -65,7 +68,7 @@return NULL ; } - actual =read (fd, nb->data,1536 ); + actual =tun_read (_fd, nb->data,1536 );if (actual <0 ) {grub_netbuff_free (nb);
@@ -76,14 +79,14 @@return nb; } -static struct grub_net_card_driver emudriver = +static struct grub_net_card_driver emudriver = { .name ="emu" , .send = send_card_buffer, .recv = get_card_packet }; -static struct grub_net_card emucard = +static struct grub_net_card emucard = { .name ="emu0" , .driver = &emudriver,
@@ -97,26 +100,17 @@GRUB_MOD_INIT (emunet) { -struct ifreq ifr; - fd =open ("/dev/net/tun" ,O_RDWR |O_NONBLOCK ); -if (fd <0 ) + _fd =tun_open (_dev,IF_MODE_TAP ); +if (_fd <0 )return ; -grub_memset (&ifr,0 ,sizeof (ifr)); - ifr.ifr_flags =IFF_TAP |IFF_NO_PI ; -if (ioctl (fd,TUNSETIFF , &ifr) <0 ) - { -close (fd); - fd =-1 ; -return ; - }grub_net_card_register (&emucard); }GRUB_MOD_FINI (emunet) { -if (fd >=0 ) +if (_fd >=0 ) { -close (fd); +tun_close (_fd, _dev);grub_net_card_unregister (&emucard); } }
net/drivers/emu/emutuntap.c renamed from opt/bzr/grub/grub-core/net/drivers/emu/emutuntap.c +365 -0
365 lines not on this page · raw message
net/drivers/emu/emutuntap.h renamed from opt/bzr/grub/grub-core/net/drivers/emu/emutuntap.h +41 -0
41 lines not on this page · raw message
net/drivers/emu/tap-win32.h renamed from opt/bzr/grub/grub-core/net/drivers/emu/tap-win32.h +87 -0
87 lines not on this page · raw message
does grub-emu is supposed to build right ? (was Re: grub2-rc1-emu under cygwin)
Quoted 41 lines · Cyrille Lefevre
Hi,
I'm attempting to build grub2-rc1 -emu under cygwin w/o success. I've made a fast and dirty patch about the missing stuff (emunet tap), see attachment,
but I don't known how to say to the build machine these symbols came from cygwin
and should be resolved at last ? see bellow... everything else seems to be ok.thanks in advance.
build environment => cygwin2 up-to-date w/ gcc4
$ uname -a CYGWIN_NT-6.0 pcvista 1.7.17(0.262/5/3) 2012-10-19 14:39 i686 Cygwinthe configure command I use :
CC=gcc-4 ./configure --with-platform=emu --enable-grub-emu-usb --enable-grub-emu-sdl
and the make command :
make -j 1 -k
-j 1 is to avoid fork failures.
what's wrong is :
cat syminfo.lst | sort | awk -f ./genmoddep.awk > moddep.lst || (rm -f moddep.lst; exit 1)
__imp__CloseHandle@4 in emunet is not defined __imp__CreateEventA@16 in emunet is not defined __imp__CreateFileA@28 in emunet is not defined __imp__DeviceIoControl@32 in emunet is not defined __imp__GetLastError@0 in emunet is not defined __imp__GetOverlappedResult@16 in emunet is not defined __imp__ReadFile@20 in emunet is not defined __imp__RegCloseKey@4 in emunet is not defined __imp__RegEnumKeyExA@32 in emunet is not defined
Quoted 8 lines
__imp__RegOpenKeyExA@20 in emunet is not defined __imp__RegQueryValueExA@24 in emunet is not defined __imp__ResetEvent@4 in emunet is not defined __imp__WaitForSingleObject@8 in emunet is not defined __imp__WriteFile@20 in emunet is not defined
_cygwin_attach_handle_to_fdin emunet is not defined_get_osfhandlein emunet is not defined Makefile:81312: recipe for target `moddep.lst' failed
Hi,
well, I've resolve the above issue by manually editing the Makefile as in the one attached.
now, I'm stuck with the following error, so, the question is, does grub-emu is supposed to build right ?
gcc-4 -DHAVE_CONFIG_H -I. -I.. -Wall -W -I../include -I../include -DGRUB_MACHINE_EMU=1 -DGRUB_MACHINE=I386_EMU -DGRUB_TARGET_CPU_I386=1 -m32 -DGRUB_FILE=\"symlist.c\" -I. -I. -I.. -I.. -I../include -I../include -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -falign-jumps=1 -falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse -mno-sse2 -mno-3dnow -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -m32 -fno-stack-protector -mno-stack-arg-probe -MT grub_emu_lite-symlist.o -MD -MP -MF .deps-core/grub_emu_lite-symlist.Tpo -c -o grub_emu_lite-symlist.o test -f 'symlist.c' || echo './'symlist.csymlist.c: In function 'grub_register_exported_symbols':
symlist.c:72:31: error: 'grub_bios_interrupt' undeclared (first use in this function) symlist.c:72:31: note: each undeclared identifier is reported only once for each function it appears in symlist.c:73:29: error: 'grub_boot_device' undeclared (first use in this function) symlist.c:148:31: error: 'grub_pc_net_config' undeclared (first use in this function) symlist.c:149:25: error: 'grub_pit_wait' undeclared (first use in this function) symlist.c:154:25: error: 'grub_pxe_call' undeclared (first use in this function) symlist.c:216:3: error: duplicate case value
symlist.c:216:3: error: previously used here
Makefile:64893: recipe for target `grub_emu_lite-symlist.o' failed
make[1]: *** [grub_emu_lite-symlist.o] Error 1
thanks in advance...
Regards,
Cyrille Lefevre
Signature · 1 line
mailto:[email protected]
Makefile renamed from Makefile.bak +13 -9
@@ -28900,8 +28900,8 @@ nodist_grub_emu_OBJECTS = \ grub_emu-grub_emu_init.$(OBJEXT) grub_emu_OBJECTS = $(am_grub_emu_OBJECTS) $(nodist_grub_emu_OBJECTS) -am__DEPENDENCIES_1 = -grub_emu_DEPENDENCIES = kernel.img$(EXEEXT) \ +am__DEPENDENCIES_1 = gnulib/libgnu.a +grub_emu_DEPENDENCIES = kernel.exec$(EXEEXT) \ $(MODULE_FILES) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
@@ -28916,7 +28916,7 @@ grub_emu_lite-symlist.$(OBJEXT) grub_emu_lite_OBJECTS = $(am_grub_emu_lite_OBJECTS) \ $(nodist_grub_emu_lite_OBJECTS) -grub_emu_lite_DEPENDENCIES = kernel.img$(EXEEXT) \ +grub_emu_lite_DEPENDENCIES = kernel.exec$(EXEEXT) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
@@ -34170,7 +34170,7 @@ HELP2MAN = HOST_CC = gcc-4 HOST_CCASFLAGS = -HOST_CFLAGS = -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -Werror +HOST_CFLAGS = -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign HOST_CPPFLAGS = -Wall -W -I$(top_builddir)/include -DGRUB_UTIL=1 -DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\" HOST_LDFLAGS = INCLUDE_NEXT = include_next
@@ -34368,14 +34368,14 @@ TARGET_CC = gcc-4 TARGET_CCAS = gcc-4 TARGET_CCASFLAGS = -g -m32 -TARGET_CFLAGS = -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -falign-jumps=1 -falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse -mno-sse2 -mno-3dnow -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -m32 -fno-stack-protector -mno-stack-arg-probe -Werror $(am__append_9) +TARGET_CFLAGS = -Os -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wempty-body -Wendif-labels -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmain -Wmissing-braces -Wmissing-field-initializers -Wmissing-format-attribute -Wmissing-noreturn -Wmultichar -Wnonnull -Woverflow -Wparentheses -Wpointer-arith -Wpointer-to-int-cast -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wstrict-aliasing -Wswitch -Wtrigraphs -Wundef -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wvariadic-macros -Wvolatile-register-var -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wpointer-sign -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations -falign-jumps=1 -falign-loops=1 -falign-functions=1 -mno-mmx -mno-sse -mno-sse2 -mno-3dnow -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -m32 -fno-stack-protector -mno-stack-arg-probe $(am__append_9) TARGET_CPP = gcc-4 -E TARGET_CPPFLAGS = -Wall -W -I$(top_srcdir)/include -I$(top_builddir)/include -DGRUB_MACHINE_EMU=1 -DGRUB_MACHINE=I386_EMU -DGRUB_TARGET_CPU_I386=1 -m32 TARGET_IMG_BASE_LDOPT = -Wl,-Ttext TARGET_IMG_CFLAGS = TARGET_IMG_LDFLAGS = -Wl,-N TARGET_IMG_LDSCRIPT = -TARGET_LDFLAGS = -m32 +TARGET_LDFLAGS = -m32 -static-libgcc TARGET_LDFLAGS_OLDMAGIC = -Wl,-N TARGET_MODULE_FORMAT = elf32 TARGET_OBJ2ELF = $(top_builddir)/grub-pe2elf
@@ -58385,14 +58385,14 @@ $(am__append_18216) $(am__append_18225) $(am__append_18234) grub_emu_SOURCES = kern/emu/full.c nodist_grub_emu_SOURCES = grub_emu_init.c -grub_emu_LDADD = kernel.img$(EXEEXT) $(MODULE_FILES) $(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) +grub_emu_LDADD = kernel.exec$(EXEEXT) gnulib/libgnu.a $(MODULE_FILES) $(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBINTL) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) grub_emu_CFLAGS = $(AM_CFLAGS) $(CFLAGS_PROGRAM) grub_emu_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM) grub_emu_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM) grub_emu_CCASFLAGS = $(AM_CCASFLAGS) $(CCASFLAGS_PROGRAM) grub_emu_lite_SOURCES = kern/emu/lite.c nodist_grub_emu_lite_SOURCES = symlist.c -grub_emu_lite_LDADD = kernel.img$(EXEEXT) $(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) +grub_emu_lite_LDADD = kernel.exec$(EXEEXT) $(LIBUTIL) $(LIBCURSES) $(LIBSDL) $(LIBUSB) $(LIBPCIACCESS) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM) grub_emu_lite_CFLAGS = $(AM_CFLAGS) $(CFLAGS_PROGRAM) grub_emu_lite_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM) grub_emu_lite_CPPFLAGS = $(AM_CPPFLAGS) $(CPPFLAGS_PROGRAM)
@@ -81301,8 +81301,12 @@ crypto.lst: $(srcdir)/lib/libgcrypt-grub/cipher/crypto.lst cp $^ $@ -syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES) +cygwin.lst: /usr/bin/cygwin1.dll + nm -u net/drivers/emu/emunet_module-emunet.o | awk '!/grub/{print "defined cygwin", $$NF}' > cygwin.lst + +syminfo.lst: gensyminfo.sh kernel_syms.lst $(MODULE_FILES) cygwin.lst cat kernel_syms.lst > [email protected] + cat cygwin.lst >> [email protected] for m in $(MODULE_FILES); do \ sh $< $$m >> [email protected] || exit 1; \ done
Re: does grub-emu is supposed to build right ? (was Re: grub2-rc1-emu under cygwin)
Quoted 1 line · Cyrille Lefevre
manually editing the
Makefile
After such a manipulation, no, it's not supposed to build. Apparently you have missed export.h altogether.
Signature · 2 lines
Regards Vladimir 'φ-coder/phcoder' Serbinenko
Quoted 6 lines · Cyrille Lefevre
Hi,
I'm attempting to build grub2-rc1 -emu under cygwin w/o success. I've made a fast and dirty patch about the missing stuff (emunet tap), see attachment,
It breaks Linux part, you need #ifdef's
# but I don't known how to say to the build machine these symbols came
Quoted 4 lines
from cygwin
and should be resolved at last ? see bellow... everything else seems to be ok.
You need to define them in include/grub/emu/export.h and condition on their presence (see how it's done for libgcc)
Additional response to this older thread, now that few things changed.
Quoted 3 lines
CC=gcc-4 ./configure --with-platform=emu --enable-grub-emu-usb --enable-grub-emu-sdl
--enable-grub-emu-usb doesn't work. It's not important enough to fix it given large amount of work it needs and not so useless as to remove it alltogether.
Quoted 19 lines
and the make command :
make -j 1 -k
-j 1 is to avoid fork failures.
what's wrong is :
cat syminfo.lst | sort | awk -f ./genmoddep.awk > moddep.lst || (rm -f moddep.lst; exit 1)
__imp__CloseHandle@4 in emunet is not defined __imp__CreateEventA@16 in emunet is not defined __imp__CreateFileA@28 in emunet is not defined __imp__DeviceIoControl@32 in emunet is not defined __imp__GetLastError@0 in emunet is not defined __imp__GetOverlappedResult@16 in emunet is not defined __imp__ReadFile@20 in emunet is not defined __imp__RegCloseKey@4 in emunet is not defined __imp__RegEnumKeyExA@32 in emunet is not defined
Quoted 9 lines
__imp__RegOpenKeyExA@20 in emunet is not defined __imp__RegQueryValueExA@24 in emunet is not defined __imp__ResetEvent@4 in emunet is not defined __imp__WaitForSingleObject@8 in emunet is not defined __imp__WriteFile@20 in emunet is not defined
_cygwin_attach_handle_to_fdin emunet is not defined_get_osfhandlein emunet is not defined Makefile:81312: recipe for target `moddep.lst' failed
I moved now this part to grub-devel/osdep/*/emunet.c. There is no problem to access host functions anymore. Now it should be as easy implementing grub-devel/osdep/windows/emunet.c and registering it in grub-devel/osdep/emunet.c.
However some of the code you copied isn't license-compatible (namely it states GPLv2-only), other files lack copyright headers altogether. Copying files from external projects for secondary objectives isn't well accepted in GNU projects under best of times. In case of copyright problem like here it's a no-go in any project.
You can try clear-up the copyright situation by e.g. asking authors to relicense tap-win32.h or rewriting it. However it still doesn't feel important enough to grant an exception to guideline regarding regarding external code.
How difficult is it to use the kernel driver without copying any code?