1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

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 <wk@gnupg.org>
(cherry picked from commit 21d9bd8b87a9f793a106095e3838eb71825189d7)

- Applied respective chnages also to gpg-card and keyboxd.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2020-02-10 16:37:34 +01:00
parent 5681b8eaa4
commit 6aff8a1328
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
32 changed files with 41 additions and 18 deletions

View File

@ -55,6 +55,7 @@
/* A large struct name "opt" to keep global flags */ /* A large struct name "opt" to keep global flags */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
unsigned int debug; /* Debug flags (DBG_foo_VALUE) */ unsigned int debug; /* Debug flags (DBG_foo_VALUE) */

View File

@ -48,6 +48,7 @@
#endif #endif
#include <npth.h> #include <npth.h>
#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL #define GNUPG_COMMON_NEED_AFLOCAL
#include "agent.h" #include "agent.h"
#include <assuan.h> /* Malloc hooks and socket wrappers. */ #include <assuan.h> /* Malloc hooks and socket wrappers. */

View File

@ -43,6 +43,7 @@
# include <windows.h> /* To initialize the sockets. fixme */ # include <windows.h> /* To initialize the sockets. fixme */
#endif #endif
#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h" #include "agent.h"
#include "../common/simple-pwquery.h" #include "../common/simple-pwquery.h"
#include "../common/i18n.h" #include "../common/i18n.h"

View File

@ -37,6 +37,7 @@
#include <fcntl.h> /* for setmode() */ #include <fcntl.h> /* for setmode() */
#endif #endif
#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h" #include "agent.h"
#include "../common/i18n.h" #include "../common/i18n.h"
#include "../common/get-passphrase.h" #include "../common/get-passphrase.h"

View File

@ -23,6 +23,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "agent.h" #include "agent.h"

View File

@ -123,6 +123,7 @@ struct close_cache_s
typedef struct close_cache_s *close_cache_t; typedef struct close_cache_s *close_cache_t;
static close_cache_t close_cache; static close_cache_t close_cache;
int iobuf_debug_mode;
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM

View File

@ -249,14 +249,7 @@ struct iobuf_struct
int subno; int subno;
}; };
#ifndef EXTERN_UNLESS_MAIN_MODULE extern int iobuf_debug_mode;
#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;
/* Change the default size for all IOBUFs to KILOBYTE. This needs to /* Change the default size for all IOBUFs to KILOBYTE. This needs to

View File

@ -48,6 +48,14 @@
#define GPG_ERR_KEYBOXD 317 #define GPG_ERR_KEYBOXD 317
#endif /*GPG_ERROR_VERSION_NUMBER*/ #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. */ /* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write) #define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)

View File

@ -55,6 +55,7 @@
#endif /*HTTP_USE_GNUTLS*/ #endif /*HTTP_USE_GNUTLS*/
#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL #define GNUPG_COMMON_NEED_AFLOCAL
#include "dirmngr.h" #include "dirmngr.h"

View File

@ -77,6 +77,7 @@ struct fingerprint_list_s
/* A large struct named "opt" to keep global flags. */ /* A large struct named "opt" to keep global flags. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
unsigned int debug; /* debug flags (DBG_foo_VALUE) */ unsigned int debug; /* debug flags (DBG_foo_VALUE) */

View File

@ -20,6 +20,7 @@
#include <config.h> #include <config.h>
#include <errno.h> #include <errno.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "gpg.h" #include "gpg.h"
#include "packet.h" #include "packet.h"
#include "keydb.h" #include "keydb.h"

View File

@ -22,9 +22,9 @@
#include "../common/types.h" #include "../common/types.h"
#include "../common/iobuf.h" #include "../common/iobuf.h"
#include "../common/util.h"
#include "keydb.h" #include "keydb.h"
#include "keyedit.h" #include "keyedit.h"
#include "../common/util.h"
/* It could be argued that the default cipher should be 3DES rather /* It could be argued that the default cipher should be 3DES rather
than AES128, and the default compression should be 0 than AES128, and the default compression should be 0

View File

@ -30,14 +30,6 @@
#include "../common/session-env.h" #include "../common/session-env.h"
#include "../common/compliance.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 /* Declaration of a keyserver spec type. The definition is found in
../common/keyserver.h. */ ../common/keyserver.h. */

View File

@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "gpg.h" #include "gpg.h"
/* A unit test consists of one or more tests. Tests can be broken /* A unit test consists of one or more tests. Tests can be broken

View File

@ -32,7 +32,6 @@
#include "../common/session-env.h" #include "../common/session-env.h"
#include "../common/strlist.h" #include "../common/strlist.h"
/* Debug values and macros. */ /* Debug values and macros. */
#define DBG_MOUNT_VALUE 1 /* Debug mount or device stuff. */ #define DBG_MOUNT_VALUE 1 /* Debug mount or device stuff. */
#define DBG_CRYPTO_VALUE 4 /* Debug low level crypto. */ #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 /* 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 struct is used by g13 and g13-syshelp and thus some fields may only
make sense for one of them. */ make sense for one of them. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
unsigned int debug; /* Debug flags (DBG_foo_VALUE). */ unsigned int debug; /* Debug flags (DBG_foo_VALUE). */

View File

@ -31,6 +31,7 @@
#endif #endif
#include <unistd.h> #include <unistd.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "g13-syshelp.h" #include "g13-syshelp.h"
#include <gcrypt.h> #include <gcrypt.h>

View File

@ -27,6 +27,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <npth.h> #include <npth.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "g13.h" #include "g13.h"
#include <gcrypt.h> #include <gcrypt.h>

View File

@ -46,6 +46,7 @@
#endif #endif
#include <npth.h> #include <npth.h>
#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL #define GNUPG_COMMON_NEED_AFLOCAL
#include "keyboxd.h" #include "keyboxd.h"
#include <assuan.h> /* Malloc hooks and socket wrappers. */ #include <assuan.h> /* Malloc hooks and socket wrappers. */

View File

@ -33,6 +33,7 @@
/* A large struct name "opt" to keep global flags */ /* A large struct name "opt" to keep global flags */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
unsigned int debug; /* Debug flags (DBG_foo_VALUE) */ unsigned int debug; /* Debug flags (DBG_foo_VALUE) */

View File

@ -37,6 +37,7 @@
#include <signal.h> #include <signal.h>
#include <npth.h> #include <npth.h>
#define INCLUDED_BY_MAIN_MODULE 1
#define GNUPG_COMMON_NEED_AFLOCAL #define GNUPG_COMMON_NEED_AFLOCAL
#include "scdaemon.h" #include "scdaemon.h"
#include <ksba.h> #include <ksba.h>

View File

@ -46,6 +46,7 @@
/* A large struct name "opt" to keep global flags. */ /* A large struct name "opt" to keep global flags. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
unsigned int debug; /* Debug flags (DBG_foo_VALUE). */ unsigned int debug; /* Debug flags (DBG_foo_VALUE). */

View File

@ -28,6 +28,8 @@
#include <fcntl.h> #include <fcntl.h>
/*#include <mcheck.h>*/ /*#include <mcheck.h>*/
#define INCLUDED_BY_MAIN_MODULE 1
#include "gpgsm.h" #include "gpgsm.h"
#include <gcrypt.h> #include <gcrypt.h>
#include <assuan.h> /* malloc hooks */ #include <assuan.h> /* malloc hooks */

View File

@ -53,6 +53,7 @@ struct keyserver_spec
/* A large struct named "opt" to keep global flags. */ /* A large struct named "opt" to keep global flags. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
unsigned int debug; /* debug flags (DBG_foo_VALUE) */ unsigned int debug; /* debug flags (DBG_foo_VALUE) */

View File

@ -27,6 +27,8 @@
# include <readline/readline.h> # include <readline/readline.h>
#endif /*HAVE_LIBREADLINE*/ #endif /*HAVE_LIBREADLINE*/
#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h" #include "../common/util.h"
#include "../common/status.h" #include "../common/status.h"
#include "../common/i18n.h" #include "../common/i18n.h"

View File

@ -25,6 +25,7 @@
/* We keep all global options in the structure OPT. */ /* We keep all global options in the structure OPT. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
int interactive; int interactive;

View File

@ -25,6 +25,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h" #include "../common/util.h"
#include "../common/status.h" #include "../common/status.h"
#include "../common/i18n.h" #include "../common/i18n.h"

View File

@ -32,6 +32,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h> #include <dirent.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h" #include "../common/util.h"
#include "../common/init.h" #include "../common/init.h"
#include "../common/sysutils.h" #include "../common/sysutils.h"

View File

@ -30,6 +30,7 @@
/* We keep all global options in the structure OPT. */ /* We keep all global options in the structure OPT. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
int verbose; int verbose;

View File

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "gpgconf.h" #include "gpgconf.h"
#include "../common/i18n.h" #include "../common/i18n.h"
#include "../common/sysutils.h" #include "../common/sysutils.h"

View File

@ -23,6 +23,7 @@
#include "../common/util.h" #include "../common/util.h"
/* We keep all global options in the structure OPT. */ /* We keep all global options in the structure OPT. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
int verbose; /* Verbosity level. */ int verbose; /* Verbosity level. */

View File

@ -34,6 +34,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#define INCLUDED_BY_MAIN_MODULE 1
#include "../common/util.h" #include "../common/util.h"
#include "../common/i18n.h" #include "../common/i18n.h"
#include "../common/sysutils.h" #include "../common/sysutils.h"

View File

@ -23,7 +23,9 @@
#include "../common/util.h" #include "../common/util.h"
#include "../common/strlist.h" #include "../common/strlist.h"
/* We keep all global options in the structure OPT. */ /* We keep all global options in the structure OPT. */
EXTERN_UNLESS_MAIN_MODULE
struct struct
{ {
int verbose; int verbose;