Binutils and gcc with LTO

I have binutils-2.25.1 installed in / usr / local / binutils -2.25.1 configured with

../configure --prefix=/usr/local/binutils-2.25.1 --enable-plugins --enable-gold --disable-werror 

And I want to create an RPM - gcc package with LTO support that uses the ld linker from / usr / local / binutils -2.25.1.

I'm trying to:

 Summary: The GNU Compiler Collection Name: gcc-custom Version: 4.9.3 %define full_name gcc-%{version} %define binutils_path /usr/local/binutils-2.25.1 Release: 0 ... Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig %description %prep %setup -q -a0 -n %{full_name} %build AR=%{binutils_path}/bin/ar NM=%{binutils_path}/bin/nm RANLIB=@ %{binutils_path}/bin/ranlib ./configure \ --prefix=/usr/local/%{full_name} \ --disable-multilib \ --enable-languages=c,c++ \ --enable-lto \ --enable-linker-build-id \ --enable-plugin \ --with-ld=%{binutils_path}/bin/ld \ --with-plugin-ld=%{binutils_path}/bin/ld \ --with-as=%{binutils_path}/bin/as make %install rm -rf $RPM_BUILD_ROOT make install DESTDIR=$RPM_BUILD_ROOT %post -p /sbin/ldconfig %postun -p /sbin/ldconfig %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) /usr/local/%{full_name} %changelog 

After installing this package, I try:

 /usr/local/gcc-4.9.3/bin/g++ -flto -fno-fat-lto-objects -fuse-linker-plugin test.cpp -o test 

And we get:

 cc1plus: error: -fno-fat-lto-objects are supported only with linker plugin 

But ld from / usr / local / binutils -2.25.1 supports the plugin

 /usr/local/binutils-2.25.1/bin/ld --help | grep plugin -plugin PLUGIN Load named plugin -plugin-opt ARG Send arg to last-loaded plugin 

In addition, gcc- {ar, nm, ranlib} from / usr / local / gcc -4.9.3 have -plugin support

 /usr/local/gcc-4.9.3/bin/gcc-ar --help | grep plugin --plugin <p> - load the specified plugin 

You need help guys

UPD I was able to solve the problem . Just replaced

 ./configure ... 

with

 mkdir build && cd build && ../configure ... 

and also added

 cd build 

to% install begin

gcc-4.9.3 / lto-plugin / congifure script is not written correctly !!!

+5
source share

Source: https://habr.com/ru/post/1232226/


All Articles