Yocto nativesdk-ncurses 构建失败,因为包含路径没有以 sysroot 为前缀
Yocto nativesdk-ncurses fails to build because of include paths not prefixed with sysroot
我正在尝试为 imx6qsabresd 板的 Yocto "dizzy" 分支构建一个 SDK。
我已经按照 https://github.com/Freescale/fsl-community-bsp-platform/blob/jethro/README.adoc 上的说明进行操作,唯一的区别是我使用了 dizzy 分支而不是 jethro。
运行 bitbake meta-toolchain
现在给我以下错误:
| echo | gawk -f /mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses/base/MKunctrl.awk bigstrings=1 >unctrl.c
| x86_64-pokysdk-linux-gcc --sysroot=/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux -DHAVE_CONFIG_H -I../ncurses -I/mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses -isystem/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include -D_GNU_SOURCE -DNDEBUG -I. -I../include -I/mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses/../include -I/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include -isystem/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include -O2 -pipe --param max-inline-insns-single=1200 -fPIC -DUSE_TERMLIB -c /mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses/tinfo/access.c -o ../obj_s/access.o
| cc1: error: /opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include: Permission denied
[..]
ERROR: Task 1368 (virtual:nativesdk:/mnt/space1/yocto-dizzy-imx6/sources/poky/meta/recipes-core/ncurses/ncurses_5.9.bb, do_compile) failed with exit code '1'
上面的相关参数是:
-I/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include
--sysroot=/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux
ncurses 是最早构建的软件包之一,我想这个问题不是 ncurses 特有的。
显然,编译器试图访问绝对包含目录 /opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include
,而不考虑 sysroot 前缀 /mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux
。两者一起 /mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include
将是正确的包含路径。
现在,谁对谁错?编译器在查看 -I
包含目录时不考虑 --sysroot
参数?还是 Yocto 食谱中某处有误?也许 Yocto 的工作是为包含路径添加前缀?还有其他提示吗?
我相信你需要应用这个 patch。具体来说,这些行
#Remove ${includedir} from CPPFLAGS, need for cross compile
sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
if [ -d "${D}${includedir}/ncurses" ]; then
for f in `find ${D}${includedir}/ncurses -name "*.h"`
do
f=`basename $f`
test -e ${D}${includedir}/$f && continue
ln -sf ncurses/$f ${D}${includedir}/$f
done
fi
diff --git a/meta/recipes-core/ncurses/ncurses.inc b/meta/recipes-core/ncurses/ncurses.inc
index 10f7dd1..225e369 100644
--- a/meta/recipes-core/ncurses/ncurses.inc
+++ b/meta/recipes-core/ncurses/ncurses.inc
@@ -13,7 +13,7 @@ BINCONFIG = "${bindir}/ncurses-config"
inherit autotools binconfig-disabled multilib_header
# Upstream has useful patches at times at ftp://invisible-island.net/ncurses/
-SRC_URI = "${GNU_MIRROR}/ncurses/ncurses-${PV}.tar.gz"
+SRC_URI = "ftp://invisible-island.net/${BPN}/current/${BP}-${REVISION}.tgz"
EXTRA_AUTORECONF = "-I m4"
CONFIG_SITE =+ "${WORKDIR}/config.cache"
@@ -97,6 +97,8 @@ do_configure() {
# broken because it requires stdin to be pollable (which is
# not the case for /dev/null redirections)
export cf_cv_working_poll=yes
+ #Remove ${includedir} from CPPFLAGS, need for cross compile
+ sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
# The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
mkdir -p ${PKG_CONFIG_LIBDIR}
@@ -105,6 +107,7 @@ do_configure() {
return 1
! ${ENABLE_WIDEC} || \
ncurses_configure "widec" "--enable-widec" "--without-progs"
+
}
do_compile() {
@@ -231,7 +234,14 @@ do_install() {
# At some point we can rely on coreutils 8.16 which has ln -r.
lnr ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so
fi
-
+ if [ -d "${D}${includedir}/ncurses" ]; then
+ for f in `find ${D}${includedir}/ncurses -name "*.h"`
+ do
+ f=`basename $f`
+ test -e ${D}${includedir}/$f && continue
+ ln -sf ncurses/$f ${D}${includedir}/$f
+ done
+ fi
oe_multilib_header curses.h
}
LightenS 的回答让我找到了正确的地方。
下面是更多详细信息:
ncurses 的 configure.in
包含对 CF_INCLUDE_DIRS
宏的调用,该宏在 aclocal.m4
中定义。该宏添加了一个包含路径,但没有在其前面加上 sysroot,这会破坏构建。
通常修复会更改 aclocal.m4
中的宏,但这是不可能的,因为 "ncurses requires a patched autoconf213 to generate the configure script. This autoconf is not available"。因此 configure
需要修补。
作为参考,这是我为 Yocto dizzy 创建的补丁:
Index: ncurses-5.9/configure
===================================================================
--- ncurses-5.9.orig/configure
+++ ncurses-5.9/configure
@@ -18601,10 +18601,10 @@ if test "$GCC" != yes; then
elif test "$includedir" != "/usr/include"; then
if test "$includedir" = '${prefix}/include' ; then
if test $prefix != /usr ; then
- CPPFLAGS="$CPPFLAGS -I${includedir}"
+ :
fi
else
- CPPFLAGS="$CPPFLAGS -I${includedir}"
+ :
fi
fi
我正在尝试为 imx6qsabresd 板的 Yocto "dizzy" 分支构建一个 SDK。 我已经按照 https://github.com/Freescale/fsl-community-bsp-platform/blob/jethro/README.adoc 上的说明进行操作,唯一的区别是我使用了 dizzy 分支而不是 jethro。
运行 bitbake meta-toolchain
现在给我以下错误:
| echo | gawk -f /mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses/base/MKunctrl.awk bigstrings=1 >unctrl.c
| x86_64-pokysdk-linux-gcc --sysroot=/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux -DHAVE_CONFIG_H -I../ncurses -I/mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses -isystem/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include -D_GNU_SOURCE -DNDEBUG -I. -I../include -I/mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses/../include -I/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include -isystem/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include -O2 -pipe --param max-inline-insns-single=1200 -fPIC -DUSE_TERMLIB -c /mnt/space1/yocto-dizzy-imx6/build/tmp/work/x86_64-nativesdk-pokysdk-linux/nativesdk-ncurses/5.9-r15.1/ncurses-5.9/ncurses/tinfo/access.c -o ../obj_s/access.o
| cc1: error: /opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include: Permission denied
[..]
ERROR: Task 1368 (virtual:nativesdk:/mnt/space1/yocto-dizzy-imx6/sources/poky/meta/recipes-core/ncurses/ncurses_5.9.bb, do_compile) failed with exit code '1'
上面的相关参数是:
-I/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include
--sysroot=/mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux
ncurses 是最早构建的软件包之一,我想这个问题不是 ncurses 特有的。
显然,编译器试图访问绝对包含目录 /opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include
,而不考虑 sysroot 前缀 /mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux
。两者一起 /mnt/space1/yocto-dizzy-imx6/build/tmp/sysroots/x86_64-nativesdk-pokysdk-linux/opt/poky/1.7.3/sysroots/x86_64-pokysdk-linux/usr/include
将是正确的包含路径。
现在,谁对谁错?编译器在查看 -I
包含目录时不考虑 --sysroot
参数?还是 Yocto 食谱中某处有误?也许 Yocto 的工作是为包含路径添加前缀?还有其他提示吗?
我相信你需要应用这个 patch。具体来说,这些行
#Remove ${includedir} from CPPFLAGS, need for cross compile
sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
if [ -d "${D}${includedir}/ncurses" ]; then
for f in `find ${D}${includedir}/ncurses -name "*.h"`
do
f=`basename $f`
test -e ${D}${includedir}/$f && continue
ln -sf ncurses/$f ${D}${includedir}/$f
done
fi
diff --git a/meta/recipes-core/ncurses/ncurses.inc b/meta/recipes-core/ncurses/ncurses.inc
index 10f7dd1..225e369 100644
--- a/meta/recipes-core/ncurses/ncurses.inc
+++ b/meta/recipes-core/ncurses/ncurses.inc
@@ -13,7 +13,7 @@ BINCONFIG = "${bindir}/ncurses-config"
inherit autotools binconfig-disabled multilib_header
# Upstream has useful patches at times at ftp://invisible-island.net/ncurses/
-SRC_URI = "${GNU_MIRROR}/ncurses/ncurses-${PV}.tar.gz"
+SRC_URI = "ftp://invisible-island.net/${BPN}/current/${BP}-${REVISION}.tgz"
EXTRA_AUTORECONF = "-I m4"
CONFIG_SITE =+ "${WORKDIR}/config.cache"
@@ -97,6 +97,8 @@ do_configure() {
# broken because it requires stdin to be pollable (which is
# not the case for /dev/null redirections)
export cf_cv_working_poll=yes
+ #Remove ${includedir} from CPPFLAGS, need for cross compile
+ sed -i 's#-I${cf_includedir}##g' ${S}/configure || die "sed CPPFLAGS"
# The --enable-pc-files requires PKG_CONFIG_LIBDIR existed
mkdir -p ${PKG_CONFIG_LIBDIR}
@@ -105,6 +107,7 @@ do_configure() {
return 1
! ${ENABLE_WIDEC} || \
ncurses_configure "widec" "--enable-widec" "--without-progs"
+
}
do_compile() {
@@ -231,7 +234,14 @@ do_install() {
# At some point we can rely on coreutils 8.16 which has ln -r.
lnr ${D}${base_libdir}/libtinfo.so.5 ${D}${libdir}/libtinfo.so
fi
-
+ if [ -d "${D}${includedir}/ncurses" ]; then
+ for f in `find ${D}${includedir}/ncurses -name "*.h"`
+ do
+ f=`basename $f`
+ test -e ${D}${includedir}/$f && continue
+ ln -sf ncurses/$f ${D}${includedir}/$f
+ done
+ fi
oe_multilib_header curses.h
}
LightenS 的回答让我找到了正确的地方。 下面是更多详细信息:
ncurses 的 configure.in
包含对 CF_INCLUDE_DIRS
宏的调用,该宏在 aclocal.m4
中定义。该宏添加了一个包含路径,但没有在其前面加上 sysroot,这会破坏构建。
通常修复会更改 aclocal.m4
中的宏,但这是不可能的,因为 "ncurses requires a patched autoconf213 to generate the configure script. This autoconf is not available"。因此 configure
需要修补。
作为参考,这是我为 Yocto dizzy 创建的补丁:
Index: ncurses-5.9/configure
===================================================================
--- ncurses-5.9.orig/configure
+++ ncurses-5.9/configure
@@ -18601,10 +18601,10 @@ if test "$GCC" != yes; then
elif test "$includedir" != "/usr/include"; then
if test "$includedir" = '${prefix}/include' ; then
if test $prefix != /usr ; then
- CPPFLAGS="$CPPFLAGS -I${includedir}"
+ :
fi
else
- CPPFLAGS="$CPPFLAGS -I${includedir}"
+ :
fi
fi