1 |
Samir Mishra <sqmishra@×××.ae> posted 448B34EC.9030009@×××.ae, excerpted |
2 |
below, on Sun, 11 Jun 2006 01:09:00 +0400: |
3 |
|
4 |
> Duncan wrote: |
5 |
>> A couple questions: |
6 |
>> |
7 |
>> -mcmodel=medium: Here's the gcc 4.1.1 manpage entry: |
8 |
>> |
9 |
>> -mcmodel=medium |
10 |
>> [] Programs can be statically or dynamically linked, but |
11 |
>> building of shared libraries are not supported with the medium model. |
12 |
>> |
13 |
>> What about that last part -- shared libraries not supported? |
14 |
>> |
15 |
>> |
16 |
> palladium ~ # file /bin/bash |
17 |
> /bin/bash: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for |
18 |
> GNU/Linux 2.6.11, dynamically linked (uses shared libs), stripped |
19 |
> palladium ~ # file /lib/libc-2.4.so |
20 |
> /lib/libc-2.4.so: ELF 64-bit LSB shared object, AMD x86-64, version 1 |
21 |
> (SYSV), stripped |
22 |
|
23 |
> I assume this is how to check if a n executable or library is shared[.] |
24 |
> I think I read somewhere that the above statement regarding lack of |
25 |
> support for building shared libraries is not accurate[.] Memory usage |
26 |
> seems reasonable for all of the applications, but given how much I know, |
27 |
> quite possible I got it wrong. |
28 |
|
29 |
Yes, that does check if it's shared, but unless there's something very |
30 |
broken with your setup (I've seen it happen when an installation script |
31 |
broke), shared libraries will always be *.so* (so is short for shared |
32 |
object, and a *.so* file is comparable to the dll, dynamic link library, |
33 |
so common on MSWormOS). Static libraries, OTOH, have the .a extension and |
34 |
are collected and archived using shar (originally referring to |
35 |
shell-archive, just like tar originally referred to tape-archive). |
36 |
|
37 |
Static libraries must be compiled directly into the executable application |
38 |
itself at compile time -- dynamic or shared libraries are loaded into the |
39 |
application by ld at runtime. Because static libraries are compiled into |
40 |
the applications themselves, the resulting applications are much larger |
41 |
(sometimes by several times), and consume much more memory, as there's a |
42 |
copy of each library (or at least the parts of it used by the application) |
43 |
for every application, all in memory at the same time. Thus, the most |
44 |
common parts of libc, for instance, will be duplicated in every single |
45 |
app, both on disk and when they are loaded in memory! |
46 |
|
47 |
Since you haven't noticed an extreme increase in memory usage, and the |
48 |
*.so files seem to be there and usable, it's quite obvious that in fact |
49 |
the gcc manpage IS inaccurate, in that case. It obviously works for you |
50 |
or by now you'd have a VERY VERY broken system and NOTHING would be |
51 |
working. |
52 |
|
53 |
So anyway, I learned that it at least isn't as bad as the gcc manpage |
54 |
would lead one to believe. =8^) |
55 |
|
56 |
That said, it /could/ be that gcc automatically disables that option for |
57 |
shared objects, if it's such that it can do so. I know it does so for |
58 |
example with -freorder-blocks-and-partition, both because the manpage says |
59 |
so, and because it spits out a warning when it does so that can be |
60 |
problematic during the pre-compilation configure phase. (It's for that |
61 |
reason that I use that flag in CFLAGS but not in CXXFLAGS, because the use |
62 |
of exceptions in C++ automatically disables it anyway, and the warning was |
63 |
causing emerge failures.) However, I'm not sure where the memory model |
64 |
comes into use. If it's only when linking the object files, gcc could |
65 |
likely detect that it's creating a shared object and act accordingly. If |
66 |
it's while actually compiling the object files from source, then it |
67 |
wouldn't necessarily know whether they were going to be shared objects or |
68 |
applications at that point. |
69 |
|
70 |
Thus, I'm not sure whether gcc is simply disabling that flag with shared |
71 |
objects or whether it actually uses it but without the harm the use flag |
72 |
implies will result. |
73 |
|
74 |
Regardless, I remain of the opinion that for most apps, it's unnecessary |
75 |
and will at minimum result in a larger binary than would otherwise be the |
76 |
case, with no benefit, so it's all-negative, even if it doesn't actually |
77 |
break anything. Again, it's possible I'm wrong about that, but if I am, |
78 |
it goes against all I've ever read on the subject. |
79 |
|
80 |
I think the bit in your other reply about that comment of being sure you |
81 |
research your CFLAGS before you use them coming back to bite you is a good |
82 |
summation. The discussion has been beneficial to both of us, however, as |
83 |
my questioning is forcing a bit more research on your part, while I |
84 |
learned that the results aren't quite as dire as the manpage implies they |
85 |
are. =8^) |
86 |
|
87 |
>> -ftracer: Of interest here are a couple other manpage entries: |
88 |
>> |
89 |
>> |
90 |
> I thought -ftracer, like -fweb, automatically did the profiling and the |
91 |
> optimization. I was under the impression that -ftracer not recommended |
92 |
> since it increases compile times (which I wasn't worried about) but |
93 |
> produces "better" executables. If the profiling has to be done manually, |
94 |
> prior to optimization, I definitely need to take this one out for my |
95 |
> CFLAGS. |
96 |
|
97 |
I'd still like to get a definitive answer from one of the devs that uses |
98 |
it. Presumably they won't be caught in the same trap of telling others to |
99 |
know their CFLAGS, but not knowing their own, that this seems to have |
100 |
caught you in. =8^) Maybe the manpage is incorrect here as well? <shrug> |
101 |
|
102 |
> BTW I've heard bad things about using -fbranch-probabilities and -fweb. |
103 |
> In fact, I tried -fweb with -ftracer and I began experiencing numerous |
104 |
> compilation failures. Everything went back to OK when I took it out. |
105 |
|
106 |
Very interesting. I'd not been aware of such. |
107 |
|
108 |
I wonder... maybe they are the automatic-profiling and manual-profiling |
109 |
parallels of the same thing? If so, it would explain both the problems |
110 |
you experienced trying to use both together and the reason one is implied |
111 |
to be manual while the other is evidently automatic. |
112 |
|
113 |
I'm afraid I'm raising more questions than I have answers! =8^( |
114 |
|
115 |
> In conclusion, I THOUGHT I had good reason, but I guess I need to do a |
116 |
> bit more research. |
117 |
|
118 |
You know... I've come to realize that ironically, I often value the |
119 |
opinions of and discussions/debates/arguments with those I disagree with |
120 |
most, particularly where they honestly challenge me and I them, more |
121 |
highly than those I tend to agree with. The reason is precisely your |
122 |
conclusion above -- those discussions/debates/arguments tend to spotlight |
123 |
the weakest points in my reasoning that I'd be very unlikely to find it on |
124 |
my own, thus stimulating an acknowledgement that I can't defend that |
125 |
particular point at that particular time and further research, which |
126 |
ultimately leads to either understanding my own position better, or a |
127 |
retraction from it. Had I not been forced by the other person to face |
128 |
that weakness, I'd have never found it and therefore never had a chance to |
129 |
adjust to it or for it. For that reason, I consider that person to have |
130 |
done me a favor for helping me find what I would have otherwise been |
131 |
unaware of, and hold an even greater respect for them than I do for those |
132 |
I always agreed with. |
133 |
|
134 |
So, it seems we are both learning here. I certainly had my misconception |
135 |
that the medium memory model would result in a broken system if used in |
136 |
CFLAGS while attempting to compile shared objects disproved, and you've |
137 |
learned your position wasn't as secure as you believed it to be, either. |
138 |
I think that means we've both benefited! =8^) |
139 |
|
140 |
The great thing about doing this on the public mailing list, is that |
141 |
others benefit as well. I know I'm always learning things from the |
142 |
discussions of others! |
143 |
|
144 |
|
145 |
|
146 |
-- |
147 |
Duncan - List replies preferred. No HTML msgs. |
148 |
"Every nonfree program has a lord, a master -- |
149 |
and if you use the program, he is your master." Richard Stallman |
150 |
|
151 |
-- |
152 |
gentoo-amd64@g.o mailing list |