Closed Hoohaha closed 9 months ago
Modified the Link parameters by adding \"
in --keep
option, like this \"--keep=*(.FlashConfig)\"
.
The build can works on linux now.
But on windows, it does not need this.
So my questions is cmsis toolbox should add quotes automatically for build/link options.
It depends on the underlying shell rules. The ninja-build manual describes the Ninja command differences between Unix and Windows:
On Unixes, commands are arrays of arguments. The Ninja command variable is passed directly to sh -c, which is then responsible for interpreting that string into an argv array. Therefore the quoting rules are those of the shell, and you can use all the normal shell operators, like && to chain multiple commands, or VAR=value cmd to set environment variables.
On Windows, commands are strings, so Ninja passes the command string directly to CreateProcess. (In the common case of simply executing a compiler this means there is less overhead.) Consequently the quoting rules are determined by the called program, which on Windows are usually provided by the C library. If you need shell interpretation of the command (such as the use of && to chain multiple commands), make the command execute the Windows shell by prefixing the command with cmd /c. Ninja may error with "invalid parameter" which usually indicates that the command line length has been exceeded.
An initial investigation shows that the direct escaping of parenthesis with backslashes works on Linux but not on Windows:
--keep=*\(.FlashConfig\)
Warning: L6319W: Ignoring --keep command
Putting the value in-between quotation marks seem to work on both Linux and Windows. In the CPRJ it would look like this:
<ldflags add="... --keep="*(.FlashConfig)""/>
However semantic operations over compiler/linker flags have been so far avoided. Pros/cons of having it done automatically need to be discussed.
@brondani What's the best way to handle this?
What's the best way to handle this?
The recommendation is to surround with quotation marks the symbols that may be interpreted differently depending on the shell used in your environment. My suggestion for this case would be like that:
misc:
- for-compiler: AC6
Link:
- --keep="*(.FlashConfig)"
Your suggestion placing quotes around the whole option is also valid has the same effect.
@brondani & @Hoohaha can this issue be closed or is there some actions to be taken?
thank you @brondani and @jkrech . close now.
Build open cmsis pack examples on linux with ARMCLANG toolchain. It report syntax error, any idea about his?