From: "luizluca at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug general/21008] New: Incompatible with MUSL libc: error.h and error() not provided
Date: Fri, 30 Dec 2016 20:42:00 -0000 [thread overview]
Message-ID: <bug-21008-10460@http.sourceware.org/bugzilla/> (raw)
https://sourceware.org/bugzilla/show_bug.cgi?id=21008
Bug ID: 21008
Summary: Incompatible with MUSL libc: error.h and error() not
provided
Product: elfutils
Version: unspecified
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: general
Assignee: unassigned at sourceware dot org
Reporter: luizluca at gmail dot com
CC: elfutils-devel at sourceware dot org
Target Milestone: ---
Hello,
From original bug 21002:
- The idea of using system.h to define error () seems fine. But the current
replacement doesn't seem complete. error () also flushes stdout first. Which we
don't really seem to use, so might not be essential. But it also calls exit
(status) if status != 0. Which is essential to how error is used in elfutils.
Also error () updates error_message_count which is used in a couple of cases to
know what exit code a program should use (if error itself didn't exit).
The proposed solution would be to:
1) move error.h inclusion into system.h and conditionally include either
error.h or err.h
2) build a good replacement for error()
The only problem is #2.
This thread is about this problem:
http://marc.info/?l=musl&m=140404527111778&w=2
The solution that was already present in OpenWRT/LEDE was simply to use:
#define error(status, errno, ...) err(status, __VA_ARGS__)
Which is not enough as error replacement. It always exits even when status is
0, it does not flush stdout and it does not increase the (absent)
error_message_count.
I didn't noticed the missing error_message_count as a problem because, for
OpenWRT/LEDE, only elfutils libs where compiled (and they don't use
error_message_count). So, for my use case, this might be enough:
#define error(status, errno, ...) \
fflush(stdout); \
warn(__VA_ARGS__); \ // == err(status,...) without exit
if (errno) exit(errno);
There is a minor problem of ignoring errno, which might be considered an
"optional feature".
For a full built, the problem is error_message_count. It is a global variable
and it must be initialized. Probably the best solution would be to create a
simplified error.h/error.c, which exports error and error_message_count and
gets optionally build and linked (autoconf) into the generated files when
error.h is absent.
Some existing approaches so far:
https://github.com/GregorR/musl-cross/blob/master/patches/elfutils-no_error.patch
(original inspiration)
https://patchwork.openembedded.org/patch/111665/
--
You are receiving this mail because:
You are on the CC list for the bug.
next reply other threads:[~2016-12-30 20:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-30 20:42 luizluca at gmail dot com [this message]
2016-12-30 21:16 ` [Bug general/21008] " luizluca at gmail dot com
2016-12-30 21:29 ` luizluca at gmail dot com
2018-07-04 14:54 ` ross at burtonini dot com
2021-08-27 17:13 ` mark at klomp dot org
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=bug-21008-10460@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=elfutils-devel@sourceware.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).