aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2020-02-10 15:37:34 +0000
committerWerner Koch <[email protected]>2020-02-10 15:50:47 +0000
commit6aff8a132815a84bab69401c1e7de96ec549fbf2 (patch)
tree00e313097a522fc1956bed6f45a5361422b561ae
parentgpg: Make really sure that --verify-files always returns an error. (diff)
downloadgnupg-6aff8a132815a84bab69401c1e7de96ec549fbf2.tar.gz
gnupg-6aff8a132815a84bab69401c1e7de96ec549fbf2.zip
build: Always use EXTERN_UNLESS_MAIN_MODULE pattern.
* common/util.h (EXTERN_UNLESS_MAIN_MODULE): Add the definion only here but now without the Norcroft-C. Change all other places where it gets defined. * common/iobuf.h (iobuf_debug_mode): Declare unconditionally as extern. * common/iobuf.c (iobuf_debug_mode): Define it here. * agent/gpg-agent.c (INCLUDED_BY_MAIN_MODULE): Define here and also in all main modules of all other programs. * g10/main.h: Put util.h before the local header files. -- This change is required for use with gcc/ld's LTO feature which does not allow common blocks. Further gcc 10 will make -fno-common the default and thus this chnage is always needed. What a pitty. Co-authored-by: Tomáš Mráz GnuPG-bug-id: 4831 Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 21d9bd8b87a9f793a106095e3838eb71825189d7) - Applied respective chnages also to gpg-card and keyboxd. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--agent/agent.h1
-rw-r--r--agent/gpg-agent.c1
-rw-r--r--agent/preset-passphrase.c1
-rw-r--r--agent/protect-tool.c1
-rw-r--r--agent/t-protect.c1
-rw-r--r--common/iobuf.c1
-rw-r--r--common/iobuf.h9
-rw-r--r--common/util.h8
-rw-r--r--dirmngr/dirmngr.c1
-rw-r--r--dirmngr/dirmngr.h1
-rw-r--r--g10/gpgcompose.c1
-rw-r--r--g10/main.h2
-rw-r--r--g10/options.h8
-rw-r--r--g10/test.c1
-rw-r--r--g13/g13-common.h2
-rw-r--r--g13/g13-syshelp.c1
-rw-r--r--g13/g13.c1
-rw-r--r--kbx/keyboxd.c1
-rw-r--r--kbx/keyboxd.h1
-rw-r--r--scd/scdaemon.c1
-rw-r--r--scd/scdaemon.h1
-rw-r--r--sm/gpgsm.c2
-rw-r--r--sm/gpgsm.h1
-rw-r--r--tools/gpg-card.c2
-rw-r--r--tools/gpg-card.h1
-rw-r--r--tools/gpg-wks-client.c1
-rw-r--r--tools/gpg-wks-server.c1
-rw-r--r--tools/gpg-wks.h1
-rw-r--r--tools/gpgconf.c1
-rw-r--r--tools/gpgconf.h1
-rw-r--r--tools/gpgtar.c1
-rw-r--r--tools/gpgtar.h2
32 files changed, 41 insertions, 18 deletions
diff --git a/agent/agent.h b/agent/agent.h
index 49cc2fd98..f7e96fcff 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -55,6 +55,7 @@
/* A large struct name "opt" to keep global flags */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE) */
diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c
index 6a7213c67..70e9e229f 100644
--- a/agent/gpg-agent.c
+++ b/agent/gpg-agent.c
@@ -48,6 +48,7 @@
#endif
#include <npth.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL
#include "agent.h"
#include <assuan.h> /* Malloc hooks and socket wrappers. */
diff --git a/agent/preset-passphrase.c b/agent/preset-passphrase.c
index e22e9d58d..7b322a0b7 100644
--- a/agent/preset-passphrase.c
+++ b/agent/preset-passphrase.c
@@ -43,6 +43,7 @@
# include <windows.h> /* To initialize the sockets. fixme */
#endif
+#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h"
#include "../common/simple-pwquery.h"
#include "../common/i18n.h"
diff --git a/agent/protect-tool.c b/agent/protect-tool.c
index 059a9bdbd..4a307abc2 100644
--- a/agent/protect-tool.c
+++ b/agent/protect-tool.c
@@ -37,6 +37,7 @@
#include <fcntl.h> /* for setmode() */
#endif
+#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h"
#include "../common/i18n.h"
#include "../common/get-passphrase.h"
diff --git a/agent/t-protect.c b/agent/t-protect.c
index d17c19325..88b552585 100644
--- a/agent/t-protect.c
+++ b/agent/t-protect.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <assert.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h"
diff --git a/common/iobuf.c b/common/iobuf.c
index db5d062cd..43f2e101c 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -123,6 +123,7 @@ struct close_cache_s
typedef struct close_cache_s *close_cache_t;
static close_cache_t close_cache;
+int iobuf_debug_mode;
#ifdef HAVE_W32_SYSTEM
diff --git a/common/iobuf.h b/common/iobuf.h
index 9c9650c61..a3d9bd547 100644
--- a/common/iobuf.h
+++ b/common/iobuf.h
@@ -249,14 +249,7 @@ struct iobuf_struct
int subno;
};
-#ifndef EXTERN_UNLESS_MAIN_MODULE
-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
-#define EXTERN_UNLESS_MAIN_MODULE extern
-#else
-#define EXTERN_UNLESS_MAIN_MODULE
-#endif
-#endif
-EXTERN_UNLESS_MAIN_MODULE int iobuf_debug_mode;
+extern int iobuf_debug_mode;
/* Change the default size for all IOBUFs to KILOBYTE. This needs to
diff --git a/common/util.h b/common/util.h
index 8ad805832..a6bab2415 100644
--- a/common/util.h
+++ b/common/util.h
@@ -48,6 +48,14 @@
#define GPG_ERR_KEYBOXD 317
#endif /*GPG_ERROR_VERSION_NUMBER*/
+#ifndef EXTERN_UNLESS_MAIN_MODULE
+# if !defined (INCLUDED_BY_MAIN_MODULE)
+# define EXTERN_UNLESS_MAIN_MODULE extern
+# else
+# define EXTERN_UNLESS_MAIN_MODULE
+# endif
+#endif
+
/* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c
index 8f28fa43d..88f0aa430 100644
--- a/dirmngr/dirmngr.c
+++ b/dirmngr/dirmngr.c
@@ -55,6 +55,7 @@
#endif /*HTTP_USE_GNUTLS*/
+#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL
#include "dirmngr.h"
diff --git a/dirmngr/dirmngr.h b/dirmngr/dirmngr.h
index b27b8e6fb..92d9d4b6a 100644
--- a/dirmngr/dirmngr.h
+++ b/dirmngr/dirmngr.h
@@ -77,6 +77,7 @@ struct fingerprint_list_s
/* A large struct named "opt" to keep global flags. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* debug flags (DBG_foo_VALUE) */
diff --git a/g10/gpgcompose.c b/g10/gpgcompose.c
index 43cecb90e..0a2b21a4c 100644
--- a/g10/gpgcompose.c
+++ b/g10/gpgcompose.c
@@ -20,6 +20,7 @@
#include <config.h>
#include <errno.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "gpg.h"
#include "packet.h"
#include "keydb.h"
diff --git a/g10/main.h b/g10/main.h
index ec58795b0..704eb339f 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -22,9 +22,9 @@
#include "../common/types.h"
#include "../common/iobuf.h"
+#include "../common/util.h"
#include "keydb.h"
#include "keyedit.h"
-#include "../common/util.h"
/* It could be argued that the default cipher should be 3DES rather
than AES128, and the default compression should be 0
diff --git a/g10/options.h b/g10/options.h
index 339804f59..e80d3ead0 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -30,14 +30,6 @@
#include "../common/session-env.h"
#include "../common/compliance.h"
-#ifndef EXTERN_UNLESS_MAIN_MODULE
-/* Norcraft can't cope with common symbols */
-#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
-#define EXTERN_UNLESS_MAIN_MODULE extern
-#else
-#define EXTERN_UNLESS_MAIN_MODULE
-#endif
-#endif
/* Declaration of a keyserver spec type. The definition is found in
../common/keyserver.h. */
diff --git a/g10/test.c b/g10/test.c
index 375f361a7..648148a10 100644
--- a/g10/test.c
+++ b/g10/test.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <string.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "gpg.h"
/* A unit test consists of one or more tests. Tests can be broken
diff --git a/g13/g13-common.h b/g13/g13-common.h
index acf25b843..42b8deebd 100644
--- a/g13/g13-common.h
+++ b/g13/g13-common.h
@@ -32,7 +32,6 @@
#include "../common/session-env.h"
#include "../common/strlist.h"
-
/* Debug values and macros. */
#define DBG_MOUNT_VALUE 1 /* Debug mount or device stuff. */
#define DBG_CRYPTO_VALUE 4 /* Debug low level crypto. */
@@ -48,6 +47,7 @@
/* A large struct named "opt" to keep global flags. Note that this
struct is used by g13 and g13-syshelp and thus some fields may only
make sense for one of them. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE). */
diff --git a/g13/g13-syshelp.c b/g13/g13-syshelp.c
index bf71ac20f..4ce74ee4c 100644
--- a/g13/g13-syshelp.c
+++ b/g13/g13-syshelp.c
@@ -31,6 +31,7 @@
#endif
#include <unistd.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "g13-syshelp.h"
#include <gcrypt.h>
diff --git a/g13/g13.c b/g13/g13.c
index 4b925ed59..6265b9f24 100644
--- a/g13/g13.c
+++ b/g13/g13.c
@@ -27,6 +27,7 @@
#include <fcntl.h>
#include <npth.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "g13.h"
#include <gcrypt.h>
diff --git a/kbx/keyboxd.c b/kbx/keyboxd.c
index 59e320467..9b46565c6 100644
--- a/kbx/keyboxd.c
+++ b/kbx/keyboxd.c
@@ -46,6 +46,7 @@
#endif
#include <npth.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL
#include "keyboxd.h"
#include <assuan.h> /* Malloc hooks and socket wrappers. */
diff --git a/kbx/keyboxd.h b/kbx/keyboxd.h
index d7bb97ab9..f0b705aad 100644
--- a/kbx/keyboxd.h
+++ b/kbx/keyboxd.h
@@ -33,6 +33,7 @@
/* A large struct name "opt" to keep global flags */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE) */
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index 1796db386..942944f38 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -37,6 +37,7 @@
#include <signal.h>
#include <npth.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL
#include "scdaemon.h"
#include <ksba.h>
diff --git a/scd/scdaemon.h b/scd/scdaemon.h
index 1c46d673a..391f16578 100644
--- a/scd/scdaemon.h
+++ b/scd/scdaemon.h
@@ -46,6 +46,7 @@
/* A large struct name "opt" to keep global flags. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* Debug flags (DBG_foo_VALUE). */
diff --git a/sm/gpgsm.c b/sm/gpgsm.c
index 2f4470ec0..8b4c9631d 100644
--- a/sm/gpgsm.c
+++ b/sm/gpgsm.c
@@ -28,6 +28,8 @@
#include <fcntl.h>
/*#include <mcheck.h>*/
+#define INCLUDED_BY_MAIN_MODULE 1
+
#include "gpgsm.h"
#include <gcrypt.h>
#include <assuan.h> /* malloc hooks */
diff --git a/sm/gpgsm.h b/sm/gpgsm.h
index 7393a80f3..15b49782b 100644
--- a/sm/gpgsm.h
+++ b/sm/gpgsm.h
@@ -53,6 +53,7 @@ struct keyserver_spec
/* A large struct named "opt" to keep global flags. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
unsigned int debug; /* debug flags (DBG_foo_VALUE) */
diff --git a/tools/gpg-card.c b/tools/gpg-card.c
index 9979020a3..3d87e2ef2 100644
--- a/tools/gpg-card.c
+++ b/tools/gpg-card.c
@@ -27,6 +27,8 @@
# include <readline/readline.h>
#endif /*HAVE_LIBREADLINE*/
+#define INCLUDED_BY_MAIN_MODULE 1
+
#include "../common/util.h"
#include "../common/status.h"
#include "../common/i18n.h"
diff --git a/tools/gpg-card.h b/tools/gpg-card.h
index 02c1ed314..5d75c2bb9 100644
--- a/tools/gpg-card.h
+++ b/tools/gpg-card.h
@@ -25,6 +25,7 @@
/* We keep all global options in the structure OPT. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
int interactive;
diff --git a/tools/gpg-wks-client.c b/tools/gpg-wks-client.c
index 861a1fc61..98ca2fb38 100644
--- a/tools/gpg-wks-client.c
+++ b/tools/gpg-wks-client.c
@@ -25,6 +25,7 @@
#include <sys/types.h>
#include <sys/stat.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h"
#include "../common/status.h"
#include "../common/i18n.h"
diff --git a/tools/gpg-wks-server.c b/tools/gpg-wks-server.c
index 2082fb87d..8cdbfaf36 100644
--- a/tools/gpg-wks-server.c
+++ b/tools/gpg-wks-server.c
@@ -32,6 +32,7 @@
#include <sys/stat.h>
#include <dirent.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h"
#include "../common/init.h"
#include "../common/sysutils.h"
diff --git a/tools/gpg-wks.h b/tools/gpg-wks.h
index 9acd7c37f..6c5dc8b17 100644
--- a/tools/gpg-wks.h
+++ b/tools/gpg-wks.h
@@ -30,6 +30,7 @@
/* We keep all global options in the structure OPT. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
int verbose;
diff --git a/tools/gpgconf.c b/tools/gpgconf.c
index 596aa957d..6dd3c0c9c 100644
--- a/tools/gpgconf.c
+++ b/tools/gpgconf.c
@@ -25,6 +25,7 @@
#include <string.h>
#include <unistd.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "gpgconf.h"
#include "../common/i18n.h"
#include "../common/sysutils.h"
diff --git a/tools/gpgconf.h b/tools/gpgconf.h
index 192259789..adb90a1f6 100644
--- a/tools/gpgconf.h
+++ b/tools/gpgconf.h
@@ -23,6 +23,7 @@
#include "../common/util.h"
/* We keep all global options in the structure OPT. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
int verbose; /* Verbosity level. */
diff --git a/tools/gpgtar.c b/tools/gpgtar.c
index b33aa6d0f..e5cbde4af 100644
--- a/tools/gpgtar.c
+++ b/tools/gpgtar.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <assert.h>
+#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h"
#include "../common/i18n.h"
#include "../common/sysutils.h"
diff --git a/tools/gpgtar.h b/tools/gpgtar.h
index 1a1b913d7..74bfb56e8 100644
--- a/tools/gpgtar.h
+++ b/tools/gpgtar.h
@@ -23,7 +23,9 @@
#include "../common/util.h"
#include "../common/strlist.h"
+
/* We keep all global options in the structure OPT. */
+EXTERN_UNLESS_MAIN_MODULE
struct
{
int verbose;