[cfe-dev] using the original file name for compiling preprocessed files ("-main-file-name"?)

Robert Lytton robert at xmos.com
Fri May 2 00:50:39 PDT 2014


Hi Richard,

I've tried to follow it through from both ends but lost my way.
I'll have a second go at it and suggest a patch.

thank you

Robert

________________________________
From: metafoo at gmail.com [metafoo at gmail.com] on behalf of Richard Smith [richard at metafoo.co.uk]
Sent: 02 May 2014 00:35
To: Robert Lytton
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] using the original file name for compiling preprocessed files ("-main-file-name"?)

On Thu, May 1, 2014 at 2:22 AM, Robert Lytton <robert at xmos.com<mailto:robert at xmos.com>> wrote:
Hi,

I would like to call clang twice, once to preprocess and second time to compile.
The second time clang is called, I would like to pass in the original file name for it to use as the ModuleID.
I tried to use:
   clang -E test.c -o tmp.i
   clang -S -x c tmp.i -o test.s    -Xclang -main-file-name -Xclang test.c   -emit-llvm

However, the ModuleID is 'tmp.i' rather than that passed in by '-main-file-name'.

This seems like a bug to me; -main-file-name should be used as the name of the input in all respects other than where we find it on disk. Care to put together a patch to fix this? (I doubt you'll be able to get anyone else to care much about what ends up in ModuleID, so I think you'll need to do the work yourself here...)

Same with:
    clang -cc1 -triple x86_64-unknown-linux-gnu -x c tmp.i -o test.s  -main-file-name test.c -emit-llvm


I am trying to achieve the same affect as using "-fpreprocessed -dumpbase <file>" with llvm-gcc.
Here it seems the gcc front end fetches the file name from the first line of the preprocessed file.

Thank you.

Robert






_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu<mailto:cfe-dev at cs.uiuc.edu>
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140502/4e4827b5/attachment.html>


More information about the cfe-dev mailing list