Clang 或 LLVM 中的“-Wa,-divide”选项

`-Wa,-divide` option in Clang or LLVM

我正在将 xv6 从 GCC 移植到 Clang,遇到以下错误消息:

clang -m32 -gdwarf-2 -Wa,-divide   -c -o swtch.o swtch.S
clang-3.8: error: unsupported argument '-divide' to option 'Wa,'

注意-Wa是用来给汇编程序传递参数的,我没弄清楚-divide选项是什么

作为修复,目前我通过将 no-integrated-as 选项传递给 Clang 来关闭集成汇编程序。但我想使用 Clang 的集成组件。忽略此选项是否安全?或者是否有其他方法可以为 Clang 提供该选项?

煤气手册documentation for --divide说:

On SVR4-derived platforms, the character / is treated as a comment character, which means that it cannot be used in expressions. The --divide option turns / into a normal character. This does not disable / at the beginning of a line starting a comment, or affect using `#' for starting a comment.

在我的 Linux 桌面上,--divide 什么都不做:as 汇编 mov $(15/2), %eax 有或没有 --divide 都很好。

所以你把它拿出来应该没问题。如果这是一个问题,并且 clang 在某些平台上确实将 / 视为注释字符,那么它通常会导致构建时失败,而不是带有隐藏错误的二进制文件。


是的,-divide 显然与 --divide 做同样的事情。但是您可能想尝试 --divide 以防 clang 的汇编程序仅支持更标准的双 - 形式。