musl.mk 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ################################################################################
  2. #
  3. # musl
  4. #
  5. ################################################################################
  6. MUSL_VERSION = 1.2.4
  7. MUSL_SITE = http://musl.libc.org/releases
  8. MUSL_LICENSE = MIT
  9. MUSL_LICENSE_FILES = COPYRIGHT
  10. MUSL_CPE_ID_VENDOR = musl-libc
  11. # Before musl is configured, we must have the first stage
  12. # cross-compiler and the kernel headers
  13. MUSL_DEPENDENCIES = host-gcc-initial linux-headers
  14. # musl does not provide an implementation for sys/queue.h or sys/cdefs.h.
  15. # So, add the musl-compat-headers package that will install those files,
  16. # into the staging directory:
  17. # sys/queue.h: header from NetBSD
  18. # sys/cdefs.h: minimalist header bundled in Buildroot
  19. MUSL_DEPENDENCIES += musl-compat-headers
  20. # musl is part of the toolchain so disable the toolchain dependency
  21. MUSL_ADD_TOOLCHAIN_DEPENDENCY = NO
  22. MUSL_INSTALL_STAGING = YES
  23. # 0004-iconv-fix-erroneous-input-validation-in-EUC-KR-decod.patch
  24. # 0005-iconv-harden-UTF-8-output-code-path-against-input-de.patch
  25. MUSL_IGNORE_CVES += CVE-2025-26519
  26. # musl does not build with LTO, so explicitly disable it
  27. # when using a compiler that may have support for LTO
  28. ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),y)
  29. MUSL_EXTRA_CFLAGS += -fno-lto
  30. endif
  31. # Thumb build is broken, build in ARM mode, since all architectures
  32. # that support Thumb1 also support ARM.
  33. ifeq ($(BR2_ARM_INSTRUCTIONS_THUMB),y)
  34. MUSL_EXTRA_CFLAGS += -marm
  35. endif
  36. define MUSL_CONFIGURE_CMDS
  37. (cd $(@D); \
  38. $(TARGET_CONFIGURE_OPTS) \
  39. CFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CFLAGS)) $(MUSL_EXTRA_CFLAGS)" \
  40. CPPFLAGS="$(filter-out -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64,$(TARGET_CPPFLAGS))" \
  41. ./configure \
  42. --target=$(GNU_TARGET_NAME) \
  43. --host=$(GNU_TARGET_NAME) \
  44. --prefix=/usr \
  45. --libdir=/lib \
  46. --disable-gcc-wrapper \
  47. --enable-static \
  48. $(if $(BR2_STATIC_LIBS),--disable-shared,--enable-shared))
  49. endef
  50. define MUSL_BUILD_CMDS
  51. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
  52. endef
  53. define MUSL_INSTALL_STAGING_CMDS
  54. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
  55. DESTDIR=$(STAGING_DIR) install-libs install-tools install-headers
  56. ln -sf libc.so $(STAGING_DIR)/lib/ld-musl*
  57. endef
  58. define MUSL_INSTALL_TARGET_CMDS
  59. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \
  60. DESTDIR=$(TARGET_DIR) install-libs
  61. $(RM) $(addprefix $(TARGET_DIR)/lib/,crt1.o crtn.o crti.o rcrt1.o Scrt1.o)
  62. ln -sf libc.so $(TARGET_DIR)/lib/ld-musl*
  63. endef
  64. $(eval $(generic-package))