xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.75k stars 769 forks source link

汇编文件每次都会编译而不是增量编译 #5327

Closed huhutm closed 1 month ago

huhutm commented 1 month ago

Xmake 版本

2.9.2

操作系统版本和架构

windows 11

描述问题

我的工程中有c文件和汇编文件,编译的时候c文件可以正常增量编译,但是汇编文件每次都会编译,无论是否有修改。

期待的结果

汇编文件也可以支持增量编译,避免重复编译

工程配置

编译器为自定义,如下: toolchain("mw") set_kind("standalone") set_sdkdir("C:/ARC/MetaWare/arc") set_toolset("cc", "gcc@ccac") set_toolset("as", "gcc@ccac") set_toolset("cxx", "gcc@ccac") set_toolset("ld", "gcc@ccac") set_toolset("ar", "ar@arac")

target("elf") set_kind("binary") set_policy("check.auto_ignore_flags", false) add_files("a.c") add_files("b.s")

附加信息和错误日志

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


Title: The assembly file will be compiled every time instead of incremental compilation

waruqi commented 1 month ago
ruki-2:gas ruki$ xmake
[ 50%]: compiling.release src/main.S
[ 75%]: linking.release test
[100%]: build ok, spent 0.204s
ruki-2:gas ruki$ xmake
[100%]: build ok, spent 0.016s

这边测试正常。

huhutm commented 1 month ago
ruki-2:gas ruki$ xmake
[ 50%]: compiling.release src/main.S
[ 75%]: linking.release test
[100%]: build ok, spent 0.204s
ruki-2:gas ruki$ xmake
[100%]: build ok, spent 0.016s

这边测试正常。

这里我的编译: PS D:\test> .\xmake_build_rtos.bat clean PS D:\test> .\xmake_build_rtos.bat flash [ 13%]: compiling.release ..\boot\flash\alps\arc_startup.S [ 20%]: cache compiling.release ..\boot\flash\source\clock.c [ 26%]: cache compiling.release ..\boot\flash\source\flash.c [ 33%]: cache compiling.release ..\boot\flash\source\flash_qspi.c [ 40%]: cache compiling.release ..\boot\flash\source\flash_sfdp.c [ 46%]: cache compiling.release ..\boot\flash\source\os_port.c [ 53%]: cache compiling.release ..\boot\flash\source\qspi_driver.c [ 60%]: cache compiling.release ..\boot\flash\source\string.c [ 66%]: cache compiling.release ..\boot\flash\source\time.c [ 73%]: cache compiling.release ..\boot\flash\source\uart.c [ 80%]: cache compiling.release ..\boot\flash\source\xprintf.c [ 86%]: cache compiling.release ..\boot\flash\alps\init.c [ 93%]: linking.release flash_access.elf [100%]: build ok, spent 0.594s PS D:\test> .\xmake_build_rtos.bat flash [ 13%]: compiling.release ..\boot\flash\alps\arc_startup.S [ 93%]: linking.release flash_access.elf [100%]: build ok, spent 0.265s PS D:\test>

waruqi commented 1 month ago

这边没法复现,你可以自己调下代码,然后提个 pr 过来:https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


It cannot be reproduced here. You can adjust the code yourself: https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

huhutm commented 1 month ago

这边没法复现,你可以自己调下代码,然后提个 pr 过来:

https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

目前发现 .S 文件对应的 .o 文件的 files_mtime[file] or os.mtime(file) 这两个值都是0,所以会重编译。

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


There is no way to reproduce it here. You can adjust the code yourself and submit a PR:

https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

At present, it is found that the two values ​​​​of files_mtime[file] or os.mtime(file) of the .o file corresponding to the .S file are both 0, so it will be recompiled.

huhutm commented 1 month ago

补充一点:depend文件中的depend部分是这样的: files = { [[..\boot\flash\alps\arc_startup.S]] }, depfilesgcc = "..\build\.objs\elf\cross\none\release\_\boot\flash\alps\arc_startup.S.o:\9 ..\boot\flash\alps\arc_startup.S\

但是ischanged打印出的文件是这样的: 0 0 1720667757 D:\work\project\pro\pro\build\.objs\elf\cross\none\release_\boot\flash\alps\arc_startup.S.o: 不知道是否与目录名不一致有关系

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


One more thing: the depend part in the depend file looks like this: files = { [[..\boot\flash\alps\arc_startup.S]] }, depfilesgcc = "..\build\.objs\elf\cross\none\release\_\boot\flash\alps\arc_startup.S.o:\9 ..\boot\ \flash\alps\arc_startup.S\

But the file printed by ischanged is like this: 0 0 1720667757 D:\work\project\CTMRR180Pro\ctmrr180pro\build.objs\elf\cross\none\release_\boot\flash\alps\arc_startup.S.o: I don’t know if it has something to do with the inconsistent directory name.

waruqi commented 1 month ago

这边没法复现,你可以自己调下代码,然后提个 pr 过来: https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

目前发现 .S 文件对应的 .o 文件的 files_mtime[file] or os.mtime(file) 这两个值都是0,所以会重编译。

那就是没有对应的 .o 文件,要么就是 as 没有编译成功,.o 文件没有被生成。。要么就是没权限读

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


There is no way to reproduce it here. You can adjust the code yourself and submit a PR: https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

It is currently found that the two values ​​​​of files_mtime[file] or os.mtime(file) of the .o file corresponding to the .S file are both 0, so it will be recompiled.

That is, there is no corresponding .o file, or as is not compiled successfully, and the .o file is not generated. . Or you don’t have permission to read it

huhutm commented 1 month ago

这边没法复现,你可以自己调下代码,然后提个 pr 过来: https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

目前发现 .S 文件对应的 .o 文件的 files_mtime[file] or os.mtime(file) 这两个值都是0,所以会重编译。

那就是没有对应的 .o 文件,要么就是 as 没有编译成功,.o 文件没有被生成。。要么就是没权限读

相应的目录下有对应的文件,如果是权限问题,其他.c的文件生成的.o都是正常的,只有.s生成的才有问题?

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


There is no way to reproduce it here. You can adjust the code yourself and submit a PR: https://github.com/xmake-io/xmake/blob/c90b483177dd45fb6e7a546b73fcd17c32bbaf23/xmake/modules/core/project/depend.lua#L96

It is currently found that the two values ​​​​of files_mtime[file] or os.mtime(file) of the .o file corresponding to the .S file are both 0, so it will be recompiled.

That means there is no corresponding .o file, or as is not compiled successfully and the .o file is not generated. . Or you don’t have permission to read it

There are corresponding files in the corresponding directories. If it is a permissions problem, the .o generated by other .c files is normal, but only the .s generated has a problem?

star-hengxing commented 1 month ago

看起来像是开发电脑上有加密软件,然后白名单没加上导致的

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


It looks like there is encryption software on the development computer, but the whitelist is not added.

waruqi commented 1 month ago

你可以自己 -vD 看下完整的 编译命令和链接命令。找下对应 .o 是否存在,如果不存在就是没生成。。

也可以自己手动复制编译命令,执行确认是否能够正常生成 .o

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


You can use -vD to see the complete compilation command and link command yourself. Check whether the corresponding .o exists. If it does not exist, it is not generated. .

You can also manually copy the compilation command yourself and execute it to confirm whether .o can be generated normally.

huhutm commented 1 month ago

你可以自己 -vD 看下完整的 编译命令和链接命令。找下对应 .o 是否存在,如果不存在就是没生成。。

也可以自己手动复制编译命令,执行确认是否能够正常生成 .o

企业微信截图_17211126511380 企业微信截图_17211126353443

编译命令和生成的文件见截图,都生成了

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


You can use -vD to see the complete compilation command and link command yourself. Check whether the corresponding .o exists. If it does not exist, it is not generated. .

You can also manually copy the compilation command and execute it to confirm whether .o can be generated normally.

Enterprise WeChat screenshot_17211126511380 Enterprise WeChat screenshot_17211126353443

See the screenshots for the compilation command and generated files, both are generated.

waruqi commented 1 month ago

补充一点:depend文件中的depend部分是这样的: files = { [[..\boot\flash\alps\arc_startup.S]] }, depfilesgcc = "..\build.objs\elf\cross\none\release_\boot\flash\alps\arc_startup.S.o:\9 ..\boot\flash\alps\arc_startup.S\

但是is_changed打印出的文件是这样的: 0 0 1720667757 D:\work\project\CTMRR180Pro\ctmrr180pro\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o: 不知道是否与目录名不一致有关系

给下完整 depfiles_gcc 的内容。。

但是is_changed打印出的文件是这样的: 0 0 1720667757

你之前没说清楚,到底是哪个文件的 mtime 是 0 。。也贴下文件路径。。

另外一种可能是它生成的 deps info 格式问题,导致没解析到正确的路径

huhutm commented 1 month ago

补充一点:depend文件中的depend部分是这样的: files = { [[..\boot\flash\alps\arc_startup.S]] }, depfiles_gcc = "..\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o:\9 ..\boot\flash\alps\arc_startup.S\ 但是is_changed打印出的文件是这样的: 0 0 1720667757 D:\work\project\pro\pro\build\.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o: 不知道是否与目录名不一致有关系

给下完整 depfiles_gcc 的内容。。

但是is_changed打印出的文件是这样的: 0 0 1720667757

你之前没说清楚,到底是哪个文件的 mtime 是 0 。。也贴下文件路径。。

另外一种可能是它生成的 deps info 格式问题,导致没解析到正确的路径

{
    values = {
        [[C:\ARC\MetaWare\arc\bin\ccac]],
        {
            "-Hasopt=-g",
            "-Hasmcpp",
            "-arcv2em",
            "-core4",
        }
    },
    depfiles_gcc = "..\\build\\.objs\\elf\\cross\\none\\release\\__\\boot\\flash\\alps\\arc_startup.S.o:\9 C:/ARC/MetaWare/arc/bin/arcdsp.s C:/ARC/MetaWare/arc/bin/arcexlib.s ..\\boot\\flash\\alps\\arc_startup.S\
\
",
    files = {
        [[..\boot\flash\alps\arc_startup.S]]
    }
}

上面就是deps文件的内容,mtime为0的文件目录:D:\work\project\pro\pro\build\.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

waruqi commented 1 month ago

上面就是deps文件的内容,mtime为0的文件目录:D:\work\project\pro\pro\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

那你看下这个文件是否存在。。

xmake l os.mtime D:\work\project\pro\pro\build\.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

执行下,看看返回值是否也是 0

huhutm commented 1 month ago

上面就是deps文件的内容,mtime为0的文件目录:D:\work\project\pro\pro\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

那你看下这个文件是否存在。。

xmake l os.mtime D:\work\project\pro\pro\build\.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

执行下,看看返回值是否也是 0

发现问题了,mtime为0的文件是

D:\work\project\pro\pro\build\.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o:

注意文件最后面的这个冒号,目录带了冒号,所以实际是找不到这个文件的,感觉是解析depend出现问题了。 在depend文件中这个文件是这样的:

..\\build\\.objs\\elf\\cross\\none\\release\\__\\boot\\flash\\alps\\arc_startup.S.o:\9

如果修改这dep文件,把目录里面的 :\9 这部分删除就是正常的了,不会重复编译。 所以看是dep生成还是解析存在问题

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


The above is the content of the deps file, the file directory with mtime 0: D:\work\project\pro\pro\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

Then check to see if this file exists. .

xmake l os.mtime D:\work\project\pro\pro\build\.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

Execute and see if the return value is also 0

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


The above is the content of the deps file, the file directory with mtime 0: D:\work\project\pro\pro\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

Then check if this file exists. .

xmake l os.mtime D:\work\project\pro\pro\build\.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o

Execute and see if the return value is also 0

Found the problem, the file with mtime 0 is D:\work\project\pro\pro\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o: Pay attention to the colon. The directory contains a colon, so this file does not actually exist. It seems that there is a problem with parsing depend.

waruqi commented 1 month ago

..\build\.objs\elf\cross\none\release\__\boot\flash\alps\arc_startup.S.o:\9

这种其实就是工具链自身乱七八糟的bug导致,莫名搞个 \9 干嘛。。却要这边来填坑。。这个也不太好兼容,处理起来平白增加解析负担 导致正常情况下依赖解析的性能下降,影响编译效率, 真是不划算。

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


..\build\.objs\elf\cross\none\release\__\boot\flash\alps\arc_startup.S.o:\9

This is actually caused by the messy bugs in the tool chain itself. Why create \9 inexplicably? . But we have to fill the hole here. . This is not very compatible, and processing it will only increase the parsing burden, leading to a decrease in performance that relies on parsing under normal circumstances, and affecting compilation efficiency. It is really not cost-effective.

huhutm commented 1 month ago

..\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o:\9

这种其实就是工具链自身乱七八糟的bug导致,莫名搞个 \9 干嘛。。却要这边来填坑。。这个也不太好兼容,处理起来平白增加解析负担 导致正常情况下依赖解析的性能下降,影响编译效率, 真是不划算。

好的,如果不改那我就自己加点判断处理掉了,谢谢!

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


..\build.objs\elf\cross\none\release__\boot\flash\alps\arc_startup.S.o:\9

This is actually caused by the messy bugs in the tool chain itself. Why create \9 inexplicably? . But we have to fill the hole here. . This is not very compatible, and processing it will only increase the parsing burden, leading to a decrease in performance that relies on parsing under normal circumstances, and affecting compilation efficiency. It is really not cost-effective.

Okay, if it doesn’t change then I will make some judgment and deal with it myself, thank you!