It seems like the -malign-double
compiler option has been removed from Clang. Example code:
#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 compiled with GCC in 32-bit mode (-m32
), this can be made to output either 8 or 4 depending on if -malign-double
is enabled or not respectively. But Clang does not appear to 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 can't seem to find any official documentation on the full list of compiler flags supported by Clang, they just seem to defer to GCC's documentation for the most part.
Is there any current equivalent to -malign-double
in Clang? Or am I stuck having to use a different compiler for now? I need it to compile some code that links against a binary-only third-party library that uses that flag.
You can use Clang in C99 mode with the -std=c99 option.
Clang has support for some of the features of the ISO C++ 2020 standard. You can use Clang in C++20 mode with the -std=c++20 option (use -std=c++2a in Clang 9 and earlier).
In the end, Apple chose to develop Clang, a new compiler front end that supports C, Objective-C and C++. In July 2007, the project received the approval for becoming open-source.
Clang supports use of either LLVM's libc++ or GCC's libstdc++ implementation of the C++ standard library.
This seems to be fixed now:
commit 3205dbb3f1f96e77e106f964dcf1b5f69fba4ecc
Author: Craig Topper <[email protected]>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With