glibc-sysroot-setup.inc 948 B

12345678910111213141516171819202122232425
  1. def sysroot_multilib_suffix(d):
  2. PATH = d.getVar('PATH', True)
  3. target_cc_arch = d.getVar('TARGET_CC_ARCH', True)
  4. options = d.getVar('TOOLCHAIN_OPTIONS', True) or d.expand('--sysroot=${STAGING_DIR_TARGET}')
  5. sysroot = external_run(d, 'gcc', *(target_cc_arch.split() + options.split() + ['-print-sysroot'])).rstrip()
  6. staging = d.getVar('STAGING_DIR_HOST', True)
  7. return os.path.relpath(sysroot, staging)
  8. create_multilib_link () {
  9. dest="$1"
  10. multilib_suffix="${@sysroot_multilib_suffix(d)}"
  11. if [ "$multilib_suffix" != "." ]; then
  12. rm -f $dest/$multilib_suffix
  13. ln -s . $dest/$multilib_suffix
  14. fi
  15. }
  16. SYSROOT_PREPROCESS_FUNCS += "external_toolchain_sysroot_adjust"
  17. external_toolchain_sysroot_adjust() {
  18. create_multilib_link ${SYSROOT_DESTDIR}
  19. # If the usr/lib directory doesn't exist, the toolchain fails to even
  20. # try to find crti.o in a completely different directory (usr/lib64)
  21. install -d ${SYSROOT_DESTDIR}/usr/lib
  22. }