Hi list, I'm currently trying to port GRUB2 to OpenBSD 5.3-amd64. I have attached a patch that adds missing defines and includes to make the code build on OpenBSD. Some ./configure tricks were also nessesary -- the old GCC in OpenBSD doesn't understand -Wempty-body option.
The build environment is the following: # as --version GNU assembler 2.15 Copyright 2002 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License. This program has absolutely no warranty. This assembler was configured for a target of `amd64-unknown-openbsd5.3'. # gcc -v Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd5.3/4.2.1/specs Target: amd64-unknown-openbsd5.3 Configured with: OpenBSD/amd64 system compiler Thread model: posix gcc version 4.2.1 20070719 So, the binutils version is 2.15 and the compiler is 4.2.1. The ./configure command line I used is the following: ./configure CFLAGS=-ftrampolines -fno-stack-protector LEX=/usr/local/bin/gflex TARGET_CFLAGS=-ftrampolines -fno-stack-protector However now I have a problem on linking stage. The last lines from build log are the following: # gmake gmake all-recursive gmake[1]: Entering directory `/home/grub/grub-2.00' Making all in grub-core/gnulib gmake[2]: Entering directory `/home/grub/grub-2.00/grub-core/gnulib' gmake all-recursive gmake[3]: Entering directory `/home/grub/grub-2.00/grub-core/gnulib' gmake[4]: Entering directory `/home/grub/grub-2.00/grub-core/gnulib' gmake[4]: Nothing to be done for `all-am'. gmake[4]: Leaving directory `/home/grub/grub-2.00/grub-core/gnulib' gmake[3]: Leaving directory `/home/grub/grub-2.00/grub-core/gnulib' gmake[2]: Leaving directory `/home/grub/grub-2.00/grub-core/gnulib' Making all in . gmake[2]: Entering directory `/home/grub/grub-2.00' gmake[2]: Leaving directory `/home/grub/grub-2.00' Making all in grub-core gmake[2]: Entering directory `/home/grub/grub-2.00/grub-core' gmake all-am gmake[3]: Entering directory `/home/grub/grub-2.00/grub-core' gcc -ftrampolines -fno-stack-protector -Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -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 -m32 -fno-PIE -fno-PIC -fno-stack-protector -mno-stack-arg-probe -Werror -Wno-trampolines -mrtd -mregparm=3 -ffreestanding -ftrampolines -fno-stack-protector -m32 -nostdlib -Wl,-N -Wl,-r,-d -o trig.module trig_module-trigtables.o /usr/bin/ld: Relocatable linking with relocations from format elf32-i386 (trig_module-trigtables.o) to format elf64-x86-64 (trig.module) is not supported collect2: ld returned 1 exit status gmake[3]: *** [trig.module] Error 1 gmake[3]: Leaving directory `/home/grub/grub-2.00/grub-core' gmake[2]: *** [all] Error 2 gmake[2]: Leaving directory `/home/grub/grub-2.00/grub-core' gmake[1]: *** [all-recursive] Error 1 gmake[1]: Leaving directory `/home/grub/grub-2.00' gmake: *** [all] Error 2 The Makefile used here is generated by ./configure and I cannot understand what it does. Could you please help me to solve the linking problem? What else do you need from me? Thanks! -- Ilya
--- grub-2.00.orig/configure Tue Jun 26 13:59:16 2012
+++ grub-2.00/configure Thu Aug 8 14:23:48 2013
@@ -20050,7 +20050,7 @@
LIBS=""
# debug flags.
-WARN_FLAGS="-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"
+WARN_FLAGS="-Wall -W -Wshadow -Wold-style-definition -Wpointer-arith -Wundef -Wextra -Waddress -Wattributes -Wcast-align -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -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_CFLAGS="$HOST_CFLAGS $WARN_FLAGS"
TARGET_CFLAGS="$TARGET_CFLAGS $WARN_FLAGS -g -Wredundant-decls -Wmissing-prototypes -Wmissing-declarations"
TARGET_CCASFLAGS="$TARGET_CCASFLAGS -g"
@@ -20485,6 +20485,7 @@
}
_ACEOF
if { ac_try='${CC-cc} ${CFLAGS} -S conftest.c'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
diff -ru grub-2.00.orig/grub-core/kern/emu/hostdisk.c grub-2.00/grub-core/kern/emu/hostdisk.c
--- grub-2.00.orig/grub-core/kern/emu/hostdisk.c Mon Jun 25 10:32:04 2012
+++ grub-2.00/grub-core/kern/emu/hostdisk.c Thu Aug 8 14:53:37 2013
@@ -96,7 +96,7 @@
# include <libdevmapper.h>
#endif
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
# define HAVE_DIOCGDINFO
# include <sys/ioctl.h>
# include <sys/disklabel.h> /* struct disklabel */
@@ -105,11 +105,16 @@
# undef HAVE_DIOCGDINFO
#endif /* defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) */
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
# ifdef HAVE_GETRAWPARTITION
# include <util.h> /* getrawpartition */
# endif /* HAVE_GETRAWPARTITION */
+# if defined(__NetBSD__)
# include <sys/fdio.h>
+# endif
+# if defined(__OpenBSD__)
+# include <sys/dkio.h>
+# endif
# ifndef RAW_FLOPPY_MAJOR
# define RAW_FLOPPY_MAJOR 9
# endif /* ! RAW_FLOPPY_MAJOR */
@@ -243,7 +248,7 @@
grub_util_get_fd_size (int fd, const char *name, unsigned *log_secsize)
{
#if !defined (__GNU__)
-# if defined(__NetBSD__)
+# if defined(__NetBSD__) || defined(__OpenBSD__)
struct disklabel label;
# elif defined (__sun__)
struct dk_minfo minfo;
@@ -260,9 +265,9 @@
#if defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) \
- || defined (__sun__)
+ || defined (__sun__) || defined(__OpenBSD__)
-# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__)
+# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) || defined(__NetBSD__) || defined (__sun__) || defined(__OpenBSD__)
if (! S_ISCHR (st.st_mode))
# else
if (! S_ISBLK (st.st_mode))
@@ -273,8 +278,10 @@
if (ioctl (fd, DIOCGMEDIASIZE, &nr))
# elif defined(__APPLE__)
if (ioctl (fd, DKIOCGETBLOCKCOUNT, &nr))
-# elif defined(__NetBSD__)
+# elif defined(__NetBSD__) || defined(__OpenBSD__)
+# if defined(__NetBSD__)
configure_device_driver (fd);
+# endif
if (ioctl (fd, DIOCGDINFO, &label) == -1)
# elif defined (__sun__)
if (!ioctl (fd, DKIOCGMEDIAINFO, &minfo))
@@ -291,7 +298,7 @@
goto fail;
# elif defined(__sun__)
sector_size = minfo.dki_lbsize;
-# elif defined(__NetBSD__)
+# elif defined(__NetBSD__) || defined(__OpenBSD__)
sector_size = label.d_secsize;
# else
if (ioctl (fd, BLKSSZGET, §or_size))
@@ -308,7 +315,7 @@
# if defined (__APPLE__)
return nr << log_sector_size;
-# elif defined(__NetBSD__)
+# elif defined(__NetBSD__) || defined(__OpenBSD__)
return (grub_uint64_t) label.d_secperunit << log_sector_size;
# elif defined (__sun__)
return minfo.dki_capacity << log_sector_size;
--- grub-2.00.orig/util/getroot.c Fri Jun 22 17:42:07 2012
+++ grub-2.00/util/getroot.c Thu Aug 8 14:40:22 2013
@@ -54,7 +54,8 @@
#include <sys/types.h>
#include <sys/wait.h>
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__)
+# include <sys/param.h>
# include <sys/mount.h>
#endif
@@ -121,7 +122,7 @@
# include <libdevmapper.h>
#endif
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
# define HAVE_DIOCGDINFO
# include <sys/ioctl.h>
# include <sys/disklabel.h> /* struct disklabel */
@@ -130,11 +131,13 @@
# undef HAVE_DIOCGDINFO
#endif /* defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) */
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined(__OpenBSD__)
# ifdef HAVE_GETRAWPARTITION
# include <util.h> /* getrawpartition */
# endif /* HAVE_GETRAWPARTITION */
+#if defined(__NetBSD__)
# include <sys/fdio.h>
+#endif
# ifndef FLOPPY_MAJOR
# define FLOPPY_MAJOR 2
# endif /* ! FLOPPY_MAJOR */
@@ -2004,7 +2007,7 @@
}
return path;
-#elif defined(__NetBSD__)
+#elif defined(__NetBSD__) || defined(__OpenBSD__)
int rawpart = -1;
# ifdef HAVE_GETRAWPARTITION
rawpart = getrawpartition();
@@ -2012,6 +2015,7 @@
if (rawpart < 0)
return xstrdup (os_dev);
+#if defined(__NetBSD__)
/* NetBSD disk wedges are of the form "/dev/rdk.*". */
if (strncmp ("/dev/rdk", os_dev, sizeof("/dev/rdk") - 1) == 0)
{
@@ -2038,6 +2042,7 @@
close (fd);
return xasprintf ("/dev/r%s%c", dkw.dkw_parent, 'a' + rawpart);
}
+#endif
/* NetBSD (disk label) partitions are of the form "/dev/r[a-z]+[0-9][a-z]". */
if (strncmp ("/dev/r", os_dev, sizeof("/dev/r") - 1) == 0 &&
@@ -2210,7 +2215,7 @@
#endif
return make_device_name (drive, -1, -1);
-#if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined (__sun__)
+#if defined(__linux__) || defined(__CYGWIN__) || defined(HAVE_DIOCGDINFO) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined (__sun__) || defined(__OpenBSD__)
/* Linux counts partitions uniformly, whether a BSD partition or a DOS
partition, so mapping them to GRUB devices is not trivial.
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Bug-grub mailing list [email protected] https://lists.gnu.org/mailman/listinfo/bug-grub
