ya.make 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. RESOURCES_LIBRARY()
  2. DEFAULT(LLD_VERSION ${CLANG_VER})
  3. TOOLCHAIN(lld)
  4. VERSION(${LLD_VERSION})
  5. # There is no backward compatibility between LLVM IR versions 16 and 18.
  6. # So, we need to select lld18 when using clang18 to compile src in LTO mode.
  7. IF (LLD_VERSION == 18)
  8. DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE_BY_JSON(LLD_ROOT lld18.json)
  9. ELSEIF (LLD_VERSION == 16)
  10. DECLARE_EXTERNAL_HOST_RESOURCES_BUNDLE_BY_JSON(LLD_ROOT lld16.json)
  11. ENDIF()
  12. IF (OS_ANDROID)
  13. # Use LLD shipped with Android NDK.
  14. LDFLAGS(
  15. -fuse-ld=lld
  16. )
  17. IF (ANDROID_API < 29)
  18. # Dynamic linker on Android does not support lld's default rosegment
  19. # prior to API Level 29 (Android Q)
  20. # See:
  21. # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#additional-required-arguments
  22. # https://github.com/android/ndk/issues/1196
  23. LDFLAGS(
  24. -Wl,--no-rosegment
  25. )
  26. ENDIF()
  27. # Enable optimized relocations format (e.g. .rela.dyn section) to reduce binary size
  28. # See:
  29. # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#relr-and-relocation-packing
  30. IF (ANDROID_API >= 30)
  31. LDFLAGS(-Wl,--pack-dyn-relocs=android+relr)
  32. ELSEIF (ANDROID_API >= 28)
  33. LDFLAGS(-Wl,--pack-dyn-relocs=android+relr,--use-android-relr-tags)
  34. ELSEIF (ANDROID_API >= 23)
  35. LDFLAGS(-Wl,--pack-dyn-relocs=android)
  36. ENDIF()
  37. ELSEIF (OS_LINUX)
  38. LDFLAGS(
  39. -fuse-ld=lld
  40. --ld-path=${LLD_ROOT_RESOURCE_GLOBAL}/bin/ld.lld
  41. # dynlinker on auld ubuntu versions can not handle .rodata stored in standalone segment [citation needed]
  42. -Wl,--no-rosegment
  43. # add build-id to binaries to allow external tools check equality of binaries
  44. -Wl,--build-id=sha1
  45. )
  46. ELSEIF (OS_DARWIN OR OS_IOS)
  47. LDFLAGS(
  48. -fuse-ld=lld
  49. --ld-path=${LLD_ROOT_RESOURCE_GLOBAL}/bin/ld64.lld
  50. )
  51. ELSEIF (OS_EMSCRIPTEN)
  52. LDFLAGS(
  53. -fuse-ld=${LLD_ROOT_RESOURCE_GLOBAL}/bin/wasm-ld
  54. # FIXME: Linker does not capture "ld-path" and therefore it can not find "wasm-ld"
  55. )
  56. ENDIF()
  57. END()