Git Product home page Git Product logo

Comments (12)

clausecker avatar clausecker commented on June 2, 2024 1

It's a warning, not an error. Hence when these files are compiled via (HTSlib's build system's) make test the diagnostic messages scroll past quickly and are easily missed. (And the tests go on to run successfully anyway.)

Strictly speaking, calling an undeclared function causes behaviour to be undefined ever since C99. It's just accepted as a legacy feature by recent compilers. You should definitely fix this.

from htslib.

jmarshall avatar jmarshall commented on June 2, 2024

If you look in those files you'll see they do in fact include <sys/time.h>.

On FreeBSD, this header provides a declaration of gettimeofday() only if __XSI_VISIBLE is non-zero. This is non-zero by default or if the code defines _XOPEN_SOURCE (see cdefs.h), but will be reset to zero if you choose strict ANSI, C99, or C11 mode. Did you select any of those?

As recently predicted might become necessary in #1586 (comment) 😄, HTSlib can ensure this is non-zero by ensuring _XOPEN_SOURCE is defined to an appropriate value. There's an old draft of that in this xopen_source branch that probably needs some 500 vs 600 work (see also #1246).

from htslib.

clausecker avatar clausecker commented on June 2, 2024

I compiled htslib 1.17 with no changes on FreeBSD and tried to build and run the unit tests when this issue happened.

from htslib.

jkbonfield avatar jkbonfield commented on June 2, 2024

I tried the latest freebsd with just ./configure;make and it works fine.

What compiler are you using, and are you setting any specific C flags?

from htslib.

clausecker avatar clausecker commented on June 2, 2024

The error occurs when building the unit tests (make test). Did you try that?

I am building htslib 1.17 with clang. We pass

-O2 -pipe  -fstack-protector-strong -isystem /usr/local/include -fno-strict-aliasing

as extra C flags when building this port.

from htslib.

jmarshall avatar jmarshall commented on June 2, 2024

It's a warning, not an error. Hence when these files are compiled via (HTSlib's build system's) make test the diagnostic messages scroll past quickly and are easily missed. (And the tests go on to run successfully anyway.)

FreeBSD's cdefs.h also sidesteps the default activation of __XSI_VISIBLE when _POSIX_C_SOURCE is set and _XOPEN_SOURCE is not set.

It turns out HTSlib's Makefile's rules for htscodecs/test/*.o add ‑D_POSIX_C_SOURCE=200112L to their compilation. This is incorrect; it should be ‑D_XOPEN_SOURCE=600 instead, as these test source files use an XSI function as well as POSIX functionality.

That's the short-term fix. The better fix would be to set _XOPEN_SOURCE globally in the HTSlib source code (as in the xopen_source branch previously mentioned), but that would be something probably best done early in a development cycle.

from htslib.

jkbonfield avatar jkbonfield commented on June 2, 2024

I tried make check, with clang and opts above (bar the /usr/local/include bit as I'm only using official packages) and see no warnings.

However this was an htscodecs build. I'm not sure we're talking about the same thing here (eg @jmarshall's comments above). Htscodecs when built from htslib has a completely different Makefile and build system, so maybe this is infact an htslib bug rather than htscodecs one? I haven't yet tested that scenario (it's soooo slow on this laptop due to inability to use kvm qemu driver and no permission to install VM tools, sigh). I'll start it going...

from htslib.

clausecker avatar clausecker commented on June 2, 2024

@jkbonfield Yes, the is an htslibs issue. I don't know why the issue was moved to this repository.

from htslib.

jkbonfield avatar jkbonfield commented on June 2, 2024

Incorrect assumptions :)

I'll move it back. Thanks for clarifying

from htslib.

jmarshall avatar jmarshall commented on June 2, 2024

It was transferred here because it appeared to be an htscodecs issue (the *.c source files come from htscodecs), but the problem turns out to be in HTSlib's build rules for the htscodecs object files. It would have been more obvious that this was the case if the OP had included the exact compilation lines from the make output as well as the diagnostics. But we got there pretty quickly anyway.


Strictly speaking, calling an undeclared function causes behaviour to be undefined ever since C99. […] You should definitely fix this.

Indeed. Feel free to read the rest of the comment you're replying to.
The point, as it whizzes by…

from htslib.

jkbonfield avatar jkbonfield commented on June 2, 2024

There's already a commentd out line to force XOPEN_SOURCE for building, which I added mainly for compatibility testing. https://github.com/samtools/htslib/blob/develop/Makefile#L37

I agree this ought to be more mainstream. I haven't yet looked at your branch, but think this is worth doing as it is basically a requirement and until now it's just been unnecessary to make this explicit.

from htslib.

jkbonfield avatar jkbonfield commented on June 2, 2024

I've tried with clang 14.0.5 on freebsd 13.2-RELEASE with the compiler options you mention and cannot reproduce this warning.

Edit: scratch that - forgot the make check bit. Well now I can reproduce, so should be easy to test fixes. Thanks

from htslib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.