Bug 1875587

Summary: ncurses: Please enable symbol versioning
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: ncursesAssignee: Miroslav Lichvar <mlichvar>
Status: ASSIGNED --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: emerg.reanimator, jaruga, mlichvar, ngompa13, sam, xjia
Target Milestone: ---Keywords: FutureFeature, Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ncurses-6.3-4.20221126.fc38 Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-12-01 09:42:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Florian Weimer 2020-09-03 19:46:50 UTC
Please investigate if it is possible to configure with --with-versioned-syms. It will improve compatibility with binaries compiled on Debian.

This should be an ABI-compatible change for Fedora. Unversioned binaries bind their symbol to the base symbol version. I do not think ncurses has compat symbols, so the base version is also the default version. But of course some testing is needed.

As a side effect, Fedora packages depending on ncurses will also receive more accurate dependencies.

Comment 1 Miroslav Lichvar 2020-09-07 07:42:09 UTC
When the symbol versioning in ncurses was introduced I asked the upstream about its purpose:

https://lists.nongnu.org/archive/html/bug-ncurses/2016-01/msg00018.html
https://lists.nongnu.org/archive/html/bug-ncurses/2016-01/msg00027.html

To me, it doesn't look like a great fit for Fedora when I consider how easily it can break and require rebuilds of packages that wouldn't be needed without symbol versioning.

Compatibility with Debian would be nice, but it would trade compatibility with distributions that don't use the versioning, which still is the upstream default. Any estimates on what percentage of distributions have this feature enabled?
 
Suggestions are welcome.

Comment 2 Florian Weimer 2020-10-14 15:02:47 UTC
I plan to investigate the (automated) creation of a link-time object that replaces the .so symbolic link which does not contain symbol versions. This way, Fedora builds would still not use symbol versions for ncurses symbols (maintaining compatibility with other distributions), but Debian binaries would still run on Fedora because the symbols are available at run time.

I don't know when I can provide tool support for this. (The tool that generates the stub link-time libraries would also be useful in several other contexts.)

Comment 3 Neal Gompa 2022-10-21 12:49:01 UTC
(In reply to Miroslav Lichvar from comment #1)
> When the symbol versioning in ncurses was introduced I asked the upstream
> about its purpose:
> 
> https://lists.nongnu.org/archive/html/bug-ncurses/2016-01/msg00018.html
> https://lists.nongnu.org/archive/html/bug-ncurses/2016-01/msg00027.html
> 
> To me, it doesn't look like a great fit for Fedora when I consider how
> easily it can break and require rebuilds of packages that wouldn't be needed
> without symbol versioning.
> 
> Compatibility with Debian would be nice, but it would trade compatibility
> with distributions that don't use the versioning, which still is the
> upstream default. Any estimates on what percentage of distributions have
> this feature enabled?
>  

All Debian family distributions have this, including the *very large* Ubuntu family.

So from a usage perspective, it's a *very common* thing.

Comment 4 Jun Aruga 2022-10-21 15:13:39 UTC
I faced this issue when I was trying to build Ruby with the WASH SDK (WebAssembly SDK) upstream project's released binary[1] that was built on the Ubuntu focal environment on their GitHub Actions workflow, on my Fedora 36 environment.[2]


```
$ ./configure LDFLAGS="-Xlinker -zstack-size=16777216" \
  --host wasm32-unknown-wasi \
  --with-destdir=./ruby-wasm32-wasi \
  --with-static-linked-ext \
  --with-ext=ripper,monitor
...
/usr/local/wasi-sdk-16.0/bin/clang: /lib64/libtinfo.so.6: no version
information available (required by /usr/local/wasi-sdk-16.0/bin/clang)
/usr/local/wasi-sdk-16.0/bin/clang: /lib64/libtinfo.so.6: no version
information available (required by /usr/local/wasi-sdk-16.0/bin/clang)
/usr/local/wasi-sdk-16.0/bin/clang: /lib64/libtinfo.so.6: no version
information available (required by /usr/local/wasi-sdk-16.0/bin/clang)
...
```

I had to build the WASH SDK[3] from the source to use it on Fedora environment.


[1] https://github.com/WebAssembly/wasi-sdk/releases
[2] https://bugs.ruby-lang.org/issues/19053#note-1
[3] https://github.com/WebAssembly/wasi-sdk

Comment 5 Aleksandrs Gumenuks 2022-11-06 19:13:31 UTC
The same issue happens with LLVM compiler found here: https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/releases

"clang: /lib64/libtinfo.so.5: no version information available (required by clang)"

Rebuilding and reinstalling the ncurses-compat-libs with --with-versioned-syms fixes the issue.

Comment 6 Miroslav Lichvar 2022-11-29 15:28:17 UTC
(In reply to Florian Weimer from comment #2)
> I plan to investigate the (automated) creation of a link-time object that
> replaces the .so symbolic link which does not contain symbol versions. This
> way, Fedora builds would still not use symbol versions for ncurses symbols
> (maintaining compatibility with other distributions), but Debian binaries
> would still run on Fedora because the symbols are available at run time.

Florian, is there any news on this tool?

Comment 7 Florian Weimer 2022-11-29 15:51:02 UTC
Not yet. In the meantime, you can do the following:

Build ncurses twice, once with symbol versions, once without.

Install the version variant into %{_libdir} under the soname.

In the developer package, turn {%_libdir}/libncurses.so into a linker script (see libc.so), pointing to the *unversioned* file installed somewhere outside the ld.so search path.

This way, linked binaries remain unversioned, but Fedora is still able to run versioned binaries.

Comment 8 Miroslav Lichvar 2022-11-30 16:50:55 UTC
Thanks, Florian. I have something that seems to be working, except the generated provides/requires are wrong. I'll see if I can fix that.

Comment 9 Florian Weimer 2022-11-30 17:06:03 UTC
(In reply to Miroslav Lichvar from comment #8)
> Thanks, Florian. I have something that seems to be working, except the
> generated provides/requires are wrong. I'll see if I can fix that.

Oh, I had not thought about that. Maybe removing the executable bit from the unversioned file helps?

But the provides for the versioned symbols should be there? What do the dependencies look like?

Comment 10 Miroslav Lichvar 2022-11-30 17:23:40 UTC
The main problem is that the devel subpackage gets the libncurses.so.6() provide which other packages will depend on, which would cause the devel subpackage to be installed everywhere.

Do we want the libs subpackage to have the versioned provides/requires? I thought we would want to filter that.

Comment 11 Florian Weimer 2022-11-30 17:28:28 UTC
(In reply to Miroslav Lichvar from comment #10)
> The main problem is that the devel subpackage gets the libncurses.so.6()
> provide which other packages will depend on, which would cause the devel
> subpackage to be installed everywhere.

Right, and removing the executable bit should fix that. I forgot about that aspect, sorry.

> Do we want the libs subpackage to have the versioned provides/requires? I
> thought we would want to filter that.

It does provide the ABI, so it should be okay to reflect it in the RPM dependencies. The dependency generators will look at what's in the linked files and not produce versioned Requires: dependencies, I think.

Comment 12 Miroslav Lichvar 2022-11-30 17:39:30 UTC
For simplicity I was installing the ncurses programs compiled with versioned symbols, so it appeared in the requirements. I think I can filter that out.

Comment 13 Florian Weimer 2022-11-30 18:08:49 UTC
(In reply to Miroslav Lichvar from comment #12)
> For simplicity I was installing the ncurses programs compiled with versioned
> symbols, so it appeared in the requirements. I think I can filter that out.

Or you could use the binaries from the unversioned build. The versioned self-dependency should be harmless, though? Isn't the guidance anyway that subpackages should depend on the exact NVR (or is this specific to downstream)?

Comment 14 Miroslav Lichvar 2022-12-01 09:42:40 UTC
This is in rawhide now. Thanks for the suggestions.

I tested building few applications and it seemed to work well. Please test and report any issues, or request untagging if it manages to completely break the system.

Unsetting the executable bit didn't seem to help, so I used the __provides_exclude_from trick.

I think removing the versioned provides+requires might be useful for detecting packages that unexpectedly link with the versioned symbols, which will break their dependencies, and it will also reduce the number of entries in the rpm database (the number of different versions in the all the ncurses libs combined is quite large).

Comment 15 Miroslav Lichvar 2023-01-02 09:15:19 UTC
This change broke building of some packages and was reverted:

https://www.mail-archive.com/devel@lists.fedoraproject.org/msg187104.html