[cfe-dev] Clang tooling and cross compiled code bases
Andrew McGregor
andrewmcgr at gmail.com
Sun Sep 9 21:15:30 PDT 2012
On 10/09/2012, at 12:43 PM, Andrew McGregor <andrewmcgr at gmail.com> wrote:
>
> On 7/09/2012, at 8:57 PM, Manuel Klimek <klimek at google.com> wrote:
>
>> On Fri, Sep 7, 2012 at 3:36 AM, Andrew McGregor <andrewmcgr at gmail.com> wrote:
>>> I have an issue where I'm trying to use a libTooling based refactoring tool on a codebase that is intended for cross-compilation. I have hacked together means to create a compile_commands.json, but the tool is ignoring -triple and -internal-isystem and therefore getting the sizes of many basic types wrong since my compile host is 64 bit and the target isn't.
>>>
>>> Is there a straightforward way of resolving this?
>>
>> I'd say: it's a bug :) Is there an easy way to reproduce this in a
>> small example?
>
> I'll try to construct one. Don't hold your breath, this is a background job.
>
> Andrew
Ok, I did get time, so here we go. Given compile_commands.json containing (obviously, change paths as appropriate):
[
{
"command": "clang -fno-signed-char -c -o foo.o foo.c",
"directory": "/home/andrewm/source/hack/minimal-clang-cc-problem",
"file": "/home/andrewm/source/hack/minimal-clang-cc-problem/foo.c",
},
]
and foo.c in the appropriate place containing:
#include <stdio.h>
#include <stdint.h>
void oinker(char *it) {
printf("%s\n", it);
}
int main(int argc, char **argv) {
uint64_t foo;
uint8_t oink[] = "oink";
oinker(oink);
return 0;
}
$ clang-check -p=/home/andrewm/source/hack/minimal-clang-cc-problem/ /home/andrewm/source/hack/minimal-clang-cc-problem/foo.c
Processing: /home/andrewm/source/hack/minimal-clang-cc-problem/foo.c.
warning: argument unused during compilation: '-fno-signed-char'
foo.c:12:10: warning: passing 'uint8_t [5]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
oinker(oink);
^~~~
foo.c:4:19: note: passing argument to parameter 'it' here
void oinker(char *it) {
^
1 warning generated.
I would argue that -fno-signed-char should be respected in this situation.
The same sort of thing applies to many arguments, including -triple (but not -target) and -isystem-internal.
Andrew
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2330 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120910/fddd4001/attachment.bin>
More information about the cfe-dev
mailing list