public inbox for gentoo-soc@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download: 
* [gentoo-soc] Week 5 Report for Musl support expansion to support GNOME desktop
@ 2022-07-17 19:14 99% listout
  0 siblings, 0 replies; 1+ results
From: listout @ 2022-07-17 19:14 UTC (permalink / raw
  To: gentoo-soc; +Cc: sam, dilfridge

Hey there folks.

With the end of week 5 I'm once again here with my weekly report. As
previous weeks this week too has been quite uneventful. I have been
working on fixing miscellaneous bugs, constantly sharing my code with
mentors and getting review to increase code quality. One such example
would be of the debugedit patch [1], where I was replacing every
instance of the error function with err for systems that does not have
error.h header. I patch got big and was my mentor sam_ was second
guessing to add it into ::gentoo. Upon review from developer blueness,
who gave the advice to use a macro to redefine the err function with
error function if error.h is not present. After a bit of research and
help from blueness I came up with something like this:

```
#ifdef HAVE_ERROR_H
#include <error.h>
#else
#include <err.h>
#define error(status, errno, ...) err(status, __VA_ARGS__)
#endif
```

Another one such example where I learned about a another macro trick was
patching mysql-connector-c package [2]. This package not only helped me
learn about the checking presence of functions and headers using various
build tools (like GNU autotools, cmake, and meson), in this case it was
cmake. I looked for the presence of three specific functions and set
compile definitions respectively. Here is is the code snippet that does
it:

```
check_symbol_exists(res_ninit "resolv.h" HAVE_RES_NINIT_FUNCTION)
check_symbol_exists(res_nsearch "resolv.h" HAVE_RES_NSEARCH_FUNCTION)
check_symbol_exists(res_nclose "resolv.h" HAVE_RES_NCLOSE_FUNCTION)
IF (HAVE_RES_NINIT_FUNCTION)
	add_compile_definitions(HAVE_RES_NINIT)
ENDIF(HAVE_RES_NINIT_FUNCTION)
IF (HAVE_RES_NSEARCH_FUNCTION)
	add_compile_definitions(HAVE_RES_NSEARCH)
ENDIF(HAVE_RES_NSEARCH_FUNCTION)
IF (HAVE_RES_NCLOSE_FUNCTION)
	add_compile_definitions(HAVE_RES_NCLOSE)
ENDIF(HAVE_RES_NCLOSE_FUNCTION)
```

With this the cmake build systems will check the resolv.h file for
presence of res_ninit, res_nsearch, and res_nclose functions and set the
compile definitions accordingly. We can then use this definitions to use
the _res_n*_ fucntions which are thread safe or the non-thread-safe
alternative ones.

Last but not the least, the libratbag package [3] taught me how to
perform the same things, check presence of functions and headers but
using meson build system. An example to use meson build system to check
for whether error.h is present on system and set a define accordingly
would be:

```
error_exists = cc.has_header('error.h')
if error_exists
	add_global_arguments('-DHAVE_ERROR_H', language : 'c')
endif
```

The above snippet check is the error.h header is present in the current
system, or provided by the current libc and then sets the HAVE_ERROR_H
if it's true or if error.h is indeed present.

So with this I'm able to now navigate around three major build systems
to handle missing functions and headers which seems to be quite common
when it comes to musl.

Apart from all these things I'm also trying to upstream a few samba
patches that would musl users [4], came across a GNOME bug where where
mutter seem to be hitting a race condition on musl (from the comments on
source code) whereas it's not the same on glibc. There is an open issue
for this upstrem [5], so I'm still waiting for the developers to reply.
However the original author of the issue does provide us with a
workaround patch which seems to be working. This mutter issue is very
specific to Xorg as I've not been able to reproduce the issue when using
Wayland.

I think this is a concise enough report for this week, there were a few
minor patches/fixes that I did but it's nothing worthy mentioning of.
Hope to find and fix more bugs in the future. Till then, long live
Gentoo.

[1]: https://github.com/gentoo/gentoo/pull/26223
[2]: https://github.com/gentoo/gentoo/pull/26353
[3]: https://github.com/gentoo/gentoo/pull/26437
[4]: https://gitlab.com/samba-team/samba/-/merge_requests/2617
[5]: https://gitlab.gnome.org/GNOME/mutter/-/issues/2103
--
Regards,
listout


^ permalink raw reply	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-07-17 19:14 99% [gentoo-soc] Week 5 Report for Musl support expansion to support GNOME desktop listout

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox