ncurses: Modify the header to always use the ABI of ncursesw

instead of the 8-bit ncurses.

We don't provide the 8-bit ncurses library and we are "faking" it using
ncursesw.  Thus innocent package may be compiled with the 8-bit ABI
(because it does not know what we are doing and so it does not use
the "expected" preprocessor definitions to enable the wide ABI) but
linked against ncursesw, causing a potential ABI mismatch.
This commit is contained in:
Xi Ruoyao 2024-01-19 12:47:33 +08:00
parent 619e4d956f
commit d282f88dea
No known key found for this signature in database
GPG Key ID: ACAAD20E19E710E3
3 changed files with 38 additions and 2 deletions

View File

@ -40,6 +40,18 @@
appropriate for the entry or if needed the entire day's listitem.
-->
<listitem>
<para>2024-01-18</para>
<itemizedlist>
<listitem>
<para>[xry111] - Edit a ncurses header to always use the
wide-character ABI compatible with libncursesw.so because we
are faking the 8-bit libncurses.so with it. Fixes
<ulink url="&lfs-ticket-root;5415">#5415</ulink>.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>2024-01-09</para>
<itemizedlist>

View File

@ -156,7 +156,9 @@ popd</userinput></screen>
<para>Install the package:</para>
<screen><userinput remap="install">make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install
echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so</userinput></screen>
echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so
sed -e 's/^#if.*XOPEN.*$/#if 1/' \
-i $LFS/usr/include/curses.h</userinput></screen>
<!--
<para>Remove an unneeded static library not handled by
<command>configure</command>:</para>
@ -185,6 +187,23 @@ echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so</userinput></screen>
</listitem>
</varlistentry>
<varlistentry>
<term><command>sed -e 's/^#if.*XOPEN.*$/#if 1/' ...</command></term>
<listitem>
<para>The header file <filename>curses.h</filename> contains
the definition of various Ncurses data structures. With different
preprocessor macro definitions two different sets of the data
structure definition may be used: the 8-bit definition is
compatible with <filename>libncurses.so</filename> and the
wide-character definition is compatible with
<filename>libncursesw.so</filename>. Since we are using
<filename>libncursesw.so</filename> as a replacement of
<filename>libncurses.so</filename>, edit the header file so it
will always use the wide-character data structure definition
compatible with <filename>libncursesw.so</filename>.</para>
</listitem>
</varlistentry>
</variablelist>
</sect2>

View File

@ -131,11 +131,16 @@
in-place. It may crash the shell process which is using code and data
from the library file. Install the package with
<literal>DESTDIR</literal>, and replace the library file correctly using
<command>install</command> command:</para>
<command>install</command> command (the header
<filename>curses.h</filename> is also edited to ensure the
wide-character ABI to be used as what we've done in
<xref linkend='ch-tools-ncurses'/>):</para>
<screen><userinput remap="install">make DESTDIR=$PWD/dest install
install -vm755 dest/usr/lib/libncursesw.so.&ncurses-version; /usr/lib
rm -v dest/usr/lib/libncursesw.so.&ncurses-version;
sed -e 's/^#if.*XOPEN.*$/#if 1/' \
-i dest/usr/include/curses.h
cp -av dest/* /</userinput></screen>
<para>Many applications still expect the linker to be able to find