toolchain.mk 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ################################################################################
  2. #
  3. # toolchain
  4. #
  5. ################################################################################
  6. ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
  7. TOOLCHAIN_DEPENDENCIES += toolchain-buildroot
  8. else ifeq ($(BR2_TOOLCHAIN_EXTERNAL),y)
  9. TOOLCHAIN_DEPENDENCIES += toolchain-external
  10. endif
  11. TOOLCHAIN_ADD_TOOLCHAIN_DEPENDENCY = NO
  12. TOOLCHAIN_INSTALL_STAGING = YES
  13. # Apply a hack that Rick Felker suggested[1] to avoid conflicts between libc
  14. # headers and kernel headers. This is needed for kernel headers older than
  15. # 4.15. Kernel headers 4.15 and newer don't require __GLIBC__ to be defined.
  16. #
  17. # Augment the original suggestion with __USE_MISC since recent kernels
  18. # (older than 4.15) require this glibc internal macro. Also, as musl defines
  19. # IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO, add another macro to suppress
  20. # them in the kernel header, and avoid macro/enum conflict.
  21. #
  22. # Kernel version 3.12 introduced the libc-compat.h header.
  23. #
  24. # [1] http://www.openwall.com/lists/musl/2015/10/08/2
  25. ifeq ($(BR2_TOOLCHAIN_USES_MUSL)$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12):$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_15),yy:)
  26. define TOOLCHAIN_MUSL_KERNEL_HEADERS_COMPATIBILITY_HACK
  27. $(SED) 's/^#if defined(__GLIBC__)$$/#if 1/' \
  28. $(STAGING_DIR)/usr/include/linux/libc-compat.h
  29. $(SED) '1s/^/#define __USE_MISC\n/' \
  30. $(STAGING_DIR)/usr/include/linux/libc-compat.h
  31. $(SED) '1s/^/#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0\n/' \
  32. $(STAGING_DIR)/usr/include/linux/libc-compat.h
  33. endef
  34. TOOLCHAIN_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_MUSL_KERNEL_HEADERS_COMPATIBILITY_HACK
  35. endif
  36. # Install default nsswitch.conf file if the skeleton doesn't provide it
  37. ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
  38. define GLIBC_COPY_NSSWITCH_FILE
  39. @if [ ! -f "$(TARGET_DIR)/etc/nsswitch.conf" ]; then \
  40. $(INSTALL) -D -m 0644 package/glibc/nsswitch.conf $(TARGET_DIR)/etc/nsswitch.conf ; \
  41. fi
  42. endef
  43. TOOLCHAIN_POST_INSTALL_TARGET_HOOKS += GLIBC_COPY_NSSWITCH_FILE
  44. endif
  45. $(eval $(virtual-package))