all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* need to unbreak Emacs build on AIX
@ 2021-01-01 23:17 Paul Eggert
  2021-01-02  6:47 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Eggert @ 2021-01-01 23:17 UTC (permalink / raw)
  To: Emacs Development

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

Commit 2020-09-12T07:11:26Z!eliz@gnu.org 
(694acda5f24e356264c3f2a55a49812e02bcb49a) broke the build on AIX 7.2, 
as AIX uses libncurses for terminfo and its libncurses does not define 
UP, BC, or CP. Normally I'd just install the attached patch into the 
emacs-27 branch and then merge to master, but I thought I'd check on the 
mailing list since I don't offhand know how close we are to a 27.2 release.


[-- Attachment #2: 0001-Fix-broken-build-on-AIX-7.2.patch --]
[-- Type: text/x-patch, Size: 2385 bytes --]

From 2504eef721805401397822accbcadc14a0cc1d0d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 1 Jan 2021 15:15:54 -0800
Subject: [PATCH] Fix broken build on AIX 7.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Without this fix, the build on AIX 7.2 with xlc fails in the ‘CCLD
temacs’ step with the diagnostic ‘ld: 0711-317 ERROR: Undefined
symbol: BC’.  This is because -lcurses does not define BC etc.
* configure.ac: When building terminfo.o, define
TERMINFO_DEFINES_BC if the library defines BC etc.
* src/terminfo.c (UP, BC, PC): Define depending on
TERMINFO_DEFINES_BC, not on TERMINFO.
---
 configure.ac   | 12 ++++++++++++
 src/terminfo.c |  6 +++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 48e96529ff..07a11cc990 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4366,6 +4366,18 @@ AC_DEFUN
 if test $TERMINFO = yes; then
   AC_DEFINE(TERMINFO, 1, [Define to 1 if you use terminfo instead of termcap.])
   TERMCAP_OBJ=terminfo.o
+  AC_CACHE_CHECK([whether terminfo defines BC],
+    [emacs_cv_terminfo_defines_BC],
+    [OLD_LIBS=$LIBS
+     LIBS="$LIBS $LIBS_TERMCAP"
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *BC;]], [[return !*BC;]])],
+       [emacs_cv_terminfo_defines_BC=yes],
+       [emacs_cv_terminfo_defines_BC=no])
+     LIBS=$OLD_LIBS])
+  if test "$emacs_cv_terminfo_defines_BC" = yes; then
+    AC_DEFINE([TERMINFO_DEFINES_BC], 1, [Define to 1 if the
+      terminfo library defines the variables BC, PC, and UP.])
+  fi
 fi
 if test "X$LIBS_TERMCAP" = "X-lncurses"; then
   AC_DEFINE(USE_NCURSES, 1, [Define to 1 if you use ncurses.])
diff --git a/src/terminfo.c b/src/terminfo.c
index 15aff317f1..a9c9572bbb 100644
--- a/src/terminfo.c
+++ b/src/terminfo.c
@@ -23,10 +23,10 @@
 
 /* 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.  But don't do that for terminfo, as that could
-   cause link errors when using -fno-common.  */
+   that set them.  But don't do that if terminfo defines them, as that
+   could cause link errors when using -fno-common.  */
 
-#if !TERMINFO
+#ifndef TERMINFO_DEFINES_BC
 char *UP, *BC, PC;
 #endif
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: need to unbreak Emacs build on AIX
  2021-01-01 23:17 need to unbreak Emacs build on AIX Paul Eggert
@ 2021-01-02  6:47 ` Eli Zaretskii
  2021-01-03 20:56   ` Paul Eggert
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2021-01-02  6:47 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Emacs-devel

> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Fri, 1 Jan 2021 15:17:41 -0800
> 
> Commit 2020-09-12T07:11:26Z!eliz@gnu.org 
> (694acda5f24e356264c3f2a55a49812e02bcb49a) broke the build on AIX 7.2, 
> as AIX uses libncurses for terminfo and its libncurses does not define 
> UP, BC, or CP. Normally I'd just install the attached patch into the 
> emacs-27 branch and then merge to master, but I thought I'd check on the 
> mailing list since I don't offhand know how close we are to a 27.2 release.

I'm okay with this change on master, obviously.  On the emacs-27
branch, please just countermand the problematic condition with
AIX-specific condition, as I don't want to change the configure script
there.

Thanks.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: need to unbreak Emacs build on AIX
  2021-01-02  6:47 ` Eli Zaretskii
@ 2021-01-03 20:56   ` Paul Eggert
  2021-01-04  3:25     ` Eli Zaretskii
  2021-01-06 15:28     ` Stefan Kangas
  0 siblings, 2 replies; 8+ messages in thread
From: Paul Eggert @ 2021-01-03 20:56 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1246 bytes --]

On 1/1/21 10:47 PM, Eli Zaretskii wrote:
> On the emacs-27
> branch, please just countermand the problematic condition with
> AIX-specific condition, as I don't want to change the configure script
> there.

I doubt whether the problem occurs only on AIX. As I understand it now, 
the problem can happen on any platform that uses the curses library from 
BSD via SVR4 and X/Open.

I now see that I misspoke when I wrote that Emacs uses libncurses on 
AIX. Emacs uses libcurses, because XLC-generated executables cannot link 
to libncurses, as libncurses requires libgcc_s.a which is a GCC-ism.

I don't offhand see how to fix this with a condition in the C code, so 
on the emacs-27 branch I merely documented the issue via the attached patch.

My guess is that the issue is rare, as the original curses library has 
been obsolete for quite some time. And given that curses does not work 
in Emacs 27 and this is the first bug report about it and I found it 
only by doing some extensive portability checking, perhaps we should 
instead drop support for curses, and insist on ncurses or tinfo or 
terminfo. I wouldn't be surprised if the Emacs curses code has other 
issues that we don't know about because nobody uses it.

[-- Attachment #2: 0001-Mention-lcurses-problem-on-AIX.patch --]
[-- Type: text/x-patch, Size: 1503 bytes --]

From 32c960bdc61e26521507f2d629ba4da8a4db842e Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 3 Jan 2021 12:32:27 -0800
Subject: [PATCH] Mention -lcurses problem on AIX

* etc/PROBLEMS: Describe problem with Emacs 27 and -lcurses.
Do not merge to master.
---
 etc/PROBLEMS | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/etc/PROBLEMS b/etc/PROBLEMS
index 2ab76e50bd..7499726678 100644
--- a/etc/PROBLEMS
+++ b/etc/PROBLEMS
@@ -2879,6 +2879,19 @@ A solution is to link with GCC, like this:
 Since the .o object files already exist, this will not recompile Emacs
 with GCC, but just restart by trying again to link temacs.
 
+*** Building Emacs with -lcurses fails with undefined symbols like BC.
+
+The 'configure' script attempts to use several terminal libraries,
+including tinfo, ncurses, and terminfo, and curses (in that order).
+If it happens to choose the long-obsolete curses library, Emacs will
+not link correctly.  Emacs 28 is expected to work around this problem;
+in the meantime you can work around it by installing tinfo, ncurses or
+terminfo instead.
+
+This problem can happen on AIX 7.2 if you build with IBM's compiler XLC,
+as AIX's ncurses library suffers from the libgcc problem mentioned above.
+To work around this, configure and build with GCC.
+
 *** Sun with acc: Link failure when using acc on a Sun.
 
 To use acc, you need additional options just before the libraries, such as
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: need to unbreak Emacs build on AIX
  2021-01-03 20:56   ` Paul Eggert
@ 2021-01-04  3:25     ` Eli Zaretskii
  2021-01-06 15:28     ` Stefan Kangas
  1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2021-01-04  3:25 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Emacs-devel

> From: Paul Eggert <eggert@cs.ucla.edu>
> Cc: Emacs-devel@gnu.org
> Date: Sun, 3 Jan 2021 12:56:54 -0800
> 
> I don't offhand see how to fix this with a condition in the C code, so 
> on the emacs-27 branch I merely documented the issue via the attached patch.

Thanks, I think this is good enough for now.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: need to unbreak Emacs build on AIX
  2021-01-03 20:56   ` Paul Eggert
  2021-01-04  3:25     ` Eli Zaretskii
@ 2021-01-06 15:28     ` Stefan Kangas
  2021-01-06 19:29       ` Paul Eggert
  1 sibling, 1 reply; 8+ messages in thread
From: Stefan Kangas @ 2021-01-06 15:28 UTC (permalink / raw)
  To: Paul Eggert, Eli Zaretskii; +Cc: Emacs-devel

Paul Eggert <eggert@cs.ucla.edu> writes:

> My guess is that the issue is rare, as the original curses library has
> been obsolete for quite some time. And given that curses does not work
> in Emacs 27 and this is the first bug report about it and I found it
> only by doing some extensive portability checking, perhaps we should
> instead drop support for curses, and insist on ncurses or tinfo or
> terminfo. I wouldn't be surprised if the Emacs curses code has other
> issues that we don't know about because nobody uses it.

Paul, just some clarifications: are you saying that curses is completely
broken in Emacs 27?  And the curses library is obsolete?

Is there any reason to keep it around?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: need to unbreak Emacs build on AIX
  2021-01-06 15:28     ` Stefan Kangas
@ 2021-01-06 19:29       ` Paul Eggert
  2021-01-06 19:38         ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Eggert @ 2021-01-06 19:29 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: Emacs-devel

On 1/6/21 7:28 AM, Stefan Kangas wrote:

> Paul, just some clarifications: are you saying that curses is completely
> broken in Emacs 27?  And the curses library is obsolete?

"Completely broken" in the sense it won't link and Emacs won't build, 
yes. (It will link in master, due to a patch I installed recently.)

And yes, the original curses library has been obsolete for at least two 
decades.

> Is there any reason to keep it around?

Not that I know of.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: need to unbreak Emacs build on AIX
  2021-01-06 19:29       ` Paul Eggert
@ 2021-01-06 19:38         ` Eli Zaretskii
  2021-01-07  6:20           ` Paul Eggert
  0 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2021-01-06 19:38 UTC (permalink / raw)
  To: Paul Eggert; +Cc: stefankangas, Emacs-devel

> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Wed, 6 Jan 2021 11:29:55 -0800
> Cc: Emacs-devel@gnu.org
> 
> "Completely broken" in the sense it won't link and Emacs won't build, 
> yes. (It will link in master, due to a patch I installed recently.)
> 
> And yes, the original curses library has been obsolete for at least two 
> decades.
> 
> > Is there any reason to keep it around?
> 
> Not that I know of.

What about ncurses?



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: need to unbreak Emacs build on AIX
  2021-01-06 19:38         ` Eli Zaretskii
@ 2021-01-07  6:20           ` Paul Eggert
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Eggert @ 2021-01-07  6:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: stefankangas, Emacs-devel

On 1/6/21 11:38 AM, Eli Zaretskii wrote:

> What about ncurses?

ncurses is still maintained (latest release 2020-02-12) and is still 
preferred by Emacs on some platforms (such as AIX) and Emacs works fine 
with it. So we should not drop support for ncurses.



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-07  6:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-01 23:17 need to unbreak Emacs build on AIX Paul Eggert
2021-01-02  6:47 ` Eli Zaretskii
2021-01-03 20:56   ` Paul Eggert
2021-01-04  3:25     ` Eli Zaretskii
2021-01-06 15:28     ` Stefan Kangas
2021-01-06 19:29       ` Paul Eggert
2021-01-06 19:38         ` Eli Zaretskii
2021-01-07  6:20           ` Paul Eggert

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.