Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: add option to enable dumping of preprocessed source (.i) #11

Closed
paradogz opened this issue Dec 16, 2014 · 12 comments
Closed

Comments

@paradogz
Copy link

When clang crashes for some reason, the preprocessed source code is needed for bug report. With clang compiler you can get it by using -save-temps option (and also -E). It would be useful if c2ffi had similar option to enable generation of .i/.ii file.

@rpav
Copy link
Owner

rpav commented Dec 16, 2014

I will look into this. It sounds like something that should be straightforward.

However, if c2ffi is crashing, please file a separate report with the issue! ;)

@paradogz
Copy link
Author

Yes, c2fii crashes, but it happens in clang code (it looks like this: http://llvm.org/bugs/show_bug.cgi?id=20608)

@rpav
Copy link
Owner

rpav commented Dec 23, 2014

Hmm, if this is not reproducible with clang itself, it's very probably still a c2ffi bug ... e.g., a missing header (the most common thing I encounter) leads to a missing type error which would otherwise stop clang, but c2ffi still tries to extract useful information.

I'm digging through the API ref now to see where to pull the preprocessed source, but it may not be straightforward. Also, have you tried 3.5?

@rpav
Copy link
Owner

rpav commented Dec 23, 2014

Ah, found PrintPreprocessedOutput but I haven't tested to see what you actually get.

@rpav
Copy link
Owner

rpav commented Dec 23, 2014

Notably, everything in that file is static, and I'm not yet sure how it's called directly. However, that may be unnecessary; Preprocessor::setPreprocessedOutput looks promising, and I'm adding some code now.

@rpav
Copy link
Owner

rpav commented Dec 23, 2014

All right, I've added this to master, but it's not in the 3.4 branch yet.

@rpav
Copy link
Owner

rpav commented Dec 23, 2014

This works in the 3.4 branch as well; once 3.5 rebuilds I'll make -o work with -E and pull that to 3.4 as well. I do recommend upgrading to 3.5 though since not much more work is likely to happen in 3.4, especially since 3.6 looks imminent.

@rpav
Copy link
Owner

rpav commented Dec 23, 2014

All right, d54f597 should complete this feature. hth.

@rpav rpav closed this as completed Dec 23, 2014
@paradogz
Copy link
Author

I used llvm 3.5 for the last tests (but it was crashing the same way). Thank you for implementation of this feature, I should test again the next week

@paradogz
Copy link
Author

Ok, I've tried out c2ffi -E and now I'm getting some error output to the console (the same when running clang with equivalent commandline btw) - see https://gist.github.com/paradogz/993c629d640b866cbb00
(the preprocessed source is generated just fine)

Addressing those errors:

  1. I guess I have to ask you to add -std=c++11 option :) (can open a separate feature request if needed)
  2. Macros. If I try to run with -M, I get that segmentation fault before anything is written to the generated file. What is the format of the generated file? / is it possible to define those macros manually?

@rpav
Copy link
Owner

rpav commented Dec 30, 2014

See #12. I've also added a --std option, but I'm not sure it'll end up being necessary.

@paradogz
Copy link
Author

paradogz commented Jan 2, 2015

it could be -std (with single dash) for clang command line compatibility (but thanx anyway!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants