[Scons-users] 回复: Ninja compilation fails after using include path file instead of "-I" option

liruncong2018 liruncong2018 at qq.com
Sat Apr 9 21:29:52 EDT 2022


The "TEMPFILE" function should be improved to improve compilation efficiency. At present, we have tested our actual project and changed "@file" to "TEMPFILE". When ninja is not enabled, the compilation time (j32) is increased from 3:45 to 6:30. The duration has increased by almost 3 minutes, which should be related to the massive creation of temporary files. If put "-o $TARGET" and "$SOURCE" directly on the command line without writing temporary files, the number of temporary files generated in large numbers can be as few as 2~3.




------------------ 原始邮件 ------------------
发件人:                                                                                                                        "SCons users mailing list"                                                                                    <bill at baddogconsulting.com>;
发送时间: 2022年4月10日(星期天) 凌晨2:31
收件人: "SCons users mailing list"<scons-users at scons.org>;

主题: Re: [Scons-users] Ninja compilation fails after using include path file instead of "-I" option



Daniel,


Is it likely we should define TEMPFILE for mingw as we do for win32?


-Bill



On Sat, Apr 9, 2022 at 12:39 AM Daniel Moody <dmoody256 at gmail.com> wrote:

hello liruncong,

You can not directly use the @ response file syntax with ninja, you should instead use SCons internal feature for this, TEMPFILE, as the ninja tool will know how to process that.


TEMPFILE is meant to be substituted in the full command line, here is an example how to make your CC compile commands use the tempfile:


env['_RT_CCCOM'] = env['CCCOM']
env['CCCOM'] = "${TEMPFILE('$_RT_CCCOM', '$CCCOMSTR')}"


Here is a diff of your project where I am using the response file in scons and it works with ninja:


diff --git a/bsp/beaglebone/SConstruct b/bsp/beaglebone/SConstruct
index e9eceb553..01c27a83f 100644
--- a/bsp/beaglebone/SConstruct
+++ b/bsp/beaglebone/SConstruct
@@ -56,8 +56,26 @@ def GenIncPathsFile(env, objs):
     env.Depends(objs, [incPathsFile])
     return incPathsFile

-incPathsFile = GenIncPathsFile(env, objs)
-env["_CPPINCFLAGS"] = "@%s" % (incPathsFile)
+env['_RT_CCCOM'] = env['CCCOM']
+env['CCCOM'] = "${TEMPFILE('$_RT_CCCOM', '$CCCOMSTR')}"
+
+# This is only to see the output command using the response file if building with scons
+env['CCCOMSTR'] = None
+
+# My system did not hit the limit in order to use response file,
+# so I had to force it to make sure
+# I could see the response files in use by scons
+env['MAXLINELENGTH'] = 10
+
+# This function make the response file use the correct slash for mingw
+from SCons.Subst import quote_spaces
+def tempfile_arg_esc_func(arg):
+    arg = quote_spaces(arg)
+    return arg.replace('\\', '/')
+env["TEMPFILEARGESCFUNC"] = tempfile_arg_esc_func
+
+#incPathsFile = GenIncPathsFile(env, objs)
+#env["_CPPINCFLAGS"] = "@%s" % (incPathsFile)

 # make a building
 DoBuilding(TARGET, objs)







On Fri, Apr 8, 2022 at 7:23 PM liruncong2018 via Scons-users <scons-users at scons.org> wrote:


git repository: https://github.com/liruncong/NinJaTest.git bsp: beaglebone
mingw: https://download-sh-cmcc.rt-thread.org:9151/www/aozima/env_released_1%20.2.0.7z gcc position : env\tools\gnu_gcc\arm_gcc\mingw\bin
python: 3.8.5(anaconda)
platform: win11
scons: https://github.com/SCons/scons.git

Directly using the "scons" command can compile successfully, but using "scons --experimental=ninja" will fail to compile. Ninja compilation fails after using include path file instead of "-I" option · Issue #4130 · SCons/scons (github.com)

Due to the length limit of the windows command line, in our actual project, the command will exceed the length limit of the windows command line, so this test case uses the "@file" option.


_______________________________________________
 Scons-users mailing list
 Scons-users at scons.org
 https://pairlist4.pair.net/mailman/listinfo/scons-users
 
 _______________________________________________
 Scons-users mailing list
 Scons-users at scons.org
 https://pairlist4.pair.net/mailman/listinfo/scons-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20220410/10681028/attachment-0001.htm>


More information about the Scons-users mailing list