Closed OuYangPaste closed 3 years ago
project.get("target.toolchains") : { "jzt21@cross_toolchain", "jzt21@cross_toolchain" }
你这 xmake.lua 里面 set_toolchains 怎么配置的,给我看下呢
目前看是在装 gv_core 时候,这个包内部也是用了 xmake.lua 。。然后里面取到 toolchains 变成 table 。。需要看下 外层 xmake.lua 配置,和 gv_core 里面的配置才能确定 为啥会重复添加。。
透传到内部 xmake.lua 维护的包,会自动 add_toolchains 透传 toolchains ,但应该也只有一次,还是 string 才对
set_toolchains 是用远程拉取的交叉编译链:
toolchain("jzt21")
set_kind("cross")
set_cross("mips-linux-uclibc-gnu-")
toolchain_end()
add_requires("cross_toolchain")
set_toolchains("jzt21@cross_toolchain")
目前来说每一级的包都会 引用类似上面的配置(实际上是放在 ~/.config/.xmake/xmakerc.lua 的全局配置),也就是说 gv_core 和 其内部所引用的所有子包,只要是用 xmake 管的,都会生效
这个project也是这么搞的 我也没法复现么 一切正常,装里面的zlib/xmake.lua port时候
https://github.com/xmake-io/xmake/blob/master/tests/projects/package/toolchain_muslcc/xmake.lua
我等下开个 github 测试仓弄个通用环境测试一下,看方不方便重现
问题定位到了,原因是因为 set_toolchains 我实际使用是带上内置变量的: set_toolchains("$(arch)@cross_toolchain") 如果改为 使用 get_config 则没有问题 比较奇特的是我另外开的通用测试程序中还是没能重现这个操作,暂时不能提供重现用例
那就怪了,这个 内置变量 似乎也没啥必然关系。。我这也没法复现
内置变量这个我是基于原项目的环境,替换使用为 muslcc 一行行注释,改动,最后定位到的,但是同样的操作用测试代码+内置 repo,目前还没有重现,不排除有别的干扰导致的这种现象,我再一一比对差异
理论上 重复设置 set_toolchains 我内部有去重的,不应该会出现两个 相同的值。。你可以全文搜下其他地方还有没有 set_toolschains 或者 add_toolchains 包括一些依赖包的xmake.lua 里面,看看是不是某个 set_toolchains 传递个 table 进去啥的
话说,xmaker.lua 本质上不是跟本地 xmake.lua 进行文件拼接 么... 现在能重现出来了,好像还跟 xmaker.lua 有关,我再对比一下等下把测试样例发上来
xmakerc.zip 补上 xmakerc.lua
其中main 所依赖的 mul 包:https://github.com/OuYangPaste/test_mul 在前面手动集成 xmakerc.lua 的内容而不直接使用 xmakerc.lua 就会没有问题
嗯 我明天再看下
我这还是复现不了
macosxarm{debug=false,shared=false,toolchains=arm@muslcc} macosxarm{debug=false,pic=true,shared=false,toolchains=arm@muslcc} macosxarm{debug=false,pic=true,shared=false,toolchains=arm@muslcc}_main
哦 你是放到了全局 xmakerc.lua 哈,终于复现了
整理完打算重新捋一遍复现步骤重新发,才看到你说复现了 Q_Q
我修复了,你再试试,是因为 $(arch)
导致 set_toolchains 里面出现了 $(arch)@xxx
和 arm@xxx
。。。因为现在去重是在 内置变量转义前做的,所以转义后 还会有部分重复数据。。我改了下解释器 应该可以了
再试试,刚忘记提交了
测试过可以了,有个好奇的地方,为什么只有放 全局 xmakerc.lua 才会出现这个问题,而把 xmakerc.lua 的内容平铺到 各自 xmake.lua 前面却不会出现呢
测试过可以了,有个好奇的地方,为什么只有放 全局 xmakerc.lua 才会出现这个问题,而把 xmakerc.lua 的内容平铺到 各自 xmake.lua 前面却不会出现呢
你平铺进去,仅仅对当前项目 xmake.lua 生效,取出来转义后的 arm@xxx 传入包里面的 xmake.lua 的 toolchains
所以子包和顶层包都是一个 arm@xxx,而你放入全局 xmakerc.lua,顶层项目透传转义后的 arm@xxx 进去,而子包自身又去全局加载了还没转义的 $(arch)@xxx
。。就出现两个值了。。
原来如此
描述问题
在自定义交叉编译链环境下,repo b 包 依赖于 a 包,当 b 包进行版本迭代后,由于 a 包 installdir hash 计算的问题,导致 a 包被重新编译,尝试切换成 clang 没有问题(这个问题会导致很多不必要的重新编译) 几番捕抓之下, 在 ~/.local/share/xmake/core/package/package.lua: _instance:buildhash 下追加以下打印:
在 ~/.local/share/xmake/modules/private/action/require/impl/package.lua: _init_requireinfo 下追加以下打印:
具体见 以下 log:
发现在第一层打印 toolchains 为正常字符串 jzt21@cross_toolchain 在下一级依赖包(包内部自行 add_requires)打印 toolchains 却为 toolchains=table: 0x7f09315cf420 判断应该是因为 toolchains 在某种情况下表现为 table, 而 table 地址序列化为字符串是个不定值,导致的重复编译 而前面 ~/.local/share/xmake/modules/private/action/require/impl/package.lua : _init_requireinfo 打印的 project.get("target.toolchains") 前后类型也不一致
相关环境