in our environment, we use mender on a musl-based custom linux distro (yocto build). i’ve stumbled across an error when building mender-flash, which uses lseek64 libc calls unavailable in musl. musl doesn’t have any of the foo64 functions, and instead just transitioned everything to be 64 bit (time_t, off_t, …) at some point.
so now i’ve replaced the lseek64 calls in libflash/platformfs.cpp with lseek, and added that patch in a yocto .bbappend file as SRC_URI:append:libc-musl = " file://lseek64.patch", so it’s applied when building for a musl-based system.
now my question is
would patches for this be accepted upstream?
would you prefer a patch on mender-flash to e.g. add a #define to map both lseek64 and lseek to the same thing, or a patch on the yocto layer like i described above?
Thanks for sharing this! Good question, any opinions here @lluiscampos@kacf?
From my personal point of view, I’d love to see more streamlined musl support as I consider it relevant for a lot of use cases.
@JohannesSchilling, do you by any chance already have this in a Github fork so you can submit PRs for discussion? Not promising that they will be merged as-is, but it provides a much better code collaboration platform.
I did some research and I think we could actually switch to plain variants everywhere, as long as -D _FILE_OFFSET_BITS=64 is defined by cmake. This causes off_t to become 64-bit everywhere, which is what those interfaces use. In addition to Linux, even QNX supports this, which I don’t think is a deal breaker, since I believe it’s not going to be used there, but it’s nice to know in any case.
So my suggestion is:
Add target_compile_definitions(crossplatform_compiler_flags INTERFACE _FILE_OFFSET_BITS=64) around here.
Change lseek64 calls (and any similar calls you find) into plain variants.