[Lldb-commits] fixing build warnings on Linux

Enrico Granata egranata at apple.com
Thu Nov 29 17:15:37 PST 2012


I don't think ScriptInterpreter.h includes Python.h

ScriptInterpreterPython.h does - at a glance the main reasons for that are:
 our ScriptInterpreterPythonObject is inlined in the .h file and uses Py_X*REF(x)
 our Locker class uses a PyGILState_STATE as a member variable
 the ScriptInterpreterPython itself defines several PyObject* member variables

We would have to look into working around these dependencies (and maybe others I failed to see) before removing the #include of Python.h
Incidentally, none of them seem insurmountable

Enrico Granata
✉ egranata@.com
✆ (408) 972-7683

On Nov 29, 2012, at 5:07 PM, "Kaylor, Andrew" <andrew.kaylor at intel.com> wrote:

> It looked to me like a whole lot of these were coming because ScriptInterpreterPython.h was being included somewhere deep in an include chain from places that probably didn't need Python at all.  I wondered if there was a way to avoid including Python.h from ScriptInterpreter.h and only bring it in when it was needed.
> 
> -Andy
> 
> -----Original Message-----
> From: lldb-commits-bounces at cs.uiuc.edu [mailto:lldb-commits-bounces at cs.uiuc.edu] On Behalf Of Kopec, Matt
> Sent: Thursday, November 29, 2012 2:05 PM
> To: lldb-commits at cs.uiuc.edu
> Subject: Re: [Lldb-commits] fixing build warnings on Linux
> 
> Moving on, another warning popping up many times:
> 
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/lldb.cpp:13:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/Debugger.h:26:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatManager.h:21:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatNavigator.h:24:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatClasses.h:28:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Interpreter/ScriptInterpreterPython.h:23:
> In file included from /usr/include/python2.7/Python.h:8:
> /usr/include/python2.7/pyconfig.h:1158:9: warning: '_POSIX_C_SOURCE' macro redefined #define _POSIX_C_SOURCE 200112L
>        ^
> /usr/include/features.h:163:10: note: previous definition is here
> # define _POSIX_C_SOURCE        200809L
>         ^
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/lldb.cpp:13:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/Debugger.h:26:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatManager.h:21:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatNavigator.h:24:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Core/FormatClasses.h:28:
> In file included from /home/mkopec1/dev/llvm/tools/lldb/source/../include/lldb/Interpreter/ScriptInterpreterPython.h:23:
> In file included from /usr/include/python2.7/Python.h:8:
> /usr/include/python2.7/pyconfig.h:1180:9: warning: '_XOPEN_SOURCE' macro redefined #define _XOPEN_SOURCE 600
>        ^
> /usr/include/features.h:165:10: note: previous definition is here # define _XOPEN_SOURCE  700
> 
> 
> 
> From Python documentation (http://docs.python.org/3.1/c-api/intro.html#include-files):
> 
> Since Python may define some pre-processor definitions which affect the standard headers on some systems, you must include Python.h before any standard headers are included.
> 
> 
> 
> I suggest adding a new header (include/lldb/lldb-python.h) and including it at the top of each source file producing this warning. The header source would look like this:
> 
> 
> #ifndef LLDB_lldb_python_h_
> #define LLDB_lldb_python_h_
> 
> // Python.h needs to be included before any system headers in order to avoid redefinition of macros
> 
> #ifdef LLDB_DISABLE_PYTHON
> 
> // Python is disabled in this build
> 
> #else
> 
> #if defined (__APPLE__)
> #include <Python/Python.h>
> #else
> #include <Python.h>
> #endif
> 
> #endif // LLDB_DISABLE_PYTHON
> 
> #endif  // LLDB_lldb_python_h_
> 
> 
> Thoughts?
> ________________________________________
> From: lldb-commits-bounces at cs.uiuc.edu [lldb-commits-bounces at cs.uiuc.edu] on behalf of Kopec, Matt [matt.kopec at intel.com]
> Sent: Thursday, November 29, 2012 3:23 PM
> To: Greg Clayton
> Cc: lldb-commits at cs.uiuc.edu
> Subject: Re: [Lldb-commits] fixing build warnings on Linux
> 
> Yes, these do exist. Initially, I will replace the warning cases. Thanks :) ________________________________________
> From: Greg Clayton [gclayton at apple.com]
> Sent: Wednesday, November 28, 2012 4:32 PM
> To: Kopec, Matt
> Cc: lldb-commits at cs.uiuc.edu
> Subject: Re: [Lldb-commits] fixing build warnings on Linux
> 
> On Nov 28, 2012, at 12:58 PM, "Kopec, Matt" <matt.kopec at intel.com> wrote:
> 
>> Hi all,
>> 
>> On Linux, there are hundreds of build warnings and I've taken steps to resolve them. Our goal is to be able to build trunk with -Werror.  Some warnings appear so often a patch would be painful to review. For these cases, I'll start with a category of warnings and a general solution on how to resolve for all instances.
>> 
>> Printf format placeholder warnings:
>> 
>> /home/mkopec1/dev/llvm/tools/lldb/source/API/SBBreakpoint.cpp:482:97: warning: format specifies type 'unsigned long long' but the argument has type 'uint64_t' (aka 'unsigned long') [-Wformat]
>>       log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %llu", m_opaque_sp.get(), (uint64_t)num_resolved);
>>                                                                                                                        ~~~                                     ^~~~~~~~~~~~~~~
>> 
>> %lu
>> 
>> On Mac OS X, uint64_t is unsigned long long but on Linux (and FreeBSD) may be unsigned long or unsigned long long. Using the macros in inttypes.h will use the correct format placeholder.
>> 
>> 
>> -         log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => %llu", m_opaque_sp.get(), (uint64_t)num_resolved);
>> +        log->Printf ("SBBreakpoint(%p)::GetNumResolvedLocations () => 
>> + %" PRIu64, m_opaque_sp.get(), (uint64_t)num_resolved);
>> 
>> Does this seem reasonable?
> 
> Yes, as long asthere are PRI macros for all formats ('i', 'u', 'x', 'o', etc).
> 
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20121129/bbb36ec0/attachment.html>


More information about the lldb-commits mailing list