LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
楼主: wangxiaohu

被遗忘的 LDFLAGS

[复制链接]
发表于 2004-11-15 14:04:12 | 显示全部楼层
最初由 ldh168 发表
谁能贴一个使用此参数后的make.conf出来?

不用吧,
# echo 'LDFLAGS="-Wl,-O1"' >> /etc/make.conf
不就行了?
发表于 2004-11-15 16:15:47 | 显示全部楼层
看GentooForum上的
[PHP]
LDFLAGS="-Wl,-O1 -Wl,-z combreloc,--relax -Wl,--enable-new-dtags -Wl,--sort-common -s"
[/PHP]
不知道,正常应该如何了~
这些都可以加到make.conf中么?
发表于 2004-11-15 17:20:00 | 显示全部楼层
加入以后如何查看?
发表于 2004-11-15 17:24:10 | 显示全部楼层
--relax是只有对alpha平台有用吧,看得晕晕乎乎的
已经-O1 -Wl了为什么还要-Wl?
发表于 2004-11-15 18:55:20 | 显示全部楼层
用LDFLAGS="-Wl,-O1 -Wl,-z combreloc,--relax -Wl,--enable-new-dtags -Wl,--sort-common -s"之后就不能编译了

checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking build system type... i686-pc-linux-gnu
checking for gcc... gcc
checking whether the C compiler (gcc -march=athlon-xp -pipe -fprefetch-loop-arrays -Wl,-O1 -Wl,-z combreloc,--relax -Wl,--enable-new-dtags  -Wl,--sort-common -s) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.

!!! ERROR: net-www/mozilla-firefox-1.0-r1 failed.
!!! Function econf, Line 449, Exitcode 1
!!! econf failed
!!! If you need support, post the topmost build error, NOT this status message.
发表于 2004-11-15 19:35:46 | 显示全部楼层
我用LDFLAGS="-Wl,-O1"编译了mozilla-firefox-1.0-r2,没问题。
发表于 2004-11-15 20:26:28 | 显示全部楼层
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 编程的应该知道。
发表于 2004-11-16 00:17:35 | 显示全部楼层
这里 -Wl 是一个 gcc 的参数,表示“后面的参数传递给 linker”,所以应该是在 CFLAGS 而不是 LDFLAGS 里面。


This is wrong.
发表于 2004-11-16 00:38:35 | 显示全部楼层
Oh, really? I got this from gcc(1) manual page. So if you say it's wrong, prove it.
发表于 2004-11-16 01:23:39 | 显示全部楼层
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.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表