如何给gcc编译设置默认参数??
如题,比如我想这么样加CFLAGS=-march=pentium3 -pipe -O3 -formit-frame-pointer -fforce-addr -falign-functions=4 -fprefetch-loop-arrays
可是这在加在那里呢才可以使gcc编译都默认使用这个参数呢??/
谢谢!!!!!!!!!! makefile or command line. :mrgreen: 用添加变量的形式……
在/etc/bashrc或者~/.bashrc文件里面添加
export CFLAGS=-march=pentium3 -pipe -O3 -formit-frame-pointer -fforce-addr -falign-functions=4 -fprefetch-loop-arrays 谢谢,2位!
不过说实话,好象修改makefile是最好的啊!
还有一个问题,就是怎么修改rpm的编译参数,我是说改它默认的不是那个spec文件。 一个例子,针对gcc 296的,gcc 3.2可以做类似修改:
For CPU i686 or PentiumPro, Pentium II, Pentium III, and Athlon
Edit the /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs file, scroll down a ways...
You'll see a section like the following:
*cpp_cpu_default:
-D__tune_i386__
*cpp_cpu:
-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__
%{march=i386:%{!mcpu*:-D__tune_i386__ }}%{march=i486:-D__i486 -D__i486__
%{!mcpu*:-D__tune_i486__ }}%{march=pentium|march=i586:-D__pentium -D__pentium__
%{!mcpu*:-D__tune_pentium__ }}%{march=pentiumpro|march=i686:-D__pentiumpro -
D__pentiumpro__ %{!mcpu*:-D__tune_pentiumpro__ }}%{march=k6:-D__k6 -D__k6__
%{!mcpu*:-D__tune_k6__ }}%{march=athlon:-D__athlon -D__athlon__ %{!mcpu*:-
D__tune_athlon__ }}%{m386|mcpu=i386:-D__tune_i386__ }%{m486|mcpu=i486:-
D__tune_i486__ }%{mpentium|mcpu=pentium|mcpu=i586:-
D__tune_pentium__ }%{mpentiumpro|mcpu=pentiumpro|mcpu=i686:-
D__tune_pentiumpro__ }%{mcpu=k6:-D__tune_k6__ }%{mcpu=athlon:-
D__tune_athlon__ }%{!march*:%{!mcpu*:%{!m386:%{!m486:%{!mpentium*:%(cpp_cpu_defa
ult)}}}}}
*cc1_cpu:
%{!mcpu*: %{m386:-mcpu=i386} %{m486:-mcpu=i486} %{mpentium:-mcpu=pentium}
%{mpentiumpro:-mcpu=pentiumpro}}
Change it for the following:
*cpp_cpu_default:
-D__tune_i686__
*cpp_cpu:
-Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__
%{march=i386:%{!mcpu*:-D__tune_i386__ }}%{march=i486:-D__i486 -D__i486__
%{!mcpu*:-D__tune_i486__ }}%{march=pentium|march=i586:-D__pentium -D__pentium__
%{!mcpu*:-D__tune_pentium__ }}%{march=pentiumpro|march=i686:-D__pentiumpro -
D__pentiumpro__ %{!mcpu*:-D__tune_pentiumpro__ }}%{march=k6:-D__k6 -D__k6__
%{!mcpu*:-D__tune_k6__ }}%{march=athlon:-D__athlon -D__athlon__ %{!mcpu*:-
D__tune_athlon__ }}%{m386|mcpu=i386:-D__tune_i386__ }%{m486|mcpu=i486:-
D__tune_i486__ }%{mpentium|mcpu=pentium|mcpu=i586:-
D__tune_pentium__ }%{mpentiumpro|mcpu=pentiumpro|mcpu=i686:-
D__tune_pentiumpro__ }%{mcpu=k6:-D__tune_k6__ }%{mcpu=athlon:-
D__tune_athlon__ }%{!march*:%{!mcpu*:%{!m386:%{!m486:%{!mpentium*:%(cpp_cpu_defa
ult)}}}}}
*cc1_cpu:
%{!mcpu*: -O3 –march=i686 -funroll-loops -fomit-frame-pointer %{m386:-mcpu=i386}
%{m486:-mcpu=i486} %{mpentium:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}} 太好了,兄弟你给了例子,真是太好了!谢谢!! 未免太累了吧?我是修改/usr/lib/rpm/rpmrc文件,虽然优化力度不大,好歹也算根据机器架构优化过了。
页:
[1]