【问题标题】:Enable php intl extension in Yocto在 Yocto 中启用 php intl 扩展
【发布时间】:2020-01-01 17:04:38
【问题描述】:

this answer 之后,我将这个内容放入meta-custom-layer/recipes-devtools/php/php_%.bbappend 文件中:

PACKAGECONFIG_pn-php = "mysql sqlite3 imap opcache openssl ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 pam', d)} apache2"

EXTRA_OECONF_append_class-target = " --with-curl=${STAGING_LIBDIR}/.."
DEPENDS_append_class-target = " icu curl"

EXTRA_OECONF =+ " --enable-mbstring --with-openssl --enable-bcmath --enable-sockets --enable-intl \
                  --with-icu-dir=${BASE_WORKDIR}/cortexa7t2hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/icu/62.1-r0/recipe-sysroot-native/usr \
                        
                  , \
                  , icu-native icu"
PACKAGECONFIG ??= "sqlite3"
PACKAGECONFIG[sqlite3] = "--with-sqlite3=${STAGING_LIBDIR}/.. \
                          --with-pdo-sqlite=${STAGING_LIBDIR}/.. \
                          , \
                          ,sqlite3"

LIBS_pn-php =" -lpthread "
export LIBS
THREADS_pn-php = "pthread"
export THREADS

但在${BASE_WORKDIR}/cortexa7t2hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/icu/62.1-r0 下的bitbake icu 之后只有一个temp 文件夹,其中包含所有icu 任务,但没有recipe-sysroot-native。我也尝试bitbake build-sysroots 没有任何变化。

因此,bitbake php 失败,因为它在该文件夹中找不到预期的文件。

更新

这里是错误信息:

检查 ICU 头文件和库的位置...未找到

配置:错误:无法检测到 ICU 前缀或 /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp- glibc/work/cortexa7t2hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/icu/62.1-r0/recipe-sysroot-native/usr/bin/icu-config 失败。

我在这里找到了icu-config

work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/recipe-sysroot/usr/bin/crossscripts/icu-config

但因为它试图将/bin附加到--with-icu-dir上设置的路径,我无法告诉它在哪里可以找到icu-config

更新2

遵循@Jussi Kukkonen 的提示后,我得到了这些奇怪的编译错误:

cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
In file included from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/../TSRM/TSRM.h:52,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend_portability.h:49,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend_types.h:27,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend.h:29,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/main/php.h:35,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/dateformat/../php_intl.h:23,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/dateformat/dateformat_format.c:21:
/usr/include/pthread.h:681:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      __cleanup_fct_attribute;
      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:693:3: warning: 'regparm' attribute directive ignored [-Wattributes]
   __cleanup_fct_attribute;
   ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:716:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      __cleanup_fct_attribute;
      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:729:3: warning: 'regparm' attribute directive ignored [-Wattributes]
   __cleanup_fct_attribute;
   ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:738:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      ;
      ^
cc1: warning: include location "/usr/include" is unsafe for cross-compilation [-Wpoison-system-directories]
In file included from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/../TSRM/TSRM.h:52,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend_portability.h:49,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend_types.h:27,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend.h:29,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/main/php.h:35,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/php_intl.h:23,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/dateformat/dateformat_parse.c:24:
/usr/include/pthread.h:681:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      __cleanup_fct_attribute;
      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:693:3: warning: 'regparm' attribute directive ignored [-Wattributes]
   __cleanup_fct_attribute;
   ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:716:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      __cleanup_fct_attribute;
      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:729:3: warning: 'regparm' attribute directive ignored [-Wattributes]
   __cleanup_fct_attribute;
   ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:738:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      ;
      ^
In file included from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/../TSRM/TSRM.h:52,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend_portability.h:49,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend_types.h:27,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/Zend/zend.h:29,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/main/php.h:35,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/php_intl.h:23,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/msgformat/msgformat.c:24:
/usr/include/pthread.h:681:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      __cleanup_fct_attribute;
      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:693:3: warning: 'regparm' attribute directive ignored [-Wattributes]
   __cleanup_fct_attribute;
   ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:716:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      __cleanup_fct_attribute;
      ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:729:3: warning: 'regparm' attribute directive ignored [-Wattributes]
   __cleanup_fct_attribute;
   ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:738:6: warning: 'regparm' attribute directive ignored [-Wattributes]
      ;
      ^
In file included from /usr/include/math.h:472,
                 from /local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/dateformat/dateformat_parse.c:22:
/local/STM32MP15-Ecosystem-v1.0.0/Distribution-Package/openstlinux-4.19-thud-mp1-19-02-20/build-openstlinuxeglfs-stm32mp1/tmp-glibc/work/cortexa7hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/php/7.2.10-r0/php-7.2.10/ext/intl/dateformat/dateformat_parse.c: In function 'zif_datefmt_parse':
/usr/include/bits/mathinline.h:751:3: error: invalid 'asm': invalid operand for code 'w'
   __asm __volatile ("fnstcw %3\n\t"           \
   ^~~~~
/usr/include/bits/mathinline.h:503:5: note: in definition of macro '__inline_mathcodeNP_'
     code;              \
     ^~~~
/usr/include/bits/mathinline.h:746:1: note: in expansion of macro '__inline_mathcodeNP'
 __inline_mathcodeNP (floor, __x, \
 ^~~~~~~~~~~~~~~~~~~
/usr/include/bits/mathinline.h:769:3: error: invalid 'asm': invalid operand for code 'w'
   __asm __volatile ("fnstcw %3\n\t"           \
   ^~~~~
/usr/include/bits/mathinline.h:503:5: note: in definition of macro '__inline_mathcodeNP_'
     code;              \
     ^~~~
/usr/include/bits/mathinline.h:764:1: note: in expansion of macro '__inline_mathcodeNP'
 __inline_mathcodeNP (ceil, __x, \
 ^~~~~~~~~~~~~~~~~~~
{standard input}: Assembler messages:
{standard input}:463: Error: bad instruction `fnstcw [sp,#16]'
{standard input}:464: Error: bad instruction `movzwl [sp,#16],r3'
{standard input}:465: Error: bad instruction `andl $0xf3ff,r3'
{standard input}:466: Error: bad instruction `orl $0x0400,r3'
{standard input}:467: Error: ARM register expected -- `movw ,[sp,#18]'
{standard input}:468: Error: bad instruction `fldcw [sp,#18]'
{standard input}:469: Error: bad instruction `frndint'
{standard input}:470: Error: bad instruction `fldcw [sp,#16]'
{standard input}:685: Error: bad instruction `fnstcw [sp,#16]'
{standard input}:686: Error: bad instruction `movzwl [sp,#16],r3'
{standard input}:687: Error: bad instruction `andl $0xf3ff,r3'
{standard input}:688: Error: bad instruction `orl $0x0800,r3'
{standard input}:689: Error: ARM register expected -- `movw ,[sp,#18]'
{standard input}:690: Error: bad instruction `fldcw [sp,#18]'
{standard input}:691: Error: bad instruction `frndint'
{standard input}:692: Error: bad instruction `fldcw [sp,#16]'
Makefile:1007: recipe for target 'ext/intl/dateformat/dateformat_parse.lo' failed
make: *** [ext/intl/dateformat/dateformat_parse.lo] Error 1
make: *** Waiting for unfinished jobs....
ERROR: oe_runmake failed
WARNING: exit code 1 from a shell command.
ERROR: Function failed: do_compile 

【问题讨论】:

  • 该 sn-p 中的几乎每一行都有些奇怪,但主要是 icu-additions 不能这样工作:它看起来像 PACKAGECONFIG 格式,但在 EXTRA_OECONF 中使用(带有硬编码的构建主机路径引导)。您可能应该添加一个 PACKAGECONFIG[icu] (类似于 sqlite3 之一)假设 php 确实需要拼写出路径。假设 php 构建不会永远持续下去,我可以快速浏览一下......
  • icu-config 是一个红鲱鱼:那些几乎从不在交叉编译情况下工作,所以它们通常甚至在 yocto 中都不可用。 pkg-config 可以工作(因为 Yocto 中有一个特殊版本),但由于某种原因,这太容易了,像 php 这样的项目似乎没有使用它。
  • @JussiKukkonen 我的 Yocto knownloedge 太少,无法完全理解您的提示。基本上我需要启用intl php 扩展来运行CakePHP 应用程序。如果有更简单的方法我很高兴学习它!

标签: php yocto


【解决方案1】:

这就是我尝试的方法(我不是 php 专家,而且构建似乎需要很长时间,以至于我自己没有在目标上测试它)。以下创建一个新的 packageconfig

PACKAGECONFIG[intl] = "--enable-intl,--disable-intl,icu"

php 实际上支持 pkg-config 所以它应该只用它找到 icu。至少配置在 Yocto Warrior 上工作正常:php 找到 icu 并启用 intl。

添加后,您可以将“intl”添加到您的 PACKAGECONFIG 行(并删除“_pn-php”后缀:它在配方文件或 bbappend 中没有用):

PACKAGECONFIG = "intl mysql sqlite3 imap opcache openssl ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6 pam', d)} apache2"

您还应该能够移除 EXTRA_OECONF 怪物。当您使用它时,可能会删除所有 sqlite3 行,除非您知道您确实需要它们(据我所知,它们已经在所有维护的 yocto 版本中)。所以删除这些:

EXTRA_OECONF =+ " --enable-mbstring --with-openssl --enable-bcmath --enable-sockets --enable-intl \
                  --with-icu-dir=${BASE_WORKDIR}/cortexa7t2hf-neon-vfpv4-openstlinux_eglfs-linux-gnueabi/icu/62.1-r0/recipe-sysroot-native/usr \

                  , \
                  , icu-native icu"
PACKAGECONFIG ??= "sqlite3"
PACKAGECONFIG[sqlite3] = "--with-sqlite3=${STAGING_LIBDIR}/.. \
                          --with-pdo-sqlite=${STAGING_LIBDIR}/.. \
                          , \
                          ,sqlite3"

说实话,剩下的几行似乎也没什么用,但也许它们并没有真正有害。

【讨论】:

  • 作为评论:Yocto 和食谱格式一开始可能会让人不知所措。盲目地复制东西并不是解决这个问题的好策略(我是从这里的经验说的)。我建议一次进行一项修改并确保它按照您的想法进行(通过 bitbaking 和查看日志、构建结果和 WORKDIR 中的 sysroot)
  • 与此同时,我正在尝试按照您的提示进行操作-我同意您的看法。我在学习 Yocto 时遇到的困难是很多东西看起来很“神奇”。毕竟它是一种编程语言,应该是关于“如何做”事情的明确规则。文档只是说明每个部分的作用,而不是如何将所有内容放在一起。
  • 只是为了确定:请您确认我应该将上面的行放在哪个文件中? meta-custom-layer/recipes-devtools/php/php_%.bbappend ?
  • 不幸的是它失败了......问题已更新日志。
  • 日志表明 /usr/include 的头文件在编译期间被使用——这些是您的构建主机头文件,因此不正确,它应该使用 sysroot 中的头文件。这可能是 php 的 intl 部分的构建系统中的错误(或者配方以某种方式为构建系统提供了错误的路径)。仔细阅读编译日志($WORKDIR/temp/log.*)和构建系统文件是我唯一可以建议的事情
【解决方案2】:

PHP 7.2.1 配方有问题。如果您在图层的“thud”分支上,那么您可能想要切换到“warrior”分支并重新运行bitbake php -v 命令或将 php 7.3.x + 文件的配方复制到您的 php recipe 目录这里https://github.com/openembedded/meta-openembedded/tree/master/meta-oe/recipes-devtools/php

此外,Jussi Kukkonen 是正确的,您可以只使用 PACKAGECONFIG 选项。您的里程会因您想要的 php 第三方库而异,但我认为这里的问题是配方。我使用以下方法让 php 在 thud 和 Warriors 分支上工作:

EXTRA_OECONF_append_class-target = " --with-curl=${STAGING_LIBDIR}/.."
DEPENDS_append_class-target = " icu curl openssl"

EXTRA_OECONF =+ " --enable-mbstring --with-openssl=${STAGING_DIR_TARGET}${exec_prefix} --enable-bcmath --enable-sockets --enable-intl \
                      , \
                      , icu-native icu"
PACKAGECONFIG ??= "intl sqlite3"
PACKAGECONFIG[sqlite3] = "--with-openssl=${STAGING_DIR_TARGET}${exec_prefix} \
              --with-sqlite3=${STAGING_LIBDIR}/.. \
                          --with-pdo-sqlite=${STAGING_LIBDIR}/.. \
                          , \
                          ,sqlite3"

LIBS_pn-php =" -lpthread "
export LIBS
THREADS_pn-php = "pthread"
export THREADS

【讨论】:

    猜你喜欢
    • 2019-06-09
    • 2018-01-17
    • 2018-05-10
    • 1970-01-01
    • 1970-01-01
    • 2012-11-16
    • 2016-07-31
    • 2016-01-21
    • 2012-04-30
    相关资源
    最近更新 更多