Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make binary fittable with alpine distribution? #265

Closed
Davidrjx opened this issue Jun 27, 2024 · 3 comments
Closed

how to make binary fittable with alpine distribution? #265

Davidrjx opened this issue Jun 27, 2024 · 3 comments

Comments

@Davidrjx
Copy link

how to build binary from source code, fittable with alpine distribution?

@jelu
Copy link
Member

jelu commented Jun 27, 2024

Someone has to patch it to work with musl.

@jelu jelu closed this as completed Jun 27, 2024
@Davidrjx
Copy link
Author

now i have switched to glibc without attempt to patch it

@poopsicles
Copy link

note to whomever decides to patch it to work with musl: strerror_r returns int on non-glibc, but the logic used to detect that doesn't work rn, so building on musl would fail with gcc 14:

dnsperf/src/strerror.c

Lines 29 to 36 in 3c452d4

#if ((_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__)
if (strerror_r(errnum, str, len)) {
(void)snprintf(str, len, "Error %d", errnum);
}
return str;
#else
return strerror_r(errnum, str, len);
#endif

$ ...configure, make, musl-gcc, etc.
> strerror.c: In function 'perf_strerror_r':
> strerror.c:35:12: error: returning 'int' from a function with return type 'const char *' makes pointer from integer without a cast [8;;https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Warning-Options.html#index-Wint-conversion-Wint-conversion8;;]
>    35 |     return strerror_r(errnum, str, len);
>       |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

alpine just removed the check, because fiddling with ifdefs is a pain...but if you wanted to do things "right", i think you'd switch it to use __gnu_linux__ instead (that shows up for musl on NixOS)...

...and add detection of _POSIX_C_SOURCE to configure.ac (something like this maybe?) so it gets emitted...but this says _POSIX_C_SOURCE shouldn't be used with autoconf, and this talks about it but gives a c++ solution...maybe it'd be easier to refactor to strerror_l because strerror_r's deprecated anyways due to these portability problems? (not sure if that's available everywhere tho..)

(maybe just using the POSIX behaviour by default, then not doing it if __gnu_linux__ or _GNU_SOURCE is present is best?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants