Mirror of the lttng-dev mailing list
 help / color / mirror / Atom feed
From: toojays@toojays.net (John Steele Scott)
Subject: [lttng-dev] lttng-ust with --std=c99 -pedantic
Date: Mon, 18 Jun 2012 21:40:42 +0930	[thread overview]
Message-ID: <4FDF1AC2.3070009@toojays.net> (raw)
In-Reply-To: <20120612155539.GA15859@Krystal>

On 13/06/12 01:25, Mathieu Desnoyers wrote:
> * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
>> Hi John,
>>
>> * John Steele Scott (toojays at toojays.net) wrote:
>>> I want to add lttng-ust tracepoints to a program which builds with "--std=c99 -pedantic". Right now this does not work.
>>>
>>> Using the demo program as an example, if you enable --std=c99, the first issue looks like:
>>>
>>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng  -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
>>> ust_tests_demo.h:27:23: warning: implicit declaration of function ?typeof? [-Wimplicit-function-declaration]
>>> ust_tests_demo.h:27:218: error: expected ?;? before ?_________p1?
>>> ust_tests_demo.h:27:395: error: ?_________p1? undeclared (first use in this function)
>>> ust_tests_demo.h:27:395: note: each undeclared identifier is reported only once for each function it appears in
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
>>> ust_tests_demo.h:35:214: error: expected ?;? before ?_________p1?
>>> ust_tests_demo.h:35:383: error: ?_________p1? undeclared (first use in this function)
>>> In file included from demo.c:35:0:
>>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
>>> ust_tests_demo2.h:27:299: error: expected ?;? before ?_________p1?
>>> ust_tests_demo2.h:27:470: error: ?_________p1? undeclared (first use in this function)
>>> In file included from demo.c:36:0:
>>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
>>> ust_tests_demo3.h:27:215: error: expected ?;? before ?_________p1?
>>> ust_tests_demo3.h:27:386: error: ?_________p1? undeclared (first use in this function)
>>>
>>> This can be easily resolved by using __typeof__() instead of typeof(). Then I can build with --std=c99. But adding -pedantic still fails:
>> I pushed a fix for this:
>>
>> commit 6423c3134bf07d4a7db56f69f2c79b540a79c4f1
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date:   Mon Jun 11 10:15:25 2012 -0400
>>
>>     Fix c99 compatibility: use __typeof__ instead of typeof in public headers
>>     
>>     Reported-by: John Steele Scott <toojays at toojays.net>
>>     Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>> I also had issues with (void) arg parameters with tracepoints, so
>> pushed:
>>
>> commit 4495dd39c05739d0fb2bc463b7c093d2459ce2b6
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date:   Tue Jun 12 11:22:46 2012 -0400
>>
>>     Fix: support -std=c99 in tracepoint macros
>>     
>>     Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>> I had also to fix userspace RCU library, with:
>>
>>
>> commit e51500edbd9919cee53bc85cbb4b22cd4786fc42
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date:   Tue Jun 12 11:24:31 2012 -0400
>>
>>     Fix c99 compatibility: use __asm__ and __volatile__ in public headers
>>     
>>     Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>> commit bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date:   Mon Jun 11 10:16:35 2012 -0400
>>
>>     Fix c99 compatibility: use __typeof__ instead of typeof in public headers
>>     
>>     Reported-by: John Steele Scott <toojays at toojays.net>
>>     Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>>
>>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -Dtypeof=__typeof__ -pedantic -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng  -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
>>> In file included from ust_tests_demo.h:25:0,
>>>                  from demo.c:34:
>>> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
>>> ../../include/lttng/tracepoint.h:251:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:255:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:260:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:264:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:268:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
>>> ust_tests_demo.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo.h:27:549: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
>>> ust_tests_demo.h:35:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo.h:35:537: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:35:0:
>>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
>>> ust_tests_demo2.h:27:245: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo2.h:27:624: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:36:0:
>>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
>>> ust_tests_demo3.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo3.h:27:540: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> I see these warnings, the only thing that currently fails is due to
>> BYTE_ORDER and BIG_ENDIAN not being defined. By adding:
>>
>> -DBYTE_ORDER=__BYTE_ORDER -DBIG_ENDIAN=__BIG_ENDIAN
>>
>> my tests/hello program, with a Makefile.am modified to do:
>>
>> hello_CFLAGS = -Werror=old-style-definition --std=c99 -pedantic
>>
>> prints many pedantic warnings, and fails with:
>>
>> ././ust_tests_hello.h:55:1: error: zero or negative size array ?__event_fields___ust_tests_hello___tptest_sighandler?
>>
>> which seems to be caused by my event with 0 fields, which try to create
>> an array of length 0.
>>
>> I'll look into this one.
> Please try again with lttng-ust master HEAD, userspace-rcu master HEAD,
> and let me know if you experience problems compiling your instrumented
> application with --std=c99 -pedantic. Please note that the probe object
> (e.g. tp.c in the tests/hello program) needs to be compiled with gnu
> extensions, so you should not use --std=c99 for this specific object.

Mathieu,

Thanks for your reply, sorry it has taken me so long to respond.

I can now build this application with userspace tracing. I was actually able to compile the probe object with --std=c99 as well (this time on Centos 6.2, didn't try yet on Ubuntu). Would you expect any problems from this? I only have a single tracepoint in this app, but it does seem to work.

The thing I forgot to mention is: okay, I can build now with -pedantic, but I can't build with "-pedantic -Werror". This application builds with "--std=c99 -pedantic -Werror" (among many other flags). I can of course remove -Werror for my tests, but in the longer term I would like to see lttng-ust enabled in our regular build, and disabling -Werror for that is not something we want to do. If I only had to disable it for the trace provider, I could negotiate that, but disabling it for any module which uses tracepoints is undesirable.

I haven't yet looked at how difficult it would be do eliminate these pedantic warnings. Do you have a feel for what is involved? Preprocessor tricks warp my mind. :(

cheers,

John



  reply	other threads:[~2012-06-18 12:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-09 23:37 John Steele Scott
2012-06-12 15:32 ` Mathieu Desnoyers
2012-06-12 15:55   ` Mathieu Desnoyers
2012-06-18 12:10     ` John Steele Scott [this message]
2012-06-18 14:11       ` Mathieu Desnoyers
2012-06-19 17:45         ` Mathieu Desnoyers
2012-06-20 13:10           ` John Steele Scott
2012-06-20 13:47             ` Mathieu Desnoyers
2012-06-21  0:51               ` John Steele Scott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4FDF1AC2.3070009@toojays.net \
    --to=toojays@toojays.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox