dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0045-fix-Mingw-W64-32-cross-compile-failure-due-to-printf.patch

4fe85b
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4fe85b
From: Andrey Borzenkov <arvidjaar@gmail.com>
4fe85b
Date: Sat, 25 Jan 2014 21:49:41 +0400
4fe85b
Subject: [PATCH] fix Mingw W64-32 cross compile failure due to printf
4fe85b
 redefinition in libintl.h
4fe85b
4fe85b
In file included from util/misc.c:36:0:
4fe85b
./include/grub/emu/misc.h:56:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]
4fe85b
 char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
4fe85b
 ^
4fe85b
./include/grub/emu/misc.h:58:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=]
4fe85b
4fe85b
The reason is libintl.h which redefines printf as libintl_printf. The problem
4fe85b
is not present in native MinGW build which avoids redefinition.  Use
4fe85b
(format (__printf__) instead which is valid replacement in GCC.
4fe85b
4fe85b
v2: add grub-core/lib/libgcrypt/src/g10lib.h
4fe85b
v3: modify g10lib.h during import
4fe85b
---
4fe85b
 include/grub/crypto.h   | 2 +-
4fe85b
 include/grub/emu/misc.h | 8 ++++----
4fe85b
 include/grub/err.h      | 2 +-
4fe85b
 ChangeLog               | 9 +++++++++
4fe85b
 util/import_gcry.py     | 6 ++++++
4fe85b
 5 files changed, 21 insertions(+), 6 deletions(-)
4fe85b
4fe85b
diff --git a/include/grub/crypto.h b/include/grub/crypto.h
4fe85b
index ec1b980d2ec..a24e89dd9cd 100644
4fe85b
--- a/include/grub/crypto.h
4fe85b
+++ b/include/grub/crypto.h
4fe85b
@@ -408,7 +408,7 @@ void _gcry_assert_failed (const char *expr, const char *file, int line,
4fe85b
                           const char *func) __attribute__ ((noreturn));
4fe85b
 
4fe85b
 void _gcry_burn_stack (int bytes);
4fe85b
-void _gcry_log_error( const char *fmt, ... )  __attribute__ ((format (printf, 1, 2)));
4fe85b
+void _gcry_log_error( const char *fmt, ... )  __attribute__ ((format (__printf__, 1, 2)));
4fe85b
 
4fe85b
 
4fe85b
 #ifdef GRUB_UTIL
4fe85b
diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h
4fe85b
index dde48c192d3..a588ba21da2 100644
4fe85b
--- a/include/grub/emu/misc.h
4fe85b
+++ b/include/grub/emu/misc.h
4fe85b
@@ -53,11 +53,11 @@ grub_util_device_is_mapped (const char *dev);
4fe85b
 void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT;
4fe85b
 void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT;
4fe85b
 char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT;
4fe85b
-char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT;
4fe85b
+char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))) WARN_UNUSED_RESULT;
4fe85b
 
4fe85b
-void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
4fe85b
-void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
4fe85b
-void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn));
4fe85b
+void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
4fe85b
+void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2)));
4fe85b
+void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn));
4fe85b
 
4fe85b
 grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void);
4fe85b
 
4fe85b
diff --git a/include/grub/err.h b/include/grub/err.h
4fe85b
index 9896fccf98a..1590c688e1d 100644
4fe85b
--- a/include/grub/err.h
4fe85b
+++ b/include/grub/err.h
4fe85b
@@ -91,6 +91,6 @@ int EXPORT_FUNC(grub_error_pop) (void);
4fe85b
 void EXPORT_FUNC(grub_print_error) (void);
4fe85b
 extern int EXPORT_VAR(grub_err_printed_errors);
4fe85b
 int grub_err_printf (const char *fmt, ...)
4fe85b
-     __attribute__ ((format (printf, 1, 2)));
4fe85b
+     __attribute__ ((format (__printf__, 1, 2)));
4fe85b
 
4fe85b
 #endif /* ! GRUB_ERR_HEADER */
4fe85b
diff --git a/ChangeLog b/ChangeLog
4fe85b
index b405b7ee5bd..c93f11fbb20 100644
4fe85b
--- a/ChangeLog
4fe85b
+++ b/ChangeLog
4fe85b
@@ -1,3 +1,12 @@
4fe85b
+
4fe85b
+2014-01-25  Andrey Borzenkov <arvidjaar@gmail.com>
4fe85b
+
4fe85b
+	* include/grub/crypto.h: Replace __attribute__ ((format (printf)) with
4fe85b
+	__attribute__ ((format (__printf__)) to fix compilation under MinGW-w64.
4fe85b
+	* include/grub/emu/misc.h: ... and here.
4fe85b
+	* include/grub/err.h: ... and here.
4fe85b
+	* util/import_gcry.py: ... and here (in files g10lib.h).
4fe85b
+
4fe85b
 2014-01-25  Andrey Borzenkov <arvidjaar@gmail.com>
4fe85b
 
4fe85b
 	* util/grub-mkimage.c: Make prefix argument mandatory.
4fe85b
diff --git a/util/import_gcry.py b/util/import_gcry.py
4fe85b
index 63ebb90f1fe..2b3322d3a12 100644
4fe85b
--- a/util/import_gcry.py
4fe85b
+++ b/util/import_gcry.py
4fe85b
@@ -534,6 +534,12 @@ for src in sorted (os.listdir (os.path.join (indir, "src"))):
4fe85b
         fw.close ()
4fe85b
         continue
4fe85b
 
4fe85b
+    if src == "g10lib.h":
4fe85b
+        fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)"))
4fe85b
+        f.close ()
4fe85b
+        fw.close ()
4fe85b
+        continue
4fe85b
+
4fe85b
     fw.write (f.read ())
4fe85b
     f.close ()
4fe85b
     fw.close ()