Bug 398338

Summary: Compilation failure on Musl due to use of vasprintf
Product: [Applications] okular Reporter: Bart Ribbers <bribbers>
Component: generalAssignee: Okular developers <okular-devel>
Status: REOPENED ---    
Severity: normal CC: aacid, vidra.jonas
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Bart Ribbers 2018-09-06 20:09:56 UTC
If building Okular on a Musl based system (like Alpine Linux or postmarketOS), compilation will fail:

okular-18.08.1/core/synctex/synctex_parser.c:8202:13: error: implicit declaration of function 'vasprintf' [-Werror=implicit-function-declaration]
         if (vasprintf(&buffer, format, va) < 0) {
             ^~~~~~~~~


This is due to the use of "vasprintf()" which is not part of POSIX (https://linux.die.net/man/3/vasprintf). It can be quite easily resolved by using "vsprintf()" instead, but I'm guessing this will cause problems during runtime due to missing the terminating null byte.
Comment 1 Albert Astals Cid 2018-09-09 18:25:40 UTC
Those files are "copied" from syntex, you should open an issue at https://github.com/jlaurens/synctex/issues since that way we can import fixes from them.

Also given that musl is kind of not easy to come by i guess it'd be great if you could provide a patch. It should not be very hard since there seems to be already an own implementation of vasprintf 

https://github.com/jlaurens/synctex/blob/2017/synctex_parser.c#L8409

Please if you open a bug on their side please link it here so we can also keep track of it.
Comment 2 Jonáš Vidra 2024-03-30 20:44:51 UTC
This bug is still present in Okular 23.08.5.

The error was fixed upstream in https://github.com/jlaurens/synctex/pull/39 but reappeared, because the fix was only applied to one branch. I filed a new upstream bug here: https://github.com/jlaurens/synctex/issues/80

There are two related pull requests currently open:
https://invent.kde.org/graphics/okular/-/merge_requests/722
https://invent.kde.org/graphics/okular/-/merge_requests/723
Comment 3 Jonáš Vidra 2024-03-30 22:37:42 UTC
> The error was fixed upstream in https://github.com/jlaurens/synctex/pull/39
> but reappeared, because the fix was only applied to one branch.

It was actually applied to all branches except for one, which was the one I checked. An import of the changes from either the `2024` stable branch or the `main` development one should fix the issue.