* [PATCH v2 1/9] Fix error when cross-compiling for windows from unix-like OS
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 2/9] compiler-rt: Add pei386_runtime_relocator stub Vladimir Serbinenko
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
In this case exeext doesn't match the expected value by autoconf
and so tests fail as autoconf looks for compiled binaries under
wrong name.
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
configure.ac | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/configure.ac b/configure.ac
index 83e3ddf90..e9c6ad8cc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -575,12 +575,22 @@ tmp_CFLAGS="$CFLAGS"
tmp_LDFLAGS="$LDFLAGS"
tmp_CPPFLAGS="$CPPFLAGS"
tmp_LIBS="$LIBS"
+tmp_EXEEXT="$EXEEXT"
+tmp_ac_exeext="$ac_exeext"
CC="$TARGET_CC"
CFLAGS="$TARGET_CFLAGS"
CPPFLAGS="$TARGET_CPPFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
LIBS=""
+case "$target_os" in
+ cygwin*|mingw32*|mingw64*) TARGET_EXEEXT=.exe ;;
+ *) TARGET_EXEEXT= ;;
+esac
+
+EXEEXT="$TARGET_EXEEXT"
+ac_exeext="$TARGET_EXEEXT"
+
if test "x$target_m32" = x1; then
# Force 32-bit mode.
TARGET_CFLAGS="$TARGET_CFLAGS -m32"
@@ -1618,6 +1628,8 @@ CFLAGS="$tmp_CFLAGS"
CPPFLAGS="$tmp_CPPFLAGS"
LDFLAGS="$tmp_LDFLAGS"
LIBS="$tmp_LIBS"
+EXEEXT="$tmp_EXEEXT"
+ac_exeext="$tmp_ac_exeext"
#
# Check for options.
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 2/9] compiler-rt: Add pei386_runtime_relocator stub
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 1/9] Fix error when cross-compiling for windows from unix-like OS Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 3/9] pe2elf: Set correct flag for relocation sections Vladimir Serbinenko
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
It's inserted by mingw and is meaningless in our environment
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
grub-core/kern/compiler-rt.c | 4 ++++
include/grub/compiler-rt.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c
index eda689a0c..28d3c62fe 100644
--- a/grub-core/kern/compiler-rt.c
+++ b/grub-core/kern/compiler-rt.c
@@ -210,6 +210,10 @@ void ___chkstk_ms (void)
void __chkstk_ms (void)
{
}
+
+void _pei386_runtime_relocator (void)
+{
+}
#endif
union component64
diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h
index 17828b322..e139ebc87 100644
--- a/include/grub/compiler-rt.h
+++ b/include/grub/compiler-rt.h
@@ -207,6 +207,7 @@ void EXPORT_FUNC (__register_frame_info) (void);
void EXPORT_FUNC (__deregister_frame_info) (void);
void EXPORT_FUNC (___chkstk_ms) (void);
void EXPORT_FUNC (__chkstk_ms) (void);
+void EXPORT_FUNC (_pei386_runtime_relocator) (void);
#endif
#endif
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 3/9] pe2elf: Set correct flag for relocation sections
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 1/9] Fix error when cross-compiling for windows from unix-like OS Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 2/9] compiler-rt: Add pei386_runtime_relocator stub Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 4/9] hostdisk: Fix cygwin compilation Vladimir Serbinenko
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
Without this flag GRUB ignores the relocation section leading to a crash
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
util/grub-pe2elf.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c
index 11331294f..b686f0c82 100644
--- a/util/grub-pe2elf.c
+++ b/util/grub-pe2elf.c
@@ -341,6 +341,7 @@ write_reloc_section (FILE* fp, const char *name, char *image,
shdr[i].sh_offset = offset;
shdr[i].sh_link = symtab_section;
shdr[i].sh_addralign = 4;
+ shdr[i].sh_flags = SHF_INFO_LINK;
shdr[i].sh_entsize = sizeof (elf_reloc_t);
shdr[i].sh_size = num_rels * sizeof (elf_reloc_t);
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 4/9] hostdisk: Fix cygwin compilation
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
` (2 preceding siblings ...)
2025-05-03 8:06 ` [PATCH v2 3/9] pe2elf: Set correct flag for relocation sections Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 5/9] Add cygwin path to unifont Vladimir Serbinenko
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
grub-core/osdep/windows/hostdisk.c | 5 +++--
include/grub/osdep/hostfile_windows.h | 10 ++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c
index aaa6e2f8e..4d37d9db0 100644
--- a/grub-core/osdep/windows/hostdisk.c
+++ b/grub-core/osdep/windows/hostdisk.c
@@ -669,13 +669,14 @@ grub_util_is_special_file (const char *name)
#else
-void
+int
grub_util_file_sync (FILE *f)
{
fflush (f);
if (!allow_fd_syncs)
- return;
+ return 0;
fsync (fileno (f));
+ return 0;
}
FILE *
diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h
index bf6451b6d..a712170d1 100644
--- a/include/grub/osdep/hostfile_windows.h
+++ b/include/grub/osdep/hostfile_windows.h
@@ -77,6 +77,16 @@ enum grub_util_fd_open_flags_t
#endif
+#ifdef __CYGWIN__
+#include <unistd.h>
+
+static inline ssize_t
+grub_util_readlink (const char *name, char *buf, size_t bufsize)
+{
+ return readlink(name, buf, bufsize);
+}
+#endif
+
LPTSTR
grub_util_utf8_to_tchar (const char *in);
char *
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 5/9] Add cygwin path to unifont
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
` (3 preceding siblings ...)
2025-05-03 8:06 ` [PATCH v2 4/9] hostdisk: Fix cygwin compilation Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 6/9] Strip extra sections generated on cygwin when creating binary images Vladimir Serbinenko
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
configure.ac | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index e9c6ad8cc..8417ce009 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1925,7 +1925,7 @@ AC_ARG_WITH([unifont],
if test "x$with_unifont" = x; then
# search in well-known directories
for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz otf otf.gz; do
- for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc /usr/pkg/share/fonts/X11/misc /usr/local/share/fonts/gnu-unifont /usr/local/share/fonts/unifont; do
+ for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc /usr/pkg/share/fonts/X11/misc /usr/local/share/fonts/gnu-unifont /usr/local/share/fonts/unifont /usr/share/fonts/opentype/unifont; do
if test -f "$dir/unifont.$ext"; then
md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
# PCF and BDF from version 6.3 isn't hanled properly by libfreetype.
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 6/9] Strip extra sections generated on cygwin when creating binary images
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
` (4 preceding siblings ...)
2025-05-03 8:06 ` [PATCH v2 5/9] Add cygwin path to unifont Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 7/9] mkrescue: Fix compilation under cygwin Vladimir Serbinenko
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
gentpl.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gentpl.py b/gentpl.py
index d8c6965d8..f20797228 100644
--- a/gentpl.py
+++ b/gentpl.py
@@ -775,7 +775,7 @@ def image(defn, platform):
if test x$(TARGET_APPLE_LINKER) = x1; then \
$(MACHO2IMG) $< $@; \
else \
- $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx -R .interp $< $@; \
+ $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx -R .interp -R .reloc -R .buildid $< $@; \
fi
""")
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 7/9] mkrescue: Fix compilation under cygwin.
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
` (5 preceding siblings ...)
2025-05-03 8:06 ` [PATCH v2 6/9] Strip extra sections generated on cygwin when creating binary images Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 8/9] Discard .buildid and .reloc in cygwin script Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 9/9] render-label: Supports canonical paths not starting with / Vladimir Serbinenko
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
Cygwin is an interesting case where grub_util_fd_sync
needs a handle but fileno returns an fd. Just use
fsync directly in this case
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
util/grub-mkrescue.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c
index 6dc71a8a1..72cc693f2 100644
--- a/util/grub-mkrescue.c
+++ b/util/grub-mkrescue.c
@@ -670,7 +670,11 @@ main (int argc, char *argv[])
"i386-pc", 0);
sz = ftello (sa);
fflush (sa);
+#ifdef __CYGWIN__
+ fsync (fileno (sa));
+#else
grub_util_fd_sync (fileno (sa));
+#endif
fclose (sa);
if (sz > 32768)
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 8/9] Discard .buildid and .reloc in cygwin script
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
` (6 preceding siblings ...)
2025-05-03 8:06 ` [PATCH v2 7/9] mkrescue: Fix compilation under cygwin Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
2025-05-03 8:06 ` [PATCH v2 9/9] render-label: Supports canonical paths not starting with / Vladimir Serbinenko
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
conf/i386-cygwin-img-ld.sc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/conf/i386-cygwin-img-ld.sc b/conf/i386-cygwin-img-ld.sc
index 578da91b0..aeba49f45 100644
--- a/conf/i386-cygwin-img-ld.sc
+++ b/conf/i386-cygwin-img-ld.sc
@@ -50,6 +50,10 @@ SECTIONS
{
*(.stabstr)
}
+ /DISCARD/ : {
+ *(.buildid)
+ *(.reloc)
+ }
}
ASSERT("__rdata_end__"=="edata", ".pdata not empty")
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v2 9/9] render-label: Supports canonical paths not starting with /
2025-05-03 8:06 [PATCH v2 0/9] Fix compilation and installation on cygwin and mingw Vladimir Serbinenko
` (7 preceding siblings ...)
2025-05-03 8:06 ` [PATCH v2 8/9] Discard .buildid and .reloc in cygwin script Vladimir Serbinenko
@ 2025-05-03 8:06 ` Vladimir Serbinenko
8 siblings, 0 replies; 10+ messages in thread
From: Vladimir Serbinenko @ 2025-05-03 8:06 UTC (permalink / raw)
To: grub-devel; +Cc: Vladimir Serbinenko
On windows canonical path starts with drive letter
Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
---
util/render-label.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/render-label.c b/util/render-label.c
index 432a5c3d2..e78175180 100644
--- a/util/render-label.c
+++ b/util/render-label.c
@@ -164,7 +164,7 @@ grub_util_render_label (const char *label_font,
strerror (errno));
}
- fontfull = xasprintf ("(host)/%s", t);
+ fontfull = xasprintf ("(host)%s", t);
free (t);
grub_font_loader_init ();
--
2.49.0
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread