mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Samuel Holland <samuel@sholland.org>
To: musl@lists.openwall.com, Chris Hall <musl@gmch.uk>
Subject: Re: Detecting musl at compile and/or configure time
Date: Sun, 30 Jun 2019 07:28:48 -0500	[thread overview]
Message-ID: <bcb39635-a804-4d2f-3b6e-60e7edfe6e66@sholland.org> (raw)
In-Reply-To: <3767f116-4a52-e9ef-a2ee-df1c23719e34@gmch.uk>

Hi,

On 6/30/19 7:03 AM, Chris Hall wrote:
> I have a little build system which tries to detect the "usual suspects"
> automatically, even without a full configure/cmake/etc. step.  If the detection
> process fails, it generates a warning and the user must (at least) add a '-Dxxx'
> to suppress that.
> 
> I confess I have only recently stumbled across musl.  Perhaps systems which
> default to musl are so rare that I can, as a practical matter, ignore them ? 
> The question then is whether to add a '-DqLIB_MUSL' gizmo to my build stuff --
> so that "musl-gcc -DqLIB_MUSL" will do the trick.

The fundamental problem with that is that you're not really checking for musl.
You're checking for "the supported version (and options) of POSIX", "the
supported version of the Linux UAPI", and "the set of extensions currently
supported by musl", which all change over time. And some of them depend on who's
distributing musl, as they may add their own customizations.

For POSIX, you should declare which version of the standard you follow with
_POSIX_C_SOURCE, which you can verify is supported with _POSIX_VERSION, or for
optional parts, the other macros in unistd.h[1].

The Linux UAPI is stable, so you can use whatever features you want as long as
you gracefully handle ENOSYS/EINVAL (or document a minimum supported version).

Extensions (anything not specified by POSIX or in the UAPI) must be detected
individually, because they may appear (or disappear! like sys/sysmacros.h) at
any time. If you know which extensions you rely on, and have fallbacks as
possible/needed, then it doesn't matter what the libc is named, or what it's
version number is. And it will be much easier to port your application to a new
environment.

[1]: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

> Thanks,
> 
> Chris
> 

Cheers,
Samuel


  reply	other threads:[~2019-06-30 12:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <26f5537f-a876-209c-a27c-cd2619f5c834@gmch.uk>
2019-06-30 12:03 ` Fwd: " Chris Hall
2019-06-30 12:28   ` Samuel Holland [this message]
2019-06-30 14:30     ` Chris Hall
2019-06-30 14:54     ` Jeffrey Walton
2019-07-02 12:19     ` Florian Weimer
2019-06-30 14:51   ` Jeffrey Walton
     [not found] <1561802993.8028.ezmlm@lists.openwall.com>
2019-06-29 11:48 ` Chris Hall
2019-06-29 13:27   ` A. Wilcox
2019-06-29 13:58     ` Szabolcs Nagy
2019-06-30 11:48       ` Chris Hall

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=bcb39635-a804-4d2f-3b6e-60e7edfe6e66@sholland.org \
    --to=samuel@sholland.org \
    --cc=musl@gmch.uk \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).