glibc-sysroot-setup.inc 1008 B

1234567891011121314151617181920212223242526272829
  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 = oe.external.run(d, 'gcc', *(target_cc_arch.split() + options.split() + ['-print-sysroot'])).rstrip()
  6. staging = d.getVar('STAGING_DIR_HOST', True)
  7. if sysroot == staging:
  8. return ''
  9. else:
  10. return os.path.relpath(sysroot, staging)
  11. create_multilib_link () {
  12. dest="$1"
  13. multilib_suffix="${@sysroot_multilib_suffix(d)}"
  14. if [ -n "$multilib_suffix" ]; then
  15. rm -rf $dest/$multilib_suffix
  16. ln -s . $dest/$multilib_suffix
  17. fi
  18. }
  19. SYSROOT_PREPROCESS_FUNCS += "external_toolchain_sysroot_adjust"
  20. external_toolchain_sysroot_adjust() {
  21. create_multilib_link ${SYSROOT_DESTDIR}
  22. # If the usr/lib directory doesn't exist, the toolchain fails to even
  23. # try to find crti.o in a completely different directory (usr/lib64)
  24. install -d ${SYSROOT_DESTDIR}/usr/lib
  25. }