public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] flag-o-matic eclass strip-unsupported-flags function
@ 2003-08-05 15:59 Douglas Russell
  2003-08-05 20:30 ` Martin Schlemmer
  0 siblings, 1 reply; 2+ messages in thread
From: Douglas Russell @ 2003-08-05 15:59 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: clearsigned data --]
[-- Type: Text/Plain, Size: 1279 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

While fixing a bug it came to my attention that when an ebuild may wish to 
strip off CFLAGS known not to work, it will have to either strip off 
unnecessarily large amounts of optimisations or run the risk of being 
incompatible with different versions of gcc.

For example, if removing -finline-functions from -O3, the optimal result with 
gcc 3 or greater is -O2 -frename-functions. However, gcc versions less than 3 
have no -frename-functions and will hence fail. Either dropping all the way 
down to -O2 unnecessarily on some systems or some conditional statements are 
required. The latter is obviously desirable to maximise optimisations. 

Rather than have conditional statements for every possible connotation of gcc 
in the ebuild however, I have written this addition to the flag-o-matic 
eclass which basically queries gcc for each of the used optimisations and 
strips the unsupported ones.

Attached is a patch for the flag-o-matic eclass. Any feedback or suggestions 
would be appreciated.

Puggy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/L9RwXYnvgFdTojMRAuruAKCfyBswJqQB50OTVRkLlWH1BMl5ugCfRe8W
kmUf7S1UuOTJ9yFkqCoMydg=
=66Lv
-----END PGP SIGNATURE-----

[-- Attachment #2: flag-o-matic.eclass.patch --]
[-- Type: text/x-diff, Size: 973 bytes --]

--- flag-o-matic.eclass	2003-08-05 16:57:27.000000000 +0100
+++ flag-o-matic.eclass.new	2003-08-05 16:53:40.000000000 +0100
@@ -33,7 +33,9 @@
 # Sets mcpu to v8 and uses the original value
 # as mtune if none specified.
 #
-
+#### strip-unsupported-flags ####
+# Strip C[XX]FLAGS of any flags not supported by
+# installed version of gcc
 
 # C[XX]FLAGS that we allow in strip-flags
 ALLOWED_FLAGS="-O -O1 -O2 -mcpu -march -mtune -fstack-protector -pipe -g"
@@ -187,3 +189,24 @@
 		done
 	fi
 }
+
+test_flag () {
+        if gcc -S -xc $1 -o /dev/null /dev/null >/dev/null 2>&1; then
+                echo "$1"
+        fi
+}
+
+strip-unsupported-flags() {
+        for x in ${CFLAGS}
+        do
+                NEW_CFLAGS=${NEW_CFLAGS}" ""`test_flag ${x}`"
+        done
+
+        for x in ${CXXFLAGS}
+        do
+                NEW_CXXFLAGS=${NEW_CXXFLAGS}" ""`test_flag ${x}`"
+        done
+
+        CFLAGS="${NEW_CFLAGS}"
+        CXXFLAGS="${NEW_CXXFLAGS}"
+}


[-- Attachment #3: Type: text/plain, Size: 37 bytes --]

--
gentoo-dev@gentoo.org mailing list

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

* Re: [gentoo-dev] flag-o-matic eclass strip-unsupported-flags function
  2003-08-05 15:59 [gentoo-dev] flag-o-matic eclass strip-unsupported-flags function Douglas Russell
@ 2003-08-05 20:30 ` Martin Schlemmer
  0 siblings, 0 replies; 2+ messages in thread
From: Martin Schlemmer @ 2003-08-05 20:30 UTC (permalink / raw
  To: Douglas Russell; +Cc: Gentoo-Dev

[-- Attachment #1: Type: text/plain, Size: 1367 bytes --]

On Tue, 2003-08-05 at 17:59, Douglas Russell wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> While fixing a bug it came to my attention that when an ebuild may wish to 
> strip off CFLAGS known not to work, it will have to either strip off 
> unnecessarily large amounts of optimisations or run the risk of being 
> incompatible with different versions of gcc.
> 
> For example, if removing -finline-functions from -O3, the optimal result with 
> gcc 3 or greater is -O2 -frename-functions. However, gcc versions less than 3 
> have no -frename-functions and will hence fail. Either dropping all the way 
> down to -O2 unnecessarily on some systems or some conditional statements are 
> required. The latter is obviously desirable to maximise optimisations. 
> 
> Rather than have conditional statements for every possible connotation of gcc 
> in the ebuild however, I have written this addition to the flag-o-matic 
> eclass which basically queries gcc for each of the used optimisations and 
> strips the unsupported ones.
> 
> Attached is a patch for the flag-o-matic eclass. Any feedback or suggestions 
> would be appreciated.
> 

What about:

  CFLAGS="-O3 -fno-inline-functions"

rather ? =)


Cheers,

-- 

Martin Schlemmer
Gentoo Linux Developer, Desktop/System Team Developer
Cape Town, South Africa



[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2003-08-05 20:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-08-05 15:59 [gentoo-dev] flag-o-matic eclass strip-unsupported-flags function Douglas Russell
2003-08-05 20:30 ` Martin Schlemmer

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