How can I check if a function exists in waf?

Joel Sherrill joel at rtems.org
Sat Feb 2 18:32:58 UTC 2019


On Sat, Feb 2, 2019, 4:11 AM Sebastian Huber <
sebastian.huber at embedded-brains.de wrote:

> ----- Am 2. Feb 2019 um 2:07 schrieb Chris Johns chrisj at rtems.org:
>
> > On 1/2/19 8:19 pm, Sebastian Huber wrote:
> >>
> >> So, there is no standard compile and link test for functions? If I use
> this
> >>
> >>     conf.check_cc(fragment = 'int main(void) { strnlen("", 0); return
> 0; }',
> >>                   header_name="string.h", features = 'c', mandatory =
> False)
> >>
> >> waf outputs
> >>
> >> Checking for header string.h                  : yes
> >>
> >> I don't want to test for string.h, I want to test for strnlen(). In
> config.log
> >> we have:
> >>
> >> ---------------------------------------------
> >> Checking for header string.h
> >> ==>
> >> int main(void) { strnlen("", 0); return 0; }
> >> <==
> >> [1/1] Compiling
> [32mbuild/.conf_check_6da1e91772980301eb2528a1d150a7ab/test.c[0m
> >>
> >> ['/usr/bin/gcc', '../test.c', '-c',
> >>
> '-o/scratch/git-rtems-tools/build/.conf_check_6da1e91772980301eb2528a1d150a7ab/testbuild/test.c.1.o']
> >>
> >> err: ../test.c: In function ‘main’:
> >> ../test.c:1:18: warning: implicit declaration of function ‘strnlen’
> >> [-Wimplicit-function-declaration]
> >>  int main(void) { strnlen("", 0); return 0; }
> >>                   ^~~~~~~
> >>
> >> yes
> >> ---------------------------------------------
> >>
> >> So, this test uses already quite some code and still is basically
> useless.
> >
> > You have a powerful language available. I would create a function to
> handle
> > repeated checks, for example:
> >
> >
> https://git.rtems.org/chrisj/rtems_waf.git/tree/rtems.py?h=libbsd-libdl#n270
> >
> > I think having the ability to perform checks for an RTEMS application
> highlights
> > the power available.
>
> Yes, I don't doubt that you can do a lot of things with Python, but it was
> a bit surprising to me that I have to write custom code for things which
> are covered by basic Autoconf macros and only because Microsoft is not able
> to ship an operating system with a strnlen() function.
>

When you can check for a function with our infrastructure, sb-check needs
to flag missing libraries needed for the tools

> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20190202/e8a6cb81/attachment-0002.html>


More information about the devel mailing list