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
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
|
{
Copyright (c) 1998-2008 by Florian Klaempfl and Peter Vreman
Reads command line options and config files
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit options;
{$i fpcdefs.inc}
interface
uses
cfileutl,cclasses,
globtype,globals,verbose,systems,cpuinfo,comprsrc;
Type
TOption=class
FirstPass,
ParaLogo,
NoPressEnter,
FPCHelpLines,
LogoWritten,
ABISetExplicitly,
FPUSetExplicitly,
CPUSetExplicitly,
OptCPUSetExplicitly: boolean;
FileLevel : longint;
QuickInfo : string;
FPCBinaryPath: string;
ParaIncludeCfgPath,
ParaIncludePath,
ParaUnitPath,
ParaObjectPath,
ParaLibraryPath,
ParaFrameworkPath,
parapackagepath : TSearchPathList;
paranamespaces : TCmdStrList;
ParaAlignment : TAlignmentInfo;
parapackages : tfphashobjectlist;
paratarget : tsystem;
paratargetasm : tasm;
paratargetdbg : tdbg;
LinkTypeSetExplicitly : boolean;
LinkerSetExplicitly : boolean;
Constructor Create;
Destructor Destroy;override;
procedure WriteLogo;
procedure WriteInfo (More: string);
procedure WriteHelpPages;
procedure WriteQuickInfo;
procedure IllegalPara(const opt:TCmdStr);
procedure UnsupportedPara(const opt:TCmdStr);
procedure IgnoredPara(const opt:TCmdStr);
function Unsetbool(var Opts:TCmdStr; Pos: Longint; const FullPara: TCmdStr; RequireBoolPara: Boolean):boolean;
procedure interpret_option(const opt :TCmdStr;ispara:boolean);
procedure Interpret_envvar(const envname : TCmdStr);
procedure Interpret_file(const filename : TPathStr);
procedure Read_Parameters;
procedure parsecmd(cmd:TCmdStr);
procedure TargetOptions(def:boolean);
procedure CheckOptionsCompatibility;
procedure ForceStaticLinking;
protected
MacVersionSet: boolean;
processorstr: TCmdStr;
function ParseMacVersionMin(out minstr, emptystr: string; const compvarname, value: string; ios: boolean): boolean;
procedure MaybeSetDefaultMacVersionMacro;
procedure VerifyTargetProcessor;
end;
TOptionClass=class of toption;
var
coption : TOptionClass;
procedure read_arguments(cmd:TCmdStr);
implementation
uses
widestr,
{$if FPC_FULLVERSION<20700}ccharset{$else}charset{$endif},
SysUtils,
version,
cutils,cmsgs,
comphook,
symtable,scanner,rabase,
symconst,
{$ifdef llvm}
{ override supported optimizer transformations at the compiler level }
llvminfo,
{$endif llvm}
dirparse,
pkgutil;
const
page_size = 24;
page_width = 80;
var
option : toption;
read_configfile, { read config file, set when a cfgfile is found }
disable_configfile : boolean;
fpcdir,
ppccfg,
param_file : string; { file to compile specified on the commandline }
{****************************************************************************
Options not supported on all platforms
****************************************************************************}
const
{ gprof (requires implementation of g_profilecode in the code generator) }
supported_targets_pg = [system_i386_linux,system_x86_64_linux,system_mipseb_linux,system_mipsel_linux,system_arm_linux]
+ [system_i386_win32]
+ [system_powerpc_darwin,system_x86_64_darwin]
+ [system_i386_GO32V2]
+ [system_i386_freebsd]
+ [system_i386_netbsd]
+ [system_i386_wdosx]
+ [system_riscv32_linux,system_riscv64_linux]
+ [system_aarch64_linux];
suppported_targets_x_smallr = systems_linux + systems_solaris + systems_android
+ [system_i386_haiku,system_x86_64_haiku]
+ [system_i386_beos]
+ [system_m68k_amiga];
{****************************************************************************
Defines
****************************************************************************}
procedure set_default_link_type;
begin
undef_system_macro('FPC_LINK_SMART');
def_system_macro('FPC_LINK_STATIC');
undef_system_macro('FPC_LINK_DYNAMIC');
init_settings.globalswitches:=init_settings.globalswitches+[cs_link_static];
init_settings.globalswitches:=init_settings.globalswitches-[cs_link_shared,cs_link_smart];
{$ifdef AIX}
init_settings.globalswitches:=init_settings.globalswitches+[cs_link_native];
{$endif}
end;
{****************************************************************************
Toption
****************************************************************************}
procedure StopOptions(err:longint);
begin
if assigned(Option) then
begin
Option.free;
Option:=nil;
end;
raise ECompilerAbortSilent.Create;
end;
function is_identifier(const s: TCmdStr): boolean;
var
i: longint;
begin
result:=false;
if (s='') or not (s[1] in ['A'..'Z','a'..'z','_']) then
exit;
for i:=2 to length(s) do
if not (s[I] in ['A'..'Z','a'..'z','0'..'9','_']) then
exit;
result:=true;
end;
procedure Toption.WriteLogo;
var
msg : TMsgStr;
p : pchar;
begin
if not LogoWritten then
begin
msg:=MessageStr(option_logo);
p:=pchar(msg);
while assigned(p) do
Comment(V_Normal,GetMsgLine(p));
LogoWritten:= true;
end;
end;
procedure Toption.WriteInfo (More: string);
var
msg_str: TMsgStr;
p : pchar;
hs,hs1,hs3,s : TCmdStr;
J: longint;
xmloutput: Text;
const
NewLineStr = '$\n';
OSTargetsPlaceholder = '$OSTARGETS';
CPUListPlaceholder = '$INSTRUCTIONSETS';
FPUListPlaceholder = '$FPUINSTRUCTIONSETS';
ABIListPlaceholder = '$ABITARGETS';
OptListPlaceholder = '$OPTIMIZATIONS';
WPOListPlaceholder = '$WPOPTIMIZATIONS';
AsmModeListPlaceholder = '$ASMMODES';
ControllerListPlaceholder = '$CONTROLLERTYPES';
FeatureListPlaceholder = '$FEATURELIST';
ModeSwitchListPlaceholder = '$MODESWITCHES';
CodeGenerationBackendPlaceholder = '$CODEGENERATIONBACKEND';
procedure SplitLine (var OrigString: TCmdStr; const Placeholder: TCmdStr;
out RemainderString: TCmdStr);
var
I: longint;
HS2: TCmdStr;
begin
RemainderString := '';
if OrigString = '' then
Exit;
repeat
I := Pos (NewLineStr, OrigString);
if I > 0 then
begin
HS2 := Copy (OrigString, 1, Pred (I));
{ Stop if this line contains the placeholder for list replacement }
if Pos (Placeholder, HS2) > 0 then
begin
RemainderString := Copy (OrigString, I + Length (NewLineStr),
Length (OrigString) - I - Length (NewLineStr));
{ Special case - NewLineStr at the end of the line }
if RemainderString = '' then
RemainderString := NewLineStr;
OrigString := HS2;
Exit;
end;
Comment (V_Normal, HS2);
Delete (OrigString, 1, Pred (I) + Length (NewLineStr));
end;
until I = 0;
if (OrigString <> '') and (Pos (Placeholder, OrigString) = 0) then
Comment (V_Normal, OrigString);
end;
procedure ListOSTargets (OrigString: TCmdStr);
var
target : tsystem;
begin
SplitLine (OrigString, OSTargetsPlaceholder, HS3);
for target:=low(tsystem) to high(tsystem) do
if assigned(targetinfos[target]) then
begin
hs1:=targetinfos[target]^.shortname;
if OrigString = '' then
Comment (V_Normal, hs1)
else
begin
hs := OrigString;
hs1:=hs1 + ': ' + targetinfos[target]^.name;
if tf_under_development in targetinfos[target]^.flags then
hs1:=hs1+' {*}';
Replace(hs,OSTargetsPlaceholder,hs1);
Comment(V_Normal,hs);
end;
end;
end;
procedure ListOSTargetsXML;
var
target : tsystem;
begin
WriteLn(xmloutput,' <ostargets>');
for target:=low(tsystem) to high(tsystem) do
if assigned(targetinfos[target]) then
begin
Write(xmloutput,' <ostarget shortname="',targetinfos[target]^.shortname,'" name="',targetinfos[target]^.name,'"');
if tf_under_development in targetinfos[target]^.flags then
Write(' experimental="1"');
WriteLn('/>');
end;
WriteLn(xmloutput,' </ostargets>');
end;
procedure ListCPUInstructionSets (OrigString: TCmdStr);
var
cpu : tcputype;
begin
SplitLine (OrigString, CPUListPlaceholder, HS3);
hs1:='';
for cpu:=low(tcputype) to high(tcputype) do
begin
if (OrigString = '') then
begin
if CPUTypeStr [CPU] <> '' then
Comment (V_Normal, CPUTypeStr [CPU]);
end
else
begin
if length(hs1+cputypestr[cpu])>70 then
begin
hs:=OrigString;
HS1 := HS1 + ',';
Replace(hs,CPUListPlaceholder,hs1);
Comment(V_Normal,hs);
hs1:=''
end
else if hs1<>'' then
hs1:=hs1+',';
if cputypestr[cpu]<>'' then
hs1:=hs1+cputypestr[cpu];
end;
end;
if (OrigString <> '') and (hs1 <> '') then
begin
hs:=OrigString;
Replace(hs,CPUListPlaceholder,hs1);
Comment(V_Normal,hs);
hs1:=''
end;
end;
procedure ListCPUInstructionSetsXML;
var
cpu : tcputype;
begin
WriteLn(xmloutput,' <cpuinstructionsets>');
for cpu:=low(tcputype) to high(tcputype) do
if CPUTypeStr [CPU] <> '' then
WriteLn(xmloutput,' <cpuinstructionset name="',CPUTypeStr [CPU], '"/>');
WriteLn(xmloutput,' </cpuinstructionsets>');
end;
procedure ListFPUInstructionSets (OrigString: TCmdStr);
var
fpu : tfputype;
begin
SplitLine (OrigString, FPUListPlaceholder, HS3);
hs1:='';
for fpu:=low(tfputype) to high(tfputype) do
begin
if (OrigString = '') then
begin
if FPUTypeStr [FPU] <> '' then
Comment (V_Normal, FPUTypeStr [FPU]);
end
else
begin
if length(hs1+fputypestr[fpu])>70 then
begin
hs:=OrigString;
HS1 := HS1 + ',';
Replace(hs,FPUListPlaceholder,hs1);
Comment(V_Normal,hs);
hs1:=''
end
else if hs1<>'' then
hs1:=hs1+',';
if fputypestr[fpu]<>'' then
hs1:=hs1+fputypestr[fpu];
end;
end;
if (OrigString <> '') and (hs1 <> '') then
begin
hs:=OrigString;
Replace(hs,FPUListPlaceholder,hs1);
Comment(V_Normal,hs);
hs1:=''
end;
end;
procedure ListFPUInstructionSetsXML;
var
fpu : tfputype;
begin
WriteLn(xmloutput,' <fpuinstructionsets>');
for fpu:=low(tfputype) to high(tfputype) do
if FPUTypeStr [fpu] <> '' then
WriteLn(xmloutput,' <cpuinstructionset name="',FPUTypeStr [fpu], '"/>');
WriteLn(xmloutput,' </fpuinstructionsets>');
end;
procedure ListABITargets (OrigString: TCmdStr);
var
abi : tabi;
begin
SplitLine (OrigString, ABIListPlaceholder, HS3);
for abi:=low(abi) to high(abi) do
begin
if not abiinfo[abi].supported then
continue;
hs1:=abiinfo[abi].name;
if hs1<>'' then
begin
if OrigString = '' then
Comment (V_Normal, HS1)
else
begin
hs:=OrigString;
Replace(hs,ABIListPlaceholder,hs1);
Comment(V_Normal,hs);
end;
end;
end;
end;
procedure ListABITargetsXML;
var
abi : tabi;
begin
WriteLn(xmloutput,' <abis>');
for abi:=low(abi) to high(abi) do
begin
if not abiinfo[abi].supported then
continue;
if abiinfo[abi].name<>'' then;
WriteLn(xmloutput,' <abi name="',abiinfo[abi].name, '"/>');
end;
WriteLn(xmloutput,' </abis>');
end;
procedure ListOptimizations (OrigString: TCmdStr);
var
opt : toptimizerswitch;
begin
SplitLine (OrigString, OptListPlaceholder, HS3);
for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
begin
if opt in supported_optimizerswitches then
begin
hs1:=OptimizerSwitchStr[opt];
if hs1<>'' then
begin
if OrigString = '' then
Comment (V_Normal, hs1)
else
begin
hs:=OrigString;
Replace(hs,OptListPlaceholder,hs1);
Comment(V_Normal,hs);
end;
end;
end;
end;
end;
procedure ListOptimizationsXML;
var
opt: toptimizerswitch;
begin
WriteLn(xmloutput,' <optimizations>');
for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
if OptimizerSwitchStr[opt]<>'' then
WriteLn(xmloutput,' <optimization name="',OptimizerSwitchStr[opt],'"/>');
WriteLn(xmloutput,' </optimizations>');
end;
procedure ListWPOptimizations (OrigString: TCmdStr);
var
wpopt: twpoptimizerswitch;
begin
SplitLine (OrigString, WPOListPlaceholder, HS3);
for wpopt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
begin
{ currently all whole program optimizations are platform-independent
if opt in supported_wpoptimizerswitches then
}
begin
hs1:=WPOptimizerSwitchStr[wpopt];
if hs1<>'' then
begin
if OrigString = '' then
Comment (V_Normal, hs1)
else
begin
hs:=OrigString;
Replace(hs,WPOListPlaceholder,hs1);
Comment(V_Normal,hs);
end;
end;
end;
end;
end;
procedure ListWPOptimizationsXML;
var
wpopt: twpoptimizerswitch;
begin
WriteLn(xmloutput,' <wpoptimizations>');
for wpopt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
if WPOptimizerSwitchStr[wpopt]<>'' then
WriteLn(xmloutput,' <wpoptimization name="',WPOptimizerSwitchStr[wpopt],'"/>');
WriteLn(xmloutput,' </wpoptimizations>');
end;
procedure ListAsmModes (OrigString: TCmdStr);
var
asmmode : tasmmode;
begin
SplitLine (OrigString, AsmModeListPlaceholder, HS3);
for asmmode:=low(tasmmode) to high(tasmmode) do
if assigned(asmmodeinfos[asmmode]) then
begin
hs1:=asmmodeinfos[asmmode]^.idtxt;
if hs1<>'' then
begin
if OrigString = '' then
Comment (V_Normal, hs1)
else
begin
hs:=OrigString;
Replace(hs,AsmModeListPlaceholder,hs1);
Comment(V_Normal,hs);
end;
end;
end;
end;
procedure ListAsmModesXML;
var
asmmode : tasmmode;
begin
WriteLn(xmloutput,' <asmmodes>');
for asmmode:=low(tasmmode) to high(tasmmode) do
if assigned(asmmodeinfos[asmmode]) then
WriteLn(xmloutput,' <asmmode name="',asmmodeinfos[asmmode]^.idtxt,'"/>');
WriteLn(xmloutput,' </asmmodes>');
end;
procedure ListControllerTypes (OrigString: TCmdStr);
var
controllertype : tcontrollertype;
begin
{$PUSH}
{$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
if (ControllerSupport) then
begin
SplitLine (OrigString, ControllerListPlaceholder, HS3);
hs1:='';
for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
begin
if (OrigString = '') then
begin
if Embedded_Controllers [ControllerType].ControllerTypeStr <> '' then
Comment (V_Normal, Embedded_Controllers [ControllerType].ControllerTypeStr);
end
else
begin
if length(hs1+embedded_controllers[controllertype].ControllerTypeStr)
>70 then
begin
hs:=OrigString;
HS1 := HS1 + ',';
Replace(hs,ControllerListPlaceholder,hs1);
Comment(V_Normal,hs);
hs1:=''
end
else if hs1<>'' then
hs1:=hs1+',';
if embedded_controllers[controllertype].ControllerTypeStr<>'' then
hs1:=hs1+embedded_controllers[controllertype].ControllerTypeStr;
end;
end;
if (OrigString <> '') and (hs1<>'') then
begin
hs:=OrigString;
Replace(hs,ControllerListPlaceholder,hs1);
Comment(V_Normal,hs);
hs1:=''
end;
end;
{$POP}
end;
procedure ListControllerTypesXML;
var
controllertype : tcontrollertype;
begin
{$PUSH}
{$WARN 6018 OFF} (* Unreachable code due to compile time evaluation *)
if (ControllerSupport) then
begin
WriteLn(xmloutput,' <controllertypes>');
for controllertype:=low(tcontrollertype) to high(tcontrollertype) do
if embedded_controllers[controllertype].ControllerTypeStr<>'' then
WriteLn(xmloutput,' <controllertype name="',embedded_controllers[controllertype].ControllerTypeStr,'"/>');
WriteLn(xmloutput,' </controllertypes>');
end;
{$POP}
end;
procedure ListFeatures (OrigString: TCmdStr);
var
Feature: TFeature;
begin
SplitLine (OrigString, FeatureListPlaceholder, HS3);
HS1 := '';
for Feature := Low (TFeature) to High (TFeature) do
begin
if (OrigString = '') then
begin
if FeatureStr [Feature] <> '' then
Comment (V_Normal, FeatureStr [Feature]);
end
else
begin
if Length (HS1 + FeatureStr [Feature]) > 70 then
begin
HS := OrigString;
HS1 := HS1 + ',';
Replace (HS, FeatureListPlaceholder, HS1);
Comment (V_Normal, HS);
HS1 := ''
end
else if HS1 <> '' then
HS1 := HS1 + ',';
if FeatureStr [Feature] <> '' then
HS1 := HS1 + FeatureStr [Feature];
end;
end;
if (OrigString <> '') and (HS1 <> '') then
begin
HS := OrigString;
Replace (HS, FeatureListPlaceholder, HS1);
Comment (V_Normal, HS);
HS1 := ''
end;
end;
procedure ListFeaturesXML;
var
Feature: TFeature;
begin
WriteLn(xmloutput,' <features>');
for Feature := Low (TFeature) to High (TFeature) do
if FeatureStr [Feature] <> '' then
WriteLn(xmloutput,' <feature name="',FeatureStr [Feature],'"/>');
WriteLn(xmloutput,' </features>');
end;
procedure ListModeswitches (OrigString: TCmdStr);
var
Modeswitch: TModeswitch;
begin
SplitLine (OrigString, ModeswitchListPlaceholder, HS3);
HS1 := '';
for Modeswitch := Low (TModeswitch) to High (TModeswitch) do
begin
if (OrigString = '') then
begin
if ModeswitchStr [Modeswitch] <> '' then
Comment (V_Normal, ModeswitchStr [Modeswitch]);
end
else
begin
if Length (HS1 + ModeswitchStr [Modeswitch]) > 60 then
begin
HS := OrigString;
HS1 := HS1 + ',';
Replace (HS, ModeswitchListPlaceholder, HS1);
Comment (V_Normal, HS);
HS1 := ''
end
else if HS1 <> '' then
HS1 := HS1 + ',';
if ModeswitchStr [Modeswitch] <> '' then
HS1 := HS1 + ModeswitchStr [Modeswitch];
end;
end;
if (OrigString <> '') and (HS1 <> '') then
begin
HS := OrigString;
Replace (HS, ModeswitchListPlaceholder, HS1);
Comment (V_Normal, HS);
HS1 := ''
end;
end;
procedure ListModeswitchesXML;
var
Modeswitch: TModeswitch;
begin
WriteLn(xmloutput,' <modeswitches>');
for Modeswitch:=Low(TModeswitch) to High(TModeswitch) do
if ModeswitchStr [Modeswitch]<>'' then
WriteLn(xmloutput,' <modeswitch name="',ModeswitchStr [Modeswitch],'"/>');
WriteLn(xmloutput,' </modeswitches>');
end;
procedure ListCodeGenerationBackend (OrigString: TCmdStr);
begin
SplitLine (OrigString, CodeGenerationBackendPlaceholder, HS3);
hs1:=cgbackend2str[cgbackend];
if OrigString = '' then
Comment (V_Normal, hs1)
else
begin
hs:=OrigString;
Replace(hs,CodeGenerationBackendPlaceholder,hs1);
Comment(V_Normal,hs);
end;
end;
procedure ListCodeGenerationBackendXML;
begin
WriteLn(xmloutput,' <codegeneratorbackend>',cgbackend2str[cgbackend],'</codegeneratorbackend>');
end;
begin
if More = '' then
begin
msg_str:=MessageStr(option_info);
p:=pchar(msg_str);
while assigned(p) do
begin
s:=GetMsgLine(p);
{ list permitted values for certain options }
if pos(OSTargetsPlaceholder,s)>0 then
ListOSTargets (S)
else if pos(CPUListPlaceholder,s)>0 then
ListCPUInstructionSets (S)
else if pos(FPUListPlaceholder,s)>0 then
ListFPUInstructionSets (S)
else if pos(ABIListPlaceholder,s)>0 then
ListABITargets (S)
else if pos(OptListPlaceholder,s)>0 then
ListOptimizations (S)
else if pos(WPOListPlaceholder,s)>0 then
ListWPOptimizations (S)
else if Pos (ModeswitchListPlaceholder, S) > 0 then
ListModeswitches (S)
else if pos(AsmModeListPlaceholder,s)>0 then
ListAsmModes (S)
else if pos(ControllerListPlaceholder,s)>0 then
ListControllerTypes (S)
else if pos(FeatureListPlaceholder,s)>0 then
ListFeatures (S)
else if pos(CodeGenerationBackendPlaceholder,s)>0 then
ListCodeGenerationBackend (S)
else
Comment(V_Normal,s);
end;
end
else if Copy(More,1,1) = 'x' then
begin
Assign(xmloutput,Copy(More,2,length(More)-1));
Rewrite(xmloutput);
WriteLn(xmloutput,'<?xml version="1.0" encoding="utf-8"?>');
WriteLn(xmloutput,'<fpcoutput>');
WriteLn(xmloutput,' <info>');
ListOSTargetsXML;
ListCPUInstructionSetsXML;
ListFPUInstructionSetsXML;
ListABITargetsXML;
ListOptimizationsXML;
ListWPOptimizationsXML;
ListModeswitchesXML;
ListAsmModesXML;
ListControllerTypesXML;
ListFeaturesXML;
ListCodeGenerationBackendXML;
WriteLn(xmloutput,' </info>');
WriteLn(xmloutput,'</fpcoutput>');
Close(xmloutput);
end
else
begin
J := 1;
while J <= Length (More) do
begin
if J > 1 then
Comment(V_Normal,''); (* Put empty line between multiple sections *)
case More [J] of
'a': ListABITargets ('');
'b': Comment(V_Normal, cgbackend2str[cgbackend]);
'c': ListCPUInstructionSets ('');
'f': ListFPUInstructionSets ('');
'i': ListAsmModes ('');
'm': ListModeswitches ('');
'o': ListOptimizations ('');
'r': ListFeatures ('');
't': ListOSTargets ('');
'u': ListControllerTypes ('');
'w': ListWPOptimizations ('');
else
IllegalPara ('-i' + More);
end;
Inc (J);
end;
end;
StopOptions(0);
end;
procedure Toption.WriteHelpPages;
function PadEnd(s:string;i:longint):string;
begin
if length(s) >= i then
S := S + ' '
else
while (length(s)<i) do
s:=s+' ';
PadEnd:=s;
end;
var
lastident,
j,outline,
ident,
HelpLineHeight,
lines : longint;
show : boolean;
opt : string[32];
input,
HelpLine,
s : string;
p : pchar;
msg_str: TMsgStr;
begin
WriteLogo;
Lines:=4;
if FPCHelpLines then
Message1(option_usage,FixFileName(FPCBinaryPath))
else
Message1(option_usage,FixFileName(system.paramstr(0)));
lastident:=0;
msg_str:=MessageStr(option_help_pages);
p:=pchar(msg_str);
while assigned(p) do
begin
{ get a line and reset }
s:=GetMsgLine(p);
ident:=0;
show:=false;
{ parse options }
case s[1] of
'F': if FPCHelpLines then
Show := true;
{$ifdef UNITALIASES}
'a',
{$endif}
{$ifdef EXTDEBUG}
'e',
{$endif EXTDEBUG}
{$ifdef i386}
'3',
{$endif}
{$ifdef x86_64}
'4',
{$endif}
{$ifdef m68k}
'6',
{$endif}
{$ifdef i8086}
'8',
{$endif}
{$ifdef aarch64}
'a',
{$endif}
{$ifdef arm}
'A',
{$endif}
{$ifdef mipsel}
'm',
{$endif}
{$ifdef mipseb}
'M',
{$endif}
{$ifdef powerpc}
'P',
{$endif}
{$ifdef powerpc64}
'p',
{$endif}
{$ifdef sparc}
'S',
{$endif}
{$ifdef sparc64}
's',
{$endif}
{$ifdef riscv32}
'R',
{$endif}
{$ifdef riscv64}
'r',
{$endif}
{$ifdef avr}
'V',
{$endif}
{$ifdef jvm}
'J',
{$endif}
{$ifdef llvm}
'L',
{$endif}
{$ifdef xtensa}
'x',
{$endif}
{$ifdef z80}
'Z',
{$endif}
{$ifdef wasm32}
'W',
{$endif}
'*' : show:=true;
end;
if show then
begin
case s[2] of
'g',
{$ifdef Unix}
'L',
{$endif}
{$ifdef os2}
'O',
{$endif}
'*' : show:=true;
else
show:=false;
end;
end;
{ now we may show the message or not }
if show then
begin
case s[3] of
'0' : begin
ident:=0;
outline:=0;
end;
'1' : begin
ident:=2;
outline:=7;
end;
'2' : begin
ident:=6;
outline:=11;
end;
'3' : begin
ident:=9;
outline:=11;
end;
else
internalerror(2013112906);
end;
j:=pos('_',s);
opt:=Copy(s,4,j-4);
if opt='*' then
opt:=''
else
if (opt=' ') or (opt[1]='@') then
opt:=PadEnd(opt,outline)
else
opt:=PadEnd('-'+opt,outline);
if (ident=0) and (lastident<>0) then
begin
Comment(V_Normal,'');
inc(Lines);
end;
HelpLine := PadEnd('',ident)+opt+Copy(s,j+1,255);
if HelpLine = '' then
HelpLineHeight := 1
else
HelpLineHeight := Succ (CharLength (HelpLine) div Page_Width);
{ page full ? }
if (lines + HelpLineHeight >= page_size - 1) then
begin
if not NoPressEnter then
begin
Message(option_help_press_enter);
readln(input);
if upper(input)='Q' then
StopOptions(0);
end;
lines:=0;
end;
Comment(V_Normal,HelpLine);
LastIdent:=Ident;
Inc (Lines, HelpLineHeight);
end;
end;
StopOptions(0);
end;
procedure Toption.IllegalPara(const opt:TCmdStr);
begin
Message1(option_illegal_para,opt);
Message(option_help_pages_para);
StopOptions(1);
end;
procedure toption.UnsupportedPara(const opt: TCmdStr);
begin
Message1(option_unsupported_target,opt);
StopOptions(1);
end;
procedure toption.IgnoredPara(const opt: TCmdStr);
begin
Message1(option_ignored_target,opt);
end;
procedure toption.ForceStaticLinking;
begin
def_system_macro('FPC_LINK_STATIC');
undef_system_macro('FPC_LINK_SMART');
undef_system_macro('FPC_LINK_DYNAMIC');
include(init_settings.globalswitches,cs_link_static);
exclude(init_settings.globalswitches,cs_link_smart);
exclude(init_settings.globalswitches,cs_link_shared);
LinkTypeSetExplicitly:=true;
end;
function toption.ParseMacVersionMin(out minstr, emptystr: string; const compvarname, value: string; ios: boolean): boolean;
function subval(start,maxlen: longint; out stop: longint): string;
var
i: longint;
begin
result:='';
i:=start;
while (i<=length(value)) and
(value[i] in ['0'..'9']) do
inc(i);
{ sufficient amount of digits? }
if (i=start) or
(i-start>maxlen) then
exit;
result:=copy(value,start,i-start);
stop:=i;
end;
var
temp,
compvarvalue: string[15];
i: longint;
osx_minor_two_digits: boolean;
begin
minstr:=value;
emptystr:='';
MacVersionSet:=false;
{ check whether the value is a valid version number }
if value='' then
begin
undef_system_macro(compvarname);
exit(true);
end;
{ major version number }
compvarvalue:=subval(1,2,i);
{ not enough digits -> invalid }
if compvarvalue='' then
exit(false);
{ already end of string -> invalid }
if (i>=length(value)) or
(value[i]<>'.') then
exit(false);
{ minor version number }
temp:=subval(i+1,2,i);
if temp='' then
exit(false);
{ on Mac OS X, the minor version number was originally limited to 1 digit;
with 10.10 the format changed and two digits were also supported; on iOS,
the minor version number always takes up two digits }
osx_minor_two_digits:=false;
if not ios then
begin
{ if the minor version number is two digits on OS X (the case since
OS X 10.10), we also have to add two digits for the patch level}
if length(temp)=2 then
osx_minor_two_digits:=true;
end
{ the minor version number always takes up two digits on iOS }
else if length(temp)=1 then
temp:='0'+temp;
compvarvalue:=compvarvalue+temp;
{ optional patch level }
if i<=length(value) then
begin
if value[i]<>'.' then
exit(false);
temp:=subval(i+1,2,i);
if temp='' then
exit(false);
{ there's only room for a single digit patch level in the version macro
for Mac OS X. gcc sets it to zero if there are more digits, but that
seems worse than clamping to 9 (don't declare as invalid like with
minor version number, because there is a precedent like 10.4.11).
As of OS X 10.10 there are two digits for the patch level
}
if not ios and
not osx_minor_two_digits then
begin
if length(temp)<>1 then
temp:='9';
end
else
begin
{ on iOS, the patch level is always two digits }
if length(temp)=1 then
temp:='0'+temp;
end;
compvarvalue:=compvarvalue+temp;
{ must be the end }
if i<=length(value) then
exit(false);
end
else if not ios and
not osx_minor_two_digits then
begin
compvarvalue:=compvarvalue+'0';
minstr:=minstr+'.0'
end
else
begin
compvarvalue:=compvarvalue+'00';
{ command line versions still only use one 0 though }
minstr:=minstr+'.0'
end;
set_system_compvar(compvarname,compvarvalue);
MacVersionSet:=true;
result:=true;
end;
procedure TOption.MaybeSetDefaultMacVersionMacro;
var
envstr: ansistring;
begin
if not(target_info.system in systems_darwin) then
exit;
if MacVersionSet then
exit;
{ check for deployment target set via environment variable }
if not(target_info.system in [system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim]) then
begin
envstr:=GetEnvironmentVariable('MACOSX_DEPLOYMENT_TARGET');
if envstr<>'' then
if not ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',envstr,false) then
Message1(option_invalid_macosx_deployment_target,envstr)
else
begin
{$ifdef llvm}
{ We only support libunwind as part of libsystem, which happened in Mac OS X 10.6 }
if CompareVersionStrings(MacOSXVersionMin,'10.6')<=0 then
Message1(option_invalid_macosx_deployment_target,envstr);
{$endif}
exit;
end;
end
else
begin
envstr:=GetEnvironmentVariable('IPHONEOS_DEPLOYMENT_TARGET');
if envstr<>'' then
if not ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',envstr,true) then
Message1(option_invalid_iphoneos_deployment_target,envstr)
else
exit;
end;
{ nothing specified -> defaults }
case target_info.system of
system_powerpc_darwin:
begin
set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1030');
MacOSXVersionMin:='10.3.0';
end;
system_powerpc64_darwin:
begin
set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1040');
MacOSXVersionMin:='10.4.0';
end;
system_i386_darwin,
system_x86_64_darwin:
begin
set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','1080');
MacOSXVersionMin:='10.8.0';
end;
system_arm_ios,
system_i386_iphonesim:
begin
set_system_compvar('IPHONE_OS_VERSION_MIN_REQUIRED','90000');
iPhoneOSVersionMin:='9.0.0';
end;
system_aarch64_ios,
system_x86_64_iphonesim:
begin
set_system_compvar('IPHONE_OS_VERSION_MIN_REQUIRED','90000');
iPhoneOSVersionMin:='9.0.0';
end;
system_aarch64_darwin:
begin
set_system_compvar('MAC_OS_X_VERSION_MIN_REQUIRED','110000');
MacOSXVersionMin:='11.0.0';
end
else
internalerror(2012031001);
end;
end;
procedure TOption.VerifyTargetProcessor;
begin
{ no custom target processor specified -> ok }
if processorstr='' then
exit;
{ custom target processor specified -> verify it's the one we support }
if upcase(processorstr)<>upcase(target_cpu_string) then
Message1(option_invalid_target_architecture,processorstr);
end;
function Toption.Unsetbool(var Opts:TCmdStr; Pos: Longint; const FullPara: TCmdStr; RequireBoolPara: boolean):boolean;
{ checks if the character after pos in Opts is a + or a - and returns resp.
false or true. If it is another character (or none), it also returns false }
begin
UnsetBool := false;
if Length(Opts)>Pos then
begin
inc(Pos);
UnsetBool := Opts[Pos] = '-';
if Opts[Pos] in ['-','+']then
delete(Opts,Pos,1)
else if RequireBoolPara then
IllegalPara(FullPara);
end;
end;
procedure TOption.interpret_option(const opt:TCmdStr;ispara:boolean);
var
code : integer;
c : char;
more : TCmdStr;
major,minor : longint;
error : integer;
j,l : longint;
d,s : TCmdStr;
hs : TCmdStr;
unicodemapping : punicodemap;
{$ifdef llvm}
disable: boolean;
{$endif}
begin
if opt='' then
exit;
{ only parse define,undef,target,verbosity,link etc options the firsttime
-Us must now also be first-passed to avoid rejection of -Sf options
earlier in command line }
if firstpass and
not(
(opt[1]='-') and
(
((length(opt)>1) and (opt[2] in ['i','d','v','T','u','n','X','l','U'])) or
((length(opt)>3) and (opt[2]='F') and (opt[3]='e')) or
((length(opt)>3) and (opt[2]='C') and (opt[3] in ['a','f','p'])) or
((length(opt)>3) and (opt[2]='W') and (opt[3] in ['m','p']))
)
) then
exit;
Message1(option_handling_option,opt);
case opt[1] of
'-' :
begin
more:=Copy(opt,3,2147483647);
if firstpass then
Message1(option_interpreting_firstpass_option,opt)
else
Message1(option_interpreting_option,opt);
case opt[2] of
'?' :
begin
if (More <> '') and (More [1] = 'F') then
begin
FPCHelpLines := true;
Delete (More, 1, 1);
FPCBinaryPath := More;
end;
WriteHelpPages;
end;
'a' :
begin
include(init_settings.globalswitches,cs_asm_leave);
j:=1;
while j<=length(more) do
begin
case more[j] of
'5' :
if (target_info.system in systems_all_windows+systems_nativent-[system_i8086_win16])
or (target_info.cpu in [cpu_mipseb, cpu_mipsel]) then
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_asm_pre_binutils_2_25)
else
include(init_settings.globalswitches,cs_asm_pre_binutils_2_25);
end
else
IllegalPara(opt);
'l' :
include(init_settings.globalswitches,cs_asm_source);
'r' :
include(init_settings.globalswitches,cs_asm_regalloc);
't' :
include(init_settings.globalswitches,cs_asm_tempalloc);
'n' :
include(init_settings.globalswitches,cs_asm_nodes);
{ -ao option must be the last, everything behind it is passed directly to
external assembler, it is ignored if internal assembler is used. }
'o' :
begin
asmextraopt:=copy(more,j+1,length(more)-j);
break;
end;
'p' :
begin
exclude(init_settings.globalswitches,cs_asm_leave);
if UnsetBool(More, 0, opt, false) then
exclude(init_settings.globalswitches,cs_asm_pipe)
else
include(init_settings.globalswitches,cs_asm_pipe);
end;
'-' :
init_settings.globalswitches:=init_settings.globalswitches -
[cs_asm_leave, cs_asm_source,cs_asm_regalloc, cs_asm_tempalloc,
cs_asm_nodes, cs_asm_pipe];
else
IllegalPara(opt);
end;
inc(j);
end;
end;
'A' :
begin
paratargetasm:=find_asm_by_string(More);
if paratargetasm=as_none then
IllegalPara(opt);
end;
'b' :
begin
// Message1(option_obsolete_switch,'-b');
if UnsetBool(More,0,opt,false) then
begin
init_settings.moduleswitches:=init_settings.moduleswitches-[cs_browser];
init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser];
end
else
begin
init_settings.moduleswitches:=init_settings.moduleswitches+[cs_browser];
end;
if More<>'' then
if (More='l') or (More='l+') then
init_settings.moduleswitches:=init_settings.moduleswitches+[cs_local_browser]
else if More='l-' then
init_settings.moduleswitches:=init_settings.moduleswitches-[cs_local_browser]
else
IllegalPara(opt);
end;
'B' :
do_build:=not UnSetBool(more,0,opt,true);
'C' :
begin
j:=1;
while j<=length(more) do
begin
case more[j] of
'3' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_ieee_errors)
Else
include(init_settings.localswitches,cs_ieee_errors);
'a' :
begin
s:=upper(copy(more,j+1,length(more)-j));
if not(SetAbiType(s,target_info.abi)) then
IllegalPara(opt);
ABISetExplicitly:=true;
break;
end;
'b' :
begin
if UnsetBool(More, j, opt, false) then
target_info.endian:=endian_little
else
target_info.endian:=endian_big;
end;
'c' :
begin
if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),init_settings.defproccall) then
IllegalPara(opt);
break;
end;
{$ifdef cpufpemu}
'e' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_fp_emulation)
Else
include(init_settings.moduleswitches,cs_fp_emulation);
end;
{$endif cpufpemu}
'E' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_fpu_exceptions)
Else
include(init_settings.localswitches,cs_check_fpu_exceptions);
'f' :
begin
s:=upper(copy(more,j+1,length(more)-j));
if not(SetFpuType(s,init_settings.fputype)) then
IllegalPara(opt);
FPUSetExplicitly:=True;
break;
end;
'F' :
begin
if not SetMinFPConstPrec(copy(more,j+1,length(more)-j),init_settings.minfpconstprec) then
IllegalPara(opt);
break;
end;
'g' :
begin
if tf_no_pic_supported in target_info.flags then
begin
{ consume a possible '-' coming after it }
UnsetBool(More, j, opt, false);
message(scan_w_pic_ignored);
end
else if UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_create_pic)
else
include(init_settings.moduleswitches,cs_create_pic);
end;
'h' :
begin
l:=pos(',',copy(more,j+1,length(more)-j));
if l=0 then
l:=length(more)-j+1;
val(copy(more,j+1,l-1),heapsize,code);
if (code<>0)
{$ifdef AVR}
or (heapsize<32)
{$else AVR}
or (heapsize<1024)
{$endif AVR}
then
IllegalPara(opt)
else if l<=length(more)-j then
begin
val(copy(more,j+l+1,length(more)),maxheapsize,code);
if code<>0 then
IllegalPara(opt)
else if (maxheapsize<heapsize) then
begin
message(scan_w_heapmax_lessthan_heapmin);
maxheapsize:=heapsize;
end;
end;
break;
end;
'i' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_io)
else
include(init_settings.localswitches,cs_check_io);
{$ifdef arm}
'I' :
begin
if (upper(copy(more,j+1,length(more)-j))='THUMB') and
{ does selected CPU really understand thumb? }
(init_settings.cputype in cpu_has_thumb) then
init_settings.instructionset:=is_thumb
else if upper(copy(more,j+1,length(more)-j))='ARM' then
init_settings.instructionset:=is_arm
else
IllegalPara(opt);
break;
end;
{$endif arm}
{$ifdef llvm}
'l':
begin
l:=j+1;
while l<=length(More) do
begin
case More[l] of
'f':
begin
More:=copy(More,l+1,length(More));
disable:=Unsetbool(More,length(More)-1,opt,false);
case More of
'lto':
begin
if not disable then
begin
include(init_settings.moduleswitches,cs_lto);
LTOExt:='.bc';
end
else
exclude(init_settings.moduleswitches,cs_lto);
end;
'ltonosystem':
begin
if not disable then
begin
include(init_settings.globalswitches,cs_lto_nosystem);
end
else
exclude(init_settings.globalswitches,cs_lto_nosystem);
end;
else
begin
IllegalPara(opt);
end;
end;
l:=length(more)+1;
end;
'v':
begin
init_settings.llvmversion:=llvmversion2enum(copy(More,l+1,length(More)));
if init_settings.llvmversion=llvmver_invalid then
begin
IllegalPara(opt);
end;
l:=length(More)+1;
end
else
begin
IllegalPara(opt);
end;
end;
end;
j:=l;
end;
{$endif llvm}
'n' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_nolink)
Else
include(init_settings.globalswitches,cs_link_nolink);
'N' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_low_addr_load)
Else
include(init_settings.localswitches,cs_check_low_addr_load);
'o' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_overflow)
Else
include(init_settings.localswitches,cs_check_overflow);
'O' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_ordinal_size)
Else
include(init_settings.localswitches,cs_check_ordinal_size);
'p' :
begin
s:=upper(copy(more,j+1,length(more)-j));
if not(Setcputype(s,init_settings)) then
IllegalPara(opt);
CPUSetExplicitly:=true;
break;
end;
'P':
begin
delete(more,1,1);
case upper(copy(more,1,pos('=',more)-1)) of
'PACKSET':
begin
delete(more,1,pos('=',more));
case more of
'0','DEFAULT','NORMAL':
init_settings.setalloc:=0;
'1','2','4','8':
init_settings.setalloc:=StrToInt(more);
else
IllegalPara(opt);
end
end;
'PACKENUM':
begin
delete(more,1,pos('=',more));
case more of
'0','DEFAULT','NORMAL':
init_settings.packenum:=4;
'1','2','4':
init_settings.packenum:=StrToInt(more);
else
IllegalPara(opt);
end;
end;
'PACKRECORD':
begin
delete(more,1,pos('=',more));
case more of
'0','DEFAULT','NORMAL':
init_settings.packrecords:=default_settings.packrecords;
'1','2','4','8','16','32':
init_settings.packrecords:=StrToInt(more);
else
IllegalPara(opt);
end;
end
else
IllegalPara(opt);
end;
end;
'r' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_range)
Else
include(init_settings.localswitches,cs_check_range);
'R' :
If UnsetBool(More, j, opt, false) then
begin
exclude(init_settings.localswitches,cs_check_range);
exclude(init_settings.localswitches,cs_check_object);
end
Else
begin
include(init_settings.localswitches,cs_check_range);
include(init_settings.localswitches,cs_check_object);
end;
's' :
begin
val(copy(more,j+1,length(more)-j),stacksize,code);
if (code<>0)
{$ifdef cpu16bitaddr}
or (stacksize>=65521)
{$else cpu16bitaddr}
or (stacksize>=67107840)
{$endif cpu16bitaddr}
or (stacksize<1024) then
IllegalPara(opt);
break;
end;
't' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_stack)
Else
include(init_settings.localswitches,cs_check_stack);
'D' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_create_dynamic)
Else
include(init_settings.moduleswitches,cs_create_dynamic);
'X' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_create_smart)
Else
include(init_settings.moduleswitches,cs_create_smart);
'T' :
begin
if not UpdateTargetSwitchStr(copy(more,j+1,length(more)),init_settings.targetswitches,true) then
IllegalPara(opt);
break;
end;
'v' :
If target_info.system in systems_jvm then
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_var_copyout)
Else
include(init_settings.localswitches,cs_check_var_copyout)
else
IllegalPara(opt);
'V':
begin
s:=upper(copy(more,j+1,length(more)-j));
if s='GLOBAL-DYNAMIC' then
init_settings.tlsmodel:=tlsm_global_dynamic
else if s='LOCAL-EXEC' then
init_settings.tlsmodel:=tlsm_local_exec
else
IllegalPara(opt);
break;
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
'd' :
begin
l:=Pos(':=',more);
if l>0 then
hs:=copy(more,1,l-1)
else
hs:=more;
if (not is_identifier(hs)) then
begin
if hs='' then
Message1(option_missing_arg,'-d')
else
Message1(option_malformed_para,opt);
StopOptions(1);
end;
if l>0 then
begin
if cs_support_macro in init_settings.moduleswitches then
set_system_macro(hs,Copy(more,l+2,255))
else
set_system_compvar(hs,Copy(more,l+2,255));
end
else
def_system_macro(hs);
end;
'D' :
begin
include(init_settings.globalswitches,cs_link_deffile);
j:=1;
while j<=length(more) do
begin
case more[j] of
'd' :
begin
description:=Copy(more,j+1,255);
break;
end;
'D' :
begin
datestr:=Copy(more,j+1,255);
break;
end;
'T' :
begin
timestr:=Copy(more,j+1,255);
break;
end;
'v' :
begin
dllversion:=Copy(more,j+1,255);
l:=pos('.',dllversion);
dllminor:=0;
error:=0;
if l>0 then
begin
val(copy(dllversion,l+1,255),minor,error);
if (error=0) and
(minor>=0) and (minor<=$ffff) then
dllminor:=minor
else
if error=0 then
error:=1;
end;
if l=0 then
l:=256;
dllmajor:=1;
major:=0;
if error=0 then
val(copy(dllversion,1,l-1),major,error);
if (error=0) and (major>=0) and (major<=$ffff) then
dllmajor:=major
else
if error=0 then
error:=1;
if error<>0 then
Message1(scan_w_wrong_version_ignored,dllversion);
break;
end;
'w' :
usewindowapi:=true;
'-' :
begin
exclude(init_settings.globalswitches,cs_link_deffile);
usewindowapi:=false;
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
'e' :
exepath:=FixPath(More,true);
'E' :
begin
if UnsetBool(More, 0, opt, true) then
exclude(init_settings.globalswitches,cs_link_nolink)
else
include(init_settings.globalswitches,cs_link_nolink);
end;
'f' :
begin
if more='PIC' then
begin
if tf_no_pic_supported in target_info.flags then
message(scan_w_pic_ignored)
else
include(init_settings.moduleswitches,cs_create_pic)
end
else
IllegalPara(opt);
end;
'F' :
begin
if more='' then
IllegalPara(opt);
c:=more[1];
Delete(more,1,1);
DefaultReplacements(More);
case c of
'a' :
autoloadunits:=more;
'c' :
begin
{ if we first specify that the system code page should be
used and then explicitly specify a code page, unset the
flag that we're using the system code page again }
SetCompileModeSwitch('SYSTEMCODEPAGE-',true);
if (upper(more)='UTF8') or (upper(more)='UTF-8') then
init_settings.sourcecodepage:=CP_UTF8
else if not(cpavailable(more)) then
Message1(option_code_page_not_available,more)
else
init_settings.sourcecodepage:=codepagebyname(more);
include(init_settings.moduleswitches,cs_explicit_codepage);
end;
'C' :
RCCompiler:=More;
'd' :
if UnsetBool(more, 0, opt, true) then
init_settings.disabledircache:=false
else
init_settings.disabledircache:=true;
'D' :
utilsdirectory:=FixPath(More,true);
'e' :
SetRedirectFile(More);
'E' :
OutputExeDir:=FixPath(More,true);
'f' :
if (target_info.system in systems_darwin) then
if ispara then
ParaFrameworkPath.AddPath(More,false)
else
frameworksearchpath.AddPath(More,true)
{$ifdef XTENSA}
else if (target_info.system=system_xtensa_freertos) then
idfpath:=FixPath(More,true)
{$endif XTENSA}
else
IllegalPara(opt);
'F' :
RCForceFPCRes:=true;
'i' :
begin
if ispara then
ParaIncludePath.AddPath(More,false)
else
includesearchpath.AddPath(More,true);
end;
'm' :
begin
s:=ExtractFileDir(more);
if TryStrToInt(ExtractFileName(more),j) then
begin
unicodemapping:=loadunicodemapping(More,More+'.txt',j);
if assigned(unicodemapping) then
registermapping(unicodemapping)
else
IllegalPara(opt);
end
else
IllegalPara(opt);
end;
'M' :
unicodepath:=FixPath(More,true);
'g' :
Message2(option_obsolete_switch_use_new,'-Fg','-Fl');
'l' :
begin
if ispara then
ParaLibraryPath.AddLibraryPath(sysrootpath,More,false)
else
LibrarySearchPath.AddLibraryPath(sysrootpath,More,true)
end;
'L' :
begin
if More<>'' then
ParaDynamicLinker:=More
else
IllegalPara(opt);
end;
'N' :
begin
if more<>'' then
paranamespaces.insert(more)
else
illegalpara(opt);
end;
'o' :
begin
if ispara then
ParaObjectPath.AddPath(More,false)
else
ObjectSearchPath.AddPath(More,true);
end;
'P' :
begin
if ispara then
parapackages.add(more,nil)
else
add_package(more,true,true);
end;
'p' :
begin
if ispara then
parapackagepath.AddPath(More,false)
else
packagesearchpath.AddPath(More,true);
end;
'r' :
Msgfilename:=More;
'R' :
ResCompiler:=More;
'u' :
begin
if ispara then
ParaUnitPath.AddPath(More,false)
else
unitsearchpath.AddPath(More,true);
end;
'U' :
OutputUnitDir:=FixPath(More,true);
'W',
'w':
begin
if More<>'' then
begin
DefaultReplacements(More);
D:=ExtractFilePath(More);
if (D<>'') then
D:=FixPath(D,True);
D:=D+ExtractFileName(More);
if (c='W') then
WpoFeedbackOutput:=D
else
WpoFeedbackInput:=D;
end
else
IllegalPara(opt);
end;
else
IllegalPara(opt);
end;
end;
'g' :
begin
if UnsetBool(More, 0, opt, false) then
begin
exclude(init_settings.moduleswitches,cs_debuginfo);
exclude(init_settings.globalswitches,cs_use_heaptrc);
exclude(init_settings.globalswitches,cs_use_lineinfo);
exclude(init_settings.localswitches,cs_checkpointer);
paratargetdbg:=dbg_none;
localvartrashing := -1;
end
else
begin
include(init_settings.moduleswitches,cs_debuginfo);
if paratargetdbg=dbg_none then
paratargetdbg:=target_info.dbg;
end;
if not RelocSectionSetExplicitly then
RelocSection:=false;
j:=1;
while j<=length(more) do
begin
case more[j] of
'c' :
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_checkpointer)
else if (target_info.system in systems_support_checkpointer) then
begin
if do_release then
Message(option_gc_incompatible_with_release_flag)
else
include(init_settings.localswitches,cs_checkpointer);
end
else
UnsupportedPara('-gc');
end;
'h' :
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_use_heaptrc)
else
begin
if cs_gdb_valgrind in init_settings.globalswitches then
Message2(option_valgrind_heaptrc_mismatch,'-gh', '-gv');
include(init_settings.globalswitches,cs_use_heaptrc);
end;
end;
'l' :
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_use_lineinfo)
else
include(init_settings.globalswitches,cs_use_lineinfo);
end;
'm' :
begin
paratargetdbg:=dbg_codeview;
end;
'o' :
begin
if not UpdateDebugStr(copy(more,j+1,length(more)),init_settings.debugswitches) then
IllegalPara(opt);
break;
end;
'p' :
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_stabs_preservecase)
else
include(init_settings.globalswitches,cs_stabs_preservecase);
end;
's' :
begin
paratargetdbg:=dbg_stabs;
end;
't' :
begin
if UnsetBool(More, j, opt, false) then
localvartrashing := -1
else
localvartrashing := (localvartrashing + 1) mod nroftrashvalues;
end;
'v' :
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_gdb_valgrind)
else
begin
if cs_use_heaptrc in init_settings.globalswitches then
Message2(option_valgrind_heaptrc_mismatch,'-gh', '-gv');
include(init_settings.globalswitches,cs_gdb_valgrind);
end;
end;
'w' :
begin
if (j<length(more)) and (more[j+1] in ['2','3','4']) then
begin
case more[j+1] of
'2': paratargetdbg:=dbg_dwarf2;
'3': paratargetdbg:=dbg_dwarf3;
'4': paratargetdbg:=dbg_dwarf4;
end;
inc(j);
end
else
paratargetdbg:=dbg_dwarf2;
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
'h' :
begin
NoPressEnter:=true;
if (More <> '') and (More [1] = 'F') then
begin
FPCHelpLines := true;
Delete (More, 1, 1);
FPCBinaryPath := More;
end;
WriteHelpPages;
end;
'i' :
begin
if (More='') or
(More [1] in ['a', 'b', 'c', 'f', 'i', 'm', 'o', 'r', 't', 'u', 'w', 'x']) then
WriteInfo (More)
else
QuickInfo:=QuickInfo+More;
end;
'I' :
begin
if ispara then
ParaIncludePath.AddPath(More,false)
else
includesearchpath.AddPath(More,false);
end;
'k' :
begin
if more<>'' then
ParaLinkOptions:=ParaLinkOptions+' '+More
else
IllegalPara(opt);
end;
'l' :
ParaLogo:=not UnSetBool(more,0,opt,true);
{$ifdef PREPROCWRITE}
'm' :
parapreprocess:=not UnSetBool(more,0,opt,true);
{$endif PREPROCWRITE}
'M' :
begin
more:=Upper(more);
if not SetCompileMode(more, true) then
if not SetCompileModeSwitch(more, true) then
IllegalPara(opt);
end;
'n' :
begin
if More='' then
disable_configfile:=true
else
IllegalPara(opt);
end;
'o' :
begin
if More<>'' then
begin
DefaultReplacements(More);
D:=ExtractFilePath(More);
if (D<>'') then
OutputExeDir:=FixPath(D,True);
OutputFileName:=ExtractFileName(More);
end
else
IllegalPara(opt);
end;
'O' :
begin
j:=1;
while j<=length(more) do
begin
case more[j] of
'1' :
init_settings.optimizerswitches:=init_settings.optimizerswitches+level1optimizerswitches;
'2' :
init_settings.optimizerswitches:=init_settings.optimizerswitches+level2optimizerswitches;
'3' :
init_settings.optimizerswitches:=init_settings.optimizerswitches+level3optimizerswitches;
'4' :
init_settings.optimizerswitches:=init_settings.optimizerswitches+level4optimizerswitches;
'a' :
begin
if not(UpdateAlignmentStr(Copy(Opt,j+3,255),ParaAlignment)) then
IllegalPara(opt);
break;
end;
's' :
include(init_settings.optimizerswitches,cs_opt_size);
'p' :
begin
if not Setoptimizecputype(copy(more,j+1,length(more)),init_settings.optimizecputype) then
begin
OptCPUSetExplicitly:=true;
{ Give warning for old i386 switches }
if (Length(More)-j=1) and
(More[j+1]>='1') and (More[j+1]<='5')then
Message2(option_obsolete_switch_use_new,'-Op<nr>','-Op<name>')
else
IllegalPara(opt);
end;
break;
end;
'o' :
begin
if not UpdateOptimizerStr(copy(more,j+1,length(more)),init_settings.optimizerswitches) then
IllegalPara(opt);
break;
end;
'-' :
begin
init_settings.optimizerswitches:=[];
FillChar(ParaAlignment,sizeof(ParaAlignment),0);
end;
{ Obsolete switches }
'g' :
Message2(option_obsolete_switch_use_new,'-Og','-Os');
'G' :
Message1(option_obsolete_switch,'-OG');
'r' :
Message2(option_obsolete_switch_use_new,'-Or','-O2 or -Ooregvar');
'u' :
Message2(option_obsolete_switch_use_new,'-Ou','-Oouncertain');
'w' :
begin
if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.dowpoptimizerswitches) then
IllegalPara(opt);
break;
end;
'W' :
begin
if not UpdateWpoStr(copy(more,j+1,length(more)),init_settings.genwpoptimizerswitches) then
IllegalPara(opt);
break;
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
'p' :
begin
if UnsetBool(More, 0, opt, false) then
begin
init_settings.moduleswitches:=init_settings.moduleswitches-[cs_profile];
undef_system_macro('FPC_PROFILE');
end
else
if Length(More)=0 then
IllegalPara(opt)
else
case more[1] of
'g' : if UnsetBool(more, 1, opt, false) then
begin
exclude(init_settings.moduleswitches,cs_profile);
undef_system_macro('FPC_PROFILE');
end
else if (target_info.system in supported_targets_pg) then
begin
include(init_settings.moduleswitches,cs_profile);
def_system_macro('FPC_PROFILE');
end
else
UnsupportedPara('-pg');
else
IllegalPara(opt);
end;
end;
'P' :
begin
{ used to select the target processor with the "fpc" binary;
give an error if it's not the target architecture supported by
this compiler binary (will be verified after the target_info
is set) }
processorstr:=More;
end;
'R' :
begin
if not SetAsmReadMode(More,init_settings.asmmode) then
IllegalPara(opt);
end;
's' :
begin
if UnsetBool(More, 0, opt, false) then
begin
init_settings.globalswitches:=init_settings.globalswitches-[cs_asm_extern,cs_link_extern,cs_link_nolink];
if more<>'' then
IllegalPara(opt);
end
else
begin
init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_extern,cs_link_extern,cs_link_nolink];
if more='h' then
init_settings.globalswitches:=init_settings.globalswitches-[cs_link_on_target,cs_assemble_on_target]
else if more='t' then
init_settings.globalswitches:=init_settings.globalswitches+[cs_link_on_target,cs_assemble_on_target]
else if more='T' then
init_settings.globalswitches:=init_settings.globalswitches+[cs_link_on_target]-[cs_asm_extern]
else if more='r' then
init_settings.globalswitches:=init_settings.globalswitches+[cs_asm_leave,cs_no_regalloc]
else if more<>'' then
IllegalPara(opt);
end;
end;
'S' :
begin
if more='' then
IllegalPara(opt);
if more[1]='I' then
begin
{$ifdef jvm}
UnsupportedPara('-SI');
{$endif}
if upper(more)='ICOM' then
init_settings.interfacetype:=it_interfacecom
else if upper(more)='ICORBA' then
init_settings.interfacetype:=it_interfacecorba
else
IllegalPara(opt);
end
else
begin
j:=1;
while j<=length(more) do
begin
case more[j] of
'2' : //an alternative to -Mobjfpc
SetCompileMode('OBJFPC',true);
'a' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_do_assertion)
else
include(init_settings.localswitches,cs_do_assertion);
'c' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_support_c_operators)
else
include(init_settings.moduleswitches,cs_support_c_operators);
'C':
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_check_all_case_coverage)
else
include(init_settings.localswitches,cs_check_all_case_coverage);
'd' : //an alternative to -Mdelphi
SetCompileMode('DELPHI',true);
'e' :
begin
SetErrorFlags(copy(more,j+1,length(more)));
break;
end;
'f' :
begin
if not(cs_compilesystem in init_settings.moduleswitches) then
Message(option_features_only_for_system_unit);
inc(j);
if more[j]='-' then
begin
if length(more)>j then
IllegalPara(opt)
else
features:=[];
end
else
begin
if (HandleFeature(upper(copy(more,j,length(more)-j+1)))) then
j:=length(more)
else
IllegalPara(opt);
end;
end;
'g' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_support_goto)
else
include(init_settings.moduleswitches,cs_support_goto);
'h' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_refcountedstrings)
else
include(init_settings.localswitches,cs_refcountedstrings);
'i' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_do_inline)
else
include(init_settings.localswitches,cs_do_inline);
'j' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_typed_const_writable)
else
include(init_settings.localswitches,cs_typed_const_writable);
'k' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_load_fpcylix_unit)
else
include(init_settings.globalswitches,cs_load_fpcylix_unit);
'm' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_support_macro)
else
include(init_settings.moduleswitches,cs_support_macro);
'o' : //an alternative to -Mtp
SetCompileMode('TP',true);
'r' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_transparent_file_names)
else
include(init_settings.globalswitches,cs_transparent_file_names);
{$ifdef gpc_mode}
'p' : //an alternative to -Mgpc
SetCompileMode('GPC',true);
{$endif}
's' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_constructor_name)
else
include(init_settings.globalswitches,cs_constructor_name);
't' :
Message1(option_obsolete_switch,'-St');
'v' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_support_vectors)
else
include(init_settings.globalswitches,cs_support_vectors);
'x' :
If UnsetBool(More, j, opt, false) then
SetCompileModeSwitch('EXCEPTIONS-',true)
else
SetCompileModeSwitch('EXCEPTIONS',true);
'y' :
If UnsetBool(More, j, opt, false) then
exclude(init_settings.localswitches,cs_typed_addresses)
else
include(init_settings.localswitches,cs_typed_addresses);
'-' :
begin
init_settings.globalswitches:=init_settings.globalswitches - [cs_constructor_name,cs_support_exceptions,
cs_support_vectors,cs_load_fpcylix_unit];
init_settings.localswitches:=init_settings.localswitches - [cs_do_assertion,cs_do_inline, cs_refcountedstrings,
cs_typed_addresses];
init_settings.moduleswitches:=init_settings.moduleswitches - [cs_support_c_operators, cs_support_goto,
cs_support_macro];
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
end;
'T' :
begin
more:=Upper(More);
if paratarget=system_none then
begin
{ remove old target define }
TargetOptions(false);
{ load new target }
paratarget:=find_system_by_string(More);
if paratarget<>system_none then
set_target(paratarget)
else
IllegalPara(opt);
{ set new define }
TargetOptions(true);
end
else
if More<>upper(target_info.shortname) then
Message1(option_target_is_already_set,target_info.shortname);
end;
'u' :
if is_identifier(more) then
undef_system_macro(more)
else
begin
if (more='') then
Message1(option_missing_arg,'-u')
else
Message1(option_malformed_para,opt);
StopOptions(1);
end;
'U' :
begin
j:=1;
while j<=length(more) do
begin
case more[j] of
{$ifdef UNITALIASES}
'a' :
begin
AddUnitAlias(Copy(More,j+1,255));
break;
end;
{$endif UNITALIASES}
'n' :
exclude(init_settings.globalswitches,cs_check_unit_name);
'p' :
begin
Message2(option_obsolete_switch_use_new,'-Up','-Fu');
break;
end;
'r' :
begin
do_release:=true;
if (cs_checkpointer in init_settings.localswitches) then
begin
Message(option_gc_incompatible_with_release_flag);
exclude(init_settings.localswitches,cs_checkpointer);
end;
end;
's' :
include(init_settings.moduleswitches,cs_compilesystem);
'-' :
begin
exclude(init_settings.moduleswitches,cs_compilesystem);
exclude(init_settings.globalswitches,cs_check_unit_name);
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
'v' :
begin
if not setverbosity(More) then
IllegalPara(opt);
end;
'V' : ; { Ignore used by fpc }
'W' :
begin
j:=1;
while j<=length(More) do
begin
case More[j] of
'A':
begin
if target_info.system in systems_all_windows then
begin
if UnsetBool(More, j, opt, false) then
SetApptype(app_cui)
else
SetApptype(app_native);
end
else
IllegalPara(opt);
end;
'b':
begin
if target_info.system in systems_darwin then
begin
if UnsetBool(More, j, opt, false) then
SetApptype(app_cui)
else
SetApptype(app_bundle)
end
else
IllegalPara(opt);
end;
'B':
begin
if target_info.system in systems_all_windows+systems_symbian+[system_z80_zxspectrum] then
begin
{ -WB200000 means set trefered base address
to $200000, but does not change relocsection boolean
this way we can create both relocatble and
non relocatable DLL at a specific base address PM }
if (length(More)>j) then
begin
val('$'+Copy(More,j+1,255),imagebase,code);
if code<>0 then
IllegalPara(opt);
ImageBaseSetExplicity:=true;
end
else
begin
RelocSection:=true;
RelocSectionSetExplicitly:=true;
end;
break;
end
else
IllegalPara(opt);
end;
'C':
begin
if target_info.system in systems_all_windows+systems_os2+systems_macos then
begin
if UnsetBool(More, j, opt, false) then
SetApptype(app_gui)
else
SetApptype(app_cui);
end
else
IllegalPara(opt);
end;
'D':
begin
if target_info.system in systems_all_windows then
begin
UseDeffileForExports:=not UnsetBool(More, j, opt, false);
UseDeffileForExportsSetExplicitly:=true;
end
else
IllegalPara(opt);
end;
'e':
begin
if (target_info.system in systems_darwin) then
begin
set_target_res(res_ext);
target_info.resobjext:='.fpcres';
end
else
IllegalPara(opt);
end;
'F':
begin
if target_info.system in systems_os2 then
begin
if UnsetBool(More, j, opt, false) then
SetApptype(app_cui)
else
SetApptype(app_fs);
end
else
IllegalPara(opt);
end;
'G':
begin
if target_info.system in systems_all_windows+systems_os2+systems_macos then
begin
if UnsetBool(More, j, opt, false) then
SetApptype(app_cui)
else
SetApptype(app_gui);
end
else
IllegalPara(opt);
end;
{$if defined(i8086)}
'h':
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_huge_code)
else
include(init_settings.moduleswitches,cs_huge_code);
end;
{$endif defined(i8086)}
'I':
begin
if target_info.system in systems_all_windows then
begin
GenerateImportSection:=not UnsetBool(More,j,opt,false);
GenerateImportSectionSetExplicitly:=true;
end
else
IllegalPara(opt);
end;
'i':
begin
if (target_info.system in systems_darwin) then
begin
set_target_res(res_macho);
target_info.resobjext:=
targetinfos[target_info.system]^.resobjext;
end
else
IllegalPara(opt);
end;
'm':
begin
{$if defined(i8086)}
if (target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) then
begin
case Upper(Copy(More,j+1,255)) of
'TINY': init_settings.x86memorymodel:=mm_tiny;
'SMALL': init_settings.x86memorymodel:=mm_small;
'MEDIUM': init_settings.x86memorymodel:=mm_medium;
'COMPACT': init_settings.x86memorymodel:=mm_compact;
'LARGE': init_settings.x86memorymodel:=mm_large;
'HUGE': init_settings.x86memorymodel:=mm_huge;
else
IllegalPara(opt);
end;
break;
end
else
{$endif defined(i8086)}
IllegalPara(opt);
end;
'M':
begin
if (target_info.system in (systems_darwin-[system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim])) and
ParseMacVersionMin(MacOSXVersionMin,iPhoneOSVersionMin,'MAC_OS_X_VERSION_MIN_REQUIRED',copy(More,2,255),false) then
begin
break;
end
else
IllegalPara(opt);
end;
'N':
begin
if target_info.system in systems_all_windows then
begin
RelocSection:=UnsetBool(More,j,opt,false);
RelocSectionSetExplicitly:=true;
end
else
IllegalPara(opt);
end;
'p':
begin
{$push}
{$warn 6018 off} { Unreachable code due to compile time evaluation }
if ((target_info.system in systems_embedded) or (target_info.system in systems_freertos)) and
ControllerSupport then
begin
s:=upper(copy(more,j+1,length(more)-j));
if not(SetControllerType(s,init_settings.controllertype)) then
IllegalPara(opt)
else
begin
if init_settings.cputype<>embedded_controllers[init_settings.controllertype].cputype then
begin
Message(scan_n_changecputype);
init_settings.cputype:=embedded_controllers[init_settings.controllertype].cputype;
end;
end;
break;
end
else
IllegalPara(opt);
{$pop}
end;
'P':
begin
if (target_info.system in [system_i386_iphonesim,system_arm_ios,system_aarch64_ios,system_x86_64_iphonesim]) and
ParseMacVersionMin(iPhoneOSVersionMin,MacOSXVersionMin,'IPHONE_OS_VERSION_MIN_REQUIRED',copy(More,2,255),true) then
begin
break;
end
else
IllegalPara(opt);
end;
{$if defined(m68k)}
'Q':
begin
if (target_info.system in [system_m68k_sinclairql]) then
begin
sinclairql_metadata_format:=Upper(Copy(More,j+1,255));
case sinclairql_metadata_format of
'QHDR', 'XTCC': ; { allowed formats }
else
IllegalPara(opt);
end;
break;
end
else
IllegalPara(opt);
end;
{$endif defined(m68k)}
'R':
begin
if target_info.system in systems_all_windows then
begin
{ support -WR+ / -WR- as synonyms to -WR / -WN }
RelocSection:=not UnsetBool(More,j,opt,false);
RelocSectionSetExplicitly:=true;
end
else
IllegalPara(opt);
end;
't':
begin
{$if defined(i8086)}
if (target_info.system in [system_i8086_msdos,system_i8086_embedded]) then
begin
case Upper(Copy(More,j+1,255)) of
'EXE': SetAppType(app_cui);
'COM': SetAppType(app_com);
else
IllegalPara(opt);
end;
break;
end
else
{$endif defined(i8086)}
IllegalPara(opt);
end;
'T':
begin
if target_info.system in systems_macos then
begin
if UnsetBool(More, j, opt, false) then
SetApptype(app_cui)
else
SetApptype(app_tool);
end
else
IllegalPara(opt);
end;
'X':
begin
if (target_info.system in systems_linux) then
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.moduleswitches,cs_executable_stack)
else
include(init_settings.moduleswitches,cs_executable_stack)
end
else
IllegalPara(opt);
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
'X' :
begin
j:=1;
while j<=length(more) do
begin
case More[j] of
'9' :
begin
if target_info.system in systems_linux then
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_pre_binutils_2_19)
else
include(init_settings.globalswitches,cs_link_pre_binutils_2_19);
end
else
IllegalPara(opt);
end;
'a' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_large)
else
include(init_settings.globalswitches,cs_large);
end;
'c' : Cshared:=TRUE;
'd' : Dontlinkstdlibpath:=TRUE;
'e' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_extern)
else
include(init_settings.globalswitches,cs_link_extern);
end;
'f' :
include(init_settings.globalswitches,cs_link_pthread);
'g' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_separate_dbg_file)
else
include(init_settings.globalswitches,cs_link_separate_dbg_file);
end;
'i' :
begin
If UnsetBool(More, j, opt, false) then
include(init_settings.globalswitches,cs_link_extern)
else
exclude(init_settings.globalswitches,cs_link_extern);
end;
'n' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_native)
else
include(init_settings.globalswitches,cs_link_native);
end;
{$ifdef llvm}
'l' :
begin
if j=length(more) then
IllegalPara(opt)
else
begin
case more[j+1] of
'S':
begin
llvmutilssuffix:=copy(more,j+2,length(more));
j:=length(more);
end
else
IllegalPara(opt);
end;
end;
end;
{$endif}
'm' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_map)
else
include(init_settings.globalswitches,cs_link_map);
end;
'p' : ; { Ignore used by fpc.pp }
'r' :
begin
if (target_info.system in suppported_targets_x_smallr) then
begin
rlinkpath:=Copy(more,2,length(More)-1);
DefaultReplacements(rlinkpath);
end
else
IgnoredPara('-Xr');
more:='';
end;
'R' :
begin
sysrootpath:=copy(more,2,length(more)-1);
defaultreplacements(sysrootpath);
more:='';
end;
's' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_strip)
else
include(init_settings.globalswitches,cs_link_strip);
end;
't' :
include(init_settings.globalswitches,cs_link_staticflag);
'u' :
begin
if target_info.system in systems_support_uf2 then
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_generate_uf2)
else
include(init_settings.globalswitches,cs_generate_uf2);
end
else
IgnoredPara('-Xu');
end;
'v' :
begin
If UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_opt_vtable)
else
include(init_settings.globalswitches,cs_link_opt_vtable);
end;
'D' :
begin
def_system_macro('FPC_LINK_DYNAMIC');
undef_system_macro('FPC_LINK_SMART');
undef_system_macro('FPC_LINK_STATIC');
exclude(init_settings.globalswitches,cs_link_static);
exclude(init_settings.globalswitches,cs_link_smart);
include(init_settings.globalswitches,cs_link_shared);
LinkTypeSetExplicitly:=true;
end;
'M' :
begin
mainaliasname:=Copy(more,2,length(More)-1);
More:='';
end;
'P' :
begin
utilsprefix:=Copy(more,2,length(More)-1);
DefaultReplacements(utilsprefix);
More:='';
end;
'L' : begin // -XLO is link order -XLA is link alias. -XLD avoids load defaults.
// these are not aggregable.
if (j=length(more)) or not (more[j+1] in ['O','A','D']) then
IllegalPara(opt)
else
begin
case more[j+1] of
'A' : begin
s:=Copy(more,3,length(More)-2);
if not LinkLibraryAliases.AddDep(s) Then
IllegalPara(opt);
end;
'O' : begin
s:=Copy(more,3,length(More)-2);
if not LinkLibraryOrder.AddWeight(s) Then
IllegalPara(opt);
end;
'D' : include(init_settings.globalswitches,cs_link_no_default_lib_order)
else
IllegalPara(opt);
end; {case}
j:=length(more);
end; {else begin}
end;
'S' :
begin
ForceStaticLinking;
end;
'V' :
begin
if UnsetBool(More, j, opt, false) then
exclude(init_settings.globalswitches,cs_link_vlink)
else
begin
include(init_settings.globalswitches,cs_link_vlink);
include(init_settings.globalswitches,cs_link_extern);
end;
LinkerSetExplicitly:=true;
end;
'X' :
begin
def_system_macro('FPC_LINK_SMART');
undef_system_macro('FPC_LINK_STATIC');
undef_system_macro('FPC_LINK_DYNAMIC');
exclude(init_settings.globalswitches,cs_link_static);
include(init_settings.globalswitches,cs_link_smart);
exclude(init_settings.globalswitches,cs_link_shared);
LinkTypeSetExplicitly:=true;
end;
'-' :
begin
exclude(init_settings.globalswitches,cs_link_staticflag);
exclude(init_settings.globalswitches,cs_link_strip);
exclude(init_settings.globalswitches,cs_link_map);
set_default_link_type;
end;
else
IllegalPara(opt);
end;
inc(j);
end;
end;
else
IllegalPara(opt);
end;
end;
'@' :
begin
Message(option_no_nested_response_file);
StopOptions(1);
end;
else
begin
if (length(param_file)<>0) then
Message2(option_only_one_source_support,param_file,opt);
param_file:=opt;
Message1(option_found_file,opt);
end;
end;
end;
procedure Toption.Interpret_file(const filename : TPathStr);
procedure RemoveSep(var fn:TPathStr);
var
i : longint;
begin
i:=0;
while (i<length(fn)) and (fn[i+1] in [',',' ',#9]) do
inc(i);
Delete(fn,1,i);
i:=length(fn);
while (i>0) and (fn[i] in [',',' ',#9]) do
dec(i);
fn:=copy(fn,1,i);
end;
function GetName(var fn:TPathStr):TPathStr;
var
i : longint;
begin
i:=0;
while (i<length(fn)) and (fn[i+1] in ['a'..'z','A'..'Z','0'..'9','_','-']) do
inc(i);
GetName:=Copy(fn,1,i);
Delete(fn,1,i);
end;
const
maxlevel = 15;
var
f : text;
s, tmp,
opts : TCmdStr;
skip : array[0..maxlevel] of boolean;
line,
level : longint;
option_read : boolean;
oldfilemode : byte;
ConfigFile: TPathStr;
begin
{ avoid infinite loop }
Inc(FileLevel);
Option_read:=false;
If FileLevel>MaxLevel then
Message(option_too_many_cfg_files);
if not ParaIncludeCfgPath.FindFile(fileName,true,ConfigFile) then
ConfigFile := ExpandFileName(filename);
{ Maybe It's Directory ?} //Jaro Change:
if PathExists(ConfigFile,false) then
begin
Message1(option_config_is_dir,filename);
exit;
end;
{ open file }
Message1(option_using_file,filename);
oldfilemode:=filemode;
filemode:=0;
assign(f,ConfigFile);
{$push}{$I-}
reset(f);
{$pop}
filemode:=oldfilemode;
if ioresult<>0 then
begin
Message1(option_unable_open_file,filename);
exit;
end;
Message1(option_start_reading_configfile,filename);
fillchar(skip,sizeof(skip),0);
level:=0;
line:=0;
while not eof(f) do
begin
readln(f,opts);
inc(line);
RemoveSep(opts);
if (opts<>'') and (opts[1]<>';') then
begin
if opts[1]='#' then
begin
Message1(option_interpreting_file_option,opts);
Delete(opts,1,1);
s:=upper(GetName(opts));
if (s='SECTION') then
begin
RemoveSep(opts);
s:=upper(GetName(opts));
if level=0 then
skip[level]:=not defined_macro(s) or (s='COMMON');
end
else
if (s='IFDEF') then
begin
RemoveSep(opts);
if Level>=maxlevel then
begin
Message2(option_too_many_ifdef,filename,tostr(line));
stopOptions(1);
end;
inc(Level);
skip[level]:=(skip[level-1] or not defined_macro(upper(GetName(opts))));
end
else
if (s='IFNDEF') then
begin
RemoveSep(opts);
if Level>=maxlevel then
begin
Message2(option_too_many_ifdef,filename,tostr(line));
stopOptions(1);
end;
inc(Level);
skip[level]:=(skip[level-1] or defined_macro(upper(GetName(opts))));
end
else
if (s='ELSE') then
begin
if Level=0 then
begin
Message2(option_else_without_if,filename,tostr(line));
stopOptions(1);
end
else
skip[level]:=skip[level-1] or (not skip[level])
end
else
if (s='ENDIF') then
begin
skip[level]:=false;
if Level=0 then
begin
Message2(option_too_many_endif,filename,tostr(line));
stopOptions(1);
end;
dec(level);
end
else
if (not skip[level]) then
begin
if (s='DEFINE') then
begin
RemoveSep(opts);
tmp:= GetName(opts);
if tmp <> '' then
def_system_macro(tmp);
Option_read:=true;
end
else
if (s='UNDEF') then
begin
RemoveSep(opts);
tmp:= GetName(opts);
if tmp <> '' then
undef_system_macro(tmp);
Option_read:=true;
end
else
if (s='WRITE') then
begin
Delete(opts,1,1);
DefaultReplacements(opts);
WriteLn(opts);
Option_read:=true;
end
else
if (s='INCLUDE') then
begin
Delete(opts,1,1);
DefaultReplacements(opts);
Interpret_file(opts);
Option_read:=true;
end
else
if (s='CFGDIR') then
begin
Delete(opts,1,1);
DefaultReplacements(opts);
ParaIncludeCfgPath.AddPath(opts,false);
Option_read:=true;
end;
end;
end
else
begin
if (opts[1]='-') or (opts[1]='@') then
begin
if (not skip[level]) then
interpret_option(opts,false);
Option_read:=true;
end
else
Message1(option_illegal_para,opts);
end;
end;
end;
if Level>0 then
Message(option_too_less_endif);
if Not Option_read then
Message1(option_no_option_found,filename)
else
Message1(option_end_reading_configfile,filename);
Close(f);
Dec(FileLevel);
end;
procedure Toption.Interpret_envvar(const envname : TCmdStr);
var
argstart,
env,
pc : pchar;
arglen : longint;
quote : set of char;
hs : TCmdStr;
begin
Message1(option_using_env,envname);
env:=GetEnvPChar(envname);
pc:=env;
hs:='';
if assigned(pc) then
begin
repeat
{ skip leading spaces }
while pc^ in [' ',#9,#13] do
inc(pc);
case pc^ of
#0 :
break;
'"' :
begin
quote:=['"'];
inc(pc);
end;
'''' :
begin
quote:=[''''];
inc(pc);
end;
else
quote:=[' ',#9,#13];
end;
{ scan until the end of the argument }
argstart:=pc;
while (pc^<>#0) and not(pc^ in quote) do
inc(pc);
{ create argument }
arglen:=pc-argstart;
{ TODO: FIXME: silent truncation of environment parameters }
if (arglen > 255) then
arglen := 255;
setlength(hs,arglen);
move(argstart^,hs[1],arglen);
interpret_option(hs,true);
{ skip quote }
if pc^ in quote then
inc(pc);
until false;
end
else
Message1(option_no_option_found,'(env) '+envname);
FreeEnvPChar(env);
end;
procedure toption.read_parameters;
var
opts : TCmdStr;
paramindex : longint;
begin
paramindex:=0;
while paramindex<paramcount do
begin
inc(paramindex);
opts:=objpas.paramstr(paramindex);
if length(opts)>0 then
case opts[1] of
'@' :
if not firstpass then
begin
Delete(opts,1,1);
Message1(option_reading_further_from,opts);
interpret_file(opts);
end;
'!' :
if not firstpass then
begin
Delete(opts,1,1);
Message1(option_reading_further_from,'(env) '+opts);
interpret_envvar(opts);
end;
else
interpret_option(opts,true);
end;
end;
end;
procedure toption.parsecmd(cmd:TCmdStr);
var
i,ps : longint;
opts : TCmdStr;
begin
while (cmd<>'') do
begin
while cmd[1]=' ' do
delete(cmd,1,1);
i:=pos(' ',cmd);
if i=0 then
i:=2147483647;
opts:=Copy(cmd,1,i-1);
Delete(cmd,1,i);
case opts[1] of
'@' :
if not firstpass then
begin
Delete(opts,1,1);
Message1(option_reading_further_from,opts);
interpret_file(opts);
end;
'!' :
if not firstpass then
begin
Delete(opts,1,1);
Message1(option_reading_further_from,'(env) '+opts);
interpret_envvar(opts);
end;
'"' :
begin
Delete(opts,1,1);
ps:=pos('"',cmd);
if (i<>256) and (ps>0) then
begin
opts:=opts + ' '+ copy(cmd,1,ps-1);
cmd:=copy(cmd,ps+1,255);
end;
interpret_option(opts,true);
end;
else
interpret_option(opts,true);
end;
end;
end;
procedure toption.writequickinfo;
var
s : string;
i : longint;
procedure addinfo(const hs:string);
begin
if s<>'' then
s:=s+' '+hs
else
s:=hs;
end;
begin
s:='';
i:=0;
while (i<length(quickinfo)) do
begin
inc(i);
case quickinfo[i] of
'S' :
begin
inc(i);
case quickinfo[i] of
'O' :
addinfo(lower(source_info.shortname));
'P' :
addinfo(source_cpu_string);
else
IllegalPara('-i'+QuickInfo);
end;
end;
'T' :
begin
inc(i);
case quickinfo[i] of
'O' :
addinfo(lower(target_info.shortname));
'P' :
AddInfo(target_cpu_string);
else
IllegalPara('-i'+QuickInfo);
end;
end;
'V' :
AddInfo(version_string);
'W' :
AddInfo(full_version_string);
'D' :
AddInfo(date_string);
'_' :
;
else
IllegalPara('-i'+QuickInfo);
end;
end;
if s<>'' then
begin
writeln(s);
stopoptions(0);
end;
end;
procedure TOption.TargetOptions(def:boolean);
var
s : string;
i : integer;
target_unsup_features : tfeatures;
begin
if def then
def_system_macro(target_info.shortname)
else
undef_system_macro(target_info.shortname);
s:=target_info.extradefines;
while (s<>'') do
begin
i:=pos(';',s);
if i=0 then
i:=length(s)+1;
if def then
def_system_macro(Copy(s,1,i-1))
else
undef_system_macro(Copy(s,1,i-1));
delete(s,1,i);
end;
if (tf_winlikewidestring in target_info.flags) then
if def then
def_system_macro('FPC_WINLIKEWIDESTRING')
else
undef_system_macro('FPC_WINLIKEWIDESTRING');
if (tf_requires_proper_alignment in target_info.flags) then
if def then
def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT')
else
undef_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
if (tf_init_final_units_by_calls in target_info.flags) then
if def then
def_system_macro('FPC_INIT_FINAL_UNITS_BY_CALLS')
else
undef_system_macro('FPC_INIT_FINAL_UNITS_BY_CALLS');
if source_info.system<>target_info.system then
if def then
def_system_macro('FPC_CROSSCOMPILING')
else
undef_system_macro('FPC_CROSSCOMPILING');
if source_info.cpu<>target_info.cpu then
if def then
def_system_macro('FPC_CPUCROSSCOMPILING')
else
def_system_macro('FPC_CPUCROSSCOMPILING');
if (tf_no_generic_stackcheck in target_info.flags) then
if def then
def_system_macro('FPC_NO_GENERIC_STACK_CHECK')
else
undef_system_macro('FPC_NO_GENERIC_STACK_CHECK');
if (tf_section_threadvars in target_info.flags) then
if def then
def_system_macro('FPC_SECTION_THREADVARS')
else
undef_system_macro('FPC_SECTION_THREADVARS');
if (tf_use_psabieh in target_info.flags) then
if def then
def_system_macro('FPC_USE_PSABIEH')
else
undef_system_macro('FPC_USE_PSABIEH');
{ Code generation flags }
if (tf_pic_default in target_info.flags) then
if def then
include(init_settings.moduleswitches,cs_create_pic)
else
exclude(init_settings.moduleswitches,cs_create_pic);
{ Resources support }
if (tf_has_winlike_resources in target_info.flags) then
if def then
def_system_macro('FPC_HAS_WINLIKERESOURCES')
else
undef_system_macro('FPC_HAS_WINLIKERESOURCES');
{ Features }
case target_info.system of
system_arm_gba:
target_unsup_features:=[f_dynlibs];
system_arm_nds:
target_unsup_features:=[f_threading,f_commandargs,f_fileio,f_textio,f_consoleio,f_dynlibs];
system_i386_nativent:
// until these features are implemented, they are disabled in the compiler
target_unsup_features:=[f_stackcheck];
system_i8086_msdos:
target_unsup_features:=[f_threading,f_dynlibs];
system_i8086_win16:
target_unsup_features:=[f_threading];
system_jvm_java32,
system_jvm_android32:
target_unsup_features:=[f_heap,f_textio,f_consoleio,f_fileio,
f_variants,f_objects,f_commandargs,
f_processes,f_stackcheck,f_dynlibs,f_softfpu,f_objectivec1,f_resources];
system_arm_palmos,
system_m68k_palmos:
target_unsup_features:=[f_threading];
system_m68k_atari:
target_unsup_features:=[f_threading];
{ classic amiga has dynamic libraries, but they cannot be integrated in the
normal dynlibs infrastructure due to architectural differences, so therefore
lets disable the feature. }
system_m68k_amiga:
target_unsup_features:=[f_dynlibs];
system_m68k_sinclairql:
target_unsup_features:=[f_threading,f_dynlibs,f_commandargs,f_exitcode];
system_z80_zxspectrum:
target_unsup_features:=[f_threading,f_dynlibs{,f_fileio,f_textio},f_commandargs,f_exitcode];
system_z80_msxdos:
target_unsup_features:=[f_threading,f_dynlibs];
else
target_unsup_features:=[];
end;
if def then
features:=features-target_unsup_features
else
features:=features+target_unsup_features;
{$if defined(atari) or defined(hasamiga)}
{ enable vlink as default linker on Atari and Amiga but not for cross compilers (for now) }
if (target_info.system in [system_m68k_amiga,system_m68k_atari,system_powerpc_amiga]) and
not LinkerSetExplicitly then
include(init_settings.globalswitches,cs_link_vlink);
{$endif}
{$ifdef m68k}
if (target_info.system in [system_m68k_sinclairql]) and
not LinkerSetExplicitly then
include(init_settings.globalswitches,cs_link_vlink);
{$endif m68k}
end;
procedure TOption.checkoptionscompatibility;
begin
{$ifdef i8086}
if (apptype=app_com) and (init_settings.x86memorymodel<>mm_tiny) then
begin
Message(option_com_files_require_tiny_model);
StopOptions(1);
end;
{$endif i8086}
{$ifndef i8086_link_intern_debuginfo}
if (cs_debuginfo in init_settings.moduleswitches) and
(target_info.system in [system_i8086_msdos,system_i8086_win16,system_i8086_embedded]) and
not (cs_link_extern in init_settings.globalswitches) then
begin
Message(option_debug_info_requires_external_linker);
include(init_settings.globalswitches,cs_link_extern);
end;
{$endif i8086_link_intern_debuginfo}
if (paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) and
not(target_info.system in (systems_darwin+[system_i8086_msdos,system_i8086_embedded])) then
begin
{ smartlink creation does not yet work with DWARF
debug info on most targets, but it works in internal assembler }
if (cs_create_smart in init_settings.moduleswitches) and
not (af_outputbinary in target_asm.flags) then
begin
Message(option_dwarf_smartlink_creation);
exclude(init_settings.moduleswitches,cs_create_smart);
end;
{ smart linking does not yet work with DWARF debug info on most targets }
if (cs_link_smart in init_settings.globalswitches) then
begin
Message(option_dwarf_smart_linking);
ForceStaticLinking;
end;
end;
{ external debug info is only supported for DWARF on darwin }
if (target_info.system in systems_darwin) and
(cs_link_separate_dbg_file in init_settings.globalswitches) and
not(paratargetdbg in [dbg_dwarf2,dbg_dwarf3]) then
begin
Message(option_debug_external_unsupported);
exclude(init_settings.globalswitches,cs_link_separate_dbg_file);
end;
{ Also create a smartlinked version, on an assembler that
does not support smartlink sections like nasm?
This is not compatible with using internal linker. }
if ((cs_link_smart in init_settings.globalswitches) or
(cs_create_smart in init_settings.moduleswitches)) and
(af_needar in target_asm.flags) and
not (af_smartlink_sections in target_asm.flags) and
not (cs_link_extern in init_settings.globalswitches) and
(target_info.link<>ld_none) and
not (cs_link_nolink in init_settings.globalswitches) then
begin
Message(option_smart_link_requires_external_linker);
include(init_settings.globalswitches,cs_link_extern);
end;
end;
constructor TOption.create;
begin
LogoWritten:=false;
NoPressEnter:=false;
FirstPass:=false;
ABISetExplicitly:=false;
FPUSetExplicitly:=false;
CPUSetExplicitly:=false;
OptCPUSetExplicitly:=false;
FileLevel:=0;
Quickinfo:='';
ParaIncludeCfgPath:=TSearchPathList.Create;
ParaIncludePath:=TSearchPathList.Create;
ParaObjectPath:=TSearchPathList.Create;
ParaUnitPath:=TSearchPathList.Create;
ParaLibraryPath:=TSearchPathList.Create;
ParaFrameworkPath:=TSearchPathList.Create;
parapackagepath:=TSearchPathList.Create;
parapackages:=TFPHashObjectList.Create;
paranamespaces:=TCmdStrList.Create;
FillChar(ParaAlignment,sizeof(ParaAlignment),0);
MacVersionSet:=false;
paratarget:=system_none;
paratargetasm:=as_none;
paratargetdbg:=dbg_none;
LinkTypeSetExplicitly:=false;
LinkerSetExplicitly:=false;
end;
destructor TOption.destroy;
begin
ParaIncludeCfgPath.Free;
ParaIncludePath.Free;
ParaObjectPath.Free;
ParaUnitPath.Free;
ParaLibraryPath.Free;
ParaFrameworkPath.Free;
parapackagepath.Free;
ParaPackages.Free;
paranamespaces.free;
end;
{****************************************************************************
Callable Routines
****************************************************************************}
function check_configfile(fn:string; var foundfn:string):boolean;
function CfgFileExists(const fn:string):boolean;
begin
Comment(V_Tried,'Configfile search: '+fn);
CfgFileExists:=FileExists(fn);
end;
var
{$ifdef Unix}
hs,
{$endif Unix}
configpath : string;
begin
foundfn:=fn;
check_configfile:=true;
{ retrieve configpath }
configpath:=FixPath(GetEnvironmentVariable('PPC_CONFIG_PATH'),false);
{$ifdef Unix}
if configpath='' then
configpath:=ExpandFileName(FixPath(exepath+'../etc/',false));
{$endif}
{
Order to read configuration file :
try reading fpc.cfg in :
1 - current dir
2 - configpath
3 - compiler path
}
if not FileExists(fn) then
begin
{$ifdef Unix}
hs:=GetEnvironmentVariable('HOME');
if (hs<>'') and CfgFileExists(FixPath(hs,false)+'.'+fn) then
foundfn:=FixPath(hs,false)+'.'+fn
else
{$endif}
if CfgFileExists(configpath+fn) then
foundfn:=configpath+fn
else
{$ifdef WINDOWS}
if (GetEnvironmentVariable('USERPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn) then
foundfn:=FixPath(GetEnvironmentVariable('USERPROFILE'),false)+fn
else
if (GetEnvironmentVariable('ALLUSERSPROFILE')<>'') and CfgFileExists(FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn) then
foundfn:=FixPath(GetEnvironmentVariable('ALLUSERSPROFILE'),false)+fn
else
{$endif WINDOWS}
{$ifndef Unix}
if CfgFileExists(exepath+fn) then
foundfn:=exepath+fn
else
{$else}
if CfgFileExists('/etc/'+fn) then
foundfn:='/etc/'+fn
else
{$endif}
check_configfile:=false;
end;
end;
procedure read_arguments(cmd:TCmdStr);
procedure def_cpu_macros;
var
abi : tabi;
fputype : tfputype;
cputype : tcputype;
controller: tcontrollertype;
s: string;
begin
{$ifdef llvm}
def_system_macro('CPULLVM');
{$endif}
for cputype:=low(tcputype) to high(tcputype) do
undef_system_macro('CPU'+Cputypestr[cputype]);
def_system_macro('CPU'+Cputypestr[init_settings.cputype]);
for fputype:=low(tfputype) to high(tfputype) do
undef_system_macro('FPU'+fputypestr[fputype]);
def_system_macro('FPU'+fputypestr[init_settings.fputype]);
{$PUSH}
{$WARN 6018 OFF} { Unreachable code due to compile time evaluation }
if ControllerSupport then
begin
for controller:=low(tcontrollertype) to high(tcontrollertype) do
begin
s:=embedded_controllers[controller].controllertypestr;
if s<>'' then
undef_system_macro('FPC_MCU_'+s);
end;
s:=embedded_controllers[init_settings.controllertype].controllertypestr;
if s<>'' then
def_system_macro('FPC_MCU_'+s);
end;
{$POP}
{ define abi }
for abi:=low(tabi) to high(tabi) do
undef_system_macro('FPC_ABI_'+abiinfo[abi].name);
def_system_macro('FPC_ABI_'+abiinfo[target_info.abi].name);
{ Define FPC_ABI_EABI in addition to FPC_ABI_EABIHF on EABI VFP hardfloat
systems since most code needs to behave the same on both}
if target_info.abi = abi_eabihf then
def_system_macro('FPC_ABI_EABI');
{ using a case is pretty useless here (FK) }
{ some stuff for TP compatibility }
{$ifdef i386}
def_system_macro('CPU86');
def_system_macro('CPU87');
def_system_macro('CPU386');
{$endif}
{ new processor stuff }
{$ifdef i386}
def_system_macro('CPUI386');
def_system_macro('CPU32');
def_system_macro('CPUX86');
def_system_macro('FPC_HAS_TYPE_EXTENDED');
def_system_macro('FPC_HAS_TYPE_DOUBLE');
def_system_macro('FPC_HAS_TYPE_SINGLE');
{$endif}
{$ifdef m68k}
def_system_macro('CPU68');
def_system_macro('CPU68K');
def_system_macro('CPUM68K');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif}
{$ifdef powerpc}
def_system_macro('CPUPOWERPC');
def_system_macro('CPUPOWERPC32');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif}
{$ifdef POWERPC64}
def_system_macro('CPUPOWERPC');
def_system_macro('CPUPOWERPC64');
def_system_macro('CPU64');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif}
{$ifdef x86_64}
def_system_macro('CPUX86_64');
def_system_macro('CPUAMD64');
def_system_macro('CPU64');
def_system_macro('CPUX64');
{ not supported for now, afaik (FK)
def_system_macro('FPC_HAS_TYPE_FLOAT128'); }
{$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
{ normally, win64 doesn't support the legacy fpu }
if target_info.system=system_x86_64_win64 then
begin
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
end;
{$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
{$endif}
{$ifdef sparc}
def_system_macro('CPUSPARCGEN');
def_system_macro('CPUSPARC');
def_system_macro('CPUSPARC32');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif}
{$ifdef sparc64}
def_system_macro('CPUSPARCGEN');
def_system_macro('CPUSPARC64');
def_system_macro('CPU64');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif}
{$ifdef arm}
def_system_macro('CPUARM');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif arm}
{$ifdef avr}
def_system_macro('CPUAVR');
def_system_macro('CPU16');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif avr}
{$ifdef jvm}
def_system_macro('CPUJVM');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif jvm}
{$ifdef mipsel}
def_system_macro('CPUMIPS');
def_system_macro('CPUMIPS32');
def_system_macro('CPUMIPSEL');
def_system_macro('CPUMIPSEL32');
def_system_macro('CPU32');
def_system_macro('FPC_HAS_TYPE_DOUBLE');
def_system_macro('FPC_HAS_TYPE_SINGLE');
def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
{ On most systems, locals are accessed relative to base pointer,
but for MIPS cpu, they are accessed relative to stack pointer.
This needs adaptation for so low level routines,
like MethodPointerLocal and related objects unit functions. }
def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
{$endif mipsel}
{$ifdef mipseb}
def_system_macro('CPUMIPS');
def_system_macro('CPUMIPS32');
def_system_macro('CPUMIPSEB');
def_system_macro('CPUMIPSEB32');
def_system_macro('CPU32');
def_system_macro('FPC_HAS_TYPE_DOUBLE');
def_system_macro('FPC_HAS_TYPE_SINGLE');
def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
{ See comment above for mipsel }
def_system_macro('FPC_LOCALS_ARE_STACK_REG_RELATIVE');
{$endif}
{$ifdef i8086}
def_system_macro('CPU86'); { Borland compatibility }
def_system_macro('CPU87'); { Borland compatibility }
def_system_macro('CPUI8086');
def_system_macro('CPU16');
def_system_macro('FPC_HAS_TYPE_EXTENDED');
def_system_macro('FPC_HAS_TYPE_DOUBLE');
def_system_macro('FPC_HAS_TYPE_SINGLE');
case init_settings.x86memorymodel of
mm_tiny: def_system_macro('FPC_MM_TINY');
mm_small: def_system_macro('FPC_MM_SMALL');
mm_medium: def_system_macro('FPC_MM_MEDIUM');
mm_compact: def_system_macro('FPC_MM_COMPACT');
mm_large: def_system_macro('FPC_MM_LARGE');
mm_huge: def_system_macro('FPC_MM_HUGE');
end;
{$endif i8086}
{$ifdef aarch64}
def_system_macro('CPUAARCH64');
def_system_macro('CPU64');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif aarch64}
{$ifdef riscv32}
def_system_macro('CPURISCV');
def_system_macro('CPURISCV32');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
{$endif riscv32}
{$ifdef riscv64}
def_system_macro('CPURISCV');
def_system_macro('CPURISCV64');
def_system_macro('CPU64');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
{$endif riscv64}
{$ifdef xtensa}
def_system_macro('CPUXTENSA');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
def_system_macro('FPC_REQUIRES_PROPER_ALIGNMENT');
{$endif xtensa}
{$ifdef z80}
def_system_macro('CPUZ80');
def_system_macro('CPU16');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif z80}
{$ifdef wasm32}
def_system_macro('CPUWASM');
def_system_macro('CPUWASM32');
def_system_macro('CPU32');
def_system_macro('FPC_CURRENCY_IS_INT64');
def_system_macro('FPC_COMP_IS_INT64');
{$endif wasm32}
{$if defined(cpu8bitalu)}
def_system_macro('CPUINT8');
{$elseif defined(cpu16bitalu)}
def_system_macro('CPUINT16');
{$elseif defined(cpu32bitalu)}
def_system_macro('CPUINT32');
{$elseif defined(cpu64bitalu)}
def_system_macro('CPUINT64');
{$endif defined(cpu64bitalu)}
{$if defined(avr)}
def_system_macro('FPC_HAS_INTERNAL_ABS_SHORTINT');
{$endif}
{$if defined(i8086) or defined(avr)}
def_system_macro('FPC_HAS_INTERNAL_ABS_SMALLINT');
{$endif i8086 or avr}
{ abs(long) is handled internally on all CPUs }
def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
{$if defined(i8086) or defined(i386) or defined(x86_64) or defined(powerpc64) or defined(aarch64)}
def_system_macro('FPC_HAS_INTERNAL_ABS_INT64');
{$endif i8086 or i386 or x86_64 or powerpc64 or aarch64}
def_system_macro('FPC_HAS_UNICODESTRING');
def_system_macro('FPC_RTTI_PACKSET1');
def_system_macro('FPC_HAS_CPSTRING');
{$ifdef x86_64}
def_system_macro('FPC_HAS_RIP_RELATIVE');
{$endif x86_64}
def_system_macro('FPC_HAS_CEXTENDED');
def_system_macro('FPC_HAS_RESSTRINITS');
{ these cpus have an inline rol/ror implementaion }
{$ifdef cpurox}
{$ifdef m68k}
if CPUM68K_HAS_ROLROR in cpu_capabilities[init_settings.cputype] then
def_system_macro('FPC_HAS_INTERNAL_ROX');
{$else}
def_system_macro('FPC_HAS_INTERNAL_ROX');
{$endif}
{$endif}
{$ifdef powerpc64}
def_system_macro('FPC_HAS_LWSYNC');
{$endif}
{ currently, all supported CPUs have an internal sar implementation }
def_system_macro('FPC_HAS_INTERNAL_SAR');
{$ifdef SUPPORT_GET_FRAME}
def_system_macro('INTERNAL_BACKTRACE');
{$endif SUPPORT_GET_FRAME}
def_system_macro('STR_CONCAT_PROCS');
{$warnings off}
if pocall_default = pocall_register then
def_system_macro('REGCALL');
{$warnings on}
end;
var
env: ansistring;
i : tfeature;
j : longint;
tmplist : TCmdStrList;
cmditem,
tmpcmditem : TCmdStrListItem;
cmdstr : TCmdStr;
{$if defined(cpucapabilities)}
cpuflag : tcpuflags;
{$endif defined(cpucapabilities)}
{$if defined(fpucapabilities)}
fpuflag : tfpuflags;
{$endif defined(fpucapabilities)}
{$if defined(cpucapabilities) or defined(fpucapabilities)}
hs : string;
{$endif defined(cpucapabilities) or defined(fpucapabilities)}
begin
option:=coption.create;
disable_configfile:=false;
{ Non-core target defines }
Option.TargetOptions(true);
{ get default messagefile }
msgfilename:=GetEnvironmentVariable('PPC_ERROR_FILE');
{ default configfile can be specified on the commandline,
remove it first }
if (cmd<>'') and (cmd[1]='[') then
begin
ppccfg:=Copy(cmd,2,pos(']',cmd)-2);
Delete(cmd,1,pos(']',cmd));
end
else
ppccfg:='fpc.cfg';
{ first pass reading of parameters, only -i -v -T etc.}
option.firstpass:=true;
if cmd<>'' then
option.parsecmd(cmd)
else
begin
option.read_parameters;
{ Write only quickinfo }
if option.quickinfo<>'' then
option.writequickinfo;
end;
option.firstpass:=false;
{ redefine target options so all defines are written even if no -Txxx is passed on the command line }
Option.TargetOptions(true);
{ target is set here, for wince the default app type is gui }
if target_info.system in systems_wince then
SetApptype(app_gui)
else
SetApptype(apptype);
{ default defines }
def_system_macro(target_info.shortname);
def_system_macro('FPC');
def_system_macro('VER'+version_nr);
def_system_macro('VER'+version_nr+'_'+release_nr);
def_system_macro('VER'+version_nr+'_'+release_nr+'_'+patch_nr);
{ Temporary defines, until things settle down }
def_system_macro('FPC_HAS_OPERATOR_ENUMERATOR');
def_system_macro('FPC_HAS_CONSTREF');
def_system_macro('FPC_STATICRIPFIXED');
def_system_macro('FPC_VARIANTCOPY_FIXED');
def_system_macro('FPC_DYNARRAYCOPY_FIXED');
def_system_macro('FPC_HAS_MEMBAR');
def_system_macro('FPC_SETBASE_USED');
def_system_macro('FPC_ALIGNED_THREADVARTABLES');
{ don't remove this, it's also for fpdoc necessary (FK) }
def_system_macro('FPC_HAS_FEATURE_SUPPORT');
{ make cpu makros available when reading the config files the second time }
def_cpu_macros;
if tf_cld in target_info.flags then
if not UpdateTargetSwitchStr('CLD', init_settings.targetswitches, true) then
InternalError(2013092801);
if tf_x86_far_procs_push_odd_bp in target_info.flags then
if not UpdateTargetSwitchStr('FARPROCSPUSHODDBP', init_settings.targetswitches, true) then
InternalError(2013092802);
{ Use standard Android NDK prefixes when cross-compiling }
if (source_info.system<>target_info.system) and (target_info.system in systems_android) then
case target_info.system of
system_arm_android:
utilsprefix:='arm-linux-androideabi-';
system_i386_android:
utilsprefix:='i686-linux-android-';
else
utilsprefix:=target_cpu_string + '-linux-android-';
end;
{ Set up default value for the heap }
if target_info.system in (systems_embedded+systems_freertos+[system_z80_zxspectrum,system_z80_msxdos]) then
begin
case target_info.system of
{$ifdef AVR}
system_avr_embedded:
if init_settings.controllertype=ct_avrsim then
heapsize:=8192
else
heapsize:=128;
{$endif AVR}
system_arm_freertos:
heapsize:=8192;
system_xtensa_freertos:
{ keep default value }
;
system_arm_embedded:
heapsize:=256;
system_mipsel_embedded:
heapsize:=256;
else
heapsize:=256;
end;
end;
{ read configuration file }
if (not disable_configfile) and
(ppccfg<>'') then
read_configfile:=check_configfile(ppccfg,ppccfg)
else
read_configfile := false;
{ Read commandline and configfile }
param_file:='';
{ read configfile }
if read_configfile then
option.interpret_file(ppccfg);
{ read parameters again to override config file }
if cmd<>'' then
option.parsecmd(cmd)
else
begin
{ Write help pages if no parameters are passed }
if (paramcount=0) then
Option.WriteHelpPages;
option.read_parameters;
{ Write only quickinfo }
if option.quickinfo<>'' then
option.writequickinfo;
end;
{ check the compatibility of different options and adjust them if necessary
(and print possible errors)
}
option.checkoptionscompatibility;
{ uses the CPUXXX-defines and target_info to determine whether the selected
target processor, if any, is supported }
Option.VerifyTargetProcessor;
{ Stop if errors in options }
if ErrorCount>0 then
StopOptions(1);
{ endian define }
case target_info.endian of
endian_little :
begin
def_system_macro('ENDIAN_LITTLE');
def_system_macro('FPC_LITTLE_ENDIAN');
end;
endian_big :
begin
def_system_macro('ENDIAN_BIG');
def_system_macro('FPC_BIG_ENDIAN');
end;
end;
{ Write logo }
if option.ParaLogo then
option.writelogo;
{ Check file to compile }
if param_file='' then
begin
Message(option_no_source_found);
StopOptions(1);
end;
{$ifndef Unix}
param_file:=FixFileName(param_file);
{$endif not unix}
inputfilepath:=ExtractFilePath(param_file);
inputfilename:=ExtractFileName(param_file);
if ExtractFileExt(inputfilename)='' then
begin
if FileExists(inputfilepath+ChangeFileExt(inputfilename,sourceext)) then
inputfilename:=ChangeFileExt(inputfilename,sourceext)
else if FileExists(inputfilepath+ChangeFileExt(inputfilename,pasext)) then
inputfilename:=ChangeFileExt(inputfilename,pasext)
else if ((m_mac in current_settings.modeswitches) or
(tf_p_ext_support in target_info.flags))
and FileExists(inputfilepath+ChangeFileExt(inputfilename,pext)) then
inputfilename:=ChangeFileExt(inputfilename,pext);
end;
{ Check output dir }
if (OutputExeDir<>'') and
not PathExists(OutputExeDir,false) then
begin
Message1(general_e_path_does_not_exist,OutputExeDir);
StopOptions(1);
end;
{ Add paths specified with parameters to the searchpaths }
UnitSearchPath.AddList(option.ParaUnitPath,true);
ObjectSearchPath.AddList(option.ParaObjectPath,true);
IncludeSearchPath.AddList(option.ParaIncludePath,true);
LibrarySearchPath.AddList(option.ParaLibraryPath,true);
FrameworkSearchPath.AddList(option.ParaFrameworkPath,true);
packagesearchpath.addlist(option.parapackagepath,true);
for j:=0 to option.parapackages.count-1 do
add_package(option.parapackages.NameOfIndex(j),true,true);
{ add default namespaces }
tmplist:=TCmdStrList.Create;
cmditem:=TCmdStrListItem(option.paranamespaces.First);
while assigned(cmditem) do
begin
{ use a temporary list cause if ";" are involved we need to reverse the
order due to how TCmdStrList behaves }
cmdstr:=cmditem.str;
repeat
j:=Pos(';',cmdstr);
if j>0 then
begin
tmplist.insert(copy(cmdstr,1,j-1));
delete(cmdstr,1,j);
end
else
tmplist.insert(cmdstr);
until j=0;
tmpcmditem:=TCmdStrListItem(tmplist.First);
while assigned(tmpcmditem) do
begin
namespacelist.insert(tmpcmditem.Str);
tmpcmditem:=TCmdStrListItem(tmpcmditem.Next);
end;
tmplist.clear;
cmditem:=TCmdStrListItem(cmditem.Next);
end;
tmplist.Free;
{ add unit environment and exepath to the unit search path }
if inputfilepath<>'' then
Unitsearchpath.AddPath(inputfilepath,true);
if not disable_configfile then
begin
env:=GetEnvironmentVariable(target_info.unit_env);
if env<>'' then
UnitSearchPath.AddPath(GetEnvironmentVariable(target_info.unit_env),false);
end;
{$ifdef Unix}
fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
if fpcdir='' then
begin
if PathExists('/usr/local/lib/fpc/'+version_string,true) then
fpcdir:='/usr/local/lib/fpc/'+version_string+'/'
else
fpcdir:='/usr/lib/fpc/'+version_string+'/';
end;
{$else unix}
fpcdir:=FixPath(GetEnvironmentVariable('FPCDIR'),false);
if fpcdir='' then
begin
fpcdir:=ExePath+'../';
if not(PathExists(fpcdir+'units',true)) and
not(PathExists(fpcdir+'rtl',true)) then
fpcdir:=fpcdir+'../';
end;
{$endif unix}
{ first try development RTL, else use the default installation path }
if not disable_configfile then
begin
if PathExists(FpcDir+'rtl',true) then
if (tf_use_8_3 in Source_Info.Flags) or
(tf_use_8_3 in Target_Info.Flags) then
UnitSearchPath.AddPath(FpcDir+'rtl/'+target_os_string,false)
else
UnitSearchPath.AddPath(FpcDir+'rtl/'+target_full_string,false)
else
if (tf_use_8_3 in Source_Info.Flags) or
(tf_use_8_3 in Target_Info.Flags) then
UnitSearchPath.AddPath(FpcDir+'units/'+target_os_string+'/rtl',false)
else
UnitSearchPath.AddPath(FpcDir+'units/'+target_full_string+'/rtl',false);
end;
{ Add exepath if the exe is not in the current dir, because that is always searched already.
Do not add it when linking on the target because then we can maybe already find
.o files that are not for the target }
if (ExePath<>cfileutl.GetCurrentDir) and
not(cs_link_on_target in init_settings.globalswitches) then
UnitSearchPath.AddPath(ExePath,false);
{ Add unit dir to the object and library path }
objectsearchpath.AddList(unitsearchpath,false);
librarysearchpath.AddList(unitsearchpath,false);
{$ifdef llvm}
{ default to clang }
if (option.paratargetasm=as_none) then
begin
option.paratargetasm:=as_clang_llvm;
end;
{$endif llvm}
{ maybe override assembler }
if (option.paratargetasm<>as_none) then
begin
if not set_target_asm(option.paratargetasm) then
begin
if assigned(asminfos[option.paratargetasm]) then
Message2(option_incompatible_asm,asminfos[option.paratargetasm]^.idtxt,target_info.name)
else
Message2(option_incompatible_asm,'<invalid assembler>',target_info.name);
set_target_asm(target_info.assemextern);
Message1(option_asm_forced,target_asm.idtxt);
end;
if (af_no_debug in asminfos[option.paratargetasm]^.flags) and
(option.paratargetdbg<>dbg_none) then
begin
Message1(option_confict_asm_debug,
asminfos[option.paratargetasm]^.idtxt);
option.paratargetdbg:=dbg_none;
exclude(init_settings.moduleswitches,cs_debuginfo);
end;
{ Some assemblers, like clang, do not support
stabs debugging format, switch to dwardé in that case }
if (af_no_stabs in asminfos[option.paratargetasm]^.flags) and
(option.paratargetdbg=dbg_stabs) then
begin
option.paratargetdbg:=dbg_dwarf2;
end;
end;
{TOptionheck a second time as we might have changed assembler just above }
option.checkoptionscompatibility;
{ maybe override debug info format }
if (option.paratargetdbg<>dbg_none) then
if not set_target_dbg(option.paratargetdbg) then
Message(option_w_unsupported_debug_format);
{ switch assembler if it's binary and we got -a on the cmdline }
if ((cs_asm_leave in init_settings.globalswitches) and
(af_outputbinary in target_asm.flags)) or
{ if -s is passed, we shouldn't call the internal assembler }
(cs_asm_extern in init_settings.globalswitches) then
begin
Message(option_switch_bin_to_src_assembler);
{$ifdef llvm}
set_target_asm(as_clang_llvm);
{$else}
set_target_asm(target_info.assemextern);
{$endif}
{ At least i8086 needs that for nasm and -CX
which is incompatible with internal linker }
option.checkoptionscompatibility;
end;
{ Force use of external linker if there is no
internal linker or the linking is skipped }
if not(cs_link_extern in init_settings.globalswitches) and
((target_info.link=ld_none) or
(cs_link_nolink in init_settings.globalswitches)) then
begin
include(init_settings.globalswitches,cs_link_extern);
end;
{ turn off stripping if compiling with debuginfo or profile }
if (
(cs_debuginfo in init_settings.moduleswitches) or
(cs_profile in init_settings.moduleswitches)
) and
not(cs_link_separate_dbg_file in init_settings.globalswitches) then
exclude(init_settings.globalswitches,cs_link_strip);
{ choose a reasonable tls model }
if (tf_section_threadvars in target_info.flags) and (init_settings.tlsmodel=tlsm_none) then
begin
if cs_create_pic in init_settings.moduleswitches then
init_settings.tlsmodel:=tlsm_global_dynamic
else
init_settings.tlsmodel:=tlsm_local_exec;
end;
{ set Mac OS X version default macros if not specified explicitly }
option.MaybeSetDefaultMacVersionMacro;
{$ifdef cpufpemu}
{ force fpu emulation on arm/wince, arm/gba, arm/embedded and arm/nds
if fpu type not explicitly set }
if not(option.FPUSetExplicitly) and
((target_info.system in [system_arm_wince,system_arm_gba,
system_m68k_amiga,system_m68k_atari,
system_arm_nds,system_arm_embedded,system_arm_freertos,
system_riscv32_embedded,system_riscv64_embedded,system_xtensa_linux,
system_z80_embedded,system_z80_zxspectrum])
{$ifdef arm}
or (target_info.abi=abi_eabi)
{$endif arm}
)
or (init_settings.fputype=fpu_soft)
then
begin
include(init_settings.moduleswitches,cs_fp_emulation);
{ cs_fp_emulation and fpu_soft are equal on arm and m68k }
init_settings.fputype:=fpu_soft;
end;
{$endif cpufpemu}
{$ifdef i386}
if target_info.system in systems_i386_default_486 then
begin
{ Avoid use of MMX/CMOVcc instructions on older systems.
Some systems might not handle these instructions correctly,
Used emulators might also be problematic. PM }
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_486;
end;
case target_info.system of
system_i386_android:
begin
{ set default cpu type to PentiumM for Android unless specified otherwise }
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_PentiumM;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_PentiumM;
{ set default fpu type to SSSE3 for Android unless specified otherwise }
if not option.FPUSetExplicitly then
init_settings.fputype:=fpu_ssse3;
end;
else
;
end;
{$endif i386}
{$ifdef xtensa}
{ xtensa-linux target does not support controller setting option -Wp }
if not(option.FPUSetExplicitly) and not(target_info.system = system_xtensa_linux) then
begin
init_settings.fputype:=embedded_controllers[init_settings.controllertype].fputype;
if (init_settings.fputype=fpu_soft) then
include(init_settings.moduleswitches,cs_fp_emulation);
end;
if not(option.CPUSetExplicitly) and (target_info.system=system_xtensa_linux) then
init_settings.cputype:=cpu_lx6;
if (target_info.system in [system_xtensa_embedded,system_xtensa_freertos]) and not(option.ABISetExplicitly) then
begin
if CPUXTENSA_REGWINDOW in cpu_capabilities[init_settings.cputype] then
target_info.abi:=abi_xtensa_windowed
else
target_info.abi:=abi_xtensa_call0;
end;
{$endif xtensa}
{$ifdef arm}
case target_info.system of
system_arm_ios:
begin
{ set default cpu type to ARMv7 for Darwin unless specified otherwise, and fpu
to VFPv3 (that's what all 32 bit ARM iOS devices use nowadays)
}
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_armv7;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_armv7;
if not option.FPUSetExplicitly then
init_settings.fputype:=fpu_vfpv3;
end;
system_arm_android:
begin
{ set default cpu type to ARMv5T for Android unless specified otherwise }
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_armv5t;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_armv5t;
end;
else
;
end;
{ set ABI defaults }
case target_info.abi of
abi_eabihf:
{ set default cpu type to ARMv7a for ARMHF unless specified otherwise }
begin
{$ifdef CPUARMV6}
{ if the compiler is built for armv6, then
inherit this setting, e.g. Raspian is armhf but
only armv6, this makes rebuilds of the compiler
easier }
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_armv6;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_armv6;
{$else CPUARMV6}
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_armv7a;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_armv7a;
{$endif CPUARMV6}
{ Set FPU type }
if not(option.FPUSetExplicitly) then
begin
if init_settings.cputype < cpu_armv7 then
init_settings.fputype:=fpu_vfpv2
else
init_settings.fputype:=fpu_vfpv3_d16;
end
else
begin
if (not(FPUARM_HAS_VFP_EXTENSION in fpu_capabilities[init_settings.fputype]))
or (target_info.system = system_arm_ios) then
begin
Message(option_illegal_fpu_eabihf);
StopOptions(1);
end;
end;
end;
abi_eabi:
begin
if target_info.system=system_arm_linux then
begin
{ this is what Debian uses }
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_armv4t;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_armv4t;
if not(option.FPUSetExplicitly) then
init_settings.fputype:=fpu_soft;
end;
end;
else
;
end;
if (init_settings.instructionset=is_thumb) and not(CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype]) then
begin
def_system_macro('CPUTHUMB');
if not option.FPUSetExplicitly then
init_settings.fputype:=fpu_soft;
if not(init_settings.fputype in [fpu_none,fpu_soft,fpu_libgcc]) then
Message2(option_unsupported_fpu,fputypestr[init_settings.fputype],'Thumb');
{$if defined(FPC_ARMEL) or defined(FPC_ARMHF)}
target_info.llvmdatalayout:='e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:32-n32-S64';
{$else FPC_ARMAL or FPC_ARMHF}
if target_info.endian=endian_little then
target_info.llvmdatalayout:='e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32';
{$endif FPC_ARMAL or FPC_ARMHF}
end;
if (init_settings.instructionset=is_thumb) and (CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype]) then
def_system_macro('CPUTHUMB2');
{$endif arm}
{$if defined(riscv32) or defined(riscv64)}
{ RISC-V defaults }
if (target_info.abi = abi_riscv_hf) then
begin
{$ifdef riscv32}
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_rv32ima;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_rv32ima;
{$else}
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_rv64imac;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_rv64imac;
{$endif}
{ Set FPU type }
if not(option.FPUSetExplicitly) then
init_settings.fputype:=fpu_fd
else
begin
if not (init_settings.fputype in [fpu_fd]) then
begin
Message(option_illegal_fpu_eabihf);
StopOptions(1);
end;
end;
end;
{$endif defined(riscv32) or defined(riscv64)}
{$ifdef jvm}
{ set default CPU type to Dalvik when targeting Android }
if target_info.system=system_jvm_android32 then
begin
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_dalvik;
end;
{$endif jvm}
{$ifdef llvm}
{ standard extension for llvm bitcode files }
target_info.asmext:='.ll';
{ don't generate dwarf cfi, llvm will do that }
exclude(target_info.flags,tf_needs_dwarf_cfi);
{$endif llvm}
{$ifdef mipsel}
case target_info.system of
system_mipsel_android:
begin
{ set default cpu type to MIPS32 rev. 1 and hard float for MIPS-Android unless specified otherwise }
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_mips32;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_mips32;
if not option.FPUSetExplicitly then
init_settings.fputype:=fpu_mips2;
end;
system_mipsel_embedded:
begin
{ set default cpu type to PIC32MX and softfloat for MIPSEL-EMBEDDED target unless specified otherwise }
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_pic32mx;
if not option.OptCPUSetExplicitly then
init_settings.optimizecputype:=cpu_pic32mx;
if not option.FPUSetExplicitly then
init_settings.fputype:=fpu_soft;
end;
else
;
end;
{$endif mipsel}
{$ifdef m68k}
if init_settings.cputype in cpu_coldfire then
def_system_macro('CPUCOLDFIRE');
case target_info.system of
system_m68k_linux,
system_m68k_netbsd:
begin
if not (option.FPUSetExplicitly) and
not (init_settings.cputype in cpu_coldfire) then
begin
{ enable HW FPU for UNIX by default, but only for
original 68k, not Coldfire }
exclude(init_settings.moduleswitches,cs_fp_emulation);
init_settings.fputype:=fpu_68881;
end;
end;
system_m68k_sinclairql:
begin
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_mc68000;
end;
system_m68k_palmos:
begin
if not option.CPUSetExplicitly then
init_settings.cputype:=cpu_mc68000;
if not (option.FPUSetExplicitly) then
begin
{ No FPU for PalmOS by default }
exclude(init_settings.moduleswitches,cs_fp_emulation);
init_settings.fputype:=fpu_none;
end;
end;
else
;
end;
{$endif m68k}
{ now we can define cpu and fpu type }
def_cpu_macros;
{ Use init_settings cpu type for asm cpu type,
if asmcputype is cpu_none,
at least as long as there is no explicit
option to set it on command line PM }
if init_settings.asmcputype = cpu_none then
init_settings.asmcputype:=init_settings.cputype;
{$ifdef llvm}
def_system_macro('CPULLVM');
{$endif llvm}
{$if defined(cpucapabilities)}
for cpuflag:=low(cpuflag) to high(cpuflag) do
begin
str(cpuflag,hs);
if cpuflag in cpu_capabilities[init_settings.cputype] then
def_system_macro(hs)
else
undef_system_macro(hs);
end;
{$endif defined(cpucapabilities)}
{$if defined(fpucapabilities)}
for fpuflag:=low(fpuflag) to high(fpuflag) do
begin
str(fpuflag,hs);
if fpuflag in fpu_capabilities[init_settings.fputype] then
def_system_macro(hs)
else
undef_system_macro(hs);
end;
{$endif defined(fpucapabilities)}
if init_settings.fputype<>fpu_none then
begin
{$if defined(i386) or defined(i8086)}
def_system_macro('FPC_HAS_TYPE_EXTENDED');
{$endif}
def_system_macro('FPC_HAS_TYPE_SINGLE');
def_system_macro('FPC_HAS_TYPE_DOUBLE');
{$if not defined(i386) and not defined(x86_64) and not defined(i8086) and not defined(aarch64)}
def_system_macro('FPC_INCLUDE_SOFTWARE_INT64_TO_DOUBLE');
{$endif}
{$if defined(m68k)}
def_system_macro('FPC_INCLUDE_SOFTWARE_LONGWORD_TO_DOUBLE');
{$endif}
{$ifdef x86_64}
{$ifndef FPC_SUPPORT_X87_TYPES_ON_WIN64}
{ normally, win64 doesn't support the legacy fpu }
if target_info.system=system_x86_64_win64 then
undef_system_macro('FPC_HAS_TYPE_EXTENDED')
else
{$endif FPC_SUPPORT_X87_TYPES_ON_WIN64}
def_system_macro('FPC_HAS_TYPE_EXTENDED');
{$endif}
end;
{ Enable now for testing }
{$ifndef DISABLE_TLS_DIRECTORY}
if target_info.system in systems_windows then
def_system_macro('FPC_USE_TLS_DIRECTORY');
{$endif not DISABLE_TLS_DIRECTORY}
{$ifndef DISABLE_WIN64_SEH}
if target_info.system=system_x86_64_win64 then
def_system_macro('FPC_USE_WIN64_SEH');
{$endif DISABLE_WIN64_SEH}
{$ifndef DISABLE_WIN32_SEH}
if target_info.system=system_i386_win32 then
def_system_macro('FPC_USE_WIN32_SEH');
{$endif not DISABLE_WIN32_SEH}
{$ifdef ARM}
{ define FPC_DOUBLE_HILO_SWAPPED if needed to properly handle doubles in RTL }
if (init_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
not(cs_fp_emulation in init_settings.moduleswitches) then
def_system_macro('FPC_DOUBLE_HILO_SWAPPED');
{$endif ARM}
{ inline bsf/bsr implementation }
{$if defined(i386) or defined(x86_64) or defined(aarch64) or defined(powerpc) or defined(powerpc64)}
def_system_macro('FPC_HAS_INTERNAL_BSF');
def_system_macro('FPC_HAS_INTERNAL_BSR');
{$endif}
{ hardware FMA support }
{$if defined(i386) or defined(x86_64)}
if (cpu_capabilities[current_settings.cputype]*[CPUX86_HAS_FMA,CPUX86_HAS_FMA4])<>[] then
begin
def_system_macro('FPC_HAS_FAST_FMA_SINGLE');
def_system_macro('FPC_HAS_FAST_FMA_DOUBLE');
end;
{$endif defined(i386) or defined(x86_64)}
{$if defined(arm)}
{ it is determined during system unit compilation if clz is used for bsf or not,
this is not perfect but the current implementation bsf/bsr does not allow another
solution }
if (CPUARM_HAS_CLZ in cpu_capabilities[init_settings.cputype]) and
((init_settings.instructionset=is_arm) or
(CPUARM_HAS_THUMB2 in cpu_capabilities[init_settings.cputype])) then
begin
def_system_macro('FPC_HAS_INTERNAL_BSR');
if CPUARM_HAS_RBIT in cpu_capabilities[init_settings.cputype] then
def_system_macro('FPC_HAS_INTERNAL_BSF');
end;
{$endif}
{$if defined(xtensa)}
{ it is determined during system unit compilation if nsau is used for bsr or not,
this is not perfect but the current implementation bsf/bsr does not allow another
solution }
if CPUXTENSA_HAS_NSAx in cpu_capabilities[init_settings.cputype] then
begin
def_system_macro('FPC_HAS_INTERNAL_BSR');
end;
{$endif}
{$if defined(powerpc64)}
{ on sysv targets, default to elfv2 for little endian and to elfv1 for
big endian (unless specified otherwise). As the gcc man page says:
"Overriding the default ABI requires special system support and is
likely to fail in spectacular ways" }
if not option.ABISetExplicitly then
begin
if (target_info.abi=abi_powerpc_sysv) and
(target_info.endian=endian_little) then
target_info.abi:=abi_powerpc_elfv2
else
if (target_info.abi=abi_powerpc_elfv2) and
(target_info.endian=endian_big) then
target_info.abi:=abi_powerpc_sysv
end;
{$endif}
{$if defined(powerpc) or defined(powerpc64)}
{ define _CALL_ELF symbol like gcc }
case target_info.abi of
abi_powerpc_sysv:
set_system_compvar('_CALL_ELF','1');
abi_powerpc_elfv2:
set_system_compvar('_CALL_ELF','2');
else
;
end;
{$endif}
{ Section smartlinking conflicts with import sections on Windows }
if GenerateImportSection and
(target_info.system in [system_i386_win32,system_x86_64_win64,system_aarch64_win64]) then
exclude(target_info.flags,tf_smartlink_sections);
if not option.LinkTypeSetExplicitly then
set_default_link_type;
{ Default alignment settings,
1. load the defaults for the target
2. override with generic optimizer setting (little size)
3. override with the user specified -Oa }
UpdateAlignment(init_settings.alignment,target_info.alignment);
if (cs_opt_size in init_settings.optimizerswitches) then
begin
init_settings.alignment.procalign:=1;
init_settings.alignment.jumpalign:=1;
init_settings.alignment.coalescealign:=1;
init_settings.alignment.loopalign:=1;
{$ifdef x86}
{ constalignmax=1 keeps the executable and thus the memory foot print small but
all processors except x86 are really hurt by this or might even crash }
init_settings.alignment.constalignmax:=1;
{$endif x86}
end;
UpdateAlignment(init_settings.alignment,option.paraalignment);
set_system_macro('FPC_VERSION',version_nr);
set_system_macro('FPC_RELEASE',release_nr);
set_system_macro('FPC_PATCH',patch_nr);
set_system_macro('FPC_FULLVERSION',Format('%d%.02d%.02d',[StrToInt(version_nr),StrToInt(release_nr),StrToInt(patch_nr)]));
if target_info.system in systems_indirect_entry_information then
def_system_macro('FPC_HAS_INDIRECT_ENTRY_INFORMATION');
if not (tf_winlikewidestring in target_info.flags) then
def_system_macro('FPC_WIDESTRING_EQUAL_UNICODESTRING');
if tf_supports_packages in target_info.flags then
def_system_macro('FPC_HAS_DYNAMIC_PACKAGES');
if target_info.system in systems_indirect_var_imports then
def_system_macro('FPC_HAS_INDIRECT_VAR_ACCESS');
if cs_compilesystem in init_settings.moduleswitches then
for i:=low(tfeature) to high(tfeature) do
if i in features then
def_system_macro('FPC_HAS_FEATURE_'+featurestr[i]);
{$push}
{$warn 6018 off} { Unreachable code due to compile time evaluation }
if ControllerSupport and (target_info.system in (systems_embedded+systems_freertos)) and
(init_settings.controllertype<>ct_none) then
begin
with embedded_controllers[init_settings.controllertype] do
begin
set_system_macro('FPC_FLASHBASE',tostr(flashbase));
set_system_macro('FPC_FLASHSIZE',tostr(flashsize));
set_system_macro('FPC_SRAMBASE',tostr(srambase));
set_system_macro('FPC_SRAMSIZE',tostr(sramsize));
set_system_macro('FPC_EEPROMBASE',tostr(eeprombase));
set_system_macro('FPC_EEPROMSIZE',tostr(eepromsize));
set_system_macro('FPC_BOOTBASE',tostr(bootbase));
set_system_macro('FPC_BOOTSIZE',tostr(bootsize));
end;
end;
{$pop}
{ as stackalign is not part of the alignment record, we do not need to define the others alignments for symmetry yet }
set_system_macro('FPC_STACKALIGNMENT',tostr(target_info.stackalign));
option.free;
Option:=nil;
clearstack_pocalls := [pocall_cdecl,pocall_cppdecl,pocall_syscall,pocall_mwpascal,pocall_sysv_abi_cdecl,pocall_ms_abi_cdecl{$ifdef z80},pocall_stdcall{$endif}];
cdecl_pocalls := [pocall_cdecl, pocall_cppdecl, pocall_mwpascal, pocall_sysv_abi_cdecl, pocall_ms_abi_cdecl];
if (tf_safecall_clearstack in target_info.flags) then
begin
include (cdecl_pocalls, pocall_safecall);
include (clearstack_pocalls, pocall_safecall)
end;
end;
initialization
coption:=toption;
finalization
if assigned(option) then
option.free;
end.
|