Mercurial > hg > CbC > CbC_gcc
comparison contrib/make_sunver.pl @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | 561a7518be6b |
children |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
14 # | 14 # |
15 # It uses elfdump when present (native), GNU readelf otherwise. | 15 # It uses elfdump when present (native), GNU readelf otherwise. |
16 # It depends on the GNU version of c++filt, since it must understand the | 16 # It depends on the GNU version of c++filt, since it must understand the |
17 # GNU mangling style. | 17 # GNU mangling style. |
18 | 18 |
19 use File::Glob ':glob'; | |
20 use FileHandle; | 19 use FileHandle; |
21 use IPC::Open2; | 20 use IPC::Open2; |
21 | |
22 # Enforce C locale. | |
23 $ENV{'LC_ALL'} = "C"; | |
24 $ENV{'LANG'} = "C"; | |
22 | 25 |
23 # Input version script, GNU style. | 26 # Input version script, GNU style. |
24 my $symvers = shift; | 27 my $symvers = shift; |
25 | 28 |
26 ########## | 29 ########## |
155 my $glob = 'glob'; | 158 my $glob = 'glob'; |
156 | 159 |
157 # We're currently inside `extern "C++"', which Sun ld doesn't understand. | 160 # We're currently inside `extern "C++"', which Sun ld doesn't understand. |
158 my $in_extern = 0; | 161 my $in_extern = 0; |
159 | 162 |
160 # We're currently inside a conditional section: just skip it. | |
161 my $in_ifdef = 0; | |
162 | |
163 # The c++filt command to use. This *must* be GNU c++filt; the Sun Studio | 163 # The c++filt command to use. This *must* be GNU c++filt; the Sun Studio |
164 # c++filt doesn't handle the GNU mangling style. | 164 # c++filt doesn't handle the GNU mangling style. |
165 my $cxxfilt = $ENV{'CXXFILT'} || "c++filt"; | 165 my $cxxfilt = $ENV{'CXXFILT'} || "c++filt"; |
166 | 166 |
167 # The current version name. | 167 # The current version name. |
182 printf "# Omitted archives with corresponding shared libraries: %s\n", | 182 printf "# Omitted archives with corresponding shared libraries: %s\n", |
183 (join ' ', @SHAREDOBJS) if $#SHAREDOBJS >= 0; | 183 (join ' ', @SHAREDOBJS) if $#SHAREDOBJS >= 0; |
184 print "#\n\n"; | 184 print "#\n\n"; |
185 | 185 |
186 while (<F>) { | 186 while (<F>) { |
187 # End of skipped section. | |
188 if (/^[ \t]*\#endif/) { | |
189 $in_ifdef = 0; | |
190 next; | |
191 } | |
192 | |
193 # Just skip a conditional section. | |
194 if ($in_ifdef) { next; } | |
195 | |
196 # Lines of the form '};' | 187 # Lines of the form '};' |
197 if (/^([ \t]*)(\}[ \t]*;[ \t]*)$/) { | 188 if (/^([ \t]*)(\}[ \t]*;[ \t]*)$/) { |
198 $glob = 'glob'; | 189 $glob = 'glob'; |
199 if ($in_extern) { | 190 if ($in_extern) { |
200 $in_extern--; | 191 $in_extern--; |
201 print "$1##$2"; | 192 print "$1##$2\n"; |
202 } else { | 193 } else { |
203 print; | 194 print; |
204 } | 195 } |
205 next; | 196 next; |
206 } | 197 } |
215 print " .force_WEAK_off_$current_version = DATA S0x0 V0x0;\n"; | 206 print " .force_WEAK_off_$current_version = DATA S0x0 V0x0;\n"; |
216 } | 207 } |
217 print; next; | 208 print; next; |
218 } | 209 } |
219 | 210 |
220 # Special comments that look like C preprocessor conditionals. | |
221 # Just skip the contents for now. | |
222 # FIXME: Allow passing in conditionals from the command line to really | |
223 # control the skipping. | |
224 if (/^[ \t]*\#ifdef/) { | |
225 $in_ifdef = 1; | |
226 next; | |
227 } | |
228 | |
229 # Comment and blank lines | 211 # Comment and blank lines |
230 if (/^[ \t]*\#/) { print; next; } | 212 if (/^[ \t]*\#/) { print; next; } |
231 if (/^[ \t]*$/) { print; next; } | 213 if (/^[ \t]*$/) { print; next; } |
232 | 214 |
233 # Lines of the form '{' | 215 # Lines of the form '{' |
275 # Catch globs. Note that '{}' is not allowed in globs by this script, | 257 # Catch globs. Note that '{}' is not allowed in globs by this script, |
276 # so only '*' and '[]' are available. | 258 # so only '*' and '[]' are available. |
277 if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) { | 259 if (/^([ \t]*)([^ \t;{}#]+);?[ \t]*$/) { |
278 my $ws = $1; | 260 my $ws = $1; |
279 my $ptn = $2; | 261 my $ptn = $2; |
280 # Turn the glob into a regex by replacing '*' with '.*'. | 262 # Turn the glob into a regex by replacing '*' with '.*', '?' with '.'. |
281 # Keep $ptn so we can still print the original form. | 263 # Keep $ptn so we can still print the original form. |
282 ($pattern = $ptn) =~ s/\*/\.\*/g; | 264 ($pattern = $ptn) =~ s/\*/\.\*/g; |
265 $pattern =~ s/\?/\./g; | |
283 | 266 |
284 if ($glob eq 'ign') { | 267 if ($glob eq 'ign') { |
285 # We're in a local: * section; just continue. | 268 # We're in a local: * section; just continue. |
286 print "$_\n"; | 269 print "$_\n"; |
287 next; | 270 next; |