tawasuyu

sergio/takana

> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…

TOML 1182Shell 87Rust 63Markdown 541592 Sutichaykuna

⎇ 85c25619adae7583b0fdbbf2bb63cbcae5f832f5 recipes/elfutils.toml TOML · 128 siq'ikuna · 8.1 KB Ñawpa willay ch'uya

harkaq: declarar deps medidas por el kernel (cosecha automática) 7ec2e86b7 · sergio ·

1# elfutils 0.194 (sólo libelf) — de-Alpinización del último build-dep del kernel.
2#
3# `tools/objtool` del kernel enlaza -lelf (libelf + gelf.h) — en x86_64 las mitigaciones fuerzan
4# CONFIG_OBJTOOL. Venía de `apk add elfutils-dev` (bootstrap-lib). Esta receta construye libelf desde
5# fuente. Misma versión que Alpine 3.23 (0.194). Build-tool de build-time (objtool corre durante la
6# compilación del kernel; libelf NO se enlaza en el bzImage) ⇒ no afecta el of_tree del 4/4.
7#
8# Construimos SÓLO libelf (+ lib/libeu.a, su helper) — objtool no necesita libdw/libdwfl/src, que son
9# los que arrastran argp/obstack/fts (lo verdaderamente difícil en musl). elfutils es glibc-céntrico;
10# musl no trae <error.h>, <argp.h>, <libintl.h> ni rawmemchr. Estrategia de shims (en compat/, vía
11# CPPFLAGS/-include) en vez de los parches completos de Alpine:
12#   - <libintl.h>: lo elimina --disable-nls (eu-config.h sólo lo incluye con ENABLE_NLS).
13#   - <error.h>:   shim con error()/error_at_line() (musl ya exporta program_invocation_short_name).
14#   - <argp.h>:    shim de tipos/decls — sólo lo usan lib/color.c y lib/printversion.c, cuyos .o van en
15#                  libeu.a pero objtool NO referencia (sólo necesita el core de libelf) ⇒ basta que
16#                  COMPILEN; las funcs argp quedan como undefined inertes en el .a.
17#   - rawmemchr:   shim inline (lo usa libelf/elf_getarsym.c), force-include global.
18# zig 0.13.0 (NO gcc): la regresión de zig 0.14 en C/musl (bisect con flex) miscompila; 0.13.0 la
19# esquiva, consistente con binutils/openssl/flex. $CC (= zig cc del lab) para los stubs y las fases.
20
21name    = "elfutils"
22version = "0.194"
23
24[source]
25tarball = "https://sourceware.org/elfutils/ftp/0.194/elfutils-0.194.tar.bz2"
26sha256  = "09e2ff033d39baa8b388a2d7fbc5390bfde99ae3b7c67c7daaf7433fbcf0f01e"
27
28[build]
29compiler    = "zig-cc"
30target      = "x86_64-linux-musl"
31link        = "dynamic"
32zig_version = "0.13.0"
33
34[deps]
35build = ["binutils"]
36
37[build.phases]
38configure = """
39mkdir -p compat && \
40printf '%s\\n' \
41  '#ifndef _COMPAT_ERROR_H' '#define _COMPAT_ERROR_H' \
42  '#include <stdio.h>' '#include <stdlib.h>' '#include <stdarg.h>' '#include <string.h>' \
43  'extern char *program_invocation_short_name;' \
44  'static inline void error(int s,int e,const char*f,...){va_list a;fflush(stdout);' \
45  ' fprintf(stderr,"%s: ",program_invocation_short_name);va_start(a,f);vfprintf(stderr,f,a);va_end(a);' \
46  ' if(e)fprintf(stderr,": %s",strerror(e));fputc(0x0a,stderr);if(s)exit(s);}' \
47  'static inline void error_at_line(int s,int e,const char*fn,unsigned ln,const char*f,...){va_list a;' \
48  ' fflush(stdout);fprintf(stderr,"%s:%s:%u: ",program_invocation_short_name,fn,ln);' \
49  ' va_start(a,f);vfprintf(stderr,f,a);va_end(a);if(e)fprintf(stderr,": %s",strerror(e));' \
50  ' fputc(0x0a,stderr);if(s)exit(s);}' \
51  '#endif' > compat/error.h && \
52printf '%s\\n' \
53  '#ifndef _COMPAT_ARGP_H' '#define _COMPAT_ARGP_H' '#include <stdio.h>' '#include <errno.h>' \
54  'typedef int error_t;' \
55  'struct argp_option{const char*name;int key;const char*arg;int flags;const char*doc;int group;};' \
56  'struct argp;' \
57  'struct argp_state{const struct argp*root_argp;int argc;char**argv;int next;unsigned flags;' \
58  ' unsigned arg_num;int quoted;void*input;void**child_inputs;void*hook;char*name;FILE*err_stream;' \
59  ' FILE*out_stream;void*pstate;};' \
60  'typedef error_t(*argp_parser_t)(int,char*,struct argp_state*);' \
61  'struct argp_child;' \
62  'struct argp{const struct argp_option*options;argp_parser_t parser;const char*args_doc;' \
63  ' const char*doc;const struct argp_child*children;char*(*help_filter)(int,const char*,void*);' \
64  ' const char*argp_domain;};' \
65  'struct argp_child{const struct argp*argp;int flags;const char*header;int group;};' \
66  '#define ARGP_ERR_UNKNOWN E2BIG' '#define ARGP_KEY_ARG 0' '#define ARGP_KEY_END 0x1000001' \
67  '#define ARGP_KEY_INIT 0x1000003' '#define ARGP_KEY_FINI 0x1000007' '#define ARGP_KEY_SUCCESS 0x1000002' \
68  '#define ARGP_HELP_SEE 0x04' '#define ARGP_HELP_STD_ERR 0x2a' \
69  '#define OPTION_ARG_OPTIONAL 0x1' '#define OPTION_HIDDEN 0x2' '#define OPTION_ALIAS 0x4' \
70  '#define OPTION_DOC 0x8' '#define OPTION_NO_USAGE 0x10' '#define ARGP_IN_ORDER 0x08' \
71  '#define ARGP_NO_HELP 0x10' '#define ARGP_NO_EXIT 0x20' '#define ARGP_LONG_ONLY 0x40' \
72  'extern const char*argp_program_version;extern const char*argp_program_bug_address;' \
73  'extern void(*argp_program_version_hook)(FILE*,struct argp_state*);' \
74  'extern error_t argp_parse(const struct argp*,int,char**,unsigned,int*,void*);' \
75  'extern void argp_help(const struct argp*,FILE*,unsigned,char*);' \
76  'extern void argp_error(const struct argp_state*,const char*,...);' \
77  '#endif' > compat/argp.h && \
78printf '%s\\n' \
79  '#ifndef _COMPAT_MUSL_EXTRA_H' '#define _COMPAT_MUSL_EXTRA_H' '#include <string.h>' \
80  '#ifndef __GLIBC__' \
81  'static inline void*rawmemchr(const void*s,int c){const unsigned char*p=s;' \
82  ' for(;*p!=(unsigned char)c;p++){}' ' return(void*)p;}' \
83  '#endif' '#endif' > compat/musl-extra.h && \
84printf '%s\\n' \
85  '#ifndef _COMPAT_LIBINTL_H' '#define _COMPAT_LIBINTL_H' \
86  '#define gettext(s) (s)' '#define dgettext(d,s) (s)' '#define dcgettext(d,s,c) (s)' \
87  '#define ngettext(s,p,n) ((n)==1?(s):(p))' '#define dngettext(d,s,p,n) ((n)==1?(s):(p))' \
88  '#define bindtextdomain(d,x) ((char*)0)' '#define textdomain(d) ((char*)0)' \
89  '#define bind_textdomain_codeset(d,c) ((char*)0)' \
90  '#endif' > compat/libintl.h && \
91printf '%s\\n' \
92  '#include <stdio.h>' 'struct argp;struct argp_state;typedef int error_t;' \
93  'const char*argp_program_version;const char*argp_program_bug_address;' \
94  'void(*argp_program_version_hook)(FILE*,struct argp_state*);' \
95  'error_t argp_parse(const struct argp*a,int c,char**v,unsigned f,int*i,void*n){return 0;}' \
96  'void argp_help(const struct argp*a,FILE*s,unsigned f,char*n){}' \
97  'void argp_error(const struct argp_state*s,const char*f,...){}' \
98  'void argp_state_help(const struct argp_state*s,FILE*t,unsigned f){}' \
99  'void argp_usage(const struct argp_state*s){}' > compat/argp-stub.c && \
100$CC -c compat/argp-stub.c -o compat/argp-stub.o && ar rcs compat/libargp.a compat/argp-stub.o && \
101printf '%s\\n' \
102  'typedef struct{int x;}FTS;typedef struct{int y;}FTSENT;' \
103  'FTS*fts_open(char*const*p,int o,int(*c)(const FTSENT**,const FTSENT**)){return 0;}' \
104  'FTSENT*fts_read(FTS*f){return 0;}' 'FTSENT*fts_children(FTS*f,int o){return 0;}' \
105  'int fts_set(FTS*f,FTSENT*e,int o){return 0;}' 'int fts_close(FTS*f){return 0;}' > compat/fts-stub.c && \
106$CC -c compat/fts-stub.c -o compat/fts-stub.o && ar rcs compat/libfts.a compat/fts-stub.o && \
107printf '%s\\n' \
108  'struct obstack;void(*obstack_alloc_failed_handler)(void);int obstack_exit_failure;' \
109  'int _obstack_begin(struct obstack*o,int s,int a,void*(*c)(long),void(*f)(void*)){return 1;}' \
110  'int _obstack_begin_1(struct obstack*o,int s,int a,void*(*c)(void*,long),void(*f)(void*,void*),void*x){return 1;}' \
111  'void _obstack_newchunk(struct obstack*o,int l){}' 'int _obstack_allocated_p(struct obstack*o,void*p){return 0;}' \
112  'void _obstack_free(struct obstack*o,void*p){}' 'int _obstack_memory_used(struct obstack*o){return 0;}' \
113  > compat/obstack-stub.c && \
114$CC -c compat/obstack-stub.c -o compat/obstack-stub.o && ar rcs compat/libobstack.a compat/obstack-stub.o && \
115CFLAGS="-O2 -g -I$PWD/compat" CPPFLAGS="-I$PWD/compat" LDFLAGS="-L$PWD/compat" \
116  ./configure --prefix=/usr --libdir=/usr/lib --disable-nls --disable-demangler \
117  --disable-libdebuginfod --disable-debuginfod --program-prefix=eu-
118"""
119# El -include del shim de rawmemchr va SÓLO en compile (en configure rompe el test "undeclared builtins"
120# de autoconf). CFLAGS aquí reemplaza el de configure (mismo valor + el -include); AM_CFLAGS (warnings/
121# -Werror) se preserva.
122compile = "make -C lib CFLAGS=\"-O2 -g -I$PWD/compat -include $PWD/compat/musl-extra.h\" && make -C libelf libelf.a libelf.so CFLAGS=\"-O2 -g -I$PWD/compat -include $PWD/compat/musl-extra.h\""
123install = """
124mkdir -p /out/usr/lib/pkgconfig /out/usr/include && \
125cp -a libelf/libelf.a libelf/libelf.so* /out/usr/lib/ && \
126cp -a libelf/libelf.h libelf/gelf.h /out/usr/include/ && \
127cp -a config/libelf.pc /out/usr/lib/pkgconfig/ 2>/dev/null || true
128"""