public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Proposal for flag-o-matic.eclass (append-ldflags)
@ 2008-12-08 16:33 Jeremy Olexa
  2008-12-09 19:14 ` Donnie Berkholz
  2008-12-14 21:39 ` [gentoo-dev] " Jeremy Olexa
  0 siblings, 2 replies; 6+ messages in thread
From: Jeremy Olexa @ 2008-12-08 16:33 UTC (permalink / raw
  To: gentoo-dev

Hello,
I am seeking a positive code review on the following change to
flag-o-matic.eclass, diff is below (reasons are below that):

%% cvs diff
Index: flag-o-matic.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/flag-o-matic.eclass,v
retrieving revision 1.126
diff -u -r1.126 flag-o-matic.eclass
--- flag-o-matic.eclass 3 Nov 2008 05:52:39 -0000       1.126
+++ flag-o-matic.eclass 25 Nov 2008 18:36:04 -0000
@@ -417,7 +417,8 @@

       x=""
       for x in "$@" ; do
-               test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}"
+               test-flag-${comp} "${x}" && flags="${flags}${flags:+ }${x}" || \
+                       ewarn "removing ${x} because ${comp} rejected it"
       done

       echo "${flags}"
@@ -656,7 +657,7 @@
                       ewarn "Appending a library link instruction
(${flag}); libraries to link to should not be passed through LDFLAGS"
       done

-       export LDFLAGS="${LDFLAGS} $*"
+       export LDFLAGS="${LDFLAGS} $(test-flags "$@")"
       return 0
 }

Reason:
We hit this little gem in Gentoo Prefix when some ebuilds started
using flags that non-GNU linkers didn't accept and actually aborted
on. For example, the darwin ld does not accept --no-as-needed. So, the
initial work-around was to check to see if we had a GNU ld, and only
apply if so. (aside, further investigation revealed that GNU and
darwin ld are actually pretty non-clever in this regard. For example,
the hp-ux linker will just ignore non-valid flags) But this is not
very friendly to the lack of Gentoo Prefix developer availability. ;)

A convienient side effect of the above patch is that it protects
Gentoo users from typos in ebuilds. For example, "append-ldflags
--foo" will cause compilation to abort, but with the above patch, a
ewarn will be issued instead and compilation will continue. Besides
typos, if the GNU ld ever changes in some non-compatible way, there
will be less breakage.

There will be claims that additional checking to the flags should not
be added to Gentoo Linux because it is redundant (Gentoo only uses GNU
ld). However, time test-flags "$@" only takes 0m0.017s on my host. I
guess this number could be larger on less modern hosts..I don't know.

Comments? Good, bad, or otherwise? The Gentoo Prefix team always aims
to have as minimal diffs as possible from the gentoo-x86 tree, hence
the motivation for this request to review and inclusion into the
gentoo-x86 tree.

Thanks,
Jeremy



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-29  2:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-08 16:33 [gentoo-dev] Proposal for flag-o-matic.eclass (append-ldflags) Jeremy Olexa
2008-12-09 19:14 ` Donnie Berkholz
2009-08-28 20:04   ` Mike Frysinger
2008-12-14 21:39 ` [gentoo-dev] " Jeremy Olexa
2009-08-28 20:08   ` Mike Frysinger
2009-08-29  7:23     ` Fabian Groffen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox