Subject: Re: bug#43195: [PATCH] Remove definitions of UP, BC and PC which should be provided by terminfo

From: Eli Zaretskii <[email-masked]>
Date: Fri, 04 Sep 2020 10:36:45 +0300

> Cc: Fangrui Song <[email-masked]>
> Date: Thu,  3 Sep 2020 17:57:48 -0700
> From: Fangrui Song via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> Otherwise if terminfo.c is compiled with -fno-common (GCC 10 and clang
> 11 default) and the archive version of the terminfo library is linked,
> there will be a multiple definition linker error.
> 
> * src/terminfo.c (UP, BC, PC): Delete.

Given the comment there, I think this should be conditioned on
actually using terminfo.  Does the following patch work for you?

diff --git a/src/terminfo.c b/src/terminfo.c
index 51fd32e..0765996 100644
--- a/src/terminfo.c
+++ b/src/terminfo.c
@@ -23,9 +23,12 @@
 
 /* Define these variables that serve as global parameters to termcap,
    so that we do not need to conditionalize the places in Emacs
-   that set them.  */
+   that set them.  But don't do that for terminfo, as that could
+   cause link errors when using -fno-common.  */
 
+#if !TERMINFO
 char *UP, *BC, PC;
+#endif
 
 /* Interface to curses/terminfo library.
    Turns out that all of the terminfo-level routines look