LinuxSir.cn,穿越时空的Linuxsir!

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

被遗忘的 LDFLAGS

[复制链接]
发表于 2004-11-16 10:07:27 | 显示全部楼层
>> -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
  1. 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:

  1. 01:05 PM tmp $ cat 1.c
  2. #include <stdio.h>

  3. int main()
  4. {
  5. #ifdef ABC
  6.         printf("ABC defined!\n");
  7. #endif
  8. }
复制代码

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.
发表于 2004-11-16 14:01:55 | 显示全部楼层
我在/etc/make.conf加了LDFLAGS,为什么emerge --info看不到?
发表于 2004-11-16 14:34:55 | 显示全部楼层
I said "... MIGHT produce ...".
发表于 2004-11-17 18:34:00 | 显示全部楼层
[PHP]LDFLAGS="-Wl,-O1 -Wl,-z -Wl,--enable-new-dtags -Wl,--sort-common -s"[/PHP]
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
发表于 2004-11-17 18:36:08 | 显示全部楼层
连接时才使用那个参数。。
发表于 2004-11-17 18:40:55 | 显示全部楼层
不知有什么好处?
[PHP]-Wl,-O1 -Wl,-z -Wl,--enable-new-dtags -Wl,--sort-common -s[/PHP]

[PHP]-Wl,-O1[/PHP]
相比,有什么不同
PS 如果添加这些“优化参数”有利无弊的话,为什么各种官方发型版没有使用,没有出现在Gentoo默认的make.conf中呢?
发表于 2004-11-17 19:33:07 | 显示全部楼层
最初由 orphen 发表
PS 如果添加这些“优化参数”有利无弊的话,为什么各种官方发型版没有使用,没有出现在Gentoo默认的make.conf中呢?

可能因为这些“优化参数”的好处根本就不是很明显。
发表于 2004-11-17 20:03:54 | 显示全部楼层
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:
多谢老大支持:)
发表于 2004-11-17 20:06:24 | 显示全部楼层
Fleta:
不会有利无弊——man page 里说了,会“显著增加链接时间“,呵呵。而且可能不是所有版本的 GCC 都支持——譬如某些平台某些版本等等。作为一个发行版,使用不保险的默认是会收获西红柿的。根据 80/20 原则,gentoo 官方自然不会把它加入默认 make.global。。。
发表于 2004-11-17 20:34:38 | 显示全部楼层

那我这样的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"
[/PHP]
CPU[PHP]
Shadow root # cat /proc/cpuinfo
processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 6
model           : 4
model name      : AMD Athlon(tm) processor
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
[/PHP]
谢谢各位达人指点:help :help :help
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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