View previous topic :: View next topic |
Author |
Message |
costel78 Guru
Joined: 20 Apr 2007 Posts: 402
|
Posted: Thu Nov 08, 2018 11:55 am Post subject: |
|
|
Some unusual, but efficient fixes:
Code: | --- notify-python-0.1.1-r3.ebuild.orig 2017-04-20 23:44:03.000000000 +0300
+++ notify-python-0.1.1-r3.ebuild 2018-11-07 20:28:42.000000000 +0200
@@ -33,6 +33,7 @@
src_configure() {
python_foreach_impl autotools-utils_src_configure
+ cp -rf /usr/bin/libtool "${WORKDIR}/${P}-python2_7/"
}
src_compile() { |
Code: | --- pulseaudio-12.2.ebuild.orig 2018-07-27 15:09:21.000000000 +0300
+++ pulseaudio-12.2.ebuild 2018-11-08 13:43:57.746017277 +0200
@@ -221,6 +221,8 @@
ECONF_SOURCE=${S} \
econf "${myconf[@]}"
+
+ cp -rf /usr/bin/libtool "${WORKDIR}/${P}-${MULTILIB_ABI_FLAG}.${ABI}/"
}
multilib_src_compile() { |
Working and tested on nomultilib profile. I do not have a multilib gentoo installation.
I also played, for a while now, with -ffast-math and -funsafe-math-optimizations and it is working well. The speed improvements are visible in multimedia apps, browsers, thunderbird.
Databases like sqlite or postgresql does not like fast-math due to time precision functions.
Troubles (and fixes)
Code: | --- opus-1.3_rc2.ebuild 2018-09-24 19:39:25.000000000 +0300
+++ opus-1.3.ebuild 2018-09-25 16:34:52.000000000 +0300
@@ -40,7 +40,7 @@
$(use_enable static-libs static)
)
for i in ${INTRINSIC_FLAGS} ; do
- use ${i} && myeconfargs+=( --enable-intrinsics )
+ use ${i} && myeconfargs+=( --enable-intrinsics --enable-float-approx )
done
ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
} |
For firefox and thunderbird embedded libopus:
Code: | --- a/media/libopus/celt/arch.h.orig 2018-11-07 16:03:50.631623766 +0200
+++ b/media/libopus/celt/arch.h 2018-11-07 16:03:59.960777735 +0200
@@ -34,6 +34,8 @@
#ifndef ARCH_H
#define ARCH_H
+#define FLOAT_APPROX 1
+
#include "opus_types.h"
#include "opus_defines.h"
|
They still bother me: dev-db/mysql-connector-c and media-libs/mesa. Mesa was ok before 17.3 or 17.2, I don't recall exactly.
If anybody have a solution, please share. _________________ Sorry for my English. I'm still learning this language. |
|
Back to top |
|
|
Tom_ Guru
Joined: 20 May 2004 Posts: 444 Location: France
|
Posted: Sun Jan 19, 2020 6:26 pm Post subject: |
|
|
I've been recently looking into lto. Even though I understand how it works, I can't figure out how to enable it properly.
As I have gcc-9.2 (compiled the lto useflags) installed, I understand that I only have to add -flto or -flto=4 (Intel 2500k with 4 cores) to CFLAGS and CXXFLAGS.
Code: | CFLAGS="-march=native -O2 -pipe -flto=4"
CXXFLAGS="${CFLAGS}"
|
What about LDFLAGS? I read about adding ${CFLAGS} to LDFLAGS. Why would i need to do that ? Is adding -flto to LDFLAGS enough ?
At the moment, what's the best linker ? BFD or Gold ? |
|
Back to top |
|
|
hedmo Veteran
Joined: 29 Aug 2009 Posts: 1305 Location: sweden
|
Posted: Sun Jan 19, 2020 9:05 pm Post subject: |
|
|
Tom_ wrote: | I've been recently looking into lto. Even though I understand how it works, I can't figure out how to enable it properly.
As I have gcc-9.2 (compiled the lto useflags) installed, I understand that I only have to add -flto or -flto=4 (Intel 2500k with 4 cores) to CFLAGS and CXXFLAGS.
Code: | CFLAGS="-march=native -O2 -pipe -flto=4"
CXXFLAGS="${CFLAGS}"
|
What about LDFLAGS? I read about adding ${CFLAGS} to LDFLAGS. Why would i need to do that ? Is adding -flto to LDFLAGS enough ?
At the moment, what's the best linker ? BFD or Gold ? |
Tom_
i just started to use LTO via lto-overlay. is this what you are talking about? i have some hard time understanding it to but as i have understand you dont need to set
-flto.id in your make.conf. lto-overlay is doing it for you.the only thing you have to do is to set what is on the guide at the git hub.
for me i have COMMON_FLAGS=
and did just set : -O3 ${CFLAGS} and -falign-functions=32 with my old stuff
regards hedmo |
|
Back to top |
|
|
costel78 Guru
Joined: 20 Apr 2007 Posts: 402
|
Posted: Mon Jan 20, 2020 1:23 pm Post subject: |
|
|
Yes, gentoo-lto is easier to use, but I don't use it, yet.
1. lto useflag on sys-devel/gcc is not mandatory. It does not activate or deactivate support for lto. gcc is able to compile with lto with or without this flag. Using it, you will compile gcc itself with lto - time and RAM consuming.
2. appending CFLAGS to LDFLAGS is might seems weird, but lto is Link Time Optimization - so the *real* optimization is done during linking so *all* optimizations flags are required during linking. _________________ Sorry for my English. I'm still learning this language. |
|
Back to top |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2716
|
Posted: Mon Jan 20, 2020 2:38 pm Post subject: |
|
|
costel78 wrote: | 2. appending CFLAGS to LDFLAGS is might seems weird, but lto is Link Time Optimization - so the *real* optimization is done during linking so *all* optimizations flags are required during linking. | Actually the optimizations used during compile-time are stored in the object files and remembered for use during link time, this allows to have different optimizations per source files if needed. You're not going to get something with no optimizations at all if you didn't have -O2 in your LDFLAGS.
I've tested it, the resulting binary is identical whether you have optimizations in LDFLAGS or not when using LTO (actually they are ignored, I can pass whatever random compiler optimizations during link-time and the resulting binary is still the same, and I'm not aware of any special cases where that may be different)
Edit: It's something GentooLTO should revert already, I believe that part is based on pretty ancient information. I've mentioned it to Shane a long time ago but he wasn't convinced, probably left it just to be safe. |
|
Back to top |
|
|
costel78 Guru
Joined: 20 Apr 2007 Posts: 402
|
Posted: Tue Jan 21, 2020 9:48 am Post subject: |
|
|
It is not first time when I hear that, first time two or three years ago, but I don't know for 100% sure who is correct. When I removed CFLAGS from LDFLAGS, some packages (under 30, if I remember correctly) grows in size significantly.
In documentation they do not pass -O2/-O3 during compile, just at linking. Here -O2 is passed at both stages.
Code: | gcc -c -O2 -flto foo.c
gcc -c -O2 -flto bar.c
gcc -o myprog -flto -O2 foo.o bar.o
| Here, -O3 it is not passed during compile of foo.c or bar.cc, but it is present during final link.
Code: | gcc -c -flto foo.c
g++ -c -flto bar.cc
gfortran -c -flto baz.f90
g++ -o myprog -flto -O3 foo.o bar.o baz.o -lgfortran |
I think it worth a question on gcc mailing list about correct behavior. _________________ Sorry for my English. I'm still learning this language. |
|
Back to top |
|
|
Ionen Developer
Joined: 06 Dec 2018 Posts: 2716
|
Posted: Tue Jan 21, 2020 8:34 pm Post subject: |
|
|
If I do something like Code: | gcc -flto -c test.c
gcc -flto -c main.c
gcc -flto -O0 test.o main.o -o out1
gcc -flto -O3 test.o main.o -o out2
gcc test.o main.o -o out3 | Then out1,2,3, are all identical (checked with diff)
If I do Code: | gcc -flto -O3 -c test.c
gcc -flto -O3 -c main.c
gcc -flto -O0 test.o main.o -o out4
gcc -flto -O3 test.o main.o -o out5
gcc test.o main.o -o out6 | out4,5,6 are identical to each others but different than out1,2,3, and also a bit smaller in size likely because -O3 was actually used and inlined my small function from test.c used in main.c. Am I testing this wrong? If command line compiler flags were used during link-time shouldn't out2 have done the same?
The flags are also of course in the object file, so the information is certainly there (this is not stored if -flto is not specified, clearly added because it needs/use it): Code: | $ strings test.o | grep O3
'-fno-openmp' '-fno-openacc' '-fPIC' '-mtune=generic' '-march=x86-64' '-O3' '-flto' |
When it comes to packages it's hard to say how they handle flags/compilation, they may be plain misusing them -- and/or maybe related to ebuilds (some packages lazily use CFLAGS+LDFLAGS during compilation and not just linking, and maybe CFLAGS no longer had -flto -- could also be the order like -fflag -fno-flag -fflag from LDFLAGS coming last). May need more digging into affected packages, rather than LTO this may be a missing optimizations issue on some parts and LDFLAGS is serving as a workaround.
Edit: There could be a special case where it's used and isn't replicated by my simple test (older compilers maybe? this is gcc9), but be good to know what is this case (if it exists and still matters). Otherwise (to me) it just feels wrong to globally put flags in a variable where they don't belong. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|