From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 50252 invoked by alias); 30 Dec 2016 20:42:23 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 50133 invoked by uid 48); 30 Dec 2016 20:42:09 -0000 From: "luizluca at gmail dot com" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: general X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: luizluca at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2016-q4/txt/msg00015.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D21008 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. Whic= h we don't really seem to use, so might not be essential. But it also calls exit (status) if status !=3D 0. Which is essential to how error is used in elfut= ils. Also error () updates error_message_count which is used in a couple of case= s 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.=20 This thread is about this problem: http://marc.info/?l=3Dmusl&m=3D140404527111778&w=3D2 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__); \ // =3D=3D 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 variab= le 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/ --=20 You are receiving this mail because: You are on the CC list for the bug.