Ada*_*eld 7 gcc clang compiler-flags
似乎-malign-double已从Clang中删除了编译器选项.示例代码:
#include <stddef.h>
#include <stdio.h>
typedef struct X { char a; long long b; } X;
int main(void)
{
printf("%zd\n", offsetof(X, b));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当使用GCC在32位模式(-m32)中编译时,可以输出8或4,具体取决于是否-malign-double分别启用.但Clang似乎不支持这个选项:
$ clang test.c -m32 -malign-double
clang: warning: argument unused during compilation: '-malign-double'
$ ./a.out
4
Run Code Online (Sandbox Code Playgroud)
铿锵版:
Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.3.0
Thread model: posix
Run Code Online (Sandbox Code Playgroud)
我似乎无法在Clang支持的完整编译器标志列表中找到任何官方文档,它们似乎只是在大多数情况下遵循GCC的文档.
-malign-double在Clang中是否有当前的等价物?或者我现在不得不使用不同的编译器?我需要它来编译一些链接到使用该标志的仅二进制第三方库的代码.
这似乎现在已修复:
commit 3205dbb3f1f96e77e106f964dcf1b5f69fba4ecc
Author: Craig Topper <craig.topper@intel.com>
Date: Thu Mar 21 20:07:24 2019 +0000
[Driver] Pass -malign-double from the driver to the cc1 command line
-malign-double is currently only implemented in the -cc1 interface.
But its declared in Options.td so it is a driver option too.
But you try to use it with the driver you'll get a message about the
option being unused.
This patch teaches the driver to pass the option through to cc1 so it won't
be unused. The Options.td says the option is x86 only but I didn't see any
x86 specific code in its implementation in cc1 so not sure if the
documentation is wrong or if I should only pass this option through the
driver on x86 targets.
Differential Revision: https://reviews.llvm.org/D59624
llvm-svn: 356706
Run Code Online (Sandbox Code Playgroud)