Bug 2159395

Summary: stellarsolver: Not compatible with strict C99 mode
Product: [Fedora] Fedora Reporter: Florian Weimer <fweimer>
Component: stellarsolverAssignee: Mattia Verga <mattia.verga>
Status: CLOSED ERRATA QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: astro-sig, mattia.verga
Target Milestone: ---Keywords: FutureFeature
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: stellarsolver-2.6-1.fc41 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-07-07 08:11:48 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:
Bug Depends On:    
Bug Blocks: 2137512    

Description Florian Weimer 2023-01-09 12:50:09 UTC
The qsort_r function comes with different prototypes on different systems. There are some tests around NEED_DECLARE_QSORT_R and NEED_SWAP_QSORT_R that try to work around that. However, they only work with compilers which accept implicit function declarations.

Without support for implicit function declarations in the compiler, I get a build failure:

In file included from /builddir/build/BUILD/stellarsolver-2.4/stellarsolver/astrometry/util/bl-sort.c:8:
/builddir/build/BUILD/stellarsolver-2.4/stellarsolver/astrometry/util/bl-sort.c: In function 'bl_sort_rec':
/builddir/build/BUILD/stellarsolver-2.4/stellarsolver/astrometry/os-features.h:123:17: error: implicit declaration of function 'qsort_r'
  123 | #define QSORT_R qsort_r
      |                 ^~~~~~~
/builddir/build/BUILD/stellarsolver-2.4/stellarsolver/astrometry/util/bl-sort.c:68:9: note: in expansion of macro 'QSORT_R'
   68 |         QSORT_R(NODE_DATA(node), node->N, list->datasize, &ft, qcompare);
      |         ^~~~~~~

If I add -D_GNU_SOURCE to the build flags, the build fails because of a conflicting prototype:

In file included from /builddir/build/BUILD/stellarsolver-2.4/stellarsolver/astrometry/blind/engine.c:40:
/builddir/build/BUILD/stellarsolver-2.4/stellarsolver/astrometry/os-features.h:113:6: error: conflicting types for 'qsort_r'; have 'void(void *, size_t,  size_t,  void *, int (*)(void *, const void *, const void *))' {aka 'void(void *, long unsigned int,  long unsigned int,  void *, int (*)(void *, const void *, const void *))'}
  113 | void qsort_r(void *base, size_t nmemb, size_t sz,
      |      ^~~~~~~
In file included from /builddir/build/BUILD/stellarsolver-2.4/stellarsolver/astrometry/blind/engine.c:13:
/usr/include/stdlib.h:854:13: note: previous declaration of 'qsort_r' with type 'void(void *, size_t,  size_t,  int (*)(const void *, const void *, void *), void *)' {aka 'void(void *, long unsigned int,  long unsigned int,  int (*)(const void *, const void *, void *), void *)'}
  854 | extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
      |             ^~~~~~~

So there does not seem to be a good way to build this program with C99 compilers on glibc (or other non-BSD platforms).

A potential workaround would involve building with -std=gnu89, but I have not tried that yet.

Also filed upstream: https://github.com/rlancaste/stellarsolver/issues/125

Comment 1 Mattia Verga 2023-01-09 17:23:09 UTC
Thanks for taking care of reporting upstream.

Comment 2 Ben Cotton 2023-02-07 15:11:59 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 38 development cycle.
Changing version to 38.

Comment 3 Fedora Update System 2024-07-07 08:05:40 UTC
FEDORA-2024-6c5e6780b2 (stellarsolver-2.6-1.fc41) has been submitted as an update to Fedora 41.
https://bodhi.fedoraproject.org/updates/FEDORA-2024-6c5e6780b2

Comment 4 Fedora Update System 2024-07-07 08:11:48 UTC
FEDORA-2024-6c5e6780b2 (stellarsolver-2.6-1.fc41) has been pushed to the Fedora 41 stable repository.
If problem still persists, please make note of it in this bug report.