1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
|
\input texinfo @c -*-texinfo-*-
@c %**start of header
@setfilename gcc.info
@c @setfilename usegcc.info
@c @setfilename portgcc.info
@c To produce the full manual, use the "gcc.info" setfilename, and
@c make sure the following do NOT begin with '@c' (and the @clear lines DO)
@set INTERNALS
@set USING
@c To produce a user-only manual, use the "usegcc.info" setfilename, and
@c make sure the following does NOT begin with '@c':
@c @clear INTERNALS
@c To produce a porter-only manual, use the "portgcc.info" setfilename,
@c and make sure the following does NOT begin with '@c':
@c @clear USING
@c (For FSF printing, turn on smallbook, comment out finalout below;
@c that is all that is needed.)
@c 6/27/96 FSF DO wants smallbook fmt for 1st bound edition.
@c @smallbook
@c i also commented out the finalout command, so if there *are* any
@c overfulls, you'll (hopefully) see the rectangle in the right hand
@c margin. -mew 15june93
@c @finalout
@c NOTE: checks/things to do:
@c
@c -have bob do a search in all seven files for "mew" (ideally --mew,
@c but i may have forgotten the occasional "--"..).
@c Just checked... all have `--'! Bob 22Jul96
@c Use this to search: grep -n '\-\-mew' *.texi
@c -item/itemx, text after all (sub/sub)section titles, etc..
@c -consider putting the lists of options on pp 17--> etc in columns or
@c some such.
@c -overfulls. do a search for "mew" in the files, and you will see
@c overfulls that i noted but could not deal with.
@c -have to add text: beginning of chapter 8
@c
@c anything else? --mew 10feb93
@c For consistency, use the following:
@c - "back end" as a noun, "back-end" as an adjective.
@c - "bit-field" not "bitfield" or "bit field" (following the C and C++
@c standards).
@c - "built-in" as an adjective ("built-in function"), or sometimes
@c "built in", not "builtin" (which isn't a word).
@c - "front end" as a noun, "front-end" as an adjective.
@c - "GCC" for the GNU Compiler Collection, both generally
@c and as the GNU C Compiler in the context of compiling C;
@c "G++" for the C++ compiler; "gcc" and "g++" (lowercase),
@c marked up with @command, for the commands for compilation when the
@c emphasis is on those; "GNU C" and "GNU C++" for language dialects;
@c and try to avoid the older term "GNU CC".
@macro gcctabopt{body}
@code{\body\}
@end macro
@macro gccoptlist{body}
@smallexample
\body\
@end smallexample
@end macro
@c Makeinfo handles the above macro OK, TeX needs manual line breaks;
@c they get lost at some point in handling the macro. But if @macro is
@c used here rather than @alias, it produces double line breaks.
@iftex
@alias gol = *
@end iftex
@ifnottex
@macro gol
@end macro
@end ifnottex
@ifset INTERNALS
@ifset USING
@settitle Using and Porting the GNU Compiler Collection (GCC)
@end ifset
@end ifset
@c seems reasonable to assume at least one of INTERNALS or USING is set...
@ifclear INTERNALS
@settitle Using the GNU Compiler Collection
@end ifclear
@ifclear USING
@settitle Porting the GNU Compiler Collection
@end ifclear
@c Create a separate index for command line options.
@defcodeindex op
@c Merge the standard indexes into a single one.
@syncodeindex fn cp
@syncodeindex vr cp
@syncodeindex ky cp
@syncodeindex pg cp
@syncodeindex tp cp
@c %**end of header
@c Use with @@smallbook.
@c Cause even numbered pages to be printed on the left hand side of
@c the page and odd numbered pages to be printed on the right hand
@c side of the page. Using this, you can print on both sides of a
@c sheet of paper and have the text on the same part of the sheet.
@c The text on right hand pages is pushed towards the right hand
@c margin and the text on left hand pages is pushed toward the left
@c hand margin.
@c (To provide the reverse effect, set bindingoffset to -0.75in.)
@c @tex
@c \global\bindingoffset=0.75in
@c \global\normaloffset =0.75in
@c @end tex
@c Change the font used for @def... commands, since the default
@c proportional one used is bad for names starting __.
@tex
\global\setfont\defbf\ttbshape{10}{\magstep1}
@end tex
@ifnottex
@dircategory Programming
@direntry
* gcc: (gcc). The GNU Compiler Collection.
@end direntry
@ifset INTERNALS
@ifset USING
This file documents the use and the internals of the GNU compiler.
@end ifset
@end ifset
@ifclear USING
This file documents the internals of the GNU compiler.
@end ifclear
@ifclear INTERNALS
This file documents the use of the GNU compiler.
@end ifclear
@sp 1
Published by the Free Software Foundation@*
59 Temple Place - Suite 330@*
Boston, MA 02111-1307 USA
@sp 1
@c When you update the list of years below, search for copyright{} and
@c update the other copy too.
Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
1999, 2000, 2001 Free Software Foundation, Inc.
@sp 1
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``GNU General Public License'' and ``Funding
Free Software'', the Front-Cover texts being (a) (see below), and with
the Back-Cover Texts being (b) (see below). A copy of the license is
included in the section entitled ``GNU Free Documentation License''.
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.
@end ifnottex
@setchapternewpage odd
@c @finalout
@titlepage
@ifset INTERNALS
@ifset USING
@center @titlefont{Using and Porting the GNU Compiler Collection}
@end ifset
@end ifset
@ifclear INTERNALS
@title Using the GNU Compiler Collection
@end ifclear
@ifclear USING
@title Porting the GNU Compiler Collection
@end ifclear
@sp 2
@center Richard M. Stallman
@sp 3
@center Last updated 22 June 2001
@sp 1
@c The version number appears five times more in this file.
@center for GCC 3.1
@page
@vskip 0pt plus 1filll
Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1998,
1999, 2000, 2001 Free Software Foundation, Inc.
@sp 2
For GCC Version 3.1@*
@sp 1
Published by the Free Software Foundation @*
59 Temple Place---Suite 330@*
Boston, MA 02111-1307, USA@*
Last printed April, 1998.@*
Printed copies are available for $50 each.@*
ISBN 1-882114-37-X
@sp 1
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``GNU General Public License'', the Front-Cover
texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below). A copy of the license is included in the section entitled
``GNU Free Documentation License''.
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.
@end titlepage
@summarycontents
@contents
@page
@node Top, G++ and GCC,, (DIR)
@top Introduction
@cindex introduction
@ifset INTERNALS
@ifset USING
This manual documents how to run, install and port the GNU
compiler, as well as its new features and incompatibilities, and how to
report bugs. It corresponds to GCC version 3.1.
@end ifset
@end ifset
@ifclear INTERNALS
This manual documents how to run and install the GNU compiler,
as well as its new features and incompatibilities, and how to report
bugs. It corresponds to GCC version 3.1.
@end ifclear
@ifclear USING
This manual documents how to port the GNU compiler,
as well as its new features and incompatibilities, and how to report
bugs. It corresponds to GCC version 3.1.
@end ifclear
@menu
@ifset USING
* G++ and GCC:: You can compile C or C++ programs.
* Standards:: Language standards supported by GCC.
* Invoking GCC:: Command options supported by @samp{gcc}.
* Installation:: How to configure, compile and install GCC.
* C Extensions:: GNU extensions to the C language family.
* C++ Extensions:: GNU extensions to the C++ language.
* Objective-C:: GNU Objective-C runtime features.
* Gcov:: gcov: a GCC test coverage program.
* Trouble:: If you have trouble installing GCC.
* Bugs:: How, why and where to report bugs.
* Service:: How to find suppliers of support for GCC.
* Contributing:: How to contribute to testing and developing GCC.
* VMS:: Using GCC on VMS.
* Makefile:: Additional Makefile and configure information.
@end ifset
@ifset INTERNALS
* Portability:: Goals of GCC's portability features.
* Interface:: Function-call interface of GCC output.
* Passes:: Order of passes, what they do, and what each file is for.
* Trees:: The source representation used by the C and C++ front ends.
* RTL:: The intermediate representation that most passes work on.
* Machine Desc:: How to write machine description instruction patterns.
* Target Macros:: How to write the machine description C macros and functions.
* Config:: Writing the @file{xm-@var{machine}.h} file.
* Fragments:: Writing the @file{t-@var{target}} and @file{x-@var{host}} files.
@end ifset
* Funding:: How to help assure funding for free software.
* GNU/Linux:: Linux and the GNU Project
* Copying:: GNU General Public License says
how you can copy and share GCC.
* GNU Free Documentation License:: How you can copy and share this manual.
* Contributors:: People who have contributed to GCC.
* Option Index:: Index to command line options.
* Index:: Index of concepts and symbol names.
@end menu
@ifset USING
@node G++ and GCC
@chapter Compile C, C++, Objective-C, Fortran, Java or CHILL
@cindex Objective-C
@cindex Fortran
@cindex Java
@cindex CHILL
Several versions of the compiler (C, C++, Objective-C, Fortran, Java
and CHILL) are integrated; this is why we use the name
``GNU Compiler Collection''. GCC can compile programs written in any of these
languages. The Fortran, CHILL, and Java compilers are described in
separate manuals.
@cindex GCC
``GCC'' is a common shorthand term for the GNU Compiler Collection. This is both
the most general name for the compiler, and the name used when the
emphasis is on compiling C programs (as the abbreviation formerly
stood for ``GNU C Compiler'').
@cindex C++
@cindex G++
When referring to C++ compilation, it is usual to call the compiler
``G++''. Since there is only one compiler, it is also accurate to call
it ``GCC'' no matter what the language context; however, the term
``G++'' is more useful when the emphasis is on compiling C++ programs.
We use the name ``GCC'' to refer to the compilation system as a
whole, and more specifically to the language-independent part of the
compiler. For example, we refer to the optimization options as
affecting the behavior of ``GCC'' or sometimes just ``the compiler''.
Front ends for other languages, such as Ada 95 and Pascal exist but
have not yet been integrated into GCC@. These front ends, like that for C++,
are built in subdirectories of GCC and link to it. The result is an
integrated compiler that can compile programs written in C, C++,
Objective-C, or any of the languages for which you have installed front
ends.
In this manual, we only discuss the options for the C, Objective-C, and
C++ compilers and those of the GCC core. Consult the documentation
of the other front ends for the options to use when compiling programs
written in other languages.
@cindex compiler compared to C++ preprocessor
@cindex intermediate C version, nonexistent
@cindex C intermediate output, nonexistent
G++ is a @emph{compiler}, not merely a preprocessor. G++ builds object
code directly from your C++ program source. There is no intermediate C
version of the program. (By contrast, for example, some other
implementations use a program that generates a C program from your C++
source.) Avoiding an intermediate C representation of the program means
that you get better object code, and better debugging information. The
GNU debugger, GDB, works with this information in the object code to
give you comprehensive C++ source-level editing capabilities
(@pxref{C,,C and C++,gdb.info, Debugging with GDB}).
@c FIXME! Someone who knows something about Objective-C ought to put in
@c a paragraph or two about it here, and move the index entry down when
@c there is more to point to than the general mention in the 1st par.
@node Standards
@chapter Language Standards Supported by GCC
@cindex C standard
@cindex C standards
@cindex ANSI C standard
@cindex ANSI C
@cindex ANSI C89
@cindex C89
@cindex ANSI X3.159-1989
@cindex X3.159-1989
@cindex ISO C standard
@cindex ISO C
@cindex ISO C89
@cindex ISO C90
@cindex ISO/IEC 9899
@cindex ISO 9899
@cindex C90
@cindex ISO C94
@cindex C94
@cindex ISO C95
@cindex C95
@cindex ISO C99
@cindex C99
@cindex ISO C9X
@cindex C9X
@cindex Technical Corrigenda
@cindex TC1
@cindex Technical Corrigendum 1
@cindex TC2
@cindex Technical Corrigendum 2
@cindex AMD1
@cindex freestanding implementation
@cindex freestanding environment
@cindex hosted implementation
@cindex hosted environment
@findex __STDC_HOSTED__
For each language compiled by GCC for which there is a standard, GCC
attempts to follow one or more versions of that standard, possibly
with some exceptions, and possibly with some extensions.
GCC supports three versions of the C standard, although support for
the most recent version is not yet complete.
@opindex std
@opindex ansi
@opindex pedantic
@opindex pedantic-errors
The original ANSI C standard (X3.159-1989) was ratified in 1989 and
published in 1990. This standard was ratified as an ISO standard
(ISO/IEC 9899:1990) later in 1990. There were no technical
differences between these publications, although the sections of the
ANSI standard were renumbered and became clauses in the ISO standard.
This standard, in both its forms, is commonly known as @dfn{C89}, or
occasionally as @dfn{C90}, from the dates of ratification. The ANSI
standard, but not the ISO standard, also came with a Rationale
document. To select this standard in GCC, use one of the options
@option{-ansi}, @option{-std=c89} or @option{-std=iso9899:1990}; to obtain
all the diagnostics required by the standard, you should also specify
@option{-pedantic} (or @option{-pedantic-errors} if you want them to be
errors rather than warnings). @xref{C Dialect Options,,Options
Controlling C Dialect}.
Errors in the 1990 ISO C standard were corrected in two Technical
Corrigenda published in 1994 and 1996. GCC does not support the
uncorrected version.
An amendment to the 1990 standard was published in 1995. This
amendment added digraphs and @code{__STDC_VERSION__} to the language,
but otherwise concerned the library. This amendment is commonly known
as @dfn{AMD1}; the amended standard is sometimes known as @dfn{C94} or
@dfn{C95}. To select this standard in GCC, use the option
@option{-std=iso9899:199409} (with, as for other standard versions,
@option{-pedantic} to receive all required diagnostics).
A new edition of the ISO C standard was published in 1999 as ISO/IEC
9899:1999, and is commonly known as @dfn{C99}. GCC has incomplete
support for this standard version; see
@uref{http://gcc.gnu.org/c99status.html} for details. To select this
standard, use @option{-std=c99} or @option{-std=iso9899:1999}. (While in
development, drafts of this standard version were referred to as
@dfn{C9X}.)
@opindex traditional
GCC also has some limited support for traditional (pre-ISO) C with the
@option{-traditional} option. This support may be of use for compiling
some very old programs that have not been updated to ISO C, but should
not be used for new programs. It will not work with some modern C
libraries such as the GNU C library.
By default, GCC provides some extensions to the C language that on
rare occasions conflict with the C standard. @xref{C
Extensions,,Extensions to the C Language Family}. Use of the
@option{-std} options listed above will disable these extensions where
they conflict with the C standard version selected. You may also
select an extended version of the C language explicitly with
@option{-std=gnu89} (for C89 with GNU extensions) or @option{-std=gnu99}
(for C99 with GNU extensions). The default, if no C language dialect
options are given, is @option{-std=gnu89}; this will change to
@option{-std=gnu99} in some future release when the C99 support is
complete. Some features that are part of the C99 standard are
accepted as extensions in C89 mode.
The ISO C standard defines (in clause 4) two classes of conforming
implementation. A @dfn{conforming hosted implementation} supports the
whole standard including all the library facilities; a @dfn{conforming
freestanding implementation} is only required to provide certain
library facilities: those in @code{<float.h>}, @code{<limits.h>},
@code{<stdarg.h>}, and @code{<stddef.h>}; since AMD1, also those in
@code{<iso646.h>}; and in C99, also those in @code{<stdbool.h>} and
@code{<stdint.h>}. In addition, complex types, added in C99, are not
required for freestanding implementations. The standard also defines
two environments for programs, a @dfn{freestanding environment},
required of all implementations and which may not have library
facilities beyond those required of freestanding implementations,
where the handling of program startup and termination are
implementation-defined, and a @dfn{hosted environment}, which is not
required, in which all the library facilities are provided and startup
is through a function @code{int main (void)} or @code{int main (int,
char *[])}. An OS kernel would be a freestanding environment; a
program using the facilities of an operating system would normally be
in a hosted implementation.
@opindex ffreestanding
GCC aims towards being usable as a conforming freestanding
implementation, or as the compiler for a conforming hosted
implementation. By default, it will act as the compiler for a hosted
implementation, defining @code{__STDC_HOSTED__} as @code{1} and
presuming that when the names of ISO C functions are used, they have
the semantics defined in the standard. To make it act as a conforming
freestanding implementation for a freestanding environment, use the
option @option{-ffreestanding}; it will then define
@code{__STDC_HOSTED__} to @code{0} and not make assumptions about the
meanings of function names from the standard library. To build an OS
kernel, you may well still need to make your own arrangements for
linking and startup. @xref{C Dialect Options,,Options Controlling C
Dialect}.
GCC does not provide the library facilities required only of hosted
implementations, nor yet all the facilities required by C99 of
freestanding implementations; to use the facilities of a hosted
environment, you will need to find them elsewhere (for example, in the
GNU C library). @xref{Standard Libraries,,Standard Libraries}.
For references to Technical Corrigenda, Rationale documents and
information concerning the history of C that is available online, see
@uref{http://gcc.gnu.org/readings.html}
@c FIXME: details of C++ standard.
There is no formal written standard for Objective-C@. The most
authoritative manual is ``Object-Oriented Programming and the
Objective-C Language'', available at a number of web sites;
@uref{http://developer.apple.com/techpubs/macosx/Cocoa/ObjectiveC/} has a
recent version, while @uref{http://www.toodarkpark.org/computers/objc/}
is an older example. @uref{http://www.gnustep.org} includes useful
information as well.
@xref{Language,,The GNU Fortran Language, g77, Using and Porting GNU
Fortran}, for details of the Fortran language supported by GCC@.
@xref{Compatibility,,Compatibility with the Java Platform, gcj, GNU gcj},
for details of compatibility between @code{gcj} and the Java Platform.
@xref{References,,Language Definition References, chill, GNU Chill},
for details of the CHILL standard.
@include invoke.texi
@include install-old.texi
@include extend.texi
@include objc.texi
@include gcov.texi
@node Trouble
@chapter Known Causes of Trouble with GCC
@cindex bugs, known
@cindex installation trouble
@cindex known causes of trouble
This section describes known problems that affect users of GCC@. Most
of these are not GCC bugs per se---if they were, we would fix them.
But the result for a user may be like the result of a bug.
Some of these problems are due to bugs in other software, some are
missing features that are too much work to add, and some are places
where people's opinions differ as to what is best.
@menu
* Actual Bugs:: Bugs we will fix later.
* Cross-Compiler Problems:: Common problems of cross compiling with GCC.
* Interoperation:: Problems using GCC with other compilers,
and with certain linkers, assemblers and debuggers.
* External Bugs:: Problems compiling certain programs.
* Incompatibilities:: GCC is incompatible with traditional C.
* Fixed Headers:: GCC uses corrected versions of system header files.
This is necessary, but doesn't always work smoothly.
* Standard Libraries:: GCC uses the system C library, which might not be
compliant with the ISO C standard.
* Disappointments:: Regrettable things we can't change, but not quite bugs.
* C++ Misunderstandings:: Common misunderstandings with GNU C++.
* Protoize Caveats:: Things to watch out for when using @code{protoize}.
* Non-bugs:: Things we think are right, but some others disagree.
* Warnings and Errors:: Which problems in your code get warnings,
and which get errors.
@end menu
@node Actual Bugs
@section Actual Bugs We Haven't Fixed Yet
@itemize @bullet
@item
The @code{fixincludes} script interacts badly with automounters; if the
directory of system header files is automounted, it tends to be
unmounted while @code{fixincludes} is running. This would seem to be a
bug in the automounter. We don't know any good way to work around it.
@item
The @code{fixproto} script will sometimes add prototypes for the
@code{sigsetjmp} and @code{siglongjmp} functions that reference the
@code{jmp_buf} type before that type is defined. To work around this,
edit the offending file and place the typedef in front of the
prototypes.
@item
@opindex pedantic-errors
When @option{-pedantic-errors} is specified, GCC will incorrectly give
an error message when a function name is specified in an expression
involving the comma operator.
@end itemize
@node Cross-Compiler Problems
@section Cross-Compiler Problems
You may run into problems with cross compilation on certain machines,
for several reasons.
@itemize @bullet
@item
Cross compilation can run into trouble for certain machines because
some target machines' assemblers require floating point numbers to be
written as @emph{integer} constants in certain contexts.
The compiler writes these integer constants by examining the floating
point value as an integer and printing that integer, because this is
simple to write and independent of the details of the floating point
representation. But this does not work if the compiler is running on
a different machine with an incompatible floating point format, or
even a different byte-ordering.
In addition, correct constant folding of floating point values
requires representing them in the target machine's format.
(The C standard does not quite require this, but in practice
it is the only way to win.)
It is now possible to overcome these problems by defining macros such
as @code{REAL_VALUE_TYPE}. But doing so is a substantial amount of
work for each target machine.
@ifset INTERNALS
@xref{Cross-compilation}.
@end ifset
@ifclear INTERNALS
@xref{Cross-compilation,,Cross Compilation and Floating Point Format,
gcc.info, Using and Porting GCC}.
@end ifclear
@item
At present, the program @file{mips-tfile} which adds debug
support to object files on MIPS systems does not work in a cross
compile environment.
@end itemize
@node Interoperation
@section Interoperation
This section lists various difficulties encountered in using GCC
together with other compilers or with the assemblers, linkers,
libraries and debuggers on certain systems.
@itemize @bullet
@item
Objective-C does not work on the RS/6000.
@item
G++ does not do name mangling in the same way as other C++
compilers. This means that object files compiled with one compiler
cannot be used with another.
This effect is intentional, to protect you from more subtle problems.
Compilers differ as to many internal details of C++ implementation,
including: how class instances are laid out, how multiple inheritance is
implemented, and how virtual function calls are handled. If the name
encoding were made the same, your programs would link against libraries
provided from other compilers---but the programs would then crash when
run. Incompatible libraries are then detected at link time, rather than
at run time.
@item
Older GDB versions sometimes fail to read the output of GCC version
2. If you have trouble, get GDB version 4.4 or later.
@item
@cindex DBX
DBX rejects some files produced by GCC, though it accepts similar
constructs in output from PCC@. Until someone can supply a coherent
description of what is valid DBX input and what is not, there is
nothing I can do about these problems. You are on your own.
@item
The GNU assembler (GAS) does not support PIC@. To generate PIC code, you
must use some other assembler, such as @file{/bin/as}.
@item
On some BSD systems, including some versions of Ultrix, use of profiling
causes static variable destructors (currently used only in C++) not to
be run.
@ignore
@cindex @code{vfork}, for the Sun-4
@item
There is a bug in @code{vfork} on the Sun-4 which causes the registers
of the child process to clobber those of the parent. Because of this,
programs that call @code{vfork} are likely to lose when compiled
optimized with GCC when the child code alters registers which contain
C variables in the parent. This affects variables which are live in the
parent across the call to @code{vfork}.
If you encounter this, you can work around the problem by declaring
variables @code{volatile} in the function that calls @code{vfork}, until
the problem goes away, or by not declaring them @code{register} and not
using @option{-O} for those source files.
@end ignore
@item
On some SGI systems, when you use @option{-lgl_s} as an option,
it gets translated magically to @samp{-lgl_s -lX11_s -lc_s}.
Naturally, this does not happen when you use GCC@.
You must specify all three options explicitly.
@item
On a Sparc, GCC aligns all values of type @code{double} on an 8-byte
boundary, and it expects every @code{double} to be so aligned. The Sun
compiler usually gives @code{double} values 8-byte alignment, with one
exception: function arguments of type @code{double} may not be aligned.
As a result, if a function compiled with Sun CC takes the address of an
argument of type @code{double} and passes this pointer of type
@code{double *} to a function compiled with GCC, dereferencing the
pointer may cause a fatal signal.
One way to solve this problem is to compile your entire program with GCC@.
Another solution is to modify the function that is compiled with
Sun CC to copy the argument into a local variable; local variables
are always properly aligned. A third solution is to modify the function
that uses the pointer to dereference it via the following function
@code{access_double} instead of directly with @samp{*}:
@smallexample
inline double
access_double (double *unaligned_ptr)
@{
union d2i @{ double d; int i[2]; @};
union d2i *p = (union d2i *) unaligned_ptr;
union d2i u;
u.i[0] = p->i[0];
u.i[1] = p->i[1];
return u.d;
@}
@end smallexample
@noindent
Storing into the pointer can be done likewise with the same union.
@item
On Solaris, the @code{malloc} function in the @file{libmalloc.a} library
may allocate memory that is only 4 byte aligned. Since GCC on the
Sparc assumes that doubles are 8 byte aligned, this may result in a
fatal signal if doubles are stored in memory allocated by the
@file{libmalloc.a} library.
The solution is to not use the @file{libmalloc.a} library. Use instead
@code{malloc} and related functions from @file{libc.a}; they do not have
this problem.
@item
Sun forgot to include a static version of @file{libdl.a} with some
versions of SunOS (mainly 4.1). This results in undefined symbols when
linking static binaries (that is, if you use @option{-static}). If you
see undefined symbols @code{_dlclose}, @code{_dlsym} or @code{_dlopen}
when linking, compile and link against the file
@file{mit/util/misc/dlsym.c} from the MIT version of X windows.
@item
The 128-bit long double format that the Sparc port supports currently
works by using the architecturally defined quad-word floating point
instructions. Since there is no hardware that supports these
instructions they must be emulated by the operating system. Long
doubles do not work in Sun OS versions 4.0.3 and earlier, because the
kernel emulator uses an obsolete and incompatible format. Long doubles
do not work in Sun OS version 4.1.1 due to a problem in a Sun library.
Long doubles do work on Sun OS versions 4.1.2 and higher, but GCC
does not enable them by default. Long doubles appear to work in Sun OS
5.x (Solaris 2.x).
@item
On HP-UX version 9.01 on the HP PA, the HP compiler @code{cc} does not
compile GCC correctly. We do not yet know why. However, GCC
compiled on earlier HP-UX versions works properly on HP-UX 9.01 and can
compile itself properly on 9.01.
@item
On the HP PA machine, ADB sometimes fails to work on functions compiled
with GCC@. Specifically, it fails to work on functions that use
@code{alloca} or variable-size arrays. This is because GCC doesn't
generate HP-UX unwind descriptors for such functions. It may even be
impossible to generate them.
@item
Debugging (@option{-g}) is not supported on the HP PA machine, unless you use
the preliminary GNU tools (@pxref{Installation}).
@item
Taking the address of a label may generate errors from the HP-UX
PA assembler. GAS for the PA does not have this problem.
@item
Using floating point parameters for indirect calls to static functions
will not work when using the HP assembler. There simply is no way for GCC
to specify what registers hold arguments for static functions when using
the HP assembler. GAS for the PA does not have this problem.
@item
In extremely rare cases involving some very large functions you may
receive errors from the HP linker complaining about an out of bounds
unconditional branch offset. This used to occur more often in previous
versions of GCC, but is now exceptionally rare. If you should run
into it, you can work around by making your function smaller.
@item
GCC compiled code sometimes emits warnings from the HP-UX assembler of
the form:
@smallexample
(warning) Use of GR3 when
frame >= 8192 may cause conflict.
@end smallexample
These warnings are harmless and can be safely ignored.
@item
The current version of the assembler (@file{/bin/as}) for the RS/6000
has certain problems that prevent the @option{-g} option in GCC from
working. Note that @file{Makefile.in} uses @option{-g} by default when
compiling @file{libgcc2.c}.
IBM has produced a fixed version of the assembler. The upgraded
assembler unfortunately was not included in any of the AIX 3.2 update
PTF releases (3.2.2, 3.2.3, or 3.2.3e). Users of AIX 3.1 should request
PTF U403044 from IBM and users of AIX 3.2 should request PTF U416277.
See the file @file{README.RS6000} for more details on these updates.
You can test for the presence of a fixed assembler by using the
command
@smallexample
as -u < /dev/null
@end smallexample
@noindent
If the command exits normally, the assembler fix already is installed.
If the assembler complains that @option{-u} is an unknown flag, you need to
order the fix.
@item
On the IBM RS/6000, compiling code of the form
@smallexample
extern int foo;
@dots{} foo @dots{}
static int foo;
@end smallexample
@noindent
will cause the linker to report an undefined symbol @code{foo}.
Although this behavior differs from most other systems, it is not a
bug because redefining an @code{extern} variable as @code{static}
is undefined in ISO C@.
@item
AIX on the RS/6000 provides support (NLS) for environments outside of
the United States. Compilers and assemblers use NLS to support
locale-specific representations of various objects including
floating-point numbers (@samp{.} vs @samp{,} for separating decimal fractions).
There have been problems reported where the library linked with GCC does
not produce the same floating-point formats that the assembler accepts.
If you have this problem, set the @env{LANG} environment variable to
@samp{C} or @samp{En_US}.
@item
@opindex fdollars-in-identifiers
Even if you specify @option{-fdollars-in-identifiers},
you cannot successfully use @samp{$} in identifiers on the RS/6000 due
to a restriction in the IBM assembler. GAS supports these
identifiers.
@item
On the RS/6000, XLC version 1.3.0.0 will miscompile @file{jump.c}. XLC
version 1.3.0.1 or later fixes this problem. You can obtain XLC-1.3.0.2
by requesting PTF 421749 from IBM@.
@item
@opindex mno-serialize-volatile
There is an assembler bug in versions of DG/UX prior to 5.4.2.01 that
occurs when the @samp{fldcr} instruction is used. GCC uses
@samp{fldcr} on the 88100 to serialize volatile memory references. Use
the option @option{-mno-serialize-volatile} if your version of the
assembler has this bug.
@item
On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
messages from the linker. These warning messages complain of mismatched
psect attributes. You can ignore them. @xref{VMS Install}.
@item
On NewsOS version 3, if you include both of the files @file{stddef.h}
and @file{sys/types.h}, you get an error because there are two typedefs
of @code{size_t}. You should change @file{sys/types.h} by adding these
lines around the definition of @code{size_t}:
@smallexample
#ifndef _SIZE_T
#define _SIZE_T
@var{actual-typedef-here}
#endif
@end smallexample
@cindex Alliant
@item
On the Alliant, the system's own convention for returning structures
and unions is unusual, and is not compatible with GCC no matter
what options are used.
@cindex RT PC
@cindex IBM RT PC
@item
@opindex mhc-struct-return
On the IBM RT PC, the MetaWare HighC compiler (hc) uses a different
convention for structure and union returning. Use the option
@option{-mhc-struct-return} to tell GCC to use a convention compatible
with it.
@cindex VAX calling convention
@cindex Ultrix calling convention
@item
@opindex fcall-saved
On Ultrix, the Fortran compiler expects registers 2 through 5 to be saved
by function calls. However, the C compiler uses conventions compatible
with BSD Unix: registers 2 through 5 may be clobbered by function calls.
GCC uses the same convention as the Ultrix C compiler. You can use
these options to produce code compatible with the Fortran compiler:
@smallexample
-fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
@end smallexample
@item
On the WE32k, you may find that programs compiled with GCC do not
work with the standard shared C library. You may need to link with
the ordinary C compiler. If you do so, you must specify the following
options:
@smallexample
-L/usr/local/lib/gcc-lib/we32k-att-sysv/2.8.1 -lgcc -lc_s
@end smallexample
The first specifies where to find the library @file{libgcc.a}
specified with the @option{-lgcc} option.
GCC does linking by invoking @command{ld}, just as @command{cc} does, and
there is no reason why it @emph{should} matter which compilation program
you use to invoke @command{ld}. If someone tracks this problem down,
it can probably be fixed easily.
@item
On the Alpha, you may get assembler errors about invalid syntax as a
result of floating point constants. This is due to a bug in the C
library functions @code{ecvt}, @code{fcvt} and @code{gcvt}. Given valid
floating point numbers, they sometimes print @samp{NaN}.
@item
On Irix 4.0.5F (and perhaps in some other versions), an assembler bug
sometimes reorders instructions incorrectly when optimization is turned
on. If you think this may be happening to you, try using the GNU
assembler; GAS version 2.1 supports ECOFF on Irix.
@opindex noasmopt
Or use the @option{-noasmopt} option when you compile GCC with itself,
and then again when you compile your program. (This is a temporary
kludge to turn off assembler optimization on Irix.) If this proves to
be what you need, edit the assembler spec in the file @file{specs} so
that it unconditionally passes @option{-O0} to the assembler, and never
passes @option{-O2} or @option{-O3}.
@end itemize
@node External Bugs
@section Problems Compiling Certain Programs
@c prevent bad page break with this line
Certain programs have problems compiling.
@itemize @bullet
@item
Parse errors may occur compiling X11 on a Decstation running Ultrix 4.2
because of problems in DEC's versions of the X11 header files
@file{X11/Xlib.h} and @file{X11/Xutil.h}. People recommend adding
@option{-I/usr/include/mit} to use the MIT versions of the header files,
using the @option{-traditional} switch to turn off ISO C, or fixing the
header files by adding this:
@example
#ifdef __STDC__
#define NeedFunctionPrototypes 0
#endif
@end example
@item
On various 386 Unix systems derived from System V, including SCO, ISC,
and ESIX, you may get error messages about running out of virtual memory
while compiling certain programs.
You can prevent this problem by linking GCC with the GNU malloc
(which thus replaces the malloc that comes with the system). GNU malloc
is available as a separate package, and also in the file
@file{src/gmalloc.c} in the GNU Emacs 19 distribution.
If you have installed GNU malloc as a separate library package, use this
option when you relink GCC:
@example
MALLOC=/usr/local/lib/libgmalloc.a
@end example
Alternatively, if you have compiled @file{gmalloc.c} from Emacs 19, copy
the object file to @file{gmalloc.o} and use this option when you relink
GCC:
@example
MALLOC=gmalloc.o
@end example
@end itemize
@node Incompatibilities
@section Incompatibilities of GCC
@cindex incompatibilities of GCC
@opindex traditional
There are several noteworthy incompatibilities between GNU C and K&R
(non-ISO) versions of C@. The @option{-traditional} option
eliminates many of these incompatibilities, @emph{but not all}, by
telling GCC to behave like a K&R C compiler.
@itemize @bullet
@cindex string constants
@cindex read-only strings
@cindex shared strings
@item
GCC normally makes string constants read-only. If several
identical-looking string constants are used, GCC stores only one
copy of the string.
@cindex @code{mktemp}, and constant strings
One consequence is that you cannot call @code{mktemp} with a string
constant argument. The function @code{mktemp} always alters the
string its argument points to.
@cindex @code{sscanf}, and constant strings
@cindex @code{fscanf}, and constant strings
@cindex @code{scanf}, and constant strings
Another consequence is that @code{sscanf} does not work on some systems
when passed a string constant as its format control string or input.
This is because @code{sscanf} incorrectly tries to write into the string
constant. Likewise @code{fscanf} and @code{scanf}.
@opindex fwritable-strings
The best solution to these problems is to change the program to use
@code{char}-array variables with initialization strings for these
purposes instead of string constants. But if this is not possible,
you can use the @option{-fwritable-strings} flag, which directs GCC
to handle string constants the same way most C compilers do.
@option{-traditional} also has this effect, among others.
@item
@code{-2147483648} is positive.
This is because 2147483648 cannot fit in the type @code{int}, so
(following the ISO C rules) its data type is @code{unsigned long int}.
Negating this value yields 2147483648 again.
@item
GCC does not substitute macro arguments when they appear inside of
string constants. For example, the following macro in GCC
@example
#define foo(a) "a"
@end example
@noindent
will produce output @code{"a"} regardless of what the argument @var{a} is.
The @option{-traditional} option directs GCC to handle such cases
(among others) in the old-fashioned (non-ISO) fashion.
@cindex @code{setjmp} incompatibilities
@cindex @code{longjmp} incompatibilities
@item
When you use @code{setjmp} and @code{longjmp}, the only automatic
variables guaranteed to remain valid are those declared
@code{volatile}. This is a consequence of automatic register
allocation. Consider this function:
@example
jmp_buf j;
foo ()
@{
int a, b;
a = fun1 ();
if (setjmp (j))
return a;
a = fun2 ();
/* @r{@code{longjmp (j)} may occur in @code{fun3}.} */
return a + fun3 ();
@}
@end example
Here @code{a} may or may not be restored to its first value when the
@code{longjmp} occurs. If @code{a} is allocated in a register, then
its first value is restored; otherwise, it keeps the last value stored
in it.
@opindex W
If you use the @option{-W} option with the @option{-O} option, you will
get a warning when GCC thinks such a problem might be possible.
The @option{-traditional} option directs GCC to put variables in
the stack by default, rather than in registers, in functions that
call @code{setjmp}. This results in the behavior found in
traditional C compilers.
@item
Programs that use preprocessing directives in the middle of macro
arguments do not work with GCC@. For example, a program like this
will not work:
@example
@group
foobar (
#define luser
hack)
@end group
@end example
ISO C does not permit such a construct. It would make sense to support
it when @option{-traditional} is used, but it is too much work to
implement.
@item
K&R compilers allow comments to cross over an inclusion boundary
(i.e.@: started in an include file and ended in the including file). I think
this would be quite ugly and can't imagine it could be needed.
@cindex external declaration scope
@cindex scope of external declarations
@cindex declaration scope
@item
Declarations of external variables and functions within a block apply
only to the block containing the declaration. In other words, they
have the same scope as any other declaration in the same place.
In some other C compilers, a @code{extern} declaration affects all the
rest of the file even if it happens within a block.
The @option{-traditional} option directs GCC to treat all @code{extern}
declarations as global, like traditional compilers.
@item
In traditional C, you can combine @code{long}, etc., with a typedef name,
as shown here:
@example
typedef int foo;
typedef long foo bar;
@end example
In ISO C, this is not allowed: @code{long} and other type modifiers
require an explicit @code{int}. Because this criterion is expressed
by Bison grammar rules rather than C code, the @option{-traditional}
flag cannot alter it.
@cindex typedef names as function parameters
@item
PCC allows typedef names to be used as function parameters. The
difficulty described immediately above applies here too.
@item
When in @option{-traditional} mode, GCC allows the following erroneous
pair of declarations to appear together in a given scope:
@example
typedef int foo;
typedef foo foo;
@end example
@item
GCC treats all characters of identifiers as significant, even when in
@option{-traditional} mode. According to K&R-1 (2.2), ``No more than the
first eight characters are significant, although more may be used.''.
Also according to K&R-1 (2.2), ``An identifier is a sequence of letters
and digits; the first character must be a letter. The underscore _
counts as a letter.'', but GCC also allows dollar signs in identifiers.
@cindex whitespace
@item
PCC allows whitespace in the middle of compound assignment operators
such as @samp{+=}. GCC, following the ISO standard, does not
allow this. The difficulty described immediately above applies here
too.
@cindex apostrophes
@cindex '
@item
GCC complains about unterminated character constants inside of
preprocessing conditionals that fail. Some programs have English
comments enclosed in conditionals that are guaranteed to fail; if these
comments contain apostrophes, GCC will probably report an error. For
example, this code would produce an error:
@example
#if 0
You can't expect this to work.
#endif
@end example
The best solution to such a problem is to put the text into an actual
C comment delimited by @samp{/*@dots{}*/}. However,
@option{-traditional} suppresses these error messages.
@item
Many user programs contain the declaration @samp{long time ();}. In the
past, the system header files on many systems did not actually declare
@code{time}, so it did not matter what type your program declared it to
return. But in systems with ISO C headers, @code{time} is declared to
return @code{time_t}, and if that is not the same as @code{long}, then
@samp{long time ();} is erroneous.
The solution is to change your program to use appropriate system headers
(@code{<time.h>} on systems with ISO C headers) and not to declare
@code{time} if the system header files declare it, or failing that to
use @code{time_t} as the return type of @code{time}.
@cindex @code{float} as function value type
@item
When compiling functions that return @code{float}, PCC converts it to
a double. GCC actually returns a @code{float}. If you are concerned
with PCC compatibility, you should declare your functions to return
@code{double}; you might as well say what you mean.
@cindex structures
@cindex unions
@item
When compiling functions that return structures or unions, GCC
output code normally uses a method different from that used on most
versions of Unix. As a result, code compiled with GCC cannot call
a structure-returning function compiled with PCC, and vice versa.
The method used by GCC is as follows: a structure or union which is
1, 2, 4 or 8 bytes long is returned like a scalar. A structure or union
with any other size is stored into an address supplied by the caller
(usually in a special, fixed register, but on some machines it is passed
on the stack). The machine-description macros @code{STRUCT_VALUE} and
@code{STRUCT_INCOMING_VALUE} tell GCC where to pass this address.
By contrast, PCC on most target machines returns structures and unions
of any size by copying the data into an area of static storage, and then
returning the address of that storage as if it were a pointer value.
The caller must copy the data from that memory area to the place where
the value is wanted. GCC does not use this method because it is
slower and nonreentrant.
On some newer machines, PCC uses a reentrant convention for all
structure and union returning. GCC on most of these machines uses a
compatible convention when returning structures and unions in memory,
but still returns small structures and unions in registers.
@opindex fpcc-struct-return
You can tell GCC to use a compatible convention for all structure and
union returning with the option @option{-fpcc-struct-return}.
@cindex preprocessing tokens
@cindex preprocessing numbers
@item
GCC complains about program fragments such as @samp{0x74ae-0x4000}
which appear to be two hexadecimal constants separated by the minus
operator. Actually, this string is a single @dfn{preprocessing token}.
Each such token must correspond to one token in C@. Since this does not,
GCC prints an error message. Although it may appear obvious that what
is meant is an operator and two values, the ISO C standard specifically
requires that this be treated as erroneous.
A @dfn{preprocessing token} is a @dfn{preprocessing number} if it
begins with a digit and is followed by letters, underscores, digits,
periods and @samp{e+}, @samp{e-}, @samp{E+}, @samp{E-}, @samp{p+},
@samp{p-}, @samp{P+}, or @samp{P-} character sequences. (In strict C89
mode, the sequences @samp{p+}, @samp{p-}, @samp{P+} and @samp{P-} cannot
appear in preprocessing numbers.)
To make the above program fragment valid, place whitespace in front of
the minus sign. This whitespace will end the preprocessing number.
@end itemize
@node Fixed Headers
@section Fixed Header Files
GCC needs to install corrected versions of some system header files.
This is because most target systems have some header files that won't
work with GCC unless they are changed. Some have bugs, some are
incompatible with ISO C, and some depend on special features of other
compilers.
Installing GCC automatically creates and installs the fixed header
files, by running a program called @code{fixincludes} (or for certain
targets an alternative such as @code{fixinc.svr4}). Normally, you
don't need to pay attention to this. But there are cases where it
doesn't do the right thing automatically.
@itemize @bullet
@item
If you update the system's header files, such as by installing a new
system version, the fixed header files of GCC are not automatically
updated. The easiest way to update them is to reinstall GCC@. (If
you want to be clever, look in the makefile and you can find a
shortcut.)
@item
On some systems, in particular SunOS 4, header file directories contain
machine-specific symbolic links in certain places. This makes it
possible to share most of the header files among hosts running the
same version of SunOS 4 on different machine models.
The programs that fix the header files do not understand this special
way of using symbolic links; therefore, the directory of fixed header
files is good only for the machine model used to build it.
In SunOS 4, only programs that look inside the kernel will notice the
difference between machine models. Therefore, for most purposes, you
need not be concerned about this.
It is possible to make separate sets of fixed header files for the
different machine models, and arrange a structure of symbolic links so
as to use the proper set, but you'll have to do this by hand.
@item
On Lynxos, GCC by default does not fix the header files. This is
because bugs in the shell cause the @code{fixincludes} script to fail.
This means you will encounter problems due to bugs in the system header
files. It may be no comfort that they aren't GCC's fault, but it
does mean that there's nothing for us to do about them.
@end itemize
@node Standard Libraries
@section Standard Libraries
@opindex Wall
GCC by itself attempts to be a conforming freestanding implementation.
@xref{Standards,,Language Standards Supported by GCC}, for details of
what this means. Beyond the library facilities required of such an
implementation, the rest of the C library is supplied by the vendor of
the operating system. If that C library doesn't conform to the C
standards, then your programs might get warnings (especially when using
@option{-Wall}) that you don't expect.
For example, the @code{sprintf} function on SunOS 4.1.3 returns
@code{char *} while the C standard says that @code{sprintf} returns an
@code{int}. The @code{fixincludes} program could make the prototype for
this function match the Standard, but that would be wrong, since the
function will still return @code{char *}.
If you need a Standard compliant library, then you need to find one, as
GCC does not provide one. The GNU C library (called @code{glibc})
provides ISO C, POSIX, BSD, SystemV and X/Open compatibility for
GNU/Linux and HURD-based GNU systems; no recent version of it supports
other systems, though some very old versions did. Version 2.2 of the
GNU C library includes nearly complete C99 support. You could also ask
your operating system vendor if newer libraries are available.
@node Disappointments
@section Disappointments and Misunderstandings
These problems are perhaps regrettable, but we don't know any practical
way around them.
@itemize @bullet
@item
Certain local variables aren't recognized by debuggers when you compile
with optimization.
This occurs because sometimes GCC optimizes the variable out of
existence. There is no way to tell the debugger how to compute the
value such a variable ``would have had'', and it is not clear that would
be desirable anyway. So GCC simply does not mention the eliminated
variable when it writes debugging information.
You have to expect a certain amount of disagreement between the
executable and your source code, when you use optimization.
@cindex conflicting types
@cindex scope of declaration
@item
Users often think it is a bug when GCC reports an error for code
like this:
@example
int foo (struct mumble *);
struct mumble @{ @dots{} @};
int foo (struct mumble *x)
@{ @dots{} @}
@end example
This code really is erroneous, because the scope of @code{struct
mumble} in the prototype is limited to the argument list containing it.
It does not refer to the @code{struct mumble} defined with file scope
immediately below---they are two unrelated types with similar names in
different scopes.
But in the definition of @code{foo}, the file-scope type is used
because that is available to be inherited. Thus, the definition and
the prototype do not match, and you get an error.
This behavior may seem silly, but it's what the ISO standard specifies.
It is easy enough for you to make your code work by moving the
definition of @code{struct mumble} above the prototype. It's not worth
being incompatible with ISO C just to avoid an error for the example
shown above.
@item
Accesses to bit-fields even in volatile objects works by accessing larger
objects, such as a byte or a word. You cannot rely on what size of
object is accessed in order to read or write the bit-field; it may even
vary for a given bit-field according to the precise usage.
If you care about controlling the amount of memory that is accessed, use
volatile but do not use bit-fields.
@item
GCC comes with shell scripts to fix certain known problems in system
header files. They install corrected copies of various header files in
a special directory where only GCC will normally look for them. The
scripts adapt to various systems by searching all the system header
files for the problem cases that we know about.
If new system header files are installed, nothing automatically arranges
to update the corrected header files. You will have to reinstall GCC
to fix the new header files. More specifically, go to the build
directory and delete the files @file{stmp-fixinc} and
@file{stmp-headers}, and the subdirectory @code{include}; then do
@samp{make install} again.
@item
@cindex floating point precision
On 68000 and x86 systems, for instance, you can get paradoxical results
if you test the precise values of floating point numbers. For example,
you can find that a floating point value which is not a NaN is not equal
to itself. This results from the fact that the floating point registers
hold a few more bits of precision than fit in a @code{double} in memory.
Compiled code moves values between memory and floating point registers
at its convenience, and moving them into memory truncates them.
@opindex ffloat-store
You can partially avoid this problem by using the @option{-ffloat-store}
option (@pxref{Optimize Options}).
@item
On the MIPS, variable argument functions using @file{varargs.h}
cannot have a floating point value for the first argument. The
reason for this is that in the absence of a prototype in scope,
if the first argument is a floating point, it is passed in a
floating point register, rather than an integer register.
If the code is rewritten to use the ISO standard @file{stdarg.h}
method of variable arguments, and the prototype is in scope at
the time of the call, everything will work fine.
@item
On the H8/300 and H8/300H, variable argument functions must be
implemented using the ISO standard @file{stdarg.h} method of
variable arguments. Furthermore, calls to functions using @file{stdarg.h}
variable arguments must have a prototype for the called function
in scope at the time of the call.
@end itemize
@node C++ Misunderstandings
@section Common Misunderstandings with GNU C++
@cindex misunderstandings in C++
@cindex surprises in C++
@cindex C++ misunderstandings
C++ is a complex language and an evolving one, and its standard
definition (the ISO C++ standard) was only recently completed. As a
result, your C++ compiler may occasionally surprise you, even when its
behavior is correct. This section discusses some areas that frequently
give rise to questions of this sort.
@menu
* Static Definitions:: Static member declarations are not definitions
* Temporaries:: Temporaries may vanish before you expect
* Copy Assignment:: Copy Assignment operators copy virtual bases twice
@end menu
@node Static Definitions
@subsection Declare @emph{and} Define Static Members
@cindex C++ static data, declaring and defining
@cindex static data in C++, declaring and defining
@cindex declaring static data in C++
@cindex defining static data in C++
When a class has static data members, it is not enough to @emph{declare}
the static member; you must also @emph{define} it. For example:
@example
class Foo
@{
@dots{}
void method();
static int bar;
@};
@end example
This declaration only establishes that the class @code{Foo} has an
@code{int} named @code{Foo::bar}, and a member function named
@code{Foo::method}. But you still need to define @emph{both}
@code{method} and @code{bar} elsewhere. According to the ISO
standard, you must supply an initializer in one (and only one) source
file, such as:
@example
int Foo::bar = 0;
@end example
Other C++ compilers may not correctly implement the standard behavior.
As a result, when you switch to @code{g++} from one of these compilers,
you may discover that a program that appeared to work correctly in fact
does not conform to the standard: @code{g++} reports as undefined
symbols any static data members that lack definitions.
@node Temporaries
@subsection Temporaries May Vanish Before You Expect
@cindex temporaries, lifetime of
@cindex portions of temporary objects, pointers to
It is dangerous to use pointers or references to @emph{portions} of a
temporary object. The compiler may very well delete the object before
you expect it to, leaving a pointer to garbage. The most common place
where this problem crops up is in classes like string classes,
especially ones that define a conversion function to type @code{char *}
or @code{const char *}---which is one reason why the standard
@code{string} class requires you to call the @code{c_str} member
function. However, any class that returns a pointer to some internal
structure is potentially subject to this problem.
For example, a program may use a function @code{strfunc} that returns
@code{string} objects, and another function @code{charfunc} that
operates on pointers to @code{char}:
@example
string strfunc ();
void charfunc (const char *);
void
f ()
@{
const char *p = strfunc().c_str();
@dots{}
charfunc (p);
@dots{}
charfunc (p);
@}
@end example
@noindent
In this situation, it may seem reasonable to save a pointer to the C
string returned by the @code{c_str} member function and use that rather
than call @code{c_str} repeatedly. However, the temporary string
created by the call to @code{strfunc} is destroyed after @code{p} is
initialized, at which point @code{p} is left pointing to freed memory.
Code like this may run successfully under some other compilers,
particularly obsolete cfront-based compilers that delete temporaries
along with normal local variables. However, the GNU C++ behavior is
standard-conforming, so if your program depends on late destruction of
temporaries it is not portable.
The safe way to write such code is to give the temporary a name, which
forces it to remain until the end of the scope of the name. For
example:
@example
string& tmp = strfunc ();
charfunc (tmp.c_str ());
@end example
@node Copy Assignment
@subsection Implicit Copy-Assignment for Virtual Bases
When a base class is virtual, only one subobject of the base class
belongs to each full object. Also, the constructors and destructors are
invoked only once, and called from the most-derived class. However, such
objects behave unspecified when being assigned. For example:
@example
struct Base@{
char *name;
Base(char *n) : name(strdup(n))@{@}
Base& operator= (const Base& other)@{
free (name);
name = strdup (other.name);
@}
@};
struct A:virtual Base@{
int val;
A():Base("A")@{@}
@};
struct B:virtual Base@{
int bval;
B():Base("B")@{@}
@};
struct Derived:public A, public B@{
Derived():Base("Derived")@{@}
@};
void func(Derived &d1, Derived &d2)
@{
d1 = d2;
@}
@end example
The C++ standard specifies that @samp{Base::Base} is only called once
when constructing or copy-constructing a Derived object. It is
unspecified whether @samp{Base::operator=} is called more than once when
the implicit copy-assignment for Derived objects is invoked (as it is
inside @samp{func} in the example).
g++ implements the ``intuitive'' algorithm for copy-assignment: assign all
direct bases, then assign all members. In that algorithm, the virtual
base subobject can be encountered many times. In the example, copying
proceeds in the following order: @samp{val}, @samp{name} (via
@code{strdup}), @samp{bval}, and @samp{name} again.
If application code relies on copy-assignment, a user-defined
copy-assignment operator removes any uncertainties. With such an
operator, the application can define whether and how the virtual base
subobject is assigned.
@node Protoize Caveats
@section Caveats of using @command{protoize}
The conversion programs @command{protoize} and @command{unprotoize} can
sometimes change a source file in a way that won't work unless you
rearrange it.
@itemize @bullet
@item
@command{protoize} can insert references to a type name or type tag before
the definition, or in a file where they are not defined.
If this happens, compiler error messages should show you where the new
references are, so fixing the file by hand is straightforward.
@item
There are some C constructs which @command{protoize} cannot figure out.
For example, it can't determine argument types for declaring a
pointer-to-function variable; this you must do by hand. @command{protoize}
inserts a comment containing @samp{???} each time it finds such a
variable; so you can find all such variables by searching for this
string. ISO C does not require declaring the argument types of
pointer-to-function types.
@item
Using @command{unprotoize} can easily introduce bugs. If the program
relied on prototypes to bring about conversion of arguments, these
conversions will not take place in the program without prototypes.
One case in which you can be sure @command{unprotoize} is safe is when
you are removing prototypes that were made with @command{protoize}; if
the program worked before without any prototypes, it will work again
without them.
@opindex Wconversion
You can find all the places where this problem might occur by compiling
the program with the @option{-Wconversion} option. It prints a warning
whenever an argument is converted.
@item
Both conversion programs can be confused if there are macro calls in and
around the text to be converted. In other words, the standard syntax
for a declaration or definition must not result from expanding a macro.
This problem is inherent in the design of C and cannot be fixed. If
only a few functions have confusing macro calls, you can easily convert
them manually.
@item
@command{protoize} cannot get the argument types for a function whose
definition was not actually compiled due to preprocessing conditionals.
When this happens, @command{protoize} changes nothing in regard to such
a function. @command{protoize} tries to detect such instances and warn
about them.
You can generally work around this problem by using @command{protoize} step
by step, each time specifying a different set of @option{-D} options for
compilation, until all of the functions have been converted. There is
no automatic way to verify that you have got them all, however.
@item
Confusion may result if there is an occasion to convert a function
declaration or definition in a region of source code where there is more
than one formal parameter list present. Thus, attempts to convert code
containing multiple (conditionally compiled) versions of a single
function header (in the same vicinity) may not produce the desired (or
expected) results.
If you plan on converting source files which contain such code, it is
recommended that you first make sure that each conditionally compiled
region of source code which contains an alternative function header also
contains at least one additional follower token (past the final right
parenthesis of the function header). This should circumvent the
problem.
@item
@command{unprotoize} can become confused when trying to convert a function
definition or declaration which contains a declaration for a
pointer-to-function formal argument which has the same name as the
function being defined or declared. We recommend you avoid such choices
of formal parameter names.
@item
You might also want to correct some of the indentation by hand and break
long lines. (The conversion programs don't write lines longer than
eighty characters in any case.)
@end itemize
@node Non-bugs
@section Certain Changes We Don't Want to Make
This section lists changes that people frequently request, but which
we do not make because we think GCC is better without them.
@itemize @bullet
@item
Checking the number and type of arguments to a function which has an
old-fashioned definition and no prototype.
Such a feature would work only occasionally---only for calls that appear
in the same file as the called function, following the definition. The
only way to check all calls reliably is to add a prototype for the
function. But adding a prototype eliminates the motivation for this
feature. So the feature is not worthwhile.
@item
Warning about using an expression whose type is signed as a shift count.
Shift count operands are probably signed more often than unsigned.
Warning about this would cause far more annoyance than good.
@item
Warning about assigning a signed value to an unsigned variable.
Such assignments must be very common; warning about them would cause
more annoyance than good.
@item
Warning when a non-void function value is ignored.
Coming as I do from a Lisp background, I balk at the idea that there is
something dangerous about discarding a value. There are functions that
return values which some callers may find useful; it makes no sense to
clutter the program with a cast to @code{void} whenever the value isn't
useful.
@item
@opindex fshort-enums
Making @option{-fshort-enums} the default.
This would cause storage layout to be incompatible with most other C
compilers. And it doesn't seem very important, given that you can get
the same result in other ways. The case where it matters most is when
the enumeration-valued object is inside a structure, and in that case
you can specify a field width explicitly.
@item
Making bit-fields unsigned by default on particular machines where ``the
ABI standard'' says to do so.
The ISO C standard leaves it up to the implementation whether a bit-field
declared plain @code{int} is signed or not. This in effect creates two
alternative dialects of C@.
@opindex fsigned-bitfields
@opindex funsigned-bitfields
The GNU C compiler supports both dialects; you can specify the signed
dialect with @option{-fsigned-bitfields} and the unsigned dialect with
@option{-funsigned-bitfields}. However, this leaves open the question of
which dialect to use by default.
Currently, the preferred dialect makes plain bit-fields signed, because
this is simplest. Since @code{int} is the same as @code{signed int} in
every other context, it is cleanest for them to be the same in bit-fields
as well.
Some computer manufacturers have published Application Binary Interface
standards which specify that plain bit-fields should be unsigned. It is
a mistake, however, to say anything about this issue in an ABI@. This is
because the handling of plain bit-fields distinguishes two dialects of C@.
Both dialects are meaningful on every type of machine. Whether a
particular object file was compiled using signed bit-fields or unsigned
is of no concern to other object files, even if they access the same
bit-fields in the same data structures.
A given program is written in one or the other of these two dialects.
The program stands a chance to work on most any machine if it is
compiled with the proper dialect. It is unlikely to work at all if
compiled with the wrong dialect.
Many users appreciate the GNU C compiler because it provides an
environment that is uniform across machines. These users would be
inconvenienced if the compiler treated plain bit-fields differently on
certain machines.
Occasionally users write programs intended only for a particular machine
type. On these occasions, the users would benefit if the GNU C compiler
were to support by default the same dialect as the other compilers on
that machine. But such applications are rare. And users writing a
program to run on more than one type of machine cannot possibly benefit
from this kind of compatibility.
This is why GCC does and will treat plain bit-fields in the same
fashion on all types of machines (by default).
There are some arguments for making bit-fields unsigned by default on all
machines. If, for example, this becomes a universal de facto standard,
it would make sense for GCC to go along with it. This is something
to be considered in the future.
(Of course, users strongly concerned about portability should indicate
explicitly in each bit-field whether it is signed or not. In this way,
they write programs which have the same meaning in both C dialects.)
@item
@opindex ansi
@opindex traditional
@opindex std
Undefining @code{__STDC__} when @option{-ansi} is not used.
Currently, GCC defines @code{__STDC__} as long as you don't use
@option{-traditional}. This provides good results in practice.
Programmers normally use conditionals on @code{__STDC__} to ask whether
it is safe to use certain features of ISO C, such as function
prototypes or ISO token concatenation. Since plain @command{gcc} supports
all the features of ISO C, the correct answer to these questions is
``yes''.
Some users try to use @code{__STDC__} to check for the availability of
certain library facilities. This is actually incorrect usage in an ISO
C program, because the ISO C standard says that a conforming
freestanding implementation should define @code{__STDC__} even though it
does not have the library facilities. @samp{gcc -ansi -pedantic} is a
conforming freestanding implementation, and it is therefore required to
define @code{__STDC__}, even though it does not come with an ISO C
library.
Sometimes people say that defining @code{__STDC__} in a compiler that
does not completely conform to the ISO C standard somehow violates the
standard. This is illogical. The standard is a standard for compilers
that claim to support ISO C, such as @samp{gcc -ansi}---not for other
compilers such as plain @command{gcc}. Whatever the ISO C standard says
is relevant to the design of plain @command{gcc} without @option{-ansi} only
for pragmatic reasons, not as a requirement.
GCC normally defines @code{__STDC__} to be 1, and in addition
defines @code{__STRICT_ANSI__} if you specify the @option{-ansi} option,
or a @option{-std} option for strict conformance to some version of ISO C@.
On some hosts, system include files use a different convention, where
@code{__STDC__} is normally 0, but is 1 if the user specifies strict
conformance to the C Standard. GCC follows the host convention when
processing system include files, but when processing user files it follows
the usual GNU C convention.
@item
Undefining @code{__STDC__} in C++.
Programs written to compile with C++-to-C translators get the
value of @code{__STDC__} that goes with the C compiler that is
subsequently used. These programs must test @code{__STDC__}
to determine what kind of C preprocessor that compiler uses:
whether they should concatenate tokens in the ISO C fashion
or in the traditional fashion.
These programs work properly with GNU C++ if @code{__STDC__} is defined.
They would not work otherwise.
In addition, many header files are written to provide prototypes in ISO
C but not in traditional C@. Many of these header files can work without
change in C++ provided @code{__STDC__} is defined. If @code{__STDC__}
is not defined, they will all fail, and will all need to be changed to
test explicitly for C++ as well.
@item
Deleting ``empty'' loops.
Historically, GCC has not deleted ``empty'' loops under the
assumption that the most likely reason you would put one in a program is
to have a delay, so deleting them will not make real programs run any
faster.
However, the rationale here is that optimization of a nonempty loop
cannot produce an empty one, which holds for C but is not always the
case for C++.
@opindex funroll-loops
Moreover, with @option{-funroll-loops} small ``empty'' loops are already
removed, so the current behavior is both sub-optimal and inconsistent
and will change in the future.
@item
Making side effects happen in the same order as in some other compiler.
@cindex side effects, order of evaluation
@cindex order of evaluation, side effects
It is never safe to depend on the order of evaluation of side effects.
For example, a function call like this may very well behave differently
from one compiler to another:
@example
void func (int, int);
int i = 2;
func (i++, i++);
@end example
There is no guarantee (in either the C or the C++ standard language
definitions) that the increments will be evaluated in any particular
order. Either increment might happen first. @code{func} might get the
arguments @samp{2, 3}, or it might get @samp{3, 2}, or even @samp{2, 2}.
@item
Not allowing structures with volatile fields in registers.
Strictly speaking, there is no prohibition in the ISO C standard
against allowing structures with volatile fields in registers, but
it does not seem to make any sense and is probably not what you wanted
to do. So the compiler will give an error message in this case.
@item
Making certain warnings into errors by default.
Some ISO C testsuites report failure when the compiler does not produce
an error message for a certain program.
@opindex pedantic-errors
ISO C requires a ``diagnostic'' message for certain kinds of invalid
programs, but a warning is defined by GCC to count as a diagnostic. If
GCC produces a warning but not an error, that is correct ISO C support.
If test suites call this ``failure'', they should be run with the GCC
option @option{-pedantic-errors}, which will turn these warnings into
errors.
@end itemize
@node Warnings and Errors
@section Warning Messages and Error Messages
@cindex error messages
@cindex warnings vs errors
@cindex messages, warning and error
The GNU compiler can produce two kinds of diagnostics: errors and
warnings. Each kind has a different purpose:
@itemize @w{}
@item
@dfn{Errors} report problems that make it impossible to compile your
program. GCC reports errors with the source file name and line
number where the problem is apparent.
@item
@dfn{Warnings} report other unusual conditions in your code that
@emph{may} indicate a problem, although compilation can (and does)
proceed. Warning messages also report the source file name and line
number, but include the text @samp{warning:} to distinguish them
from error messages.
@end itemize
Warnings may indicate danger points where you should check to make sure
that your program really does what you intend; or the use of obsolete
features; or the use of nonstandard features of GNU C or C++. Many
warnings are issued only if you ask for them, with one of the @option{-W}
options (for instance, @option{-Wall} requests a variety of useful
warnings).
@opindex pedantic
@opindex pedantic-errors
GCC always tries to compile your program if possible; it never
gratuitously rejects a program whose meaning is clear merely because
(for instance) it fails to conform to a standard. In some cases,
however, the C and C++ standards specify that certain extensions are
forbidden, and a diagnostic @emph{must} be issued by a conforming
compiler. The @option{-pedantic} option tells GCC to issue warnings in
such cases; @option{-pedantic-errors} says to make them errors instead.
This does not mean that @emph{all} non-ISO constructs get warnings
or errors.
@xref{Warning Options,,Options to Request or Suppress Warnings}, for
more detail on these and related command-line options.
@node Bugs
@chapter Reporting Bugs
@cindex bugs
@cindex reporting bugs
Your bug reports play an essential role in making GCC reliable.
When you encounter a problem, the first thing to do is to see if it is
already known. @xref{Trouble}. If it isn't known, then you should
report the problem.
Reporting a bug may help you by bringing a solution to your problem, or
it may not. (If it does not, look in the service directory; see
@ref{Service}.) In any case, the principal function of a bug report is
to help the entire community by making the next version of GCC work
better. Bug reports are your contribution to the maintenance of GCC@.
Since the maintainers are very overloaded, we cannot respond to every
bug report. However, if the bug has not been fixed, we are likely to
send you a patch and ask you to tell us whether it works.
In order for a bug report to serve its purpose, you must include the
information that makes for fixing the bug.
@menu
* Criteria: Bug Criteria. Have you really found a bug?
* Where: Bug Lists. Where to send your bug report.
* Reporting: Bug Reporting. How to report a bug effectively.
* GNATS: gccbug. You can use a bug reporting tool.
* Patches: Sending Patches. How to send a patch for GCC.
* Known: Trouble. Known problems.
* Help: Service. Where to ask for help.
@end menu
@node Bug Criteria,Bug Lists,,Bugs
@section Have You Found a Bug?
@cindex bug criteria
If you are not sure whether you have found a bug, here are some guidelines:
@itemize @bullet
@cindex fatal signal
@cindex core dump
@item
If the compiler gets a fatal signal, for any input whatever, that is a
compiler bug. Reliable compilers never crash.
@cindex invalid assembly code
@cindex assembly code, invalid
@item
If the compiler produces invalid assembly code, for any input whatever
(except an @code{asm} statement), that is a compiler bug, unless the
compiler reports errors (not just warnings) which would ordinarily
prevent the assembler from being run.
@cindex undefined behavior
@cindex undefined function value
@cindex increment operators
@item
If the compiler produces valid assembly code that does not correctly
execute the input source code, that is a compiler bug.
However, you must double-check to make sure, because you may have run
into an incompatibility between GNU C and traditional C
(@pxref{Incompatibilities}). These incompatibilities might be considered
bugs, but they are inescapable consequences of valuable features.
Or you may have a program whose behavior is undefined, which happened
by chance to give the desired results with another C or C++ compiler.
For example, in many nonoptimizing compilers, you can write @samp{x;}
at the end of a function instead of @samp{return x;}, with the same
results. But the value of the function is undefined if @code{return}
is omitted; it is not a bug when GCC produces different results.
Problems often result from expressions with two increment operators,
as in @code{f (*p++, *p++)}. Your previous compiler might have
interpreted that expression the way you intended; GCC might
interpret it another way. Neither compiler is wrong. The bug is
in your code.
After you have localized the error to a single source line, it should
be easy to check for these things. If your program is correct and
well defined, you have found a compiler bug.
@item
If the compiler produces an error message for valid input, that is a
compiler bug.
@cindex invalid input
@item
If the compiler does not produce an error message for invalid input,
that is a compiler bug. However, you should note that your idea of
``invalid input'' might be my idea of ``an extension'' or ``support
for traditional practice''.
@item
If you are an experienced user of one of the languages GCC supports, your
suggestions for improvement of GCC are welcome in any case.
@end itemize
@node Bug Lists,Bug Reporting,Bug Criteria,Bugs
@section Where to Report Bugs
@cindex bug report mailing lists
@kindex gcc-bugs@@gcc.gnu.org or bug-gcc@@gnu.org
Send bug reports for the GNU Compiler Collection to
@email{gcc-bugs@@gcc.gnu.org}. In accordance with the GNU-wide
convention, in which bug reports for tool ``foo'' are sent
to @samp{bug-foo@@gnu.org}, the address @email{bug-gcc@@gnu.org}
may also be used; it will forward to the address given above.
Please read @uref{http://gcc.gnu.org/bugs.html} for additional and/or
more up-to-date bug reporting instructions before you post a bug report.
@node Bug Reporting,gccbug,Bug Lists,Bugs
@section How to Report Bugs
@cindex compiler bugs, reporting
The fundamental principle of reporting bugs usefully is this:
@strong{report all the facts}. If you are not sure whether to state a
fact or leave it out, state it!
Often people omit facts because they think they know what causes the
problem and they conclude that some details don't matter. Thus, you might
assume that the name of the variable you use in an example does not matter.
Well, probably it doesn't, but one cannot be sure. Perhaps the bug is a
stray memory reference which happens to fetch from the location where that
name is stored in memory; perhaps, if the name were different, the contents
of that location would fool the compiler into doing the right thing despite
the bug. Play it safe and give a specific, complete example. That is the
easiest thing for you to do, and the most helpful.
Keep in mind that the purpose of a bug report is to enable someone to
fix the bug if it is not known. It isn't very important what happens if
the bug is already known. Therefore, always write your bug reports on
the assumption that the bug is not known.
Sometimes people give a few sketchy facts and ask, ``Does this ring a
bell?'' This cannot help us fix a bug, so it is basically useless. We
respond by asking for enough details to enable us to investigate.
You might as well expedite matters by sending them to begin with.
Try to make your bug report self-contained. If we have to ask you for
more information, it is best if you include all the previous information
in your response, as well as the information that was missing.
Please report each bug in a separate message. This makes it easier for
us to track which bugs have been fixed and to forward your bugs reports
to the appropriate maintainer.
To enable someone to investigate the bug, you should include all these
things:
@itemize @bullet
@item
The version of GCC@. You can get this by running it with the
@option{-v} option.
Without this, we won't know whether there is any point in looking for
the bug in the current version of GCC@.
@item
A complete input file that will reproduce the bug. If the bug is in the
C preprocessor, send a source file and any header files that it
requires. If the bug is in the compiler proper (@file{cc1}), send the
preprocessor output generated by adding @option{-save-temps} to the
compilation command (@pxref{Debugging Options}). When you do this, use
the same @option{-I}, @option{-D} or @option{-U} options that you used in
actual compilation. Then send the @var{input}.i or @var{input}.ii files
generated.
A single statement is not enough of an example. In order to compile it,
it must be embedded in a complete file of compiler input; and the bug
might depend on the details of how this is done.
Without a real example one can compile, all anyone can do about your bug
report is wish you luck. It would be futile to try to guess how to
provoke the bug. For example, bugs in register allocation and reloading
frequently depend on every little detail of the function they happen in.
Even if the input file that fails comes from a GNU program, you should
still send the complete test case. Don't ask the GCC maintainers to
do the extra work of obtaining the program in question---they are all
overworked as it is. Also, the problem may depend on what is in the
header files on your system; it is unreliable for the GCC maintainers
to try the problem with the header files available to them. By sending
CPP output, you can eliminate this source of uncertainty and save us
a certain percentage of wild goose chases.
@item
The command arguments you gave GCC to compile that example
and observe the bug. For example, did you use @option{-O}? To guarantee
you won't omit something important, list all the options.
If we were to try to guess the arguments, we would probably guess wrong
and then we would not encounter the bug.
@item
The type of machine you are using, and the operating system name and
version number.
@item
The operands you gave to the @code{configure} command when you installed
the compiler.
@item
A complete list of any modifications you have made to the compiler
source. (We don't promise to investigate the bug unless it happens in
an unmodified compiler. But if you've made modifications and don't tell
us, then you are sending us on a wild goose chase.)
Be precise about these changes. A description in English is not
enough---send a context diff for them.
Adding files of your own (such as a machine description for a machine we
don't support) is a modification of the compiler source.
@item
Details of any other deviations from the standard procedure for installing
GCC@.
@item
A description of what behavior you observe that you believe is
incorrect. For example, ``The compiler gets a fatal signal,'' or,
``The assembler instruction at line 208 in the output is incorrect.''
Of course, if the bug is that the compiler gets a fatal signal, then one
can't miss it. But if the bug is incorrect output, the maintainer might
not notice unless it is glaringly wrong. None of us has time to study
all the assembler code from a 50-line C program just on the chance that
one instruction might be wrong. We need @emph{you} to do this part!
Even if the problem you experience is a fatal signal, you should still
say so explicitly. Suppose something strange is going on, such as, your
copy of the compiler is out of synch, or you have encountered a bug in
the C library on your system. (This has happened!) Your copy might
crash and the copy here would not. If you @i{said} to expect a crash,
then when the compiler here fails to crash, we would know that the bug
was not happening. If you don't say to expect a crash, then we would
not know whether the bug was happening. We would not be able to draw
any conclusion from our observations.
If the problem is a diagnostic when compiling GCC with some other
compiler, say whether it is a warning or an error.
Often the observed symptom is incorrect output when your program is run.
Sad to say, this is not enough information unless the program is short
and simple. None of us has time to study a large program to figure out
how it would work if compiled correctly, much less which line of it was
compiled wrong. So you will have to do that. Tell us which source line
it is, and what incorrect result happens when that line is executed. A
person who understands the program can find this as easily as finding a
bug in the program itself.
@item
If you send examples of assembler code output from GCC,
please use @option{-g} when you make them. The debugging information
includes source line numbers which are essential for correlating the
output with the input.
@item
If you wish to mention something in the GCC source, refer to it by
context, not by line number.
The line numbers in the development sources don't match those in your
sources. Your line numbers would convey no useful information to the
maintainers.
@item
Additional information from a debugger might enable someone to find a
problem on a machine which he does not have available. However, you
need to think when you collect this information if you want it to have
any chance of being useful.
@cindex backtrace for bug reports
For example, many people send just a backtrace, but that is never
useful by itself. A simple backtrace with arguments conveys little
about GCC because the compiler is largely data-driven; the same
functions are called over and over for different RTL insns, doing
different things depending on the details of the insn.
Most of the arguments listed in the backtrace are useless because they
are pointers to RTL list structure. The numeric values of the
pointers, which the debugger prints in the backtrace, have no
significance whatever; all that matters is the contents of the objects
they point to (and most of the contents are other such pointers).
In addition, most compiler passes consist of one or more loops that
scan the RTL insn sequence. The most vital piece of information about
such a loop---which insn it has reached---is usually in a local variable,
not in an argument.
@findex debug_rtx
What you need to provide in addition to a backtrace are the values of
the local variables for several stack frames up. When a local
variable or an argument is an RTX, first print its value and then use
the GDB command @code{pr} to print the RTL expression that it points
to. (If GDB doesn't run on your machine, use your debugger to call
the function @code{debug_rtx} with the RTX as an argument.) In
general, whenever a variable is a pointer, its value is no use
without the data it points to.
@end itemize
Here are some things that are not necessary:
@itemize @bullet
@item
A description of the envelope of the bug.
Often people who encounter a bug spend a lot of time investigating
which changes to the input file will make the bug go away and which
changes will not affect it.
This is often time consuming and not very useful, because the way we
will find the bug is by running a single example under the debugger with
breakpoints, not by pure deduction from a series of examples. You might
as well save your time for something else.
Of course, if you can find a simpler example to report @emph{instead} of
the original one, that is a convenience. Errors in the output will be
easier to spot, running under the debugger will take less time, etc.
Most GCC bugs involve just one function, so the most straightforward
way to simplify an example is to delete all the function definitions
except the one where the bug occurs. Those earlier in the file may be
replaced by external declarations if the crucial function depends on
them. (Exception: inline functions may affect compilation of functions
defined later in the file.)
However, simplification is not vital; if you don't want to do this,
report the bug anyway and send the entire test case you used.
@item
In particular, some people insert conditionals @samp{#ifdef BUG} around
a statement which, if removed, makes the bug not happen. These are just
clutter; we won't pay any attention to them anyway. Besides, you should
send us cpp output, and that can't have conditionals.
@item
A patch for the bug.
A patch for the bug is useful if it is a good one. But don't omit the
necessary information, such as the test case, on the assumption that a
patch is all we need. We might see problems with your patch and decide
to fix the problem another way, or we might not understand it at all.
Sometimes with a program as complicated as GCC it is very hard to
construct an example that will make the program follow a certain path
through the code. If you don't send the example, we won't be able to
construct one, so we won't be able to verify that the bug is fixed.
And if we can't understand what bug you are trying to fix, or why your
patch should be an improvement, we won't install it. A test case will
help us to understand.
@xref{Sending Patches}, for guidelines on how to make it easy for us to
understand and install your patches.
@item
A guess about what the bug is or what it depends on.
Such guesses are usually wrong. Even I can't guess right about such
things without first using the debugger to find the facts.
@item
A core dump file.
We have no way of examining a core dump for your type of machine
unless we have an identical system---and if we do have one,
we should be able to reproduce the crash ourselves.
@end itemize
@node gccbug,Sending Patches, Bug Reporting, Bugs
@section The gccbug script
@cindex gccbug script
To simplify creation of bug reports, and to allow better tracking of
reports, we use the GNATS bug tracking system. Part of that system is
the @code{gccbug} script. This is a Unix shell script, so you need a
shell to run it. It is normally installed in the same directory where
@code{gcc} is installed.
The gccbug script is derived from send-pr, @pxref{using
send-pr,,Creating new Problem Reports,send-pr,Reporting Problems}. When
invoked, it starts a text editor so you can fill out the various fields
of the report. When the you quit the editor, the report is automatically
send to the bug reporting address.
A number of fields in this bug report form are specific to GCC, and are
explained at @uref{http://gcc.gnu.org/gnats.html}.
@node Sending Patches,, gccbug, Bugs
@section Sending Patches for GCC
If you would like to write bug fixes or improvements for the GNU C
compiler, that is very helpful. Send suggested fixes to the patches
mailing list, @email{gcc-patches@@gcc.gnu.org}.
Please follow these guidelines so we can study your patches efficiently.
If you don't follow these guidelines, your information might still be
useful, but using it will take extra work. Maintaining GCC is a lot
of work in the best of circumstances, and we can't keep up unless you do
your best to help.
@itemize @bullet
@item
Send an explanation with your changes of what problem they fix or what
improvement they bring about. For a bug fix, just include a copy of the
bug report, and explain why the change fixes the bug.
(Referring to a bug report is not as good as including it, because then
we will have to look it up, and we have probably already deleted it if
we've already fixed the bug.)
@item
Always include a proper bug report for the problem you think you have
fixed. We need to convince ourselves that the change is right before
installing it. Even if it is right, we might have trouble judging it if
we don't have a way to reproduce the problem.
@item
Include all the comments that are appropriate to help people reading the
source in the future understand why this change was needed.
@item
Don't mix together changes made for different reasons.
Send them @emph{individually}.
If you make two changes for separate reasons, then we might not want to
install them both. We might want to install just one. If you send them
all jumbled together in a single set of diffs, we have to do extra work
to disentangle them---to figure out which parts of the change serve
which purpose. If we don't have time for this, we might have to ignore
your changes entirely.
If you send each change as soon as you have written it, with its own
explanation, then the two changes never get tangled up, and we can
consider each one properly without any extra work to disentangle them.
Ideally, each change you send should be impossible to subdivide into
parts that we might want to consider separately, because each of its
parts gets its motivation from the other parts.
@item
Send each change as soon as that change is finished. Sometimes people
think they are helping us by accumulating many changes to send them all
together. As explained above, this is absolutely the worst thing you
could do.
Since you should send each change separately, you might as well send it
right away. That gives us the option of installing it immediately if it
is important.
@item
Use @samp{diff -c} to make your diffs. Diffs without context are hard
for us to install reliably. More than that, they make it hard for us to
study the diffs to decide whether we want to install them. Unidiff
format is better than contextless diffs, but not as easy to read as
@option{-c} format.
If you have GNU diff, use @samp{diff -cp}, which shows the name of the
function that each change occurs in.
@item
Write the change log entries for your changes. We get lots of changes,
and we don't have time to do all the change log writing ourselves.
Read the @file{ChangeLog} file to see what sorts of information to put
in, and to learn the style that we use. The purpose of the change log
is to show people where to find what was changed. So you need to be
specific about what functions you changed; in large functions, it's
often helpful to indicate where within the function the change was.
On the other hand, once you have shown people where to find the change,
you need not explain its purpose. Thus, if you add a new function, all
you need to say about it is that it is new. If you feel that the
purpose needs explaining, it probably does---but the explanation will be
much more useful if you put it in comments in the code.
If you would like your name to appear in the header line for who made
the change, send us the header line.
@item
When you write the fix, keep in mind that we can't install a change that
would break other systems.
People often suggest fixing a problem by changing machine-independent
files such as @file{toplev.c} to do something special that a particular
system needs. Sometimes it is totally obvious that such changes would
break GCC for almost all users. We can't possibly make a change like
that. At best it might tell us how to write another patch that would
solve the problem acceptably.
Sometimes people send fixes that @emph{might} be an improvement in
general---but it is hard to be sure of this. It's hard to install
such changes because we have to study them very carefully. Of course,
a good explanation of the reasoning by which you concluded the change
was correct can help convince us.
The safest changes are changes to the configuration files for a
particular machine. These are safe because they can't create new bugs
on other machines.
Please help us keep up with the workload by designing the patch in a
form that is good to install.
@end itemize
@node Service
@chapter How To Get Help with GCC
If you need help installing, using or changing GCC, there are two
ways to find it:
@itemize @bullet
@item
Send a message to a suitable network mailing list. First try
@email{gcc-help@@gcc.gnu.org} (for help installing or using GCC), and if
that brings no response, try @email{gcc@@gcc.gnu.org}. For help
changing GCC, ask @email{gcc@@gcc.gnu.org}. If you think you have found
a bug in GCC, please report it following the instructions at
@pxref{Bug Reporting}.
@item
Look in the service directory for someone who might help you for a fee.
The service directory is found at
@uref{http://www.gnu.org/prep/service.html}.
@end itemize
@c For further information, see
@c @uref{http://gcc.gnu.org/cgi-bin/fom.cgi?file=12}.
@c FIXME: this URL may be too volatile, this FAQ entry needs to move to
@c the regular web pages before we can uncomment the reference.
@node Contributing
@chapter Contributing to GCC Development
If you would like to help pretest GCC releases to assure they work well,
our current development sources are available by CVS (see
@uref{http://gcc.gnu.org/cvs.html}). Source and binary snapshots are
also available for FTP; see @uref{http://gcc.gnu.org/snapshots.html}.
If you would like to work on improvements to GCC, please read
@uref{http://gcc.gnu.org/contribute.html} and
@uref{http://gcc.gnu.org/contributewhy.html} for information on how to
make useful contributions and avoid duplication of effort. Suggested
projects are listed at @uref{http://gcc.gnu.org/projects/}.
@node VMS
@chapter Using GCC on VMS
@c prevent bad page break with this line
Here is how to use GCC on VMS@.
@menu
* Include Files and VMS:: Where the preprocessor looks for the include files.
* Global Declarations:: How to do globaldef, globalref and globalvalue with
GCC.
* VMS Misc:: Misc information.
@end menu
@node Include Files and VMS
@section Include Files and VMS
@cindex include files and VMS
@cindex VMS and include files
@cindex header files and VMS
Due to the differences between the filesystems of Unix and VMS, GCC
attempts to translate file names in @samp{#include} into names that VMS
will understand. The basic strategy is to prepend a prefix to the
specification of the include file, convert the whole filename to a VMS
filename, and then try to open the file. GCC tries various prefixes
one by one until one of them succeeds:
@enumerate
@item
The first prefix is the @samp{GNU_CC_INCLUDE:} logical name: this is
where GNU C header files are traditionally stored. If you wish to store
header files in non-standard locations, then you can assign the logical
@samp{GNU_CC_INCLUDE} to be a search list, where each element of the
list is suitable for use with a rooted logical.
@item
The next prefix tried is @samp{SYS$SYSROOT:[SYSLIB.]}. This is where
VAX-C header files are traditionally stored.
@item
If the include file specification by itself is a valid VMS filename, the
preprocessor then uses this name with no prefix in an attempt to open
the include file.
@item
If the file specification is not a valid VMS filename (i.e.@: does not
contain a device or a directory specifier, and contains a @samp{/}
character), the preprocessor tries to convert it from Unix syntax to
VMS syntax.
Conversion works like this: the first directory name becomes a device,
and the rest of the directories are converted into VMS-format directory
names. For example, the name @file{X11/foobar.h} is
translated to @file{X11:[000000]foobar.h} or @file{X11:foobar.h},
whichever one can be opened. This strategy allows you to assign a
logical name to point to the actual location of the header files.
@item
If none of these strategies succeeds, the @samp{#include} fails.
@end enumerate
Include directives of the form:
@example
#include foobar
@end example
@noindent
are a common source of incompatibility between VAX-C and GCC@. VAX-C
treats this much like a standard @code{#include <foobar.h>} directive.
That is incompatible with the ISO C behavior implemented by GCC: to
expand the name @code{foobar} as a macro. Macro expansion should
eventually yield one of the two standard formats for @code{#include}:
@example
#include "@var{file}"
#include <@var{file}>
@end example
If you have this problem, the best solution is to modify the source to
convert the @code{#include} directives to one of the two standard forms.
That will work with either compiler. If you want a quick and dirty fix,
define the file names as macros with the proper expansion, like this:
@example
#define stdio <stdio.h>
@end example
@noindent
This will work, as long as the name doesn't conflict with anything else
in the program.
Another source of incompatibility is that VAX-C assumes that:
@example
#include "foobar"
@end example
@noindent
is actually asking for the file @file{foobar.h}. GCC does not
make this assumption, and instead takes what you ask for literally;
it tries to read the file @file{foobar}. The best way to avoid this
problem is to always specify the desired file extension in your include
directives.
GCC for VMS is distributed with a set of include files that is
sufficient to compile most general purpose programs. Even though the
GCC distribution does not contain header files to define constants
and structures for some VMS system-specific functions, there is no
reason why you cannot use GCC with any of these functions. You first
may have to generate or create header files, either by using the public
domain utility @code{UNSDL} (which can be found on a DECUS tape), or by
extracting the relevant modules from one of the system macro libraries,
and using an editor to construct a C header file.
A @code{#include} file name cannot contain a DECNET node name. The
preprocessor reports an I/O error if you attempt to use a node name,
whether explicitly, or implicitly via a logical name.
@node Global Declarations
@section Global Declarations and VMS
@findex GLOBALREF
@findex GLOBALDEF
@findex GLOBALVALUEDEF
@findex GLOBALVALUEREF
GCC does not provide the @code{globalref}, @code{globaldef} and
@code{globalvalue} keywords of VAX-C@. You can get the same effect with
an obscure feature of GAS, the GNU assembler. (This requires GAS
version 1.39 or later.) The following macros allow you to use this
feature in a fairly natural way:
@smallexample
#ifdef __GNUC__
#define GLOBALREF(TYPE,NAME) \
TYPE NAME \
asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME)
#define GLOBALDEF(TYPE,NAME,VALUE) \
TYPE NAME \
asm ("_$$PsectAttributes_GLOBALSYMBOL$$" #NAME) \
= VALUE
#define GLOBALVALUEREF(TYPE,NAME) \
const TYPE NAME[1] \
asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME)
#define GLOBALVALUEDEF(TYPE,NAME,VALUE) \
const TYPE NAME[1] \
asm ("_$$PsectAttributes_GLOBALVALUE$$" #NAME) \
= @{VALUE@}
#else
#define GLOBALREF(TYPE,NAME) \
globalref TYPE NAME
#define GLOBALDEF(TYPE,NAME,VALUE) \
globaldef TYPE NAME = VALUE
#define GLOBALVALUEDEF(TYPE,NAME,VALUE) \
globalvalue TYPE NAME = VALUE
#define GLOBALVALUEREF(TYPE,NAME) \
globalvalue TYPE NAME
#endif
@end smallexample
@noindent
(The @code{_$$PsectAttributes_GLOBALSYMBOL} prefix at the start of the
name is removed by the assembler, after it has modified the attributes
of the symbol). These macros are provided in the VMS binaries
distribution in a header file @file{GNU_HACKS.H}. An example of the
usage is:
@example
GLOBALREF (int, ijk);
GLOBALDEF (int, jkl, 0);
@end example
The macros @code{GLOBALREF} and @code{GLOBALDEF} cannot be used
straightforwardly for arrays, since there is no way to insert the array
dimension into the declaration at the right place. However, you can
declare an array with these macros if you first define a typedef for the
array type, like this:
@example
typedef int intvector[10];
GLOBALREF (intvector, foo);
@end example
Array and structure initializers will also break the macros; you can
define the initializer to be a macro of its own, or you can expand the
@code{GLOBALDEF} macro by hand. You may find a case where you wish to
use the @code{GLOBALDEF} macro with a large array, but you are not
interested in explicitly initializing each element of the array. In
such cases you can use an initializer like: @code{@{0,@}}, which will
initialize the entire array to @code{0}.
A shortcoming of this implementation is that a variable declared with
@code{GLOBALVALUEREF} or @code{GLOBALVALUEDEF} is always an array. For
example, the declaration:
@example
GLOBALVALUEREF(int, ijk);
@end example
@noindent
declares the variable @code{ijk} as an array of type @code{int [1]}.
This is done because a globalvalue is actually a constant; its ``value''
is what the linker would normally consider an address. That is not how
an integer value works in C, but it is how an array works. So treating
the symbol as an array name gives consistent results---with the
exception that the value seems to have the wrong type. @strong{Don't
try to access an element of the array.} It doesn't have any elements.
The array ``address'' may not be the address of actual storage.
The fact that the symbol is an array may lead to warnings where the
variable is used. Insert type casts to avoid the warnings. Here is an
example; it takes advantage of the ISO C feature allowing macros that
expand to use the same name as the macro itself.
@example
GLOBALVALUEREF (int, ss$_normal);
GLOBALVALUEDEF (int, xyzzy,123);
#ifdef __GNUC__
#define ss$_normal ((int) ss$_normal)
#define xyzzy ((int) xyzzy)
#endif
@end example
Don't use @code{globaldef} or @code{globalref} with a variable whose
type is an enumeration type; this is not implemented. Instead, make the
variable an integer, and use a @code{globalvaluedef} for each of the
enumeration values. An example of this would be:
@example
#ifdef __GNUC__
GLOBALDEF (int, color, 0);
GLOBALVALUEDEF (int, RED, 0);
GLOBALVALUEDEF (int, BLUE, 1);
GLOBALVALUEDEF (int, GREEN, 3);
#else
enum globaldef color @{RED, BLUE, GREEN = 3@};
#endif
@end example
@node VMS Misc
@section Other VMS Issues
@cindex exit status and VMS
@cindex return value of @code{main}
@cindex @code{main} and the exit status
GCC automatically arranges for @code{main} to return 1 by default if
you fail to specify an explicit return value. This will be interpreted
by VMS as a status code indicating a normal successful completion.
Version 1 of GCC did not provide this default.
GCC on VMS works only with the GNU assembler, GAS@. You need version
1.37 or later of GAS in order to produce value debugging information for
the VMS debugger. Use the ordinary VMS linker with the object files
produced by GAS@.
@cindex shared VMS run time system
@cindex @file{VAXCRTL}
Under previous versions of GCC, the generated code would occasionally
give strange results when linked to the sharable @file{VAXCRTL} library.
Now this should work.
A caveat for use of @code{const} global variables: the @code{const}
modifier must be specified in every external declaration of the variable
in all of the source files that use that variable. Otherwise the linker
will issue warnings about conflicting attributes for the variable. Your
program will still work despite the warnings, but the variable will be
placed in writable storage.
@cindex name augmentation
@cindex case sensitivity and VMS
@cindex VMS and case sensitivity
Although the VMS linker does distinguish between upper and lower case
letters in global symbols, most VMS compilers convert all such symbols
into upper case and most run-time library routines also have upper case
names. To be able to reliably call such routines, GCC (by means of
the assembler GAS) converts global symbols into upper case like other
VMS compilers. However, since the usual practice in C is to distinguish
case, GCC (via GAS) tries to preserve usual C behavior by augmenting
each name that is not all lower case. This means truncating the name
to at most 23 characters and then adding more characters at the end
which encode the case pattern of those 23. Names which contain at
least one dollar sign are an exception; they are converted directly into
upper case without augmentation.
Name augmentation yields bad results for programs that use precompiled
libraries (such as Xlib) which were generated by another compiler. You
can use the compiler option @samp{/NOCASE_HACK} to inhibit augmentation;
it makes external C functions and variables case-independent as is usual
on VMS@. Alternatively, you could write all references to the functions
and variables in such libraries using lower case; this will work on VMS,
but is not portable to other systems. The compiler option @samp{/NAMES}
also provides control over global name handling.
Function and variable names are handled somewhat differently with G++.
The GNU C++ compiler performs @dfn{name mangling} on function
names, which means that it adds information to the function name to
describe the data types of the arguments that the function takes. One
result of this is that the name of a function can become very long.
Since the VMS linker only recognizes the first 31 characters in a name,
special action is taken to ensure that each function and variable has a
unique name that can be represented in 31 characters.
If the name (plus a name augmentation, if required) is less than 32
characters in length, then no special action is performed. If the name
is longer than 31 characters, the assembler (GAS) will generate a
hash string based upon the function name, truncate the function name to
23 characters, and append the hash string to the truncated name. If the
@samp{/VERBOSE} compiler option is used, the assembler will print both
the full and truncated names of each symbol that is truncated.
The @samp{/NOCASE_HACK} compiler option should not be used when you are
compiling programs that use libg++. libg++ has several instances of
objects (i.e. @code{Filebuf} and @code{filebuf}) which become
indistinguishable in a case-insensitive environment. This leads to
cases where you need to inhibit augmentation selectively (if you were
using libg++ and Xlib in the same program, for example). There is no
special feature for doing this, but you can get the result by defining a
macro for each mixed case symbol for which you wish to inhibit
augmentation. The macro should expand into the lower case equivalent of
itself. For example:
@example
#define StuDlyCapS studlycaps
@end example
These macro definitions can be placed in a header file to minimize the
number of changes to your source code.
@node Makefile
@chapter Additional Makefile and configure information.
@section Makefile Targets
@cindex makefile targets
@cindex targets, makefile
@table @code
@item all
This is the default target. Depending on what your build/host/target
configuration is, it coordinates all the things that need to be built.
@item doc
Produce info-formatted documentation. Also, @code{make dvi} is
available for DVI-formatted documentation, and @code{make
generated-manpages} to generate man pages.
@item mostlyclean
Delete the files made while building the compiler.
@item clean
That, and all the other files built by @code{make all}.
@item distclean
That, and all the files created by @code{configure}.
@item extraclean
That, and any temporary or intermediate files, like emacs backup files.
@item maintainer-clean
Distclean plus any file that can be generated from other files. Note
that additional tools may be required beyond what is normally needed to
build gcc.
@item install
Installs gcc.
@item uninstall
Deletes installed files.
@item check
Run the testsuite. This creates a @file{testsuite} subdirectory that
has various @file{.sum} and @file{.log} files containing the results of
the testing. You can run subsets with, for example, @code{make check-gcc}.
You can specify specific tests by setting RUNTESTFLAGS to be the name
of the @file{.exp} file, optionally followed by (for some tests) an equals
and a file wildcard, like:
@example
make check-gcc RUNTESTFLAGS="execute.exp=19980413-*"
@end example
Note that running the testsuite may require additional tools be
installed, such as TCL or dejagnu.
@item bootstrap
Builds gcc three times---once with the native compiler, once with the
native-built compiler it just built, and once with the compiler it built
the second time. In theory, the last two should produce the same
results, which @code{make compare} can check. Each step of this process
is called a ``stage'', and the results of each stage @var{N}
(@var{N} = 1@dots{}3) are copied to a subdirectory @file{stage@var{N}/}.
@item bootstrap-lean
Like @code{bootstrap}, except that the various stages are removed once
they're no longer needed. This saves disk space.
@item bubblestrap
Once bootstrapped, this incrementally rebuilds each of the three stages,
one at a time. It does this by ``bubbling'' the stages up from their
subdirectories, rebuilding them, and copying them back to their
subdirectories. This will allow you to, for example, quickly rebuild a
bootstrapped compiler after changing the sources, without having to do a
full bootstrap.
@item quickstrap
Rebuilds the most recently built stage. Since each stage requires
special invocation, using this target means you don't have to keep track
of which stage you're on or what invocation that stage needs.
@item cleanstrap
Removed everything (@code{make clean}) and rebuilds (@code{make bootstrap}).
@item stage@var{N} (@var{N} = 1@dots{}4)
For each stage, moves the appropriate files to the @file{stage@var{N}}
subdirectory.
@item unstage@var{N} (@var{N} = 1@dots{}4)
Undoes the corresponding @code{stage@var{N}}.
@item restage@var{N} (@var{N} = 1@dots{}4)
Undoes the corresponding @code{stage@var{N}} and rebuilds it with the
appropriate flags.
@item compare
Compares the results of stages 2 and 3. This ensures that the compiler
is running properly, since it should produce the same object files
regardless of how it itself was compiled.
@end table
@section Configure Terms and History
@cindex configure terms
@cindex canadian
This section is not instructions for building GCC. If you are trying to
do a build, you should first read @uref{http://gcc.gnu.org/install/} or
whatever installation instructions came with your source package.
The configure and build process has a long and colorful history, and can
be confusing to anyone who doesn't know why things are the way they are.
While there are other documents which describe the configuration process
in detail, here are a few things that everyone working on GCC should
know.
There are three system names that the build knows about: the machine you
are building on (@dfn{build}), the machine that you are building for
(@dfn{host}), and the machine that GCC will produce code for
(@dfn{target}). When you configure GCC, you specify these with
@option{--build=}, @option{--host=}, and @option{--target=}.
Specifying the host without specifying the build should be avoided, as
@command{configure} may (and once did) assume that the host you specify
is also the build, which may not be true.
If build, host, and target are all the same, this is called a
@dfn{native}. If build and host are the same but target is different,
this is called a @dfn{cross}. If build, host, and target are all
different this is called a @dfn{canadian} (for obscure reasons dealing
with Canada's political party and the background of the person working
on the build at that time). If host and target are the same, but build
is different, you are using a cross-compiler to build a native for a
different system. Some people call this a @dfn{host-x-host},
@dfn{crossed native}, or @dfn{cross-built native}. If build and target
are the same, but host is different, you are using a cross compiler to
build a cross compiler that produces code for the machine you're
building on. This is rare, so there is no common say of describing it
(although I propose calling it a @dfn{crossback}).
If build and host are the same, the GCC you are building will also be
used to build the target libraries (like @code{libstdc++}). If build and host
are different, you must have already build and installed a cross
compiler that will be used to build the target libraries (if you
configured with @option{--target=foo-bar}, this compiler will be called
@command{foo-bar-gcc}).
In the case of target libraries, the machine you're building for is the
machine you specified with @option{--target}. So, build is the machine
you're building on (no change there), host is the machine you're
building for (the target libraries are built for the target, so host is
the target you specified), and target doesn't apply (because you're not
building a compiler, you're building libraries). The configure/make
process will adjust these variables as needed. It also sets
@code{$with_cross_host} to the original @option{--host} value in case you
need it.
Libiberty, for example, is built twice. The first time, host comes from
@option{--host} and the second time host comes from @option{--target}.
Historically, libiberty has not been built for the build machine,
though, which causes some interesting issues with programs used to
generate sources for the build. Fixing this, so that libiberty is built
three times, has long been on the to-do list.
@end ifset
@ifset INTERNALS
@node Portability
@chapter GCC and Portability
@cindex portability
@cindex GCC and portability
The main goal of GCC was to make a good, fast compiler for machines in
the class that the GNU system aims to run on: 32-bit machines that address
8-bit bytes and have several general registers. Elegance, theoretical
power and simplicity are only secondary.
GCC gets most of the information about the target machine from a machine
description which gives an algebraic formula for each of the machine's
instructions. This is a very clean way to describe the target. But when
the compiler needs information that is difficult to express in this
fashion, I have not hesitated to define an ad-hoc parameter to the machine
description. The purpose of portability is to reduce the total work needed
on the compiler; it was not of interest for its own sake.
@cindex endianness
@cindex autoincrement addressing, availability
@findex abort
GCC does not contain machine dependent code, but it does contain code
that depends on machine parameters such as endianness (whether the most
significant byte has the highest or lowest address of the bytes in a word)
and the availability of autoincrement addressing. In the RTL-generation
pass, it is often necessary to have multiple strategies for generating code
for a particular kind of syntax tree, strategies that are usable for different
combinations of parameters. Often I have not tried to address all possible
cases, but only the common ones or only the ones that I have encountered.
As a result, a new target may require additional strategies. You will know
if this happens because the compiler will call @code{abort}. Fortunately,
the new strategies can be added in a machine-independent fashion, and will
affect only the target machines that need them.
@end ifset
@ifset INTERNALS
@node Interface
@chapter Interfacing to GCC Output
@cindex interfacing to GCC output
@cindex run-time conventions
@cindex function call conventions
@cindex conventions, run-time
GCC is normally configured to use the same function calling convention
normally in use on the target system. This is done with the
machine-description macros described (@pxref{Target Macros}).
@cindex unions, returning
@cindex structures, returning
@cindex returning structures and unions
However, returning of structure and union values is done differently on
some target machines. As a result, functions compiled with PCC
returning such types cannot be called from code compiled with GCC,
and vice versa. This does not cause trouble often because few Unix
library routines return structures or unions.
GCC code returns structures and unions that are 1, 2, 4 or 8 bytes
long in the same registers used for @code{int} or @code{double} return
values. (GCC typically allocates variables of such types in
registers also.) Structures and unions of other sizes are returned by
storing them into an address passed by the caller (usually in a
register). The machine-description macros @code{STRUCT_VALUE} and
@code{STRUCT_INCOMING_VALUE} tell GCC where to pass this address.
By contrast, PCC on most target machines returns structures and unions
of any size by copying the data into an area of static storage, and then
returning the address of that storage as if it were a pointer value.
The caller must copy the data from that memory area to the place where
the value is wanted. This is slower than the method used by GCC, and
fails to be reentrant.
On some target machines, such as RISC machines and the 80386, the
standard system convention is to pass to the subroutine the address of
where to return the value. On these machines, GCC has been
configured to be compatible with the standard compiler, when this method
is used. It may not be compatible for structures of 1, 2, 4 or 8 bytes.
@cindex argument passing
@cindex passing arguments
GCC uses the system's standard convention for passing arguments. On
some machines, the first few arguments are passed in registers; in
others, all are passed on the stack. It would be possible to use
registers for argument passing on any machine, and this would probably
result in a significant speedup. But the result would be complete
incompatibility with code that follows the standard convention. So this
change is practical only if you are switching to GCC as the sole C
compiler for the system. We may implement register argument passing on
certain machines once we have a complete GNU system so that we can
compile the libraries with GCC@.
On some machines (particularly the Sparc), certain types of arguments
are passed ``by invisible reference''. This means that the value is
stored in memory, and the address of the memory location is passed to
the subroutine.
@cindex @code{longjmp} and automatic variables
If you use @code{longjmp}, beware of automatic variables. ISO C says that
automatic variables that are not declared @code{volatile} have undefined
values after a @code{longjmp}. And this is all GCC promises to do,
because it is very difficult to restore register variables correctly, and
one of GCC's features is that it can put variables in registers without
your asking it to.
If you want a variable to be unaltered by @code{longjmp}, and you don't
want to write @code{volatile} because old C compilers don't accept it,
just take the address of the variable. If a variable's address is ever
taken, even if just to compute it and ignore it, then the variable cannot
go in a register:
@example
@{
int careful;
&careful;
@dots{}
@}
@end example
@cindex arithmetic libraries
@cindex math libraries
@opindex msoft-float
Code compiled with GCC may call certain library routines. Most of
them handle arithmetic for which there are no instructions. This
includes multiply and divide on some machines, and floating point
operations on any machine for which floating point support is disabled
with @option{-msoft-float}. Some standard parts of the C library, such as
@code{bcopy} or @code{memcpy}, are also called automatically. The usual
function call interface is used for calling the library routines.
Some of these routines can be defined in mostly machine-independent C;
they appear in @file{libgcc2.c}. Others must be hand-written in
assembly language for each processor. Wherever they are defined, they
are compiled into the support library, @file{libgcc.a}, which is
automatically searched when you link programs with GCC@.
@end ifset
@ifset INTERNALS
@node Passes
@chapter Passes and Files of the Compiler
@cindex passes and files of the compiler
@cindex files and passes of the compiler
@cindex compiler passes and files
@cindex top level of compiler
The overall control structure of the compiler is in @file{toplev.c}. This
file is responsible for initialization, decoding arguments, opening and
closing files, and sequencing the passes.
@cindex parsing pass
The parsing pass is invoked only once, to parse the entire input. A
high level tree representation is then generated from the input,
one function at a time. This tree code is then transformed into RTL
intermediate code, and processed. The files involved in transforming
the trees into RTL are @file{expr.c}, @file{expmed.c}, and
@file{stmt.c}.
@c Note, the above files aren't strictly the only files involved. It's
@c all over the place (function.c, final.c,etc). However, those are
@c the files that are supposed to be directly involved, and have
@c their purpose listed as such, so i've only listed them.
The order of trees that are processed, is not
necessarily the same order they are generated from
the input, due to deferred inlining, and other considerations.
@findex rest_of_compilation
@findex rest_of_decl_compilation
Each time the parsing pass reads a complete function definition or
top-level declaration, it calls either the function
@code{rest_of_compilation}, or the function
@code{rest_of_decl_compilation} in @file{toplev.c}, which are
responsible for all further processing necessary, ending with output of
the assembler language. All other compiler passes run, in sequence,
within @code{rest_of_compilation}. When that function returns from
compiling a function definition, the storage used for that function
definition's compilation is entirely freed, unless it is an inline
function, or was deferred for some reason (this can occur in
templates, for example).
@ifset USING
(@pxref{Inline,,An Inline Function is As Fast As a Macro}).
@end ifset
@ifclear USING
(@pxref{Inline,,An Inline Function is As Fast As a Macro,gcc.texi,Using GCC}).
@end ifclear
Here is a list of all the passes of the compiler and their source files.
Also included is a description of where debugging dumps can be requested
with @option{-d} options.
@itemize @bullet
@item
Parsing. This pass reads the entire text of a function definition,
constructing a high level tree representation. (Because of the semantic
analysis that takes place during this pass, it does more than is
formally considered to be parsing.)
The tree representation does not entirely follow C syntax, because it is
intended to support other languages as well.
Language-specific data type analysis is also done in this pass, and every
tree node that represents an expression has a data type attached.
Variables are represented as declaration nodes.
The language-independent source files for parsing are
@file{stor-layout.c}, @file{fold-const.c}, and @file{tree.c}.
There are also header files @file{tree.h} and @file{tree.def}
which define the format of the tree representation.
C Preprocessing, for language front ends, that want or require it, is
performed by cpplib, which is covered in seperate documentation. In
particular, the internals are covered in @xref{Top, ,Cpplib internals, cppinternals, Cpplib Internals}.
@c Avoiding overfull is tricky here.
The source files to parse C are
@file{c-aux-info.c},
@file{c-convert.c},
@file{c-decl.c},
@file{c-errors.c},
@file{c-lang.c},
@file{c-parse.in},
and
@file{c-typeck.c},
along with a header file
@file{c-tree.h}
and some files shared with Objective-C and C++.
The source files for parsing C++ are in @file{cp/}.
They are @file{parse.y},
@file{class.c},
@file{cvt.c}, @file{decl.c}, @file{decl2.c},
@file{except.c},
@file{expr.c}, @file{init.c}, @file{lex.c},
@file{method.c}, @file{ptree.c},
@file{search.c}, @file{spew.c},
@file{semantics.c}, @file{tree.c},
@file{typeck2.c}, and
@file{typeck.c}, along with header files @file{cp-tree.def},
@file{cp-tree.h}, and @file{decl.h}.
The special source files for parsing Objective-C are in @file{objc/}.
They are @file{objc-parse.y}, @file{objc-act.c}, @file{objc-tree.def}, and
@file{objc-act.h}. Certain C-specific files are used for this as
well.
The files
@file{c-common.c},
@file{c-common.def},
@file{c-dump.c},
@file{c-format.c},
@file{c-lex.c},
@file{c-pragma.c},
and
@file{c-semantics.c},
along with header files
@file{c-common.h},
@file{c-dump.h},
@file{c-lex.h},
and
@file{c-pragma.h},
are also used for all of the above languages.
@cindex Tree optimization
@item
Tree optimization. This is the optimization of the tree
representation, before converting into RTL code.
@cindex inline on trees, automatic
Currently, the main optimization performed here is tree-based
inlining.
This is implemented for C++ in @file{cp/optimize.c}. Note that
tree based inlining turns off rtx based inlining (since it's more
powerful, it would be a waste of time to do rtx based inlining in
addition).
The C front end currently does not perform tree based inlining.
@cindex constant folding
@cindex arithmetic simplifications
@cindex simplifications, arithmetic
Constant folding and some arithmetic simplifications are also done
during this pass, on the tree representation.
The routines that perform these tasks are located in @file{fold-const.c}.
@cindex RTL generation
@item
RTL generation. This is the conversion of syntax tree into RTL code.
@cindex target-parameter-dependent code
This is where the bulk of target-parameter-dependent code is found,
since often it is necessary for strategies to apply only when certain
standard kinds of instructions are available. The purpose of named
instruction patterns is to provide this information to the RTL
generation pass.
@cindex tail recursion optimization
Optimization is done in this pass for @code{if}-conditions that are
comparisons, boolean operations or conditional expressions. Tail
recursion is detected at this time also. Decisions are made about how
best to arrange loops and how to output @code{switch} statements.
@c Avoiding overfull is tricky here.
The source files for RTL generation include
@file{stmt.c},
@file{calls.c},
@file{expr.c},
@file{explow.c},
@file{expmed.c},
@file{function.c},
@file{optabs.c}
and @file{emit-rtl.c}.
Also, the file
@file{insn-emit.c}, generated from the machine description by the
program @code{genemit}, is used in this pass. The header file
@file{expr.h} is used for communication within this pass.
@findex genflags
@findex gencodes
The header files @file{insn-flags.h} and @file{insn-codes.h},
generated from the machine description by the programs @code{genflags}
and @code{gencodes}, tell this pass which standard names are available
for use and which patterns correspond to them.
Aside from debugging information output, none of the following passes
refers to the tree structure representation of the function (only
part of which is saved).
@cindex inline on rtx, automatic
The decision of whether the function can and should be expanded inline
in its subsequent callers is made at the end of rtl generation. The
function must meet certain criteria, currently related to the size of
the function and the types and number of parameters it has. Note that
this function may contain loops, recursive calls to itself
(tail-recursive functions can be inlined!), gotos, in short, all
constructs supported by GCC@. The file @file{integrate.c} contains
the code to save a function's rtl for later inlining and to inline that
rtl when the function is called. The header file @file{integrate.h}
is also used for this purpose.
@opindex dr
The option @option{-dr} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.rtl} to
the input file name.
@c Should the exception handling pass be talked about here?
@cindex sibling call optimization
@item
Sibiling call optimization. This pass performs tail recursion
elimination, and tail and sibling call optimizations. The purpose of
these optimizations is to reduce the overhead of function calls,
whenever possible.
The source file of this pass is @file{sibcall.c}
@opindex di
The option @option{-di} causes a debugging dump of the RTL code after
this pass is run. This dump file's name is made by appending
@samp{.sibling} to the input file name.
@cindex jump optimization
@cindex unreachable code
@cindex dead code
@item
Jump optimization. This pass simplifies jumps to the following
instruction, jumps across jumps, and jumps to jumps. It deletes
unreferenced labels and unreachable code, except that unreachable code
that contains a loop is not recognized as unreachable in this pass.
(Such loops are deleted later in the basic block analysis.) It also
converts some code originally written with jumps into sequences of
instructions that directly set values from the results of comparisons,
if the machine has such instructions.
Jump optimization is performed two or three times. The first time is
immediately following RTL generation. The second time is after CSE,
but only if CSE says repeated jump optimization is needed. The
last time is right before the final pass. That time, cross-jumping
and deletion of no-op move instructions are done together with the
optimizations described above.
The source file of this pass is @file{jump.c}.
@opindex dj
The option @option{-dj} causes a debugging dump of the RTL code after
this pass is run for the first time. This dump file's name is made by
appending @samp{.jump} to the input file name.
@cindex register use analysis
@item
Register scan. This pass finds the first and last use of each
register, as a guide for common subexpression elimination. Its source
is in @file{regclass.c}.
@cindex jump threading
@item
@opindex fthread-jumps
Jump threading. This pass detects a condition jump that branches to an
identical or inverse test. Such jumps can be @samp{threaded} through
the second conditional test. The source code for this pass is in
@file{jump.c}. This optimization is only performed if
@option{-fthread-jumps} is enabled.
@cindex SSA optimizations
@cindex Single Static Assignment optimizations
@opindex fssa
@item
Static Single Assignment (SSA) based optimization passes. The
SSA conversion passes (to/from) are turned on by the @option{-fssa}
option (it is also done automatically if you enable an SSA optimization pass).
These passes utilize a form called Static Single Assignment. In SSA form,
each variable (pseudo register) is only set once, giving you def-use
and use-def chains for free, and enabling a lot more optimization
passes to be run in linear time.
Conversion to and from SSA form is handled by functions in
@file{ssa.c}.
@opindex de
The option @option{-de} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.ssa} to
the input file name.
@itemize @bullet
@cindex SSA Conditional Constant Propagation
@cindex Conditional Constant Propagation, SSA based
@cindex conditional constant propagation
@opindex fssa-ccp
@item
SSA Conditional Constant Propagation. Turned on by the @option{-fssa-ccp}
SSA Aggressive Dead Code Elimination. Turned on by the @option{-fssa-dce}
option. This pass performs conditional constant propagation to simplify
instructions including conditional branches. This pass is more aggressive
than the constant propgation done by the CSE and GCSE pases, but operates
in linear time.
@opindex dW
The option @option{-dW} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.ssaccp} to
the input file name.
@cindex SSA DCE
@cindex DCE, SSA based
@cindex dead code elimination
@opindex fssa-dce
@item
SSA Aggressive Dead Code Elimination. Turned on by the @option{-fssa-dce}
option. This pass performs elimination of code considered unnecessary because
it has no externally visible effects on the program. It operates in
linear time.
@opindex dX
The option @option{-dX} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.ssadce} to
the input file name.
@end itemize
@cindex common subexpression elimination
@cindex constant propagation
@item
Common subexpression elimination. This pass also does constant
propagation. Its source files are @file{cse.c}, and @file{cselib.c}.
If constant propagation causes conditional jumps to become
unconditional or to become no-ops, jump optimization is run again when
CSE is finished.
@opindex ds
The option @option{-ds} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.cse} to
the input file name.
@cindex global common subexpression elimination
@cindex constant propagation
@cindex copy propagation
@item
Global common subexpression elimination. This pass performs two
different types of GCSE depending on whether you are optimizing for
size or not (LCM based GCSE tends to increase code size for a gain in
speed, while Morel-Renvoise based GCSE does not).
When optimizing for size, GCSE is done using Morel-Renvoise Partial
Redundancy Elimination, with the exception that it does not try to move
invariants out of loops---that is left to the loop optimization pass.
If MR PRE GCSE is done, code hoisting (aka unification) is also done, as
well as load motion.
If you are optimizing for speed, LCM (lazy code motion) based GCSE is
done. LCM is based on the work of Knoop, Ruthing, and Steffen. LCM
based GCSE also does loop invariant code motion. We also perform load
and store motion when optimizing for speed.
Regardless of which type of GCSE is used, the GCSE pass also performs
global constant and copy propagation.
The source file for this pass is @file{gcse.c}, and the LCM routines
are in @file{lcm.c}.
@opindex dG
The option @option{-dG} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.gcse} to
the input file name.
@cindex loop optimization
@cindex code motion
@cindex strength-reduction
@item
Loop optimization. This pass moves constant expressions out of loops,
and optionally does strength-reduction and loop unrolling as well.
Its source files are @file{loop.c} and @file{unroll.c}, plus the header
@file{loop.h} used for communication between them. Loop unrolling uses
some functions in @file{integrate.c} and the header @file{integrate.h}.
Loop dependency analysis routines are contained in @file{dependence.c}.
@opindex dL
The option @option{-dL} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.loop} to
the input file name.
@item
@opindex frerun-cse-after-loop
If @option{-frerun-cse-after-loop} was enabled, a second common
subexpression elimination pass is performed after the loop optimization
pass. Jump threading is also done again at this time if it was specified.
@opindex dt
The option @option{-dt} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.cse2} to
the input file name.
@cindex data flow analysis
@cindex analysis, data flow
@cindex basic blocks
@item
Data flow analysis (@file{flow.c}). This pass divides the program
into basic blocks (and in the process deletes unreachable loops); then
it computes which pseudo-registers are live at each point in the
program, and makes the first instruction that uses a value point at
the instruction that computed the value.
@cindex autoincrement/decrement analysis
This pass also deletes computations whose results are never used, and
combines memory references with add or subtract instructions to make
autoincrement or autodecrement addressing.
@opindex df
The option @option{-df} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.flow} to
the input file name. If stupid register allocation is in use, this
dump file reflects the full results of such allocation.
@cindex instruction combination
@item
Instruction combination (@file{combine.c}). This pass attempts to
combine groups of two or three instructions that are related by data
flow into single instructions. It combines the RTL expressions for
the instructions by substitution, simplifies the result using algebra,
and then attempts to match the result against the machine description.
@opindex dc
The option @option{-dc} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.combine}
to the input file name.
@cindex if conversion
@item
If-conversion is a transformation that transforms control dependencies
into data dependencies (IE it transforms conditional code into a
single control stream).
It is implemented in the file @file{ifcvt.c}.
@opindex dE
The option @option{-dE} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.ce} to
the input file name.
@cindex register movement
@item
Register movement (@file{regmove.c}). This pass looks for cases where
matching constraints would force an instruction to need a reload, and
this reload would be a register to register move. It then attempts
to change the registers used by the instruction to avoid the move
instruction.
@opindex dN
The option @option{-dN} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.regmove}
to the input file name.
@cindex instruction scheduling
@cindex scheduling, instruction
@item
Instruction scheduling (@file{sched.c}). This pass looks for
instructions whose output will not be available by the time that it is
used in subsequent instructions. (Memory loads and floating point
instructions often have this behavior on RISC machines). It re-orders
instructions within a basic block to try to separate the definition and
use of items that otherwise would cause pipeline stalls.
Instruction scheduling is performed twice. The first time is immediately
after instruction combination and the second is immediately after reload.
@opindex dS
The option @option{-dS} causes a debugging dump of the RTL code after this
pass is run for the first time. The dump file's name is made by
appending @samp{.sched} to the input file name.
@cindex register class preference pass
@item
Register class preferencing. The RTL code is scanned to find out
which register class is best for each pseudo register. The source
file is @file{regclass.c}.
@cindex register allocation
@cindex local register allocation
@item
Local register allocation (@file{local-alloc.c}). This pass allocates
hard registers to pseudo registers that are used only within one basic
block. Because the basic block is linear, it can use fast and
powerful techniques to do a very good job.
@opindex dl
The option @option{-dl} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.lreg} to
the input file name.
@cindex global register allocation
@item
Global register allocation (@file{global.c}). This pass
allocates hard registers for the remaining pseudo registers (those
whose life spans are not contained in one basic block).
@cindex reloading
@item
Reloading. This pass renumbers pseudo registers with the hardware
registers numbers they were allocated. Pseudo registers that did not
get hard registers are replaced with stack slots. Then it finds
instructions that are invalid because a value has failed to end up in
a register, or has ended up in a register of the wrong kind. It fixes
up these instructions by reloading the problematical values
temporarily into registers. Additional instructions are generated to
do the copying.
The reload pass also optionally eliminates the frame pointer and inserts
instructions to save and restore call-clobbered registers around calls.
Source files are @file{reload.c} and @file{reload1.c}, plus the header
@file{reload.h} used for communication between them.
@opindex dg
The option @option{-dg} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.greg} to
the input file name.
@cindex instruction scheduling
@cindex scheduling, instruction
@item
Instruction scheduling is repeated here to try to avoid pipeline stalls
due to memory loads generated for spilled pseudo registers.
@opindex dR
The option @option{-dR} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.sched2}
to the input file name.
@cindex basic block reordering
@cindex reordering, block
@item
Basic block reordering. This pass implements profile guided code
positioning. If profile information is not available, various types of
static analysis are performed to make the predictions normally coming
from the profile feedback (IE execution frequency, branch probability,
etc). It is implemented in the file @file{bb-reorder.c}, and the
various prediction routines are in @file{predict.c}.
@opindex dB
The option @option{-dB} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.bbro} to
the input file name.
@cindex cross-jumping
@cindex no-op move instructions
@item
Jump optimization is repeated, this time including cross-jumping
and deletion of no-op move instructions.
@opindex dJ
The option @option{-dJ} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.jump2}
to the input file name.
@cindex delayed branch scheduling
@cindex scheduling, delayed branch
@item
Delayed branch scheduling. This optional pass attempts to find
instructions that can go into the delay slots of other instructions,
usually jumps and calls. The source file name is @file{reorg.c}.
@opindex dd
The option @option{-dd} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.dbr}
to the input file name.
@cindex branch shortening
@item
Branch shortening. On many RISC machines, branch instructions have a
limited range. Thus, longer sequences of instructions must be used for
long branches. In this pass, the compiler figures out what how far each
instruction will be from each other instruction, and therefore whether
the usual instructions, or the longer sequences, must be used for each
branch.
@cindex register-to-stack conversion
@item
Conversion from usage of some hard registers to usage of a register
stack may be done at this point. Currently, this is supported only
for the floating-point registers of the Intel 80387 coprocessor. The
source file name is @file{reg-stack.c}.
@opindex dk
The options @option{-dk} causes a debugging dump of the RTL code after
this pass. This dump file's name is made by appending @samp{.stack}
to the input file name.
@cindex final pass
@cindex peephole optimization
@item
Final. This pass outputs the assembler code for the function. It is
also responsible for identifying spurious test and compare
instructions. Machine-specific peephole optimizations are performed
at the same time. The function entry and exit sequences are generated
directly as assembler code in this pass; they never exist as RTL@.
The source files are @file{final.c} plus @file{insn-output.c}; the
latter is generated automatically from the machine description by the
tool @file{genoutput}. The header file @file{conditions.h} is used
for communication between these files.
@cindex debugging information generation
@item
Debugging information output. This is run after final because it must
output the stack slot offsets for pseudo registers that did not get
hard registers. Source files are @file{dbxout.c} for DBX symbol table
format, @file{sdbout.c} for SDB symbol table format, @file{dwarfout.c}
for DWARF symbol table format, and the files @file{dwarf2out.c} and
@file{dwarf2asm.c} for DWARF2 symbol table format.
@end itemize
Some additional files are used by all or many passes:
@itemize @bullet
@item
Every pass uses @file{machmode.def} and @file{machmode.h} which define
the machine modes.
@item
Several passes use @file{real.h}, which defines the default
representation of floating point constants and how to operate on them.
@item
All the passes that work with RTL use the header files @file{rtl.h}
and @file{rtl.def}, and subroutines in file @file{rtl.c}. The tools
@code{gen*} also use these files to read and work with the machine
description RTL@.
@item
All the tools that read the machine description use support routines
found in @file{gensupport.c}, @file{errors.c}, and @file{read-rtl.c}.
@findex genconfig
@item
Several passes refer to the header file @file{insn-config.h} which
contains a few parameters (C macro definitions) generated
automatically from the machine description RTL by the tool
@code{genconfig}.
@cindex instruction recognizer
@item
Several passes use the instruction recognizer, which consists of
@file{recog.c} and @file{recog.h}, plus the files @file{insn-recog.c}
and @file{insn-extract.c} that are generated automatically from the
machine description by the tools @file{genrecog} and
@file{genextract}.
@item
Several passes use the header files @file{regs.h} which defines the
information recorded about pseudo register usage, and @file{basic-block.h}
which defines the information recorded about basic blocks.
@item
@file{hard-reg-set.h} defines the type @code{HARD_REG_SET}, a bit-vector
with a bit for each hard register, and some macros to manipulate it.
This type is just @code{int} if the machine has few enough hard registers;
otherwise it is an array of @code{int} and some of the macros expand
into loops.
@item
Several passes use instruction attributes. A definition of the
attributes defined for a particular machine is in file
@file{insn-attr.h}, which is generated from the machine description by
the program @file{genattr}. The file @file{insn-attrtab.c} contains
subroutines to obtain the attribute values for insns. It is generated
from the machine description by the program @file{genattrtab}.
@end itemize
@end ifset
@ifset INTERNALS
@include c-tree.texi
@include rtl.texi
@include md.texi
@include tm.texi
@end ifset
@ifset INTERNALS
@node Config
@chapter The Configuration File
@cindex configuration file
@cindex @file{xm-@var{machine}.h}
The configuration file @file{xm-@var{machine}.h} contains macro
definitions that describe the machine and system on which the compiler
is running, unlike the definitions in @file{@var{machine}.h}, which
describe the machine for which the compiler is producing output. Most
of the values in @file{xm-@var{machine}.h} are actually the same on all
machines that GCC runs on, so large parts of all configuration files
are identical. But there are some macros that vary:
@table @code
@findex USG
@item USG
Define this macro if the host system is System V@.
@findex VMS
@item VMS
Define this macro if the host system is VMS@.
@findex FATAL_EXIT_CODE
@item FATAL_EXIT_CODE
A C expression for the status code to be returned when the compiler
exits after serious errors. The default is the system-provided macro
@samp{EXIT_FAILURE}, or @samp{1} if the system doesn't define that
macro. Define this macro only if these defaults are incorrect.
@findex SUCCESS_EXIT_CODE
@item SUCCESS_EXIT_CODE
A C expression for the status code to be returned when the compiler
exits without serious errors. (Warnings are not serious errors.) The
default is the system-provided macro @samp{EXIT_SUCCESS}, or @samp{0} if
the system doesn't define that macro. Define this macro only if these
defaults are incorrect.
@findex HOST_WORDS_BIG_ENDIAN
@item HOST_WORDS_BIG_ENDIAN
Defined if the host machine stores words of multi-word values in
big-endian order. (GCC does not depend on the host byte ordering
within a word.)
@findex HOST_FLOAT_WORDS_BIG_ENDIAN
@item HOST_FLOAT_WORDS_BIG_ENDIAN
Define this macro to be 1 if the host machine stores @code{DFmode},
@code{XFmode} or @code{TFmode} floating point numbers in memory with the
word containing the sign bit at the lowest address; otherwise, define it
to be zero.
This macro need not be defined if the ordering is the same as for
multi-word integers.
@findex HOST_FLOAT_FORMAT
@item HOST_FLOAT_FORMAT
A numeric code distinguishing the floating point format for the host
machine. See @code{TARGET_FLOAT_FORMAT} in @ref{Storage Layout} for the
alternatives and default.
@findex HOST_BITS_PER_CHAR
@item HOST_BITS_PER_CHAR
A C expression for the number of bits in @code{char} on the host
machine.
@findex HOST_BITS_PER_SHORT
@item HOST_BITS_PER_SHORT
A C expression for the number of bits in @code{short} on the host
machine.
@findex HOST_BITS_PER_INT
@item HOST_BITS_PER_INT
A C expression for the number of bits in @code{int} on the host
machine.
@findex HOST_BITS_PER_LONG
@item HOST_BITS_PER_LONG
A C expression for the number of bits in @code{long} on the host
machine.
@findex HOST_BITS_PER_LONGLONG
@item HOST_BITS_PER_LONGLONG
A C expression for the number of bits in @code{long long} on the host
machine.
@findex ONLY_INT_FIELDS
@item ONLY_INT_FIELDS
Define this macro to indicate that the host compiler only supports
@code{int} bit-fields, rather than other integral types, including
@code{enum}, as do most C compilers.
@findex OBSTACK_CHUNK_SIZE
@item OBSTACK_CHUNK_SIZE
A C expression for the size of ordinary obstack chunks.
If you don't define this, a usually-reasonable default is used.
@findex OBSTACK_CHUNK_ALLOC
@item OBSTACK_CHUNK_ALLOC
The function used to allocate obstack chunks.
If you don't define this, @code{xmalloc} is used.
@findex OBSTACK_CHUNK_FREE
@item OBSTACK_CHUNK_FREE
The function used to free obstack chunks.
If you don't define this, @code{free} is used.
@findex USE_C_ALLOCA
@item USE_C_ALLOCA
Define this macro to indicate that the compiler is running with the
@code{alloca} implemented in C@. This version of @code{alloca} can be
found in the file @file{alloca.c}; to use it, you must also alter the
@file{Makefile} variable @code{ALLOCA}. (This is done automatically
for the systems on which we know it is needed.)
If you do define this macro, you should probably do it as follows:
@example
#ifndef __GNUC__
#define USE_C_ALLOCA
#else
#define alloca __builtin_alloca
#endif
@end example
@noindent
so that when the compiler is compiled with GCC it uses the more
efficient built-in @code{alloca} function.
@item FUNCTION_CONVERSION_BUG
@findex FUNCTION_CONVERSION_BUG
Define this macro to indicate that the host compiler does not properly
handle converting a function value to a pointer-to-function when it is
used in an expression.
@findex MULTIBYTE_CHARS
@item MULTIBYTE_CHARS
Define this macro to enable support for multibyte characters in the
input to GCC@. This requires that the host system support the ISO C
library functions for converting multibyte characters to wide
characters.
@findex POSIX
@item POSIX
Define this if your system is POSIX.1 compliant.
@findex PATH_SEPARATOR
@item PATH_SEPARATOR
Define this macro to be a C character constant representing the
character used to separate components in paths. The default value is
the colon character
@findex DIR_SEPARATOR
@item DIR_SEPARATOR
If your system uses some character other than slash to separate
directory names within a file specification, define this macro to be a C
character constant specifying that character. When GCC displays file
names, the character you specify will be used. GCC will test for
both slash and the character you specify when parsing filenames.
@findex DIR_SEPARATOR_2
@item DIR_SEPARATOR_2
If your system uses an alternative character other than
@samp{DIR_SEPARATOR} to separate directory names within a file
specification, define this macro to be a C character constant specifying
that character. If you define this macro, GCC will test for slash,
@samp{DIR_SEPARATOR}, and @samp{DIR_SEPARATOR_2} when parsing filenames.
@findex TARGET_OBJECT_SUFFIX
@item TARGET_OBJECT_SUFFIX
Define this macro to be a C string representing the suffix for object
files on your target machine. If you do not define this macro, GCC will
use @samp{.o} as the suffix for object files.
@findex TARGET_EXECUTABLE_SUFFIX
@item TARGET_EXECUTABLE_SUFFIX
Define this macro to be a C string representing the suffix to be
automatically added to executable files on your target machine. If you
do not define this macro, GCC will use the null string as the suffix for
executable files.
@findex HOST_OBJECT_SUFFIX
@item HOST_OBJECT_SUFFIX
Define this macro to be a C string representing the suffix for object
files on your host machine (@samp{xm-*.h}). If you do not define this
macro, GCC will use @samp{.o} as the suffix for object files.
@findex HOST_EXECUTABLE_SUFFIX
@item HOST_EXECUTABLE_SUFFIX
Define this macro to be a C string representing the suffix for
executable files on your host machine (@samp{xm-*.h}). If you do not
define this macro, GCC will use the null string as the suffix for
executable files.
@findex HOST_BIT_BUCKET
@item HOST_BIT_BUCKET
The name of a file or file-like object on the host system which acts as
a ``bit bucket''. If you do not define this macro, GCC will use
@samp{/dev/null} as the bit bucket. If the target does not support a
bit bucket, this should be defined to the null string, or some other
illegal filename. If the bit bucket is not writable, GCC will use a
temporary file instead.
@findex COLLECT_EXPORT_LIST
@item COLLECT_EXPORT_LIST
If defined, @code{collect2} will scan the individual object files
specified on its command line and create an export list for the linker.
Define this macro for systems like AIX, where the linker discards
object files that are not referenced from @code{main} and uses export
lists.
@findex COLLECT2_HOST_INITIALIZATION
@item COLLECT2_HOST_INITIALIZATION
If defined, a C statement (sans semicolon) that performs host-dependent
initialization when @code{collect2} is being initialized.
@findex GCC_DRIVER_HOST_INITIALIZATION
@item GCC_DRIVER_HOST_INITIALIZATION
If defined, a C statement (sans semicolon) that performs host-dependent
initialization when a compilation driver is being initialized.
@findex UPDATE_PATH_HOST_CANONICALIZE
@item UPDATE_PATH_HOST_CANONICALIZE (@var{path}, @var{key})
If defined, a C statement (sans semicolon) that performs host-dependent
canonicalization when a path used in a compilation driver or preprocessor is
canonicalized. @var{path} is the path to be canonicalized, and @var{key} is
a translation prefix when its value isn't @code{NULL}. If the C statement
does canonicalize @var{path}, the new path should be returned.
@end table
@findex bzero
@findex bcmp
In addition, configuration files for system V define @code{bcopy},
@code{bzero} and @code{bcmp} as aliases. Some files define @code{alloca}
as a macro when compiled with GCC, in order to take advantage of the
benefit of GCC's built-in @code{alloca}.
@node Fragments
@chapter Makefile Fragments
@cindex makefile fragment
When you configure GCC using the @file{configure} script
(@pxref{Installation}), it will construct the file @file{Makefile} from
the template file @file{Makefile.in}. When it does this, it will
incorporate makefile fragment files from the @file{config} directory,
named @file{t-@var{target}} and @file{x-@var{host}}. If these files do
not exist, it means nothing needs to be added for a given target or
host.
@menu
* Target Fragment:: Writing the @file{t-@var{target}} file.
* Host Fragment:: Writing the @file{x-@var{host}} file.
@end menu
@node Target Fragment
@section The Target Makefile Fragment
@cindex target makefile fragment
@cindex @file{t-@var{target}}
The target makefile fragment, @file{t-@var{target}}, defines special
target dependent variables and targets used in the @file{Makefile}:
@table @code
@findex LIBGCC2_CFLAGS
@item LIBGCC2_CFLAGS
Compiler flags to use when compiling @file{libgcc2.c}.
@findex LIB2FUNCS_EXTRA
@item LIB2FUNCS_EXTRA
A list of source file names to be compiled or assembled and inserted
into @file{libgcc.a}.
@findex Floating Point Emulation
@item Floating Point Emulation
To have GCC include software floating point libraries in @file{libgcc.a}
define @code{FPBIT} and @code{DPBIT} along with a few rules as follows:
@smallexample
# We want fine grained libraries, so use the new code
# to build the floating point emulation libraries.
FPBIT = fp-bit.c
DPBIT = dp-bit.c
fp-bit.c: $(srcdir)/config/fp-bit.c
echo '#define FLOAT' > fp-bit.c
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
dp-bit.c: $(srcdir)/config/fp-bit.c
cat $(srcdir)/config/fp-bit.c > dp-bit.c
@end smallexample
You may need to provide additional #defines at the beginning of @file{fp-bit.c}
and @file{dp-bit.c} to control target endianness and other options.
@findex CRTSTUFF_T_CFLAGS
@item CRTSTUFF_T_CFLAGS
Special flags used when compiling @file{crtstuff.c}.
@xref{Initialization}.
@findex CRTSTUFF_T_CFLAGS_S
@item CRTSTUFF_T_CFLAGS_S
Special flags used when compiling @file{crtstuff.c} for shared
linking. Used if you use @file{crtbeginS.o} and @file{crtendS.o}
in @code{EXTRA-PARTS}.
@xref{Initialization}.
@findex MULTILIB_OPTIONS
@item MULTILIB_OPTIONS
For some targets, invoking GCC in different ways produces objects
that can not be linked together. For example, for some targets GCC
produces both big and little endian code. For these targets, you must
arrange for multiple versions of @file{libgcc.a} to be compiled, one for
each set of incompatible options. When GCC invokes the linker, it
arranges to link in the right version of @file{libgcc.a}, based on
the command line options used.
The @code{MULTILIB_OPTIONS} macro lists the set of options for which
special versions of @file{libgcc.a} must be built. Write options that
are mutually incompatible side by side, separated by a slash. Write
options that may be used together separated by a space. The build
procedure will build all combinations of compatible options.
For example, if you set @code{MULTILIB_OPTIONS} to @samp{m68000/m68020
msoft-float}, @file{Makefile} will build special versions of
@file{libgcc.a} using the following sets of options: @option{-m68000},
@option{-m68020}, @option{-msoft-float}, @samp{-m68000 -msoft-float}, and
@samp{-m68020 -msoft-float}.
@findex MULTILIB_DIRNAMES
@item MULTILIB_DIRNAMES
If @code{MULTILIB_OPTIONS} is used, this variable specifies the
directory names that should be used to hold the various libraries.
Write one element in @code{MULTILIB_DIRNAMES} for each element in
@code{MULTILIB_OPTIONS}. If @code{MULTILIB_DIRNAMES} is not used, the
default value will be @code{MULTILIB_OPTIONS}, with all slashes treated
as spaces.
For example, if @code{MULTILIB_OPTIONS} is set to @samp{m68000/m68020
msoft-float}, then the default value of @code{MULTILIB_DIRNAMES} is
@samp{m68000 m68020 msoft-float}. You may specify a different value if
you desire a different set of directory names.
@findex MULTILIB_MATCHES
@item MULTILIB_MATCHES
Sometimes the same option may be written in two different ways. If an
option is listed in @code{MULTILIB_OPTIONS}, GCC needs to know about
any synonyms. In that case, set @code{MULTILIB_MATCHES} to a list of
items of the form @samp{option=option} to describe all relevant
synonyms. For example, @samp{m68000=mc68000 m68020=mc68020}.
@findex MULTILIB_EXCEPTIONS
@item MULTILIB_EXCEPTIONS
Sometimes when there are multiple sets of @code{MULTILIB_OPTIONS} being
specified, there are combinations that should not be built. In that
case, set @code{MULTILIB_EXCEPTIONS} to be all of the switch exceptions
in shell case syntax that should not be built.
For example, in the PowerPC embedded ABI support, it is not desirable
to build libraries compiled with the @option{-mcall-aix} option
and either of the @option{-fleading-underscore} or @option{-mlittle} options
at the same time. Therefore @code{MULTILIB_EXCEPTIONS} is set to
@code{*mcall-aix/*fleading-underscore* *mlittle/*mcall-aix*}.
@findex MULTILIB_EXTRA_OPTS
@item MULTILIB_EXTRA_OPTS
Sometimes it is desirable that when building multiple versions of
@file{libgcc.a} certain options should always be passed on to the
compiler. In that case, set @code{MULTILIB_EXTRA_OPTS} to be the list
of options to be used for all builds.
@end table
@node Host Fragment
@section The Host Makefile Fragment
@cindex host makefile fragment
@cindex @file{x-@var{host}}
The host makefile fragment, @file{x-@var{host}}, defines special host
dependent variables and targets used in the @file{Makefile}:
@table @code
@findex CC
@item CC
The compiler to use when building the first stage.
@findex INSTALL
@item INSTALL
The install program to use.
@end table
@end ifset
@include funding.texi
@node GNU/Linux
@unnumbered Linux and the GNU Project
Many computer users run a modified version of the GNU system every
day, without realizing it. Through a peculiar turn of events, the
version of GNU which is widely used today is more often known as
``Linux'', and many users are not aware of the extent of its
connection with the GNU Project.
There really is a Linux; it is a kernel, and these people are using
it. But you can't use a kernel by itself; a kernel is useful only as
part of a whole system. The system in which Linux is typically used
is a modified variant of the GNU system---in other words, a Linux-based
GNU system.
Many users are not fully aware of the distinction between the kernel,
which is Linux, and the whole system, which they also call ``Linux''.
The ambiguous use of the name doesn't promote understanding.
Programmers generally know that Linux is a kernel. But since they
have generally heard the whole system called ``Linux'' as well, they
often envisage a history which fits that name. For example, many
believe that once Linus Torvalds finished writing the kernel, his
friends looked around for other free software, and for no particular
reason most everything necessary to make a Unix-like system was
already available.
What they found was no accident---it was the GNU system. The available
free software added up to a complete system because the GNU Project
had been working since 1984 to make one. The GNU Manifesto
had set forth the goal of developing a free Unix-like system, called
GNU@. By the time Linux was written, the system was almost finished.
Most free software projects have the goal of developing a particular
program for a particular job. For example, Linus Torvalds set out to
write a Unix-like kernel (Linux); Donald Knuth set out to write a text
formatter (TeX); Bob Scheifler set out to develop a window system (X
Windows). It's natural to measure the contribution of this kind of
project by specific programs that came from the project.
If we tried to measure the GNU Project's contribution in this way,
what would we conclude? One CD-ROM vendor found that in their ``Linux
distribution'', GNU software was the largest single contingent, around
28% of the total source code, and this included some of the essential
major components without which there could be no system. Linux itself
was about 3%. So if you were going to pick a name for the system
based on who wrote the programs in the system, the most appropriate
single choice would be ``GNU''@.
But we don't think that is the right way to consider the question.
The GNU Project was not, is not, a project to develop specific
software packages. It was not a project to develop a C compiler,
although we did. It was not a project to develop a text editor,
although we developed one. The GNU Project's aim was to develop
@emph{a complete free Unix-like system}.
Many people have made major contributions to the free software in the
system, and they all deserve credit. But the reason it is @emph{a
system}---and not just a collection of useful programs---is because the
GNU Project set out to make it one. We wrote the programs that were
needed to make a @emph{complete} free system. We wrote essential but
unexciting major components, such as the assembler and linker, because
you can't have a system without them. A complete system needs more
than just programming tools, so we wrote other components as well,
such as the Bourne Again SHell, the PostScript interpreter
Ghostscript, and the GNU C library.
By the early 90s we had put together the whole system aside from the
kernel (and we were also working on a kernel, the GNU Hurd, which runs
on top of Mach). Developing this kernel has been a lot harder than we
expected, and we are still working on finishing it.
Fortunately, you don't have to wait for it, because Linux is working
now. When Linus Torvalds wrote Linux, he filled the last major gap.
People could then put Linux together with the GNU system to make a
complete free system: a Linux-based GNU system (or GNU/Linux system,
for short).
Putting them together sounds simple, but it was not a trivial job.
The GNU C library (called glibc for short) needed substantial changes.
Integrating a complete system as a distribution that would work ``out
of the box'' was a big job, too. It required addressing the issue of
how to install and boot the system---a problem we had not tackled,
because we hadn't yet reached that point. The people who developed
the various system distributions made a substantial contribution.
The GNU Project supports GNU/Linux systems as well as @emph{the}
GNU system---even with funds. We funded the rewriting of the
Linux-related extensions to the GNU C library, so that now they are
well integrated, and the newest GNU/Linux systems use the current
library release with no changes. We also funded an early stage of the
development of Debian GNU/Linux.
We use Linux-based GNU systems today for most of our work, and we hope
you use them too. But please don't confuse the public by using the
name ``Linux'' ambiguously. Linux is the kernel, one of the essential
major components of the system. The system as a whole is more or less
the GNU system.
@include gpl.texi
@c ---------------------------------------------------------------------
@c GFDL
@c ---------------------------------------------------------------------
@include fdl.texi
@node Contributors
@unnumbered Contributors to GCC
@cindex contributors
@include contrib.texi
@c ---------------------------------------------------------------------
@c Indexes
@c ---------------------------------------------------------------------
@node Option Index
@unnumbered Option Index
GCC's command line options are indexed here without any initial @samp{-}
or @samp{--}. Where an option has both positive and negative forms
(such as @option{-f@var{option}} and @option{-fno-@var{option}}),
relevant entries in the manual are indexed under the most appropriate
form; it may sometimes be useful to look up both forms.
@printindex op
@node Index
@unnumbered Index
@printindex cp
@c ---------------------------------------------------------------------
@c Epilogue
@c ---------------------------------------------------------------------
@bye
|