Hi There, I've recently switched my LDFLAGS, which previously was "-Wl,--as-needed" but is now LDFLAGS=-Wl,-O1,--hash-style=gnu,--sort-common,--as-needed". Some packages which use the filter-ldflags function from the flag-o-matic eclass to filter "--as-needed" now break, because this flag is not filtered when combined with other linker flags in a comma-separated list. When LDFLAGS is set to a single -Wl value, or when each linker flag is space-separated (i.e. LDFLAGS="-Wl,--as-needed -Wl,-O1"), the function works as expected. I have attached a test ebuild which demonstrates the problem. To use, simply set LDFLAGS to a list of flags, such as: LDFLAGS=-Wl,-O1,--as-needed" # simple case with one extra flag The test ebuild will not filter "--as-needed" when LDFLAGS is set as above. As far as I can tell from the manpage of gcc, this appears to be a valid way of setting multiple linker flags, as gcc will split the flags at the commas when passing them to the linker. Steps to re-produce: 1. Download the test ebuild 2. Set some funky LDFLAGS which contain --as-needed in addition to others. 3. Run the src_compile function of the test ebuild: ebuild test-flagomatic.ebuild digest compile Results: >>> Creating Manifest for /usr/local/overlays/misc/dev-libs/test-flagomatic * checking ebuild checksums ;-) ... [ ok ] * checking auxfile checksums ;-) ... [ ok ] * checking miscfile checksums ;-) ... [ ok ] >>> Unpacking source... >>> Source unpacked. >>> Compiling source in /var/tmp/portage/dev-libs/test-flagomatic-0.1/work ... * LDFLAGS before: -Wl,-O1,--hash-style=gnu,--sort-common,--as-needed * LDFLAGS after: -Wl,-O1,--hash-style=gnu,--sort-common,--as-needed >>> Source compiled. Expected results: The --as-needed flag should be filtered, the "LDFLAGS after..." line should not display this flag. Please let me know if this is incorrect usage of the filter-ldflags function and what the correct usage should be in this case. I will then file bugs against the packages which I have encountered that break with a list of LDFLAGS set as above. Thanks and regards, Joshua Rich
Created attachment 158951 [details] test ebuild Run the src_compile function of this ebuild with a comma-separated list of linker flags as LDFLAGS to see the issue: 1. export LDFLAGS=-Wl,-O1,--as-needed" 2. ebuild test-flagomatic-0.1.ebuild digest compile
this just gets to be too messy just use clear flags and keep them as units: -Wl,-O1 -Wl,--as-needed -Wl,------
(In reply to comment #2) > this just gets to be too messy > > just use clear flags and keep them as units: > -Wl,-O1 -Wl,--as-needed -Wl,------ > Ok, no worries, thanks for the reply. Regards, Joshua Rich