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

kpatch-build: add missing include for musl #1436

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Conversation

androw
Copy link
Contributor

@androw androw commented Jan 21, 2025

create-kpatch-module.c can't compile because limits.h is not included by other file with musl libc.

Adding the import permits the build to work on musl system.

https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/78844/diffs

@joe-lawrence
Copy link
Contributor

Thanks @androw , do you happen to have the compilation error? Just curious, thanks.

@androw
Copy link
Contributor Author

androw commented Jan 21, 2025

gcc -Os -fstack-clash-protection -Wformat -Werror=format-security -fno-plt -std=gnu11 -MMD -MP -I../kmod/patch -Iinsn -Wall -Wsign-compare -Wconversion -Wno-sign-conversion -g -Werror   -c -o create-kpatch-module.o create-kpatch-module.c
create-kpatch-module.c: In function 'create_dynamic_rela_sections':
create-kpatch-module.c:101:54: error: 'INT_MAX' undeclared (first use in this function)
  101 |                 if (type == R_X86_64_64 && (addend > INT_MAX || addend <= INT_MIN)) {
      |                                                      ^~~~~~~
create-kpatch-module.c:29:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
   28 | #include "kpatch-patch.h"
  +++ |+#include <limits.h>
   29 | 
create-kpatch-module.c:101:54: note: each undeclared identifier is reported only once for each function it appears in
  101 |                 if (type == R_X86_64_64 && (addend > INT_MAX || addend <= INT_MIN)) {
      |                                                      ^~~~~~~
create-kpatch-module.c:101:75: error: 'INT_MIN' undeclared (first use in this function)
  101 |                 if (type == R_X86_64_64 && (addend > INT_MAX || addend <= INT_MIN)) {
      |                                                                           ^~~~~~~
create-kpatch-module.c:101:75: note: 'INT_MIN' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
make[1]: *** [<builtin>: create-kpatch-module.o] Error 1

Full log here: https://gist.github.com/androw/22b6ee74a6d5edb6f9ce3b926fb6237e

@joe-lawrence
Copy link
Contributor

Interesting. On a Fedora system, it seems that argp.h pulls it in:

$ CFLAGS=-H make
[ ... snip ... ]
. /usr/include/argp.h
.. /usr/lib/gcc/x86_64-redhat-linux/12/include/limits.h
... /usr/lib/gcc/x86_64-redhat-linux/12/include/syslimits.h
.... /usr/lib/gcc/x86_64-redhat-linux/12/include/limits.h
..... /usr/include/limits.h

@joe-lawrence joe-lawrence merged commit 5124601 into dynup:master Jan 23, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants