Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 470884 - dev-libs/elfutils: build fails on uclibc
Summary: dev-libs/elfutils: build fails on uclibc
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement with 1 vote (vote)
Assignee: Anthony Basile
URL: https://lists.fedorahosted.org/piperm...
Whiteboard:
Keywords:
: 533024 (view as bug list)
Depends on: 547292
Blocks: uclibc-porting
  Show dependency tree
 
Reported: 2013-05-21 14:48 UTC by Anthony Basile
Modified: 2022-01-02 10:24 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Replace __mempcpy with mempcpy (elfutils-0.155-fallback-mempcpy.patch,2.08 KB, patch)
2013-05-21 14:55 UTC, Anthony Basile
Details | Diff
Use argp-standalone (elfutils-0.155-link-argp-standalone.patch,2.79 KB, patch)
2013-05-21 14:57 UTC, Anthony Basile
Details | Diff
Remove mcheck/mtrace (elfutils-0.155-remove-mtrace.patch,5.89 KB, patch)
2013-05-21 14:59 UTC, Anthony Basile
Details | Diff
Remove DL_CALL_FCT: uclibc does not support gprof (elfutils-0.155-remove-profiling-support.patch,6.49 KB, patch)
2013-05-22 12:46 UTC, Anthony Basile
Details | Diff
Replace obstack_printf with asprintf/obstack_grow (elfutils-0.155-replace-obstack_printf.patch,1.24 KB, patch)
2013-05-30 01:58 UTC, Anthony Basile
Details | Diff
Use argp-standalone (elfutils-0.155-link-argp-standalone.patch,5.42 KB, patch)
2013-05-30 02:08 UTC, Anthony Basile
Details | Diff
Fall back on mempcpy if __mempcpy is not available (0001-libelf-elf_begin.c-fall-back-on-mempcpy-if-no-__memp.patch,1.37 KB, patch)
2013-06-09 01:27 UTC, Anthony Basile
Details | Diff
Check if argp is provided by libc or is standalone (0002-Link-against-standalone-argp-library.patch,7.42 KB, patch)
2013-06-09 01:29 UTC, Anthony Basile
Details | Diff
Use asprintf+obstack_grow if obstack_printf is not available (0003-Fall-back-on-asprintf-if-obstack_printf-is-not-avail.patch,1.99 KB, text/plain)
2013-06-09 01:31 UTC, Anthony Basile
Details
Check if mtrace() is available and disable it if it is not. (0004-Check-for-mtrace-and-disable-if-not-available.patch,4.14 KB, patch)
2013-06-09 01:32 UTC, Anthony Basile
Details | Diff
Fall back on utimes if futimes is not available (0005-Fall-back-on-utimes-if-futimes-is-not-available.patch,2.38 KB, patch)
2013-06-09 01:34 UTC, Anthony Basile
Details | Diff
Check if DL_CALL_FCT is available and disable if it is not (0006-Remove-DL_CALL_FCT-wrapper-which-is-used-in-profilin.patch,937 bytes, patch)
2013-06-09 01:35 UTC, Anthony Basile
Details | Diff
Check if libc provides dgettext (elfutils-0.158-check-libc-dgettext.patch,9.14 KB, patch)
2014-05-02 11:07 UTC, Alex Guzman
Details | Diff
Check if argp is provided by libc or is standalone (0.158) (elfutils-0.158-check-standalone-argp.patch,7.63 KB, patch)
2014-05-02 11:10 UTC, Alex Guzman
Details | Diff
Fix ar.c to use the FUTIMES macro (elfutils-0.158-utimes-fallback.patch,1.17 KB, patch)
2014-05-02 11:19 UTC, Alex Guzman
Details | Diff
elfutils-0.166-check-libc-dgettext.patch (elfutils-0.166-check-libc-dgettext.patch,4.73 KB, patch)
2017-01-10 02:08 UTC, René Rhéaume
Details | Diff
elfutils-0.166-utimes-fallback.patch (elfutils-0.166-utimes-fallback.patch,354 bytes, patch)
2017-01-10 02:12 UTC, René Rhéaume
Details | Diff
elfutils-0.166-really-make-werror-conditional-to-build-werror.patch (elfutils-0.166-really-make-werror-conditional-to-build-werror.patch,868 bytes, patch)
2017-01-10 02:17 UTC, René Rhéaume
Details | Diff
elfutils-0.166-asprintf-insteadof-obstack_printf.patch (elfutils-0.166-asprintf-insteadof-obstack_printf.patch,2.30 KB, patch)
2017-01-10 02:25 UTC, René Rhéaume
Details | Diff
elfutils-0.166.ebuild.patch (elfutils-0.166.ebuild.patch,1.97 KB, patch)
2017-01-10 02:36 UTC, René Rhéaume
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Basile gentoo-dev 2013-05-21 14:48:24 UTC
Okay the title says it all.  This may be a hopeless task because of all the glibc-ism, but I've made some headway and I'll track the changes here.

Reproducible: Always
Comment 1 Anthony Basile gentoo-dev 2013-05-21 14:55:38 UTC
Created attachment 348828 [details, diff]
Replace __mempcpy with mempcpy

This replace glibc's __mempcpy with mempcpy.  Neither are posix, although uclibc does provide the later.
Comment 2 Anthony Basile gentoo-dev 2013-05-21 14:57:06 UTC
Created attachment 348830 [details, diff]
Use argp-standalone

Since argp is not part of uclibc, we use the breakout library sys-libs/argp-standalone.  But then we need to tell the build system to link against it.
Comment 3 Anthony Basile gentoo-dev 2013-05-21 14:59:31 UTC
Created attachment 348832 [details, diff]
Remove mcheck/mtrace

mtrace is a diagnostic function which sets up hooks for malloc and friends.  It doesn't exist in uclibc and we can live without it.
Comment 4 Anthony Basile gentoo-dev 2013-05-21 17:34:55 UTC
Another problem is that elfutils makes use of obstack_printf in src/nm.c.  While uclibc does support obstacks, it doesn't have obstack_printf which could be added.
Comment 5 Anthony Basile gentoo-dev 2013-05-22 12:46:23 UTC
Created attachment 348908 [details, diff]
Remove DL_CALL_FCT: uclibc does not support gprof

ld.h defines several DL_CALL_FCT wraps for profiling which is not supported by uclibc.  We remove the wrapper.
Comment 6 Anthony Basile gentoo-dev 2013-05-30 01:58:16 UTC
Created attachment 349604 [details, diff]
Replace obstack_printf with asprintf/obstack_grow

uclibc has almost all the other obstack_* functions so we can just use asprintf.  We may want to add a free here after obstack_grow() to prevent a memory leak.
Comment 7 Anthony Basile gentoo-dev 2013-05-30 02:08:18 UTC
Created attachment 349608 [details, diff]
Use argp-standalone

I forgot to add the tests in the previous patch.
Comment 8 Anthony Basile gentoo-dev 2013-05-31 10:26:14 UTC
I did this because libelf doesn't provide ELF_C_RDWR_MMAP, bug #470882, although it does build fine on uclibc.  I'm now thinking to add the mmap code there rather than this mess.

Anyhow, here it is if toolchain finds any of this useful, else feel free to close wontfix.
Comment 9 SpanKY gentoo-dev 2013-05-31 18:59:09 UTC
Comment on attachment 348828 [details, diff]
Replace __mempcpy with mempcpy

this looks way more complicated than it needs to be.  why not do:

#ifndef HAVE___MEMPCPY
# define __mempcpy mempcpy
#endif

you could probably even do that in the configure.ac file w/AC_DEFINE
Comment 10 SpanKY gentoo-dev 2013-05-31 19:00:37 UTC
Comment on attachment 348832 [details, diff]
Remove mcheck/mtrace

this sucks, but i don't have a better idea

you should add configure.ac checks for mcheck.h and do things based on that:
#ifdef HAVE_MCHECK_H
#include <mcheck.h>
#else
#define mtrace()
#endif

general comment: you need to clean up your patches.  please see:
http://dev.gentoo.org/~vapier/clean-patches
Comment 11 SpanKY gentoo-dev 2013-05-31 19:02:32 UTC
Comment on attachment 348908 [details, diff]
Remove DL_CALL_FCT: uclibc does not support gprof

seems like you could do this at the top with three lines:
#ifndef DL_CALL_FCT
#define DL_CALL_FCT(f, a) f a
#endif
Comment 12 SpanKY gentoo-dev 2013-05-31 19:06:33 UTC
Comment on attachment 349604 [details, diff]
Replace obstack_printf with asprintf/obstack_grow

since obstack isn't part of POSIX, but uClibc does have optional support, i'd update uClibc to support this func

otherwise, you can avoid modifying the code with something like:
#ifndef HAVE_OBSTACK_PRINTF
# define obstack_printf(x, ...) ({ \
  char *s; \
  int n = asprintf(&s, __VA_ARGS__); \
  obstack_grow(&whereob, s, n); \
  n; \
})
#endif
Comment 13 Anthony Basile gentoo-dev 2013-06-09 01:27:39 UTC
Created attachment 350476 [details, diff]
Fall back on mempcpy if __mempcpy is not available

This patch and the following set are against elfutils' git master/HEAD
Comment 14 Anthony Basile gentoo-dev 2013-06-09 01:29:32 UTC
Created attachment 350478 [details, diff]
Check if argp is provided by libc or is standalone

This improves the previous patch by adding a check in configure.ac whether argp is provided by the system's libc, if it is not check if you can link against it using -largp (for a standalone) or fail it it can't be found.
Comment 15 Anthony Basile gentoo-dev 2013-06-09 01:31:42 UTC
Created attachment 350480 [details]
Use asprintf+obstack_grow if obstack_printf is not available

I'm going to try to write the implementation for obstack_printf for uClibc.  It should be a learning experience.  In the mean time this is the fallback on asprintf.
Comment 16 Anthony Basile gentoo-dev 2013-06-09 01:32:22 UTC
Created attachment 350482 [details, diff]
Check if mtrace() is available and disable it if it is not.
Comment 17 Anthony Basile gentoo-dev 2013-06-09 01:34:41 UTC
Created attachment 350484 [details, diff]
Fall back on utimes if futimes is not available

This adds a check in configure.ac for futimes and falls back on utimes if not available.  At every point in the code, the file name is available as well as a file descriptor.  We could probably just unconditionally replace futimes with utimes safely, but the check is cheap enough.
Comment 18 Anthony Basile gentoo-dev 2013-06-09 01:35:33 UTC
Created attachment 350486 [details, diff]
Check if DL_CALL_FCT is available and disable if it is not
Comment 19 Anthony Basile gentoo-dev 2013-06-09 01:37:03 UTC
(In reply to SpanKY from comment #10) 
> general comment: you need to clean up your patches.  please see:
> http://dev.gentoo.org/~vapier/clean-patches

I know.  I know. :P

I'm going to test those patches on glibc.  The checks in configure.ac should make things work just fine there so we don't have to do something ugly like

  use uclibc && epatch ...
Comment 20 Anthony Basile gentoo-dev 2013-06-09 01:39:49 UTC
Hmm ... rereading the patches I noticed I used AC_CHECK_FUNCS_ONCE in 1 and 3 where AC_CHECK_FUNC would have been sufficient.
Comment 21 Anthony Basile gentoo-dev 2013-06-09 02:10:35 UTC
Okay for the records, I just tested on a glibc system and everything looks good.  Built fine and some random runs looked fine too.
Comment 22 Anthony Basile gentoo-dev 2013-06-10 01:32:50 UTC
(In reply to SpanKY from comment #12)
> Comment on attachment 349604 [details, diff] [details, diff]
> Replace obstack_printf with asprintf/obstack_grow
> 
> since obstack isn't part of POSIX, but uClibc does have optional support,
> i'd update uClibc to support this func
> 
> otherwise, you can avoid modifying the code with something like:
> #ifndef HAVE_OBSTACK_PRINTF
> # define obstack_printf(x, ...) ({ \
>   char *s; \
>   int n = asprintf(&s, __VA_ARGS__); \
>   obstack_grow(&whereob, s, n); \
>   n; \
> })
> #endif


Shouldn't &whereob be x?  I unthinkingly just copied this but in two places in the  Use_asprointf++obstack_grow patch, so I should probably fix that.
Comment 23 Anthony Basile gentoo-dev 2013-06-11 14:36:48 UTC
(In reply to Anthony Basile from comment #22)
> (In reply to SpanKY from comment #12)
> > Comment on attachment 349604 [details, diff] [details, diff] [details, diff]
> > Replace obstack_printf with asprintf/obstack_grow
> > 
> > since obstack isn't part of POSIX, but uClibc does have optional support,
> > i'd update uClibc to support this func
> > 
> > otherwise, you can avoid modifying the code with something like:
> > #ifndef HAVE_OBSTACK_PRINTF
> > # define obstack_printf(x, ...) ({ \
> >   char *s; \
> >   int n = asprintf(&s, __VA_ARGS__); \
> >   obstack_grow(&whereob, s, n); \
> >   n; \
> > })
> > #endif
> 
> 
> Shouldn't &whereob be x?  I unthinkingly just copied this but in two places
> in the  Use_asprointf++obstack_grow patch, so I should probably fix that.

Actually let's implement this in uclibc since all the pieces are there.  I've submitted a patch upstream.  It "works" but I'm not sure I have all my bases covered in terms of all the necessary ifdefs.  Its here:

   http://lists.uclibc.org/pipermail/uclibc/2013-June/047805.html
Comment 25 SpanKY gentoo-dev 2013-06-18 19:37:16 UTC
(In reply to Anthony Basile from comment #22)

probably.  i didn't actually compile/test any of the code i posted ... just typed it out into the field to show the direction w/actual code.
Comment 26 Alex Guzman 2014-05-02 05:58:43 UTC
Just fudging around with this at the moment and I noticed that one of the things it's currently puking on is not finding 'libintl_dgettext'. This is built in with glibc, but not uClibc. For uClibc, it's necessary to add -lintl to the flags.
Comment 27 Alex Guzman 2014-05-02 10:59:21 UTC
I actually managed to cobble together an ebuild that compiles and runs most of the utilities included, but eu-nm and eu-objdump both segfault. Looking at the core dump, it looks like the argparse library is responsible. I applied the same patches on a glibc machine, and it built + ran fine, too. Specifically, something about the way it handles color options (which nm and objdump use) causes the segfault.
Comment 28 Alex Guzman 2014-05-02 11:07:11 UTC
Created attachment 376194 [details, diff]
Check if libc provides dgettext

dgettext is called internally, and it's assumed to be provided by glibc. uClibc doesn't provide it, but gettext does. This checks if libc provides it, and failing that, it checks if gettext does and adjusts accordingly.
Comment 29 Alex Guzman 2014-05-02 11:10:26 UTC
Created attachment 376196 [details, diff]
Check if argp is provided by libc or is standalone (0.158)

There are some changes to Makefiles in 0.158 (eu-stack was added, among other things). The argp patch is updated accordingly.
Comment 30 Alex Guzman 2014-05-02 11:19:06 UTC
Created attachment 376198 [details, diff]
Fix ar.c to use the FUTIMES macro

Upstream added support for detection of futimes/utimes and uses a macro in strip.c to implement the switch. No need to reinvent the wheel and implement it ourselves, but seeing as there's no uclibc release with futimes, this is worth using.
Comment 31 Anthony Basile gentoo-dev 2014-05-02 12:09:26 UTC
(In reply to Daniel Guzman from comment #26)
> Just fudging around with this at the moment and I noticed that one of the
> things it's currently puking on is not finding 'libintl_dgettext'. This is
> built in with glibc, but not uClibc. For uClibc, it's necessary to add
> -lintl to the flags.

If you are using the stages from the mirror under /release, then you need to add -lintl.
Comment 32 Anthony Basile gentoo-dev 2015-04-21 13:47:19 UTC
*** Bug 533024 has been marked as a duplicate of this bug. ***
Comment 33 Anthony Basile gentoo-dev 2015-04-24 11:51:49 UTC
Someone else brought up the issue upstream.  I alerted them to this bug report:

 https://lists.fedorahosted.org/pipermail/elfutils-devel/2015-April/004754.html

I never dreamed upstream would have been interested in this.  Let's see where that discussion goes and we might push these upstream.
Comment 34 Anthony Basile gentoo-dev 2015-10-11 13:12:09 UTC
(In reply to Anthony Basile from comment #33)
> Someone else brought up the issue upstream.  I alerted them to this bug
> report:
> 
>  https://lists.fedorahosted.org/pipermail/elfutils-devel/2015-April/004754.
> html
> 
> I never dreamed upstream would have been interested in this.  Let's see
> where that discussion goes and we might push these upstream.

we need obstack_printf backported from the master branch to 0.9.33 branch (or a new release of uclibc, haha!).  Also, I'd like to have obstack turned on by default in the config file else people upgrading with an old config file will learn the hard way just how many gnu utilities, like those provided by coreutils, use obstack_printf().  i know uclibc doesn't support upgrading, but ...

after that, elfutils builds.  you do need to link against libintl if you're using gettext to provide it the way i do on the stages.
Comment 35 René Rhéaume 2017-01-10 02:08:01 UTC
Created attachment 459426 [details, diff]
elfutils-0.166-check-libc-dgettext.patch

Check if gettext is provided by libc or libintl, updated for 0.166
Comment 36 René Rhéaume 2017-01-10 02:12:54 UTC
Created attachment 459428 [details, diff]
elfutils-0.166-utimes-fallback.patch

Fall to utimes when futimes is not available, updated for version 0.166.

Upstream changed one the futimes calls with the POSIX 2008 futimens, making the updated patch smaller. Maybe we should switch the other call for consistency.
Comment 37 René Rhéaume 2017-01-10 02:17:02 UTC
Created attachment 459430 [details, diff]
elfutils-0.166-really-make-werror-conditional-to-build-werror.patch

The sed instruction in the ebuild does not seem to remove -Werror across makefiles.

So I basically adapted the patched called 
0005-really-make-werror-conditional-to-build-werror.patch I took from uclibc buildroot
Comment 38 René Rhéaume 2017-01-10 02:25:33 UTC
Created attachment 459432 [details, diff]
elfutils-0.166-asprintf-insteadof-obstack_printf.patch

This is a patch I made myself. It replaces obstack_printf usage, that is not provided by legacy uclibc, with asprintf, which is.

I really need this to be compatible with *legacy uclibc 0.9.33.2* so that I can build fix-gnustack, in order to remove the pesky GNU_STACK mark on my uclibc-ng binaries and complete my migration to uclibc-ng.

This patch also needs a careful review before sending it upstream.
Comment 39 René Rhéaume 2017-01-10 02:36:17 UTC
Created attachment 459434 [details, diff]
elfutils-0.166.ebuild.patch
Comment 40 René Rhéaume 2017-01-10 02:47:46 UTC
(In reply to René Rhéaume from comment #39)
> Created attachment 459434 [details, diff] [details, diff]
> elfutils-0.166.ebuild.patch

You may not be able to use the ebuild patch as is, because my last emerge --sync dates back from last October and I will sync again after I migrated to uclibc-ng.

All code patches provided by Alex Guzman for version 0.158 should be considered obsolete, because version 0.158 is no longer in the tree and my patches superseded his (except for argp which has been fixed upstream).

However, I used the "Fall back on mempcpy if __mempcpy is not available" and  "Check if DL_CALL_FCT is available and disable if it is not" patches from Anthony Basile in this bug report. His argp and mtrace patches were made obsolete by upstream and the utimes patch has been updated.
Comment 41 Anthony Basile gentoo-dev 2017-01-10 09:07:12 UTC
(In reply to René Rhéaume from comment #40)
> (In reply to René Rhéaume from comment #39)
> > Created attachment 459434 [details, diff] [details, diff] [details, diff]
> > elfutils-0.166.ebuild.patch
> 
> You may not be able to use the ebuild patch as is, because my last emerge
> --sync dates back from last October and I will sync again after I migrated
> to uclibc-ng.
> 
> All code patches provided by Alex Guzman for version 0.158 should be
> considered obsolete, because version 0.158 is no longer in the tree and my
> patches superseded his (except for argp which has been fixed upstream).
> 
> However, I used the "Fall back on mempcpy if __mempcpy is not available" and
> "Check if DL_CALL_FCT is available and disable if it is not" patches from
> Anthony Basile in this bug report. His argp and mtrace patches were made
> obsolete by upstream and the utimes patch has been updated.

i haven't returned to this, but last time i checked you didn't need all those patches.
Comment 42 Arusekk 2020-04-02 10:58:47 UTC
I managed to install and successfully use it without patches on latest version (elfutils-0.178).

I only added an environment with LDFLAGS="-lintl -lobstack" to package.env, and additionally installed sys-libs/argp-standalone and sys-libs/obstack-standalone before emerging.
I hope this helps the packaging effort :)
Comment 43 David Seifert gentoo-dev 2022-01-02 10:24:48 UTC
uclibc support in Gentoo has been removed.