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
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.
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.
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.
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.
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.
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.
Created attachment 349608 [details, diff] Use argp-standalone I forgot to add the tests in the previous patch.
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 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 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 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 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
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
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.
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.
Created attachment 350482 [details, diff] Check if mtrace() is available and disable it if it is not.
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.
Created attachment 350486 [details, diff] Check if DL_CALL_FCT is available and disable if it is not
(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 ...
Hmm ... rereading the patches I noticed I used AC_CHECK_FUNCS_ONCE in 1 and 3 where AC_CHECK_FUNC would have been sufficient.
Okay for the records, I just tested on a glibc system and everything looks good. Built fine and some random runs looked fine too.
(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.
(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 on attachment 350480 [details] Use asprintf+obstack_grow if obstack_printf is not available uClibc now supports obstack_printf. See: http://git.uclibc.org/uClibc/commit/?id=f143f920694cec922ed2ac4082aab223acc413df http://git.uclibc.org/uClibc/commit/?id=10d12e77d5cdffd064719356a87f839225916a4a http://git.uclibc.org/uClibc/commit/?id=975bca165c3e10e74c05c0384fd58f45a7025a3c
(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.
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.
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.
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.
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.
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.
(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.
*** Bug 533024 has been marked as a duplicate of this bug. ***
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.
(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.
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
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.
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
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.
Created attachment 459434 [details, diff] elfutils-0.166.ebuild.patch
(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.
(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.
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 :)
uclibc support in Gentoo has been removed.