LinuxSir.Org  
| 网站首页 | 论坛帮助 |

欢迎来到LinuxSir.Org!
您还未登录,请登录后查看论坛,或者点击论坛上方的注册链接注册新账号。


发表新主题 回复
精华主题  
主题工具
旧 04-11-15, 19:35 第 16 帖
Fleta
 
Fleta 的头像
 
 
注册会员  
  注册日期: Sep 2003
  帖子: 1,310
  精华: 2
 

我用LDFLAGS="-Wl,-O1"编译了mozilla-firefox-1.0-r2,没问题。







__________________
You naughty little...little...creep, I'm gonna kick your ass!
2.6.14-nitro2
  Fleta 当前离线   回复时引用此帖
旧 04-11-15, 20:26 第 17 帖
完美废人
 
 
 
注册会员  
  注册日期: Oct 2004
  帖子: 72
  精华: 0
 

LDFLAGS="-Wl,-O1"

这里 -Wl 是一个 gcc 的参数,表示“后面的参数传递给 linker”,所以应该是在 CFLAGS 而不是 LDFLAGS 里面。我觉得值得注意的几个东西是
CFLAGS 的 -DNDEBUG (会减少一些编译的代码,譬如 assert)
LDFLAGS 的 -S(--strip-debug,不知道和 portage 的 strip 是不是重复了)
至于 -O 标志,不论 GCC 还是 LD 都表示会极大增加编译时间和消耗内存,所以根据 80/20 原则,我用的是 CFLAGS 的 -O ,LDFLAGS 里面没有:)

所有这些编译符号,都可以在 gcc(1) 和 ld(1) 里面找到;-DNDEBUG 宏是个 ANSI 标准,学过 C 编程的应该知道。







__________________
十里秦淮灯似火,一街评事人如潮
Do RH/FC, No Gain: JUST ENJOY IT
  完美废人 当前离线   回复时引用此帖
旧 04-11-16, 00:17 第 18 帖
MACHINE
 
MACHINE 的头像
 
 
注册会员  
  注册日期: Nov 2003
  我的住址: 中国 / 加拿大 / 澳大利亚
  帖子: 221
  精华: 1
 

引用:
这里 -Wl 是一个 gcc 的参数,表示“后面的参数传递给 linker”,所以应该是在 CFLAGS 而不是 LDFLAGS 里面。
This is wrong.







__________________
Simple life, Simple linux, Archlinux.
  MACHINE 当前离线   回复时引用此帖
旧 04-11-16, 00:38 第 19 帖
完美废人
 
 
 
注册会员  
  注册日期: Oct 2004
  帖子: 72
  精华: 0
 

Oh, really? I got this from gcc(1) manual page. So if you say it's wrong, prove it.
  完美废人 当前离线   回复时引用此帖
旧 04-11-16, 01:23 第 20 帖
MACHINE
 
MACHINE 的头像
 
 
注册会员  
  注册日期: Nov 2003
  我的住址: 中国 / 加拿大 / 澳大利亚
  帖子: 221
  精华: 1
 

LDFLAGS is the role for sending linker flags to gcc.
And, if you add "Wl,anything_fills_here" to gcc, gcc will compille anything with that flag and hence MIGHT produce incorrect code if the source file is C program instead of C++ or without any library it links to.

此帖于 04-11-16 03:07 被 MACHINE 编辑.
  MACHINE 当前离线   回复时引用此帖
旧 04-11-16, 10:07 第 21 帖
完美废人
 
 
 
注册会员  
  注册日期: Oct 2004
  帖子: 72
  精华: 0
 

>> -Wl,option
Pass option as an option to the linker. If option contains commas,
it is split into multiple options at the commas.

This is what I've got. I understand this as, when calling
代码:
gcc -Wl,-O1 something.c
here -O1 is passed to ld, not gcc itself. If you still disagree with one sentence, I won't keep on going.

LDFLAGS and CFLAGS only take there effection when they've been written in Makefiles. Bare gcc itself understands neither of them. Simply try this:

代码:
01:05 PM tmp $ cat 1.c #include <stdio.h> int main() { #ifdef ABC printf("ABC defined!\n"); #endif }
Compile it for 3 times:
1: gcc CFLAGS="-DABC" 1.c
2: gcc LDFLAGS="-DABC" 1.c
3: gcc -Wl,-DABC 1.c

And run what ever you got for each time.
  完美废人 当前离线   回复时引用此帖
旧 04-11-16, 14:01 第 22 帖
lilyerr
 
 
 
注册会员  
  注册日期: Oct 2004
  帖子: 525
  精华: 0
 

我在/etc/make.conf加了LDFLAGS,为什么emerge --info看不到?







__________________
中国3G开发论坛[url]http://www.xgdev.net/bbs[/url]
  lilyerr 当前离线   回复时引用此帖
旧 04-11-16, 14:34 第 23 帖
MACHINE
 
MACHINE 的头像
 
 
注册会员  
  注册日期: Nov 2003
  我的住址: 中国 / 加拿大 / 澳大利亚
  帖子: 221
  精华: 1
 

I said "... MIGHT produce ...".
  MACHINE 当前离线   回复时引用此帖
旧 04-11-17, 18:34 第 24 帖
orphen
 
orphen 的头像
 
 
注册会员  
  注册日期: Nov 2002
  我的住址: 东北 沈阳
  帖子: 2,189
  精华: 0
 

PHP 代码:
LDFLAGS="-Wl,-O1 -Wl,-z -Wl,--enable-new-dtags -Wl,--sort-common -s" 
emerge prozilla实验成功
值得注意的是
checking for gcc... gcc
checking whether the C compiler (gcc -march=athlon-tbird -O3 -mmmx -m3dnow -pipe -fforce-addr -fomit-frame-pointer -funroll-loops -falign-functions=4 -maccumulate-outgoing-args -ftracer -Wl,-O1 -Wl,-z -Wl,--enable-new-dtags -Wl,--sort-common -s) works... yes
checking whether the C compiler (gcc -march=athlon-tbird -O3 -mmmx -m3dnow -pipe -fforce-addr -fomit-frame-pointer -funroll-loops -falign-functions=4 -maccumulate-outgoing-args -ftracer -Wl,-O1 -Wl,-z -Wl,--enable-new-dtags -Wl,--sort-common -s) is a cross-compiler... no
checking whether we are using GNU C... yes

gcc -DHAVE_CONFIG_H -I. -I.. -I/usr/include -march=athlon-tbird -O3 -mmmx -m3dnow -pipe -fforce-addr -fomit-frame-pointer -funroll-loops -falign-functions=4 -maccumulate-outgoing-args -ftracer -D_REENTRANT -Wall -DGLOBAL_CONF_FILE="\"/etc/prozilla.conf\"" -c connection.c

gcc -march=athlon-tbird -O3 -mmmx -m3dnow -pipe -fforce-addr -fomit-frame-pointer -funroll-loops -falign-functions=4 -maccumulate-outgoing-args -ftracer -D_REENTRANT -Wall -DGLOBAL_CONF_FILE="\"/etc/prozilla.conf\"" -Wl,-O1 -Wl,-z -Wl,--enable-new-dtags -Wl,--sort-common -s -o proz connect.o connection.o curses.o ftp.o ftp-retr.o ftpparse.o ftpsearch.o getopt.o http-retr.o http.o init.o logfile.o main.o misc.o netrc.o ping.o resume.o debug.o url.o -L/usr/lib -lncurses -lpthread







__________________
AMD Athlon64 3200+ (Venice)
ASUS nForce4 Ultra
VDATA DDR400 512MB X4
ST SATA2 160GB + ST SATA 160GB (RAID0)
Nvidia Geforce 6600 GT
ADSL 2Mbps

此帖于 04-11-17 18:36 被 orphen 编辑.
  orphen 当前离线   回复时引用此帖
旧 04-11-17, 18:36 第 25 帖
sunmoon1997
 
sunmoon1997 的头像
 
 
★☆版主★☆  
  注册日期: Mar 2004
  帖子: 1,744
  精华: 9
 

连接时才使用那个参数。。







__________________
sunmoon1997@localhost ~ $ emerge --info
Portage 2.1_rc1-r2 (default-linux/amd64/2006.0, gcc-4.0.3, glibc-2.4-r2, 2.6.16-gentoo-r6 x86_64)
=================================================================
System uname: 2.6.16-gentoo-r6 x86_64 AMD Athlon(tm) 64 Processor 3000+
Gentoo Base System version 1.12.0_pre19

Can you understand linux?
Can you foresee the future of linux?
  sunmoon1997 当前离线   回复时引用此帖
旧 04-11-17, 18:40 第 26 帖
orphen
 
orphen 的头像
 
 
注册会员  
  注册日期: Nov 2002
  我的住址: 东北 沈阳
  帖子: 2,189
  精华: 0
 

不知有什么好处?
PHP 代码:
-Wl,-O1 -Wl,--Wl,--enable-new-dtags -Wl,--sort-common -

PHP 代码:
-Wl,-O1 
相比,有什么不同
PS 如果添加这些“优化参数”有利无弊的话,为什么各种官方发型版没有使用,没有出现在Gentoo默认的make.conf中呢?
  orphen 当前离线   回复时引用此帖
旧 04-11-17, 19:33 第 27 帖
Fleta
 
Fleta 的头像
 
 
注册会员  
  注册日期: Sep 2003
  帖子: 1,310
  精华: 2
 

引用:
最初由 orphen 发表
PS 如果添加这些“优化参数”有利无弊的话,为什么各种官方发型版没有使用,没有出现在Gentoo默认的make.conf中呢? [/b]
可能因为这些“优化参数”的好处根本就不是很明显。
  Fleta 当前离线   回复时引用此帖
旧 04-11-17, 20:03 第 28 帖
完美废人
 
 
 
注册会员  
  注册日期: Oct 2004
  帖子: 72
  精华: 0
 

MACHINE:
I'm talking about where this option is taking effection, not talking about what effection it's taking on the final result, so your "might be" is being used somewhere off topic.

Sunmoon:
多谢老大支持:)
  完美废人 当前离线   回复时引用此帖
旧 04-11-17, 20:06 第 29 帖
完美废人
 
 
 
注册会员  
  注册日期: Oct 2004
  帖子: 72
  精华: 0
 

Fleta:
不会有利无弊——man page 里说了,会“显著增加链接时间“,呵呵。而且可能不是所有版本的 GCC 都支持——譬如某些平台某些版本等等。作为一个发行版,使用不保险的默认是会收获西红柿的。根据 80/20 原则,gentoo 官方自然不会把它加入默认 make.global。。。
  完美废人 当前离线   回复时引用此帖
旧 04-11-17, 20:34 第 30 帖
orphen
 
orphen 的头像
 
 
注册会员  
  注册日期: Nov 2002
  我的住址: 东北 沈阳
  帖子: 2,189
  精华: 0
 


那我这样的CPU,如下的make.conf是不是达到了最大优化呢?
哪位达人能指点一二
PHP 代码:
Shadow root # cat /etc/make.conf
# These settings were set by the catalyst build script that automatically builtthis stage
CFLAGS="-march=athlon-tbird -O3 -mmmx -m3dnow -pipe -fforce-addr -fomit-frame-pointer -funroll-loops -falign-functions=4 -maccumulate-outgoing-args -ftracer"
CHOST="i686-pc-linux-gnu"
USE="3dnow 3dnowex acpi acpi4linux artswrappersuid chroot cjk directfb \
     divx4linux extensions fbcon freetype glc glx gnutls mmx mmxext net nptl \
     nptlonly truetype-fonts unicode -apm -gnome -spell"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -s"
FETCHCOMMAND='/usr/bin/proz --no-getch --no-search ${URI} -P ${DISTDIR}'
GENTOO_MIRRORS="http://mirror.gentoo.gr.jp/ http://gentoo.gg3.net/ http://gentoo.llarian.net/ ftp://gentoo.llarian.net/pub/gentoo/"
#PORTDIR_OVERLAY="/usr/local/portage /usr/local/glc"
VIDEO_CARDS="radeon"
ALSA_CARDS="ens1371"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage" 
CPU
PHP 代码:
Shadow root # cat /proc/cpuinfo
processor       0
vendor_id       
AuthenticAMD
cpu family      
6
model           
4
model name      
AMD Athlon(tmprocessor
stepping        
2
cpu MHz         
1208.940
cache size      
256 KB
fdiv_bug        
no
hlt_bug         
no
f00f_bug        
no
coma_bug        
no
fpu             
yes
fpu_exception   
yes
cpuid level     
1
wp              
yes
flags           
fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr syscall mmxext 3dnowext 3dnow
bogomips        
2392.06 
谢谢各位达人指点

此帖于 04-11-17 22:44 被 orphen 编辑.
  orphen 当前离线   回复时引用此帖
发表新主题 回复


主题工具

发帖规则
您 [不可以] 发表新主题
您 [不可以] 回复主题
您 [不可以] 上传附件
您 [不可以] 编辑您的帖子

已 [启用] BB 代码
已 [启用] 表情符号
已 [启用] IMG 代码
已 [禁用] HTML 代码
[论坛跳转…]


所有时间均为[北京时间]。现在的时间是 16:52


Powered by vBulletin 版本 3.6.8
版权所有 ©2000 - 2012, Jelsoft Enterprises Ltd.
官方中文技术支持: vBulletin 中文
版权所有 ©2002 - 2011, LinuxSir.Org