Does Klang have the equivalent flag GCC -malign-double?

It looks like the -malign-double compiler option has been removed from Clang. Code example:

 #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; } 

When compiling with GCC in 32-bit mode ( -m32 ), this can be done to output 8 or 4, depending on whether the -malign-double option is -malign-double or not. But Clang does not support this option:

 $ clang test.c -m32 -malign-double clang: warning: argument unused during compilation: '-malign-double' $ ./a.out 4 

Clang Version:

 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 

I cannot find any official documentation in the full list of compiler flags supported by Clang, they seem to be most likely to refer to the GCC documentation.

Does Clang have the current equivalent -malign-double ? Or am I stuck to use another compiler? I need it to compile some code that references a third-party binary library that uses this flag.

+6
source share
1 answer

Apparently, you can use -mllvm -malign-double as a workaround.

Quote from https://codereview.chromium.org/1310173005 :

While LLVM supports the -malign-double option, Clang does not. Passing to -mllvm -malign-double cannot be used as a workaround as this will cause the machine description to be used by the Clan and LLVM.

+1
source

Source: https://habr.com/ru/post/913866/


All Articles