From 8a2db5b2724e8585cc675993ad170181bee9d085 Mon Sep 17 00:00:00 2001 From: misomosi Date: Thu, 28 May 2026 19:22:52 -0400 Subject: [PATCH] Add MUSL compilation script, diff --- FSLibcNotes/README.md | 10 ++ FSLibcNotes/musl.git.diff | 58 ++++++++ FSLibcNotes/sources/ctype.txt | 37 +++++ FSLibcNotes/sources/errno.txt | 1 + FSLibcNotes/sources/fenv.txt | 7 + FSLibcNotes/sources/internal.txt | 3 + FSLibcNotes/sources/locale.txt | 2 + FSLibcNotes/sources/math.txt | 232 ++++++++++++++++++++++++++++++ FSLibcNotes/sources/multibyte.txt | 20 +++ FSLibcNotes/sources/prng.txt | 10 ++ FSLibcNotes/sources/regex.txt | 5 + FSLibcNotes/sources/search.txt | 8 ++ FSLibcNotes/sources/stdio.txt | 14 ++ FSLibcNotes/sources/stdlib.txt | 13 ++ FSLibcNotes/sources/string.txt | 73 ++++++++++ 15 files changed, 493 insertions(+) create mode 100644 FSLibcNotes/musl.git.diff create mode 100644 FSLibcNotes/sources/ctype.txt create mode 100644 FSLibcNotes/sources/errno.txt create mode 100644 FSLibcNotes/sources/fenv.txt create mode 100644 FSLibcNotes/sources/internal.txt create mode 100644 FSLibcNotes/sources/locale.txt create mode 100644 FSLibcNotes/sources/math.txt create mode 100644 FSLibcNotes/sources/multibyte.txt create mode 100644 FSLibcNotes/sources/prng.txt create mode 100644 FSLibcNotes/sources/regex.txt create mode 100644 FSLibcNotes/sources/search.txt create mode 100644 FSLibcNotes/sources/stdio.txt create mode 100644 FSLibcNotes/sources/stdlib.txt create mode 100644 FSLibcNotes/sources/string.txt diff --git a/FSLibcNotes/README.md b/FSLibcNotes/README.md index 81cbefc..eee14db 100644 --- a/FSLibcNotes/README.md +++ b/FSLibcNotes/README.md @@ -56,3 +56,13 @@ optional in std C, they're tricky/bad practice, etc. * signal.h (UNIX-only) * setjmp.h (Hard to implement without arch-specific support) * locale.h (Introduces inconsistencies and gotchas in I/O) + +## sources/, Make.sh, musl.git.diff + +This is a handy script, list of sources, and a MUSL git diff +that can compile a significant number of functions in MUSL +for freestanding use like mentioned before. You have to define some +functions like \_\_errno\_location and strerror, but it's +otherwise mostly functional and painless. Before you run +the script inside the repository, you apply musl.git.diff +to prepare the sources for such a compilation diff --git a/FSLibcNotes/musl.git.diff b/FSLibcNotes/musl.git.diff new file mode 100644 index 0000000..1e34c2f --- /dev/null +++ b/FSLibcNotes/musl.git.diff @@ -0,0 +1,58 @@ +diff --git a/arch/aarch64/bits/alltypes.h.in b/arch/aarch64/bits/alltypes.h.in +index c547ca0b..74fb11c4 100644 +--- a/arch/aarch64/bits/alltypes.h.in ++++ b/arch/aarch64/bits/alltypes.h.in +@@ -1,6 +1,12 @@ ++#ifndef _WIN64 + #define _Addr long + #define _Int64 long + #define _Reg long ++#else ++#define _Addr long long ++#define _Int64 long long ++#define _Reg long long ++#endif + + #if __AARCH64EB__ + #define __BYTE_ORDER 4321 +diff --git a/arch/x86_64/bits/alltypes.h.in b/arch/x86_64/bits/alltypes.h.in +index 5cd8a299..cd86d650 100644 +--- a/arch/x86_64/bits/alltypes.h.in ++++ b/arch/x86_64/bits/alltypes.h.in +@@ -1,6 +1,12 @@ ++#ifndef _WIN64 + #define _Addr long + #define _Int64 long + #define _Reg long ++#else ++#define _Addr long long ++#define _Int64 long long ++#define _Reg long long ++#endif + + #define __BYTE_ORDER 1234 + #define __LONG_MAX 0x7fffffffffffffffL +diff --git a/src/internal/locale_impl.h b/src/internal/locale_impl.h +index 4431a92e..81a427c7 100644 +--- a/src/internal/locale_impl.h ++++ b/src/internal/locale_impl.h +@@ -4,7 +4,6 @@ + #include + #include + #include "libc.h" +-#include "pthread_impl.h" + + #define LOCALE_NAME_MAX 23 + +@@ -37,9 +36,9 @@ hidden char *__gettextdomain(void); + #define C_LOCALE ((locale_t)&__c_locale) + #define UTF8_LOCALE ((locale_t)&__c_dot_utf8_locale) + +-#define CURRENT_LOCALE (__pthread_self()->locale) ++#define CURRENT_LOCALE UTF8_LOCALE + +-#define CURRENT_UTF8 (!!__pthread_self()->locale->cat[LC_CTYPE]) ++#define CURRENT_UTF8 1 + + #undef MB_CUR_MAX + #define MB_CUR_MAX (CURRENT_UTF8 ? 4 : 1) diff --git a/FSLibcNotes/sources/ctype.txt b/FSLibcNotes/sources/ctype.txt new file mode 100644 index 0000000..db677cc --- /dev/null +++ b/FSLibcNotes/sources/ctype.txt @@ -0,0 +1,37 @@ +src/ctype/__ctype_b_loc.c +src/ctype/__ctype_get_mb_cur_max.c +src/ctype/__ctype_tolower_loc.c +src/ctype/__ctype_toupper_loc.c +src/ctype/isalnum.c +src/ctype/isalpha.c +src/ctype/isascii.c +src/ctype/isblank.c +src/ctype/iscntrl.c +src/ctype/isdigit.c +src/ctype/isgraph.c +src/ctype/islower.c +src/ctype/isprint.c +src/ctype/ispunct.c +src/ctype/isspace.c +src/ctype/isupper.c +src/ctype/iswalnum.c +src/ctype/iswalpha.c +src/ctype/iswblank.c +src/ctype/iswcntrl.c +src/ctype/iswctype.c +src/ctype/iswdigit.c +src/ctype/iswgraph.c +src/ctype/iswlower.c +src/ctype/iswprint.c +src/ctype/iswpunct.c +src/ctype/iswspace.c +src/ctype/iswupper.c +src/ctype/iswxdigit.c +src/ctype/isxdigit.c +src/ctype/toascii.c +src/ctype/tolower.c +src/ctype/toupper.c +src/ctype/towctrans.c +src/ctype/wcswidth.c +src/ctype/wctrans.c +src/ctype/wcwidth.c diff --git a/FSLibcNotes/sources/errno.txt b/FSLibcNotes/sources/errno.txt new file mode 100644 index 0000000..82ae925 --- /dev/null +++ b/FSLibcNotes/sources/errno.txt @@ -0,0 +1 @@ +src/errno/strerror.c diff --git a/FSLibcNotes/sources/fenv.txt b/FSLibcNotes/sources/fenv.txt new file mode 100644 index 0000000..d7a4034 --- /dev/null +++ b/FSLibcNotes/sources/fenv.txt @@ -0,0 +1,7 @@ +src/fenv/__flt_rounds.c +src/fenv/fegetexceptflag.c +src/fenv/feholdexcept.c +src/fenv/fenv.c +src/fenv/fesetexceptflag.c +src/fenv/fesetround.c +src/fenv/feupdateenv.c diff --git a/FSLibcNotes/sources/internal.txt b/FSLibcNotes/sources/internal.txt new file mode 100644 index 0000000..1ebc2a3 --- /dev/null +++ b/FSLibcNotes/sources/internal.txt @@ -0,0 +1,3 @@ +src/internal/shgetc.c +src/internal/floatscan.c +src/internal/intscan.c diff --git a/FSLibcNotes/sources/locale.txt b/FSLibcNotes/sources/locale.txt new file mode 100644 index 0000000..d16cb59 --- /dev/null +++ b/FSLibcNotes/sources/locale.txt @@ -0,0 +1,2 @@ +src/locale/c_locale.c +src/locale/__lctrans.c diff --git a/FSLibcNotes/sources/math.txt b/FSLibcNotes/sources/math.txt new file mode 100644 index 0000000..3b92ad4 --- /dev/null +++ b/FSLibcNotes/sources/math.txt @@ -0,0 +1,232 @@ +src/math/__cos.c +src/math/__cosdf.c +src/math/__cosl.c +src/math/__expo2.c +src/math/__expo2f.c +src/math/__fpclassify.c +src/math/__fpclassifyf.c +src/math/__fpclassifyl.c +src/math/__invtrigl.c +src/math/__math_divzero.c +src/math/__math_divzerof.c +src/math/__math_invalid.c +src/math/__math_invalidf.c +src/math/__math_invalidl.c +src/math/__math_oflow.c +src/math/__math_oflowf.c +src/math/__math_uflow.c +src/math/__math_uflowf.c +src/math/__math_xflow.c +src/math/__math_xflowf.c +src/math/__polevll.c +src/math/__rem_pio2.c +src/math/__rem_pio2_large.c +src/math/__rem_pio2f.c +src/math/__rem_pio2l.c +src/math/__signbit.c +src/math/__signbitf.c +src/math/__signbitl.c +src/math/__sin.c +src/math/__sindf.c +src/math/__sinl.c +src/math/__tan.c +src/math/__tandf.c +src/math/__tanl.c +src/math/acos.c +src/math/acosf.c +src/math/acosh.c +src/math/acoshf.c +src/math/acoshl.c +src/math/acosl.c +src/math/asin.c +src/math/asinf.c +src/math/asinh.c +src/math/asinhf.c +src/math/asinhl.c +src/math/asinl.c +src/math/atan.c +src/math/atan2.c +src/math/atan2f.c +src/math/atan2l.c +src/math/atanf.c +src/math/atanh.c +src/math/atanhf.c +src/math/atanhl.c +src/math/atanl.c +src/math/cbrt.c +src/math/cbrtf.c +src/math/cbrtl.c +src/math/ceil.c +src/math/ceilf.c +src/math/ceill.c +src/math/copysign.c +src/math/copysignf.c +src/math/copysignl.c +src/math/cos.c +src/math/cosf.c +src/math/cosh.c +src/math/coshf.c +src/math/coshl.c +src/math/cosl.c +src/math/erf.c +src/math/erff.c +src/math/erfl.c +src/math/exp.c +src/math/exp10.c +src/math/exp10f.c +src/math/exp10l.c +src/math/exp2.c +src/math/exp2f.c +src/math/exp2f_data.c +src/math/exp2l.c +src/math/exp_data.c +src/math/expf.c +src/math/expl.c +src/math/expm1.c +src/math/expm1f.c +src/math/expm1l.c +src/math/fabs.c +src/math/fabsf.c +src/math/fabsl.c +src/math/fdim.c +src/math/fdimf.c +src/math/fdiml.c +src/math/finite.c +src/math/finitef.c +src/math/floor.c +src/math/floorf.c +src/math/floorl.c +src/math/fma.c +src/math/fmaf.c +src/math/fmal.c +src/math/fmax.c +src/math/fmaxf.c +src/math/fmaxl.c +src/math/fmin.c +src/math/fminf.c +src/math/fminl.c +src/math/fmod.c +src/math/fmodf.c +src/math/fmodl.c +src/math/frexp.c +src/math/frexpf.c +src/math/frexpl.c +src/math/hypot.c +src/math/hypotf.c +src/math/hypotl.c +src/math/ilogb.c +src/math/ilogbf.c +src/math/ilogbl.c +src/math/j0.c +src/math/j0f.c +src/math/j1.c +src/math/j1f.c +src/math/jn.c +src/math/jnf.c +src/math/ldexp.c +src/math/ldexpf.c +src/math/ldexpl.c +src/math/lgamma.c +src/math/lgamma_r.c +src/math/lgammaf.c +src/math/lgammaf_r.c +src/math/lgammal.c +src/math/llrint.c +src/math/llrintf.c +src/math/llrintl.c +src/math/llround.c +src/math/llroundf.c +src/math/llroundl.c +src/math/log.c +src/math/log10.c +src/math/log10f.c +src/math/log10l.c +src/math/log1p.c +src/math/log1pf.c +src/math/log1pl.c +src/math/log2.c +src/math/log2_data.c +src/math/log2f.c +src/math/log2f_data.c +src/math/log2l.c +src/math/log_data.c +src/math/logb.c +src/math/logbf.c +src/math/logbl.c +src/math/logf.c +src/math/logf_data.c +src/math/logl.c +src/math/lrint.c +src/math/lrintf.c +src/math/lrintl.c +src/math/lround.c +src/math/lroundf.c +src/math/lroundl.c +src/math/modf.c +src/math/modff.c +src/math/modfl.c +src/math/nan.c +src/math/nanf.c +src/math/nanl.c +src/math/nearbyint.c +src/math/nearbyintf.c +src/math/nearbyintl.c +src/math/nextafter.c +src/math/nextafterf.c +src/math/nextafterl.c +src/math/nexttoward.c +src/math/nexttowardf.c +src/math/nexttowardl.c +src/math/pow.c +src/math/pow_data.c +src/math/powf.c +src/math/powf_data.c +src/math/powl.c +src/math/remainder.c +src/math/remainderf.c +src/math/remainderl.c +src/math/remquo.c +src/math/remquof.c +src/math/remquol.c +src/math/rint.c +src/math/rintf.c +src/math/rintl.c +src/math/round.c +src/math/roundf.c +src/math/roundl.c +src/math/scalb.c +src/math/scalbf.c +src/math/scalbln.c +src/math/scalblnf.c +src/math/scalblnl.c +src/math/scalbn.c +src/math/scalbnf.c +src/math/scalbnl.c +src/math/signgam.c +src/math/significand.c +src/math/significandf.c +src/math/sin.c +src/math/sincos.c +src/math/sincosf.c +src/math/sincosl.c +src/math/sinf.c +src/math/sinh.c +src/math/sinhf.c +src/math/sinhl.c +src/math/sinl.c +src/math/sqrt.c +src/math/sqrt_data.c +src/math/sqrtf.c +src/math/sqrtl.c +src/math/tan.c +src/math/tanf.c +src/math/tanh.c +src/math/tanhf.c +src/math/tanhl.c +src/math/tanl.c +src/math/tgamma.c +src/math/tgammaf.c +src/math/tgammal.c +src/math/trunc.c +src/math/truncf.c +src/math/truncl.c diff --git a/FSLibcNotes/sources/multibyte.txt b/FSLibcNotes/sources/multibyte.txt new file mode 100644 index 0000000..b7ba74a --- /dev/null +++ b/FSLibcNotes/sources/multibyte.txt @@ -0,0 +1,20 @@ +src/multibyte/btowc.c +src/multibyte/c16rtomb.c +src/multibyte/c32rtomb.c +src/multibyte/internal.c +src/multibyte/mblen.c +src/multibyte/mbrlen.c +src/multibyte/mbrtoc16.c +src/multibyte/mbrtoc32.c +src/multibyte/mbrtowc.c +src/multibyte/mbsinit.c +src/multibyte/mbsnrtowcs.c +src/multibyte/mbsrtowcs.c +src/multibyte/mbstowcs.c +src/multibyte/mbtowc.c +src/multibyte/wcrtomb.c +src/multibyte/wcsnrtombs.c +src/multibyte/wcsrtombs.c +src/multibyte/wcstombs.c +src/multibyte/wctob.c +src/multibyte/wctomb.c diff --git a/FSLibcNotes/sources/prng.txt b/FSLibcNotes/sources/prng.txt new file mode 100644 index 0000000..2f6a7c8 --- /dev/null +++ b/FSLibcNotes/sources/prng.txt @@ -0,0 +1,10 @@ +src/prng/__rand48_step.c +src/prng/__seed48.c +src/prng/drand48.c +src/prng/lcong48.c +src/prng/lrand48.c +src/prng/mrand48.c +src/prng/rand.c +src/prng/rand_r.c +src/prng/seed48.c +src/prng/srand48.c diff --git a/FSLibcNotes/sources/regex.txt b/FSLibcNotes/sources/regex.txt new file mode 100644 index 0000000..ef886ba --- /dev/null +++ b/FSLibcNotes/sources/regex.txt @@ -0,0 +1,5 @@ +src/regex/fnmatch.c +src/regex/regcomp.c +src/regex/regerror.c +src/regex/regexec.c +src/regex/tre-mem.c diff --git a/FSLibcNotes/sources/search.txt b/FSLibcNotes/sources/search.txt new file mode 100644 index 0000000..86687f8 --- /dev/null +++ b/FSLibcNotes/sources/search.txt @@ -0,0 +1,8 @@ +src/search/hsearch.c +src/search/insque.c +src/search/lsearch.c +src/search/tdelete.c +src/search/tdestroy.c +src/search/tfind.c +src/search/tsearch.c +src/search/twalk.c diff --git a/FSLibcNotes/sources/stdio.txt b/FSLibcNotes/sources/stdio.txt new file mode 100644 index 0000000..fc9213b --- /dev/null +++ b/FSLibcNotes/sources/stdio.txt @@ -0,0 +1,14 @@ +src/stdio/__uflow.c +src/stdio/__toread.c +src/stdio/fread.c +src/stdio/__towrite.c +src/stdio/fwrite.c +src/stdio/vsnprintf.c +src/stdio/snprintf.c +src/stdio/vfprintf.c +src/stdio/vasprintf.c +src/stdio/asprintf.c +src/stdio/sscanf.c +src/stdio/vsscanf.c +src/stdio/vfscanf.c + diff --git a/FSLibcNotes/sources/stdlib.txt b/FSLibcNotes/sources/stdlib.txt new file mode 100644 index 0000000..53d2fd2 --- /dev/null +++ b/FSLibcNotes/sources/stdlib.txt @@ -0,0 +1,13 @@ +src/stdlib/abs.c +src/stdlib/bsearch.c +src/stdlib/div.c +src/stdlib/imaxabs.c +src/stdlib/imaxdiv.c +src/stdlib/labs.c +src/stdlib/ldiv.c +src/stdlib/llabs.c +src/stdlib/lldiv.c +src/stdlib/qsort.c +src/stdlib/qsort_nr.c +src/stdlib/strtod.c +src/stdlib/strtol.c diff --git a/FSLibcNotes/sources/string.txt b/FSLibcNotes/sources/string.txt new file mode 100644 index 0000000..19b541e --- /dev/null +++ b/FSLibcNotes/sources/string.txt @@ -0,0 +1,73 @@ +src/string/bcmp.c +src/string/bcopy.c +src/string/bzero.c +src/string/explicit_bzero.c +src/string/index.c +src/string/memccpy.c +src/string/memchr.c +src/string/memcmp.c +src/string/memcpy.c +src/string/memmem.c +src/string/memmove.c +src/string/mempcpy.c +src/string/memrchr.c +src/string/memset.c +src/string/rindex.c +src/string/stpcpy.c +src/string/stpncpy.c +src/string/strcasecmp.c +src/string/strcasestr.c +src/string/strcat.c +src/string/strchr.c +src/string/strchrnul.c +src/string/strcmp.c +src/string/strcpy.c +src/string/strcspn.c +src/string/strdup.c +src/string/strerror_r.c +src/string/strlcat.c +src/string/strlcpy.c +src/string/strlen.c +src/string/strncasecmp.c +src/string/strncat.c +src/string/strncmp.c +src/string/strncpy.c +src/string/strndup.c +src/string/strnlen.c +src/string/strpbrk.c +src/string/strrchr.c +src/string/strsep.c +src/string/strspn.c +src/string/strstr.c +src/string/strtok.c +src/string/strtok_r.c +src/string/strverscmp.c +src/string/swab.c +src/string/wcpcpy.c +src/string/wcpncpy.c +src/string/wcscasecmp.c +src/string/wcscasecmp_l.c +src/string/wcscat.c +src/string/wcschr.c +src/string/wcscmp.c +src/string/wcscpy.c +src/string/wcscspn.c +src/string/wcsdup.c +src/string/wcslen.c +src/string/wcsncasecmp.c +src/string/wcsncasecmp_l.c +src/string/wcsncat.c +src/string/wcsncmp.c +src/string/wcsncpy.c +src/string/wcsnlen.c +src/string/wcspbrk.c +src/string/wcsrchr.c +src/string/wcsspn.c +src/string/wcsstr.c +src/string/wcstok.c +src/string/wcswcs.c +src/string/wmemchr.c +src/string/wmemcmp.c +src/string/wmemcpy.c +src/string/wmemmove.c +src/string/wmemset.c -- 2.49.1