mirror of
https://github.com/jart/cosmopolitan.git
synced 2026-11-07 17:22:16 -10:00
Compare commits
1404
Commits
fastpython
...
3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ae5223eae | ||
|
|
8f82a5f968 | ||
|
|
d1300623d2 | ||
|
|
7b8024d088 | ||
|
|
e6b59bced2 | ||
|
|
c9fecf3a55 | ||
|
|
06c6baaf50 | ||
|
|
bd48e6c666 | ||
|
|
cdf556e7d2 | ||
|
|
a657f3e878 | ||
|
|
2db2f40a98 | ||
|
|
aca2261cda | ||
|
|
d1a283a588 | ||
|
|
3851025b77 | ||
|
|
bdc453b22d | ||
|
|
0e0398cd5d | ||
|
|
4bcb107cb0 | ||
|
|
d458642790 | ||
|
|
b81a1bd9a8 | ||
|
|
49b0eaa69f | ||
|
|
f7343319cc | ||
|
|
3a1f887928 | ||
|
|
f92ad74e6b | ||
|
|
6e4b9b6515 | ||
|
|
3b086af91b | ||
|
|
5cb9b2658c | ||
|
|
285c565051 | ||
|
|
ec3275179f | ||
|
|
9cc4f33c76 | ||
|
|
9d372f48dd | ||
|
|
211d5d902e | ||
|
|
3b4dbc9fdd | ||
|
|
820c3599ed | ||
|
|
94dc7a684e | ||
|
|
791f79fcb3 | ||
|
|
af7cb3c82f | ||
|
|
982dc4db87 | ||
|
|
6918c3ffc2 | ||
|
|
af8236264e | ||
|
|
4631d34d0d | ||
|
|
1694edf85c | ||
|
|
f26a280cda | ||
|
|
4825737509 | ||
|
|
695f74035d | ||
|
|
11c18fa644 | ||
|
|
85f64f3851 | ||
|
|
ff250a0c10 | ||
|
|
ee8a861635 | ||
|
|
e8ecf31ad5 | ||
|
|
a201e694ee | ||
|
|
5212f78c33 | ||
|
|
fcdda40f19 | ||
|
|
b01282e23e | ||
|
|
ff77f2a6af | ||
|
|
b99512ac58 | ||
|
|
c315315896 | ||
|
|
cc8c56e814 | ||
|
|
3ffc17c50e | ||
|
|
ed316491ca | ||
|
|
4f5d5a6813 | ||
|
|
22cf6e11eb | ||
|
|
c88f95a892 | ||
|
|
0c5dd7b342 | ||
|
|
d6c2830850 | ||
|
|
ececec4c94 | ||
|
|
ec480f5aa0 | ||
|
|
c4eb838516 | ||
|
|
81f391dd22 | ||
|
|
00084577a3 | ||
|
|
6430e474b4 | ||
|
|
20c77338e6 | ||
|
|
8a0008d985 | ||
|
|
a359de7893 | ||
|
|
77a7873057 | ||
|
|
1965d7488e | ||
|
|
26e254fb4d | ||
|
|
99dc1281f5 | ||
|
|
8bdaddd81d | ||
|
|
032b1f3449 | ||
|
|
dcda6f7d8d | ||
|
|
b592716d1c | ||
|
|
0e087143fd | ||
|
|
6cff3137c5 | ||
|
|
425c055116 | ||
|
|
f9c9a323fe | ||
|
|
f531acc8f9 | ||
|
|
8596e83cce | ||
|
|
b21842ed7a | ||
|
|
0d748ad58e | ||
|
|
e2b3c3618e | ||
|
|
4021cd0c1e | ||
|
|
4c74f09393 | ||
|
|
58ef4e6df8 | ||
|
|
b9eb656e41 | ||
|
|
7e08a97cea | ||
|
|
6ef2a471e4 | ||
|
|
63a1636e1f | ||
|
|
755ae64e73 | ||
|
|
fffcd98b0e | ||
|
|
ebf784d4f5 | ||
|
|
ec957491ea | ||
|
|
d6f72aa4a6 | ||
|
|
4f517503e4 | ||
|
|
610e0d95cb | ||
|
|
965516e313 | ||
|
|
9c7b81ee0f | ||
|
|
5b42c810a5 | ||
|
|
7100b1cf91 | ||
|
|
bf835de612 | ||
|
|
3f9b39883f | ||
|
|
1d8937d528 | ||
|
|
d967a94c9a | ||
|
|
d0d027810a | ||
|
|
3a9cac4892 | ||
|
|
eebc24b9cd | ||
|
|
04bd488da7 | ||
|
|
8d1c81ac9f | ||
|
|
b76b2be2d0 | ||
|
|
dc6c67256f | ||
|
|
74caabb823 | ||
|
|
507d7a0b0b | ||
|
|
110559ce6a | ||
|
|
4658ae539f | ||
|
|
de3f3a9e5a | ||
|
|
0e586c834a | ||
|
|
b494d56549 | ||
|
|
f5b39e9f31 | ||
|
|
2b67e15b3d | ||
|
|
9c0821def7 | ||
|
|
ef6387ee5e | ||
|
|
c776a32f75 | ||
|
|
a033b65a33 | ||
|
|
2366848db5 | ||
|
|
d1b937bf1d | ||
|
|
504a4bbf84 | ||
|
|
5d5b4ce691 | ||
|
|
b40d41085d | ||
|
|
6942d7b820 | ||
|
|
ab9a284640 | ||
|
|
3f2f0e3a74 | ||
|
|
399d14aadf | ||
|
|
566cb5963f | ||
|
|
f491276b62 | ||
|
|
60f2ea36ca | ||
|
|
e11fa30791 | ||
|
|
d53c335a45 | ||
|
|
8fc778162e | ||
|
|
2cbd09b4d4 | ||
|
|
0105e3e2b6 | ||
|
|
e3c456d23a | ||
|
|
dd53f31147 | ||
|
|
2f35bbf046 | ||
|
|
9dd50f7dfc | ||
|
|
50394064d7 | ||
|
|
1a5ef5ba13 | ||
|
|
c48ee8e4fe | ||
|
|
33d280c8ba | ||
|
|
decf216655 | ||
|
|
929478c524 | ||
|
|
44b88d659d | ||
|
|
f729810f85 | ||
|
|
712b1aab3c | ||
|
|
c8aa33e0e2 | ||
|
|
d9d5f45e2d | ||
|
|
58352df0a4 | ||
|
|
2ebc5781a1 | ||
|
|
801224df67 | ||
|
|
bd49ea1c3a | ||
|
|
18bb5888e1 | ||
|
|
140a8a52e5 | ||
|
|
6c7b4fcbd3 | ||
|
|
06082c7d37 | ||
|
|
7926aa8bfa | ||
|
|
5018171fa5 | ||
|
|
b0e3258709 | ||
|
|
83341a4269 | ||
|
|
7e0a09feec | ||
|
|
6843150e0c | ||
|
|
53d3f9d9c5 | ||
|
|
9c79c5682c | ||
|
|
e0c2b91b3e | ||
|
|
4fb6cbc1fe | ||
|
|
925219bdf3 | ||
|
|
eb84a25994 | ||
|
|
94ea34367a | ||
|
|
ff198e7577 | ||
|
|
3d172c99fe | ||
|
|
82b1e61443 | ||
|
|
0ba3199915 | ||
|
|
ac92f25296 | ||
|
|
0ffc0dd461 | ||
|
|
3eec69f9c3 | ||
|
|
f83eb440f7 | ||
|
|
1d4eb08fa1 | ||
|
|
5c9e03e3e0 | ||
|
|
18536950b3 | ||
|
|
1ee2e89326 | ||
|
|
a1b1fdd1a4 | ||
|
|
a2d269dc38 | ||
|
|
ee6566a152 | ||
|
|
f7ae50462a | ||
|
|
3dc86ce154 | ||
|
|
0e4c828a8e | ||
|
|
e1316d6565 | ||
|
|
d3cf9d4ef1 | ||
|
|
42ba9901e4 | ||
|
|
41396ff48a | ||
|
|
95fbdb4f76 | ||
|
|
1cc8ff6a55 | ||
|
|
9ae230afad | ||
|
|
a75175fe94 | ||
|
|
0c43c98de1 | ||
|
|
a092fda388 | ||
|
|
3a8579252d | ||
|
|
a1dd777f22 | ||
|
|
0d3c1c8b1a | ||
|
|
a186143f62 | ||
|
|
00acd81b2f | ||
|
|
0a24b4fc3c | ||
|
|
88612a2cd7 | ||
|
|
97b7116953 | ||
|
|
73c0faa1b5 | ||
|
|
168d1c157e | ||
|
|
fe044e22cc | ||
|
|
0c630d95b5 | ||
|
|
197aa0d465 | ||
|
|
7ec84655b4 | ||
|
|
8b62bff364 | ||
|
|
5f1e129222 | ||
|
|
c0348330a5 | ||
|
|
dc8fbf38ad | ||
|
|
ce0a3065f3 | ||
|
|
40eb3b9d5d | ||
|
|
963e10b9bf | ||
|
|
053681cb97 | ||
|
|
5a77db2cd5 | ||
|
|
48b2afb192 | ||
|
|
fb2bd313ae | ||
|
|
f10845ab9f | ||
|
|
461c835784 | ||
|
|
226375933a | ||
|
|
0409096658 | ||
|
|
5ac522f0de | ||
|
|
8514933b60 | ||
|
|
d7c79f43ef | ||
|
|
afc58a8b41 | ||
|
|
2c0f0bab0b | ||
|
|
12452976bd | ||
|
|
b881c0ec9e | ||
|
|
ba03cd95c5 | ||
|
|
562a1384cd | ||
|
|
52d28966f7 | ||
|
|
207e18a060 | ||
|
|
7bc20bff3e | ||
|
|
1353db7d3f | ||
|
|
4eebd6b9dc | ||
|
|
2a1c588826 | ||
|
|
e6b7c16a53 | ||
|
|
c3440d040c | ||
|
|
8dc11afcf6 | ||
|
|
4778cd4d27 | ||
|
|
06b749ae03 | ||
|
|
50d8d953ce | ||
|
|
e47c0cc929 | ||
|
|
5a6a4819d4 | ||
|
|
2676ec55de | ||
|
|
8ff48201ca | ||
|
|
f6407d5f7c | ||
|
|
4a59210008 | ||
|
|
9b55dbe417 | ||
|
|
2eb7148474 | ||
|
|
4b2023ffab | ||
|
|
23e235b7a5 | ||
|
|
22f81a8d50 | ||
|
|
25678db2a0 | ||
|
|
4d629fd424 | ||
|
|
32682f0ce7 | ||
|
|
7512318a2a | ||
|
|
8767e9ad6a | ||
|
|
daf4454a06 | ||
|
|
01fd655097 | ||
|
|
9793d3524f | ||
|
|
b6182db813 | ||
|
|
61b9677c05 | ||
|
|
b94b29d79c | ||
|
|
b8a6a989c0 | ||
|
|
e1b83399bd | ||
|
|
e9e8bbe6da | ||
|
|
eb40cb371d | ||
|
|
5b908bc756 | ||
|
|
7558549d44 | ||
|
|
42b9b75749 | ||
|
|
f554dd800e | ||
|
|
9cc3e37263 | ||
|
|
39f20dbb13 | ||
|
|
682b74ed88 | ||
|
|
35dcaca53c | ||
|
|
a91a945b88 | ||
|
|
4aa1d09b9e | ||
|
|
fc34ba2596 | ||
|
|
bcf9af94bf | ||
|
|
b5eab2b0b7 | ||
|
|
8fdb31681a | ||
|
|
6ae18a10ba | ||
|
|
1904a3cae8 | ||
|
|
8f522cb702 | ||
|
|
5655c9a4e7 | ||
|
|
72f8bd10b7 | ||
|
|
992a4638ae | ||
|
|
90645f4dac | ||
|
|
5c40800d69 | ||
|
|
1422e96b4e | ||
|
|
b852650c08 | ||
|
|
6881a2ecea | ||
|
|
021c71b651 | ||
|
|
e7eb0b3070 | ||
|
|
80db9de173 | ||
|
|
210187cf77 | ||
|
|
cc1732bc42 | ||
|
|
550b52abf6 | ||
|
|
91791e9f38 | ||
|
|
89d1fad7ee | ||
|
|
296ee3ec58 | ||
|
|
282dd8e7b7 | ||
|
|
410c8785c9 | ||
|
|
5a4cf9560f | ||
|
|
ba49e86e20 | ||
|
|
802e7eb4ef | ||
|
|
4a8a81eb9f | ||
|
|
fd34ef732d | ||
|
|
1bfb3aab1b | ||
|
|
414667b1c9 | ||
|
|
45186c74ac | ||
|
|
e8de1e4766 | ||
|
|
80c174d494 | ||
|
|
bbfe4fbd11 | ||
|
|
ca19ecf49c | ||
|
|
1f2a5a8fc1 | ||
|
|
285e8a2348 | ||
|
|
4edbc98811 | ||
|
|
5e2f7f7ced | ||
|
|
95fab334e4 | ||
|
|
b3e3359d22 | ||
|
|
cba15bc77a | ||
|
|
8d24a18c62 | ||
|
|
1f6f9e6701 | ||
|
|
a88290e595 | ||
|
|
5250feb7ad | ||
|
|
c91de6a356 | ||
|
|
ea607781f8 | ||
|
|
bb3ebedfce | ||
|
|
290a49952e | ||
|
|
64aca4dc4f | ||
|
|
4e81d3277c | ||
|
|
12a33858c9 | ||
|
|
6cb9553706 | ||
|
|
ca990ef091 | ||
|
|
f312f706f4 | ||
|
|
5f57fc1f59 | ||
|
|
5a455eaa0b | ||
|
|
59766efd3e | ||
|
|
86d9323a43 | ||
|
|
a0237a017c | ||
|
|
4c093155a3 | ||
|
|
d04430f4ef | ||
|
|
ae0ee59614 | ||
|
|
e5e3cdf447 | ||
|
|
7e46645193 | ||
|
|
036b9a0002 | ||
|
|
aef9a69a60 | ||
|
|
135080fd3e | ||
|
|
2b73e72d59 | ||
|
|
ca2860947f | ||
|
|
08ff26c817 | ||
|
|
8303e23b3a | ||
|
|
57cc257f58 | ||
|
|
a493b64233 | ||
|
|
b008950d90 | ||
|
|
12438cce16 | ||
|
|
fc82f77a46 | ||
|
|
3dac9f8999 | ||
|
|
d9e27203d4 | ||
|
|
b31ba86ace | ||
|
|
bf6459e324 | ||
|
|
1c2da3a55a | ||
|
|
420f889ac3 | ||
|
|
e8b43903b2 | ||
|
|
f42089d5c6 | ||
|
|
fec139f423 | ||
|
|
7c9ef924bf | ||
|
|
b7bf052a4b | ||
|
|
369f9740de | ||
|
|
497d4fa6d1 | ||
|
|
614229e3f4 | ||
|
|
1a839ba41d | ||
|
|
4a6be2154d | ||
|
|
3e702e8f65 | ||
|
|
a8ff220654 | ||
|
|
d484e1dbd4 | ||
|
|
d5b8b644c2 | ||
|
|
f7bccf5513 | ||
|
|
6758c3f400 | ||
|
|
9a5d69c842 | ||
|
|
12e07798df | ||
|
|
9c6d78c26d | ||
|
|
221adfa606 | ||
|
|
4ad4c2625d | ||
|
|
e3eb55cc8f | ||
|
|
36f52ea687 | ||
|
|
669b4c5f19 | ||
|
|
ba42248575 | ||
|
|
999481ace0 | ||
|
|
7f925e6be9 | ||
|
|
2f4335e081 | ||
|
|
0adefbf152 | ||
|
|
a412ca7a77 | ||
|
|
426d441994 | ||
|
|
4f39139fe0 | ||
|
|
0d084d01b9 | ||
|
|
390aee960a | ||
|
|
792b1c84c0 | ||
|
|
2d6ea2fbc9 | ||
|
|
58b2f9bd6b | ||
|
|
893703a07b | ||
|
|
775f456d4c | ||
|
|
e2f429b742 | ||
|
|
ba180e754d | ||
|
|
713d4424c6 | ||
|
|
e16b969829 | ||
|
|
2112fb1736 | ||
|
|
2aa044cb0c | ||
|
|
c8a9d3458e | ||
|
|
c5de653b98 | ||
|
|
22fcab131c | ||
|
|
da7c8c7b54 | ||
|
|
f5520209f5 | ||
|
|
ae365928c5 | ||
|
|
5923d483a4 | ||
|
|
0312898979 | ||
|
|
db16f0129a | ||
|
|
c395d16230 | ||
|
|
1011db793f | ||
|
|
ca88fc34c3 | ||
|
|
ad97d7b9db | ||
|
|
18a24935cc | ||
|
|
8b69acc1cc | ||
|
|
0468ca02fe | ||
|
|
7355499a6a | ||
|
|
1208ac9f10 | ||
|
|
298ba74a45 | ||
|
|
b15f9eb58f | ||
|
|
60eb34509b | ||
|
|
a808b3e738 | ||
|
|
0f1ead8943 | ||
|
|
dfabcd84c1 | ||
|
|
71d955be1d | ||
|
|
e4ee1da652 | ||
|
|
ff9c15f48a | ||
|
|
b275e664ec | ||
|
|
e323527ffa | ||
|
|
08fef9b277 | ||
|
|
94dcf81954 | ||
|
|
2b6261a52d | ||
|
|
0eb621f75e | ||
|
|
9634227181 | ||
|
|
9fce2751c8 | ||
|
|
49c1dea03b | ||
|
|
4b8874ceb9 | ||
|
|
cf19e3e46a | ||
|
|
1429a7b3ef | ||
|
|
7486a2cd51 | ||
|
|
fd0da9c0df | ||
|
|
6d36584ff2 | ||
|
|
f422edaf15 | ||
|
|
1473eafd1a | ||
|
|
cac86197cb | ||
|
|
006c44ff5d | ||
|
|
be3e109309 | ||
|
|
2bad436abf | ||
|
|
7ab4630cc9 | ||
|
|
5dab97b6d4 | ||
|
|
b38a442386 | ||
|
|
0708310041 | ||
|
|
cd27a53345 | ||
|
|
416e173448 | ||
|
|
d73523864a | ||
|
|
eb69a42863 | ||
|
|
651826b660 | ||
|
|
6dcdf91458 | ||
|
|
a6586cafb2 | ||
|
|
e496ee7a80 | ||
|
|
a4b6803556 | ||
|
|
9c72fef086 | ||
|
|
10d1c6da18 | ||
|
|
5ed84e04f8 | ||
|
|
25fa6acc4d | ||
|
|
9a46c5afc4 | ||
|
|
97ae5f7b1e | ||
|
|
1c7c277432 | ||
|
|
70ca8c4016 | ||
|
|
73507d5f4e | ||
|
|
d2f811eff3 | ||
|
|
2e5181666f | ||
|
|
5c0ce6b83e | ||
|
|
f6b3019796 | ||
|
|
dd04aeba1c | ||
|
|
57c0dcdc29 | ||
|
|
6d39c6f646 | ||
|
|
5a3c646307 | ||
|
|
0da47c51de | ||
|
|
120079b0a6 | ||
|
|
3da887c58f | ||
|
|
4922bc4890 | ||
|
|
ed161b240e | ||
|
|
531bfbd61f | ||
|
|
cd0b12ed1a | ||
|
|
0dc0758574 | ||
|
|
bcae817215 | ||
|
|
b850b14300 | ||
|
|
a277170c9a | ||
|
|
711bd095db | ||
|
|
d55b019284 | ||
|
|
f2af97711b | ||
|
|
b46ac13504 | ||
|
|
cee6871710 | ||
|
|
b74d8c1acd | ||
|
|
fc595a7111 | ||
|
|
bf7843833f | ||
|
|
251dcb07eb | ||
|
|
b407327972 | ||
|
|
aee50b1327 | ||
|
|
4de2cf34e6 | ||
|
|
52f1db7220 | ||
|
|
c995838e5c | ||
|
|
539bddce8c | ||
|
|
002df0f16c | ||
|
|
be16bcdcd3 | ||
|
|
cb9a0466f1 | ||
|
|
543c93f623 | ||
|
|
3f0bcdc3ef | ||
|
|
0d7c265392 | ||
|
|
022536cab6 | ||
|
|
2278327eba | ||
|
|
37d40e087f | ||
|
|
179e048bba | ||
|
|
c2590cf7a0 | ||
|
|
89d1e5b8f2 | ||
|
|
5e60e5ad10 | ||
|
|
6b06a8176d | ||
|
|
14d036b68d | ||
|
|
fae0c0286f | ||
|
|
d6ff4c754e | ||
|
|
f44d88707e | ||
|
|
fc96af058b | ||
|
|
bd6069deb5 | ||
|
|
e9735a7738 | ||
|
|
0ea10c8631 | ||
|
|
e522aa3a07 | ||
|
|
d7b88734cd | ||
|
|
da8f5009fd | ||
|
|
ef9776755e | ||
|
|
da336b3ea8 | ||
|
|
69bee64a59 | ||
|
|
f7ff77d865 | ||
|
|
648bf6555c | ||
|
|
60cb435cb4 | ||
|
|
64c284003d | ||
|
|
3d2d04b25e | ||
|
|
5af19b7eed | ||
|
|
8111462789 | ||
|
|
f52f65b2e3 | ||
|
|
997ce29ddc | ||
|
|
d38700687a | ||
|
|
0f89140882 | ||
|
|
0cee831da3 | ||
|
|
b41f91c658 | ||
|
|
e7329b7cba | ||
|
|
c19ac8729d | ||
|
|
9d2f993364 | ||
|
|
31dab8a75d | ||
|
|
7a06760e6f | ||
|
|
9209ea63a7 | ||
|
|
84b9b8ed87 | ||
|
|
e557058ac8 | ||
|
|
467a332e38 | ||
|
|
7ae556463a | ||
|
|
c424352a0a | ||
|
|
d5910e2673 | ||
|
|
9b7c8db846 | ||
|
|
4a6fd3d910 | ||
|
|
38df0a4186 | ||
|
|
1c0adb556d | ||
|
|
8aca94f951 | ||
|
|
38e3ab57a6 | ||
|
|
672ccda37c | ||
|
|
9849b4c7ba | ||
|
|
3421b9a580 | ||
|
|
29d695f4c9 | ||
|
|
7d6835c0dd | ||
|
|
05197afca2 | ||
|
|
bc353f454b | ||
|
|
7bc24888fe | ||
|
|
59ac141e49 | ||
|
|
60b68d7152 | ||
|
|
a5b483f2d4 | ||
|
|
d3efa47f81 | ||
|
|
7822917fc2 | ||
|
|
81ee11a16e | ||
|
|
f155205eb0 | ||
|
|
e46ef487a8 | ||
|
|
afc07b9339 | ||
|
|
edb8fef06c | ||
|
|
b75a4654cf | ||
|
|
fe3216e961 | ||
|
|
174d288e66 | ||
|
|
9f9b240f3d | ||
|
|
726f04e8aa | ||
|
|
556697cbd8 | ||
|
|
3ee3736a01 | ||
|
|
01bd7d1008 | ||
|
|
32321ab1e9 | ||
|
|
3b4fcd8575 | ||
|
|
6ba3b448f3 | ||
|
|
91e167caaf | ||
|
|
ccbae7799e | ||
|
|
af24c19db3 | ||
|
|
950a1b310b | ||
|
|
daca5499b9 | ||
|
|
2526a9b8c7 | ||
|
|
7549a5755e | ||
|
|
795d295590 | ||
|
|
3f3cb0650b | ||
|
|
acd8900071 | ||
|
|
6c60793f3a | ||
|
|
ad97775370 | ||
|
|
0b5f84dd20 | ||
|
|
27b5deefb1 | ||
|
|
ecb2ef7c39 | ||
|
|
304cf8869c | ||
|
|
3e0ddf70e9 | ||
|
|
5005f2e446 | ||
|
|
bc8532688b | ||
|
|
09811e739f | ||
|
|
24988f2351 | ||
|
|
b46f763ee7 | ||
|
|
87708c5d6e | ||
|
|
8c2bf341e9 | ||
|
|
6cc9e08f1b | ||
|
|
bfb85fe6d0 | ||
|
|
2cc1d5ac4c | ||
|
|
6e582d245b | ||
|
|
2395a9eced | ||
|
|
0060940d84 | ||
|
|
1ea01fc905 | ||
|
|
c7a8cd21e9 | ||
|
|
224c12f54d | ||
|
|
be29b709b7 | ||
|
|
e14ae1642e | ||
|
|
40991ec992 | ||
|
|
97bb5a3a80 | ||
|
|
bc3d84341d | ||
|
|
c937fbb222 | ||
|
|
cdf9e8c8a3 | ||
|
|
4c40c500b8 | ||
|
|
3665232d66 | ||
|
|
775944a2d0 | ||
|
|
994e1f4386 | ||
|
|
3733b43a8f | ||
|
|
134ffee519 | ||
|
|
6c90f830d9 | ||
|
|
14731d61fa | ||
|
|
418bcb39af | ||
|
|
3f49889841 | ||
|
|
1ad2f530f9 | ||
|
|
654ceaba7d | ||
|
|
6a3330d7c9 | ||
|
|
945699694e | ||
|
|
aab4ee4072 | ||
|
|
8f5678882d | ||
|
|
9fa6725067 | ||
|
|
06f9a5b627 | ||
|
|
446a1f7c5a | ||
|
|
df08b541af | ||
|
|
e0fabd1d49 | ||
|
|
9cf2bdc9a8 | ||
|
|
ed5b763a0c | ||
|
|
22b63d0b98 | ||
|
|
6f7d0cb1c3 | ||
|
|
b69f3d2488 | ||
|
|
0305194d98 | ||
|
|
55ddf73484 | ||
|
|
569c031934 | ||
|
|
9b89a7c51d | ||
|
|
b5cb71ab84 | ||
|
|
3de35e196c | ||
|
|
5dff63a31c | ||
|
|
cdb2284f0d | ||
|
|
333768440c | ||
|
|
cfcf5918bc | ||
|
|
bae7367774 | ||
|
|
155b378a39 | ||
|
|
e9272f03fb | ||
|
|
3265324e00 | ||
|
|
c3208eb9d5 | ||
|
|
1729a8259c | ||
|
|
094ccbb4bd | ||
|
|
e97f1a99cf | ||
|
|
1db76c288e | ||
|
|
f68151c010 | ||
|
|
2d17ab016c | ||
|
|
c32e2d4486 | ||
|
|
5140897c27 | ||
|
|
9f963dc597 | ||
|
|
0547eabcd6 | ||
|
|
b73e35c6fa | ||
|
|
0e2b1bfeed | ||
|
|
571c2c3c69 | ||
|
|
b7c07d548c | ||
|
|
6c323383e5 | ||
|
|
de511bc71a | ||
|
|
114176c304 | ||
|
|
a849a63771 | ||
|
|
4339d9f15e | ||
|
|
d5c9308a43 | ||
|
|
8bd9ad8342 | ||
|
|
3fdb1c14f1 | ||
|
|
598640864a | ||
|
|
d861d2787b | ||
|
|
dbf12c30b0 | ||
|
|
11ec60d5fc | ||
|
|
55c6297e13 | ||
|
|
12d9e1e128 | ||
|
|
7ff0ea8c13 | ||
|
|
7de2f229a7 | ||
|
|
4b4ea046c4 | ||
|
|
44c315d789 | ||
|
|
8cd4248f7f | ||
|
|
d721ff8938 | ||
|
|
9be364d40a | ||
|
|
af24f21556 | ||
|
|
b0287ef34c | ||
|
|
6a04bc3318 | ||
|
|
8dd4ec68d0 | ||
|
|
b9dc74b672 | ||
|
|
e1590e1e38 | ||
|
|
8569704c1d | ||
|
|
9c017c98d3 | ||
|
|
74879bf067 | ||
|
|
8a3d8497e3 | ||
|
|
3c00d8c29c | ||
|
|
1ef955c33b | ||
|
|
494d74271b | ||
|
|
12212894eb | ||
|
|
a4522fba8d | ||
|
|
0c70e8963d | ||
|
|
b66bd064d8 | ||
|
|
c5c4dfcd21 | ||
|
|
c5659b93f8 | ||
|
|
263711965f | ||
|
|
33b5b5b312 | ||
|
|
d213a48190 | ||
|
|
3f0414e1cb | ||
|
|
adaaeb7dd0 | ||
|
|
164e2ab27b | ||
|
|
d2cec808dc | ||
|
|
91a3252434 | ||
|
|
8cab92a069 | ||
|
|
5a632cf72d | ||
|
|
7b74f6e20e | ||
|
|
253cc1754b | ||
|
|
8722006c46 | ||
|
|
58d22c7c3d | ||
|
|
2227cefa5d | ||
|
|
f0bf9f3389 | ||
|
|
04cd62c319 | ||
|
|
e204fc0820 | ||
|
|
b76540105d | ||
|
|
14e3025749 | ||
|
|
51fa5535ac | ||
|
|
bea0b55576 | ||
|
|
57b39d8793 | ||
|
|
d52170ca34 | ||
|
|
bf757c4646 | ||
|
|
99a92048b4 | ||
|
|
2f1679e5cf | ||
|
|
ee49b71be2 | ||
|
|
73845be1f0 | ||
|
|
35203c0551 | ||
|
|
83d41e4588 | ||
|
|
a51edaa0db | ||
|
|
d76dfadc7a | ||
|
|
8835b82a7c | ||
|
|
2827df688a | ||
|
|
1ce101c5a5 | ||
|
|
fcbf64b906 | ||
|
|
283fd9e590 | ||
|
|
6bb9ce553e | ||
|
|
75832f7379 | ||
|
|
897e33ccc4 | ||
|
|
27416e7dd6 | ||
|
|
6c3048821c | ||
|
|
2d5f2bebb0 | ||
|
|
db509ee158 | ||
|
|
640b9bfb48 | ||
|
|
30e1c5bca9 | ||
|
|
2d479f7b11 | ||
|
|
d7372e651d | ||
|
|
8e176fb026 | ||
|
|
c2211c9e63 | ||
|
|
f7ee9d7d99 | ||
|
|
e3fe127ccd | ||
|
|
fbdab72e3b | ||
|
|
1f735a4af3 | ||
|
|
e5f705ace3 | ||
|
|
a1aaf23dc1 | ||
|
|
ce588dd56b | ||
|
|
255d834f8f | ||
|
|
f0701d2a24 | ||
|
|
d3b599a796 | ||
|
|
0cf9716039 | ||
|
|
7ab15e0b23 | ||
|
|
6c0bbfac4a | ||
|
|
5584f6adcf | ||
|
|
d36d0634db | ||
|
|
e1699c5b68 | ||
|
|
2e54c8f9fc | ||
|
|
ead3fc2b31 | ||
|
|
62ca1b0902 | ||
|
|
ad775a75b8 | ||
|
|
b212f49ef4 | ||
|
|
e62d7b8789 | ||
|
|
0ea0d33a77 | ||
|
|
367d06d9e4 | ||
|
|
17aea99bb3 | ||
|
|
7cf66bc161 | ||
|
|
8a0a2c0c36 | ||
|
|
05b8f82371 | ||
|
|
625aa365f1 | ||
|
|
6b8b58fdf5 | ||
|
|
10fd8bdb70 | ||
|
|
2d64b9994b | ||
|
|
4c3ab6d11e | ||
|
|
7b993d561c | ||
|
|
e015defa70 | ||
|
|
37ebd8f8d5 | ||
|
|
7e1c78b4f3 | ||
|
|
c1d99676c4 | ||
|
|
95f54eeb40 | ||
|
|
5c5cf0e01d | ||
|
|
3b81bec5ae | ||
|
|
de48bae30e | ||
|
|
6746d768c6 | ||
|
|
4e939d1761 | ||
|
|
ae5d06dc53 | ||
|
|
133c693650 | ||
|
|
c464f45692 | ||
|
|
d4744048ba | ||
|
|
6b3d257588 | ||
|
|
0277d7d6e9 | ||
|
|
7bd4179b9b | ||
|
|
b77cae2d57 | ||
|
|
5546559034 | ||
|
|
13c1c45075 | ||
|
|
6a5717a48f | ||
|
|
a8cf0f7e89 | ||
|
|
cf93ecbbb2 | ||
|
|
acdf591833 | ||
|
|
8d9ac3da50 | ||
|
|
638c56e3a5 | ||
|
|
c9d7838213 | ||
|
|
9c06067c84 | ||
|
|
9d7514a906 | ||
|
|
84e89a55d4 | ||
|
|
db8217b37b | ||
|
|
449fb2fb59 | ||
|
|
5f552338d6 | ||
|
|
af3df0893b | ||
|
|
4238e4def9 | ||
|
|
ab301401c7 | ||
|
|
42bd79a461 | ||
|
|
066ed2b2b2 | ||
|
|
bd118dafa0 | ||
|
|
e98514cdb7 | ||
|
|
3443039f34 | ||
|
|
3d2cf95af1 | ||
|
|
c921dc78f0 | ||
|
|
6c71bd5969 | ||
|
|
8593580d0a | ||
|
|
f968e2a726 | ||
|
|
31ac58a57b | ||
|
|
638e14bbf3 | ||
|
|
03dd14c298 | ||
|
|
16fc83f9ce | ||
|
|
ffedbfe14d | ||
|
|
3828c08aa0 | ||
|
|
ce5cb8a2f8 | ||
|
|
31e4b0867b | ||
|
|
513a659dd2 | ||
|
|
48ce3ad7cc | ||
|
|
742251dd92 | ||
|
|
76d2f68c91 | ||
|
|
b5904947e9 | ||
|
|
516b68606f | ||
|
|
6bb8b26d70 | ||
|
|
31e746c937 | ||
|
|
5a2bb07b36 | ||
|
|
84caee23ba | ||
|
|
9de3d8f1e6 | ||
|
|
d4000bb8f7 | ||
|
|
8b469389f6 | ||
|
|
9172fd42a0 | ||
|
|
1837dc2e85 | ||
|
|
439ad21b12 | ||
|
|
7e2eae5c15 | ||
|
|
d3f3cb7ab4 | ||
|
|
097634d75c | ||
|
|
ed205e98a1 | ||
|
|
98254a7c1f | ||
|
|
92cb144fff | ||
|
|
f716435260 | ||
|
|
6e52a84a51 | ||
|
|
f7e22a33a1 | ||
|
|
69f4152f38 | ||
|
|
057e8f5b54 | ||
|
|
bf59defc0c | ||
|
|
574eba8352 | ||
|
|
6598940d8a | ||
|
|
e81edf7b04 | ||
|
|
b1d9d11be1 | ||
|
|
38c3fa63fe | ||
|
|
1c6b5c0acd | ||
|
|
4f4889ddf7 | ||
|
|
5b11033d4d | ||
|
|
4d25f8c3c9 | ||
|
|
866b21a151 | ||
|
|
4700984456 | ||
|
|
ea04d00752 | ||
|
|
6c724c0f1a | ||
|
|
aa34340f3d | ||
|
|
b4e38851ff | ||
|
|
13d67fed38 | ||
|
|
2e3958c6dc | ||
|
|
6c49e36537 | ||
|
|
7f966de489 | ||
|
|
baf51a4a23 | ||
|
|
ccd057a85d | ||
|
|
0a589add41 | ||
|
|
28b9d9f781 | ||
|
|
bcdd5c5f74 | ||
|
|
4901e1b8cb | ||
|
|
1d744ea11b | ||
|
|
b707fca77a | ||
|
|
60164a7266 | ||
|
|
0cea6c560f | ||
|
|
1d490fcb94 | ||
|
|
12d9f7ade6 | ||
|
|
30cc2c8dc1 | ||
|
|
e3cd476a9b | ||
|
|
3027d67037 | ||
|
|
6d52664aa7 | ||
|
|
3f3e7e92d7 | ||
|
|
7965ed0232 | ||
|
|
6ee18986e4 | ||
|
|
4814b6bdf8 | ||
|
|
3c10fb5580 | ||
|
|
0272f638a5 | ||
|
|
9308463b0f | ||
|
|
594615a0ff | ||
|
|
11a1c62d11 | ||
|
|
aeee2f9106 | ||
|
|
694a0da990 | ||
|
|
9877c04fac | ||
|
|
3f015b1e51 | ||
|
|
84764ce7b8 | ||
|
|
68ca49bfdd | ||
|
|
331fdd1d29 | ||
|
|
c0b325bafa | ||
|
|
5fa77f1e8f | ||
|
|
5f4f6b0e69 | ||
|
|
e4d6e263d4 | ||
|
|
28f0104330 | ||
|
|
4a1419fefa | ||
|
|
ee82cee432 | ||
|
|
9e86980191 | ||
|
|
7756e27993 | ||
|
|
2189877856 | ||
|
|
d37536bd4b | ||
|
|
727d9cbf56 | ||
|
|
896db8843f | ||
|
|
c9e68b0ebc | ||
|
|
85aecbda67 | ||
|
|
a9145e7f1e | ||
|
|
182d7720cf | ||
|
|
1c83670229 | ||
|
|
c5b9902ac9 | ||
|
|
50a6df89b8 | ||
|
|
fe5c475f83 | ||
|
|
a18044c504 | ||
|
|
11ac8f11a9 | ||
|
|
059fe22ea3 | ||
|
|
853b6c3864 | ||
|
|
5df3e4e7a8 | ||
|
|
2eebb198a9 | ||
|
|
9f8e6c10dd | ||
|
|
5297897ba1 | ||
|
|
3c92adfd6e | ||
|
|
a6f65eea7c | ||
|
|
32eec7df4c | ||
|
|
283729dfe0 | ||
|
|
b4e9a77e74 | ||
|
|
f6dab99f44 | ||
|
|
b535937fca | ||
|
|
893cc06fc2 | ||
|
|
5cd0e876bd | ||
|
|
b1de862e16 | ||
|
|
2f515ac5e3 | ||
|
|
61257d48d4 | ||
|
|
fa5c2a24b5 | ||
|
|
fbc053e018 | ||
|
|
5d837c4e7c | ||
|
|
1bce1ca2e0 | ||
|
|
a9d77362f9 | ||
|
|
4b9ee980a1 | ||
|
|
e55ef556aa | ||
|
|
7f26779d6f | ||
|
|
3d07f362d7 | ||
|
|
f79b2fe23a | ||
|
|
e4258015b7 | ||
|
|
49905fed0b | ||
|
|
44da16255a | ||
|
|
a4601a24d3 | ||
|
|
0dd9629562 | ||
|
|
3fc23c6cbc | ||
|
|
2b54f1bcf6 | ||
|
|
206f073181 | ||
|
|
17cbe73411 | ||
|
|
2415afab0e | ||
|
|
1235ad6006 | ||
|
|
9545062175 | ||
|
|
0e773e23ad | ||
|
|
fc097ac275 | ||
|
|
4b23985b7f | ||
|
|
ff28e38ef1 | ||
|
|
b8e9f71d33 | ||
|
|
1216b6e7c7 | ||
|
|
56eff8544f | ||
|
|
f317a47cd8 | ||
|
|
a988896048 | ||
|
|
5ddf43332e | ||
|
|
d5312b60f7 | ||
|
|
25041b8026 | ||
|
|
2c7fe0f361 | ||
|
|
8c895453e2 | ||
|
|
c1cfca8ae1 | ||
|
|
67b28b9af1 | ||
|
|
52ed099fe6 | ||
|
|
5e04827949 | ||
|
|
bc90db0d4b | ||
|
|
7b34f32fc4 | ||
|
|
a0ddb889da | ||
|
|
34e39ad027 | ||
|
|
2c7f865b12 | ||
|
|
d0d9cd38c5 | ||
|
|
c06ffd458c | ||
|
|
42c38bc3e3 | ||
|
|
fae2a17d2c | ||
|
|
e466dd0553 | ||
|
|
579080cd4c | ||
|
|
42b34c26f8 | ||
|
|
8b13e1acc8 | ||
|
|
58c77a9b1d | ||
|
|
bba7f5e296 | ||
|
|
1c387727fe | ||
|
|
dae0583ee5 | ||
|
|
a3865ecc3c | ||
|
|
3c285337a2 | ||
|
|
91953dd308 | ||
|
|
8b72490431 | ||
|
|
8cdec62f5b | ||
|
|
4ddfc47d6e | ||
|
|
6070a53e89 | ||
|
|
a5849f8549 | ||
|
|
29af890efa | ||
|
|
517267a577 | ||
|
|
e96aceae41 | ||
|
|
1ae6cfc198 | ||
|
|
e32288d4ea | ||
|
|
c260345e06 | ||
|
|
5ea618f0af | ||
|
|
5deda43766 | ||
|
|
c6d8e516b2 | ||
|
|
41c86fe86b | ||
|
|
8a967ae6fe | ||
|
|
af4687cc3f | ||
|
|
1531f1a4a7 | ||
|
|
fde939291d | ||
|
|
f8520e10b2 | ||
|
|
2528536cff | ||
|
|
a41669dec6 | ||
|
|
fa1e8a3e65 | ||
|
|
3c7ae0fc72 | ||
|
|
ecc8962555 | ||
|
|
e1a40783da | ||
|
|
adac64a52b | ||
|
|
4e7ce1538c | ||
|
|
701564de19 | ||
|
|
cfb5d3e406 | ||
|
|
e011973593 | ||
|
|
da6d610056 | ||
|
|
13ee75150c | ||
|
|
425ff5dff0 | ||
|
|
909e54510d | ||
|
|
de5de19004 | ||
|
|
cb67223051 | ||
|
|
7e9fb0a9f1 | ||
|
|
10b97ca630 | ||
|
|
8f12cd980d | ||
|
|
1a29424c52 | ||
|
|
d230a01222 | ||
|
|
d44ff6ce1f | ||
|
|
cef50f2a6b | ||
|
|
99e67c348b | ||
|
|
e8632cfc30 | ||
|
|
312ed5c67c | ||
|
|
1f229e4efc | ||
|
|
4e9662cbc7 | ||
|
|
056dc5f554 | ||
|
|
db0d8dd806 | ||
|
|
7838edae88 | ||
|
|
96781d0679 | ||
|
|
f4fc16754a | ||
|
|
8141988e92 | ||
|
|
fb4382e9a4 | ||
|
|
c8a2f04058 | ||
|
|
4245da19e2 | ||
|
|
b4ae385a6a | ||
|
|
c21412bc2c | ||
|
|
ec2cb88058 | ||
|
|
6e52cba37a | ||
|
|
9208c83f7a | ||
|
|
c6bbca55e9 | ||
|
|
b2c6ec6eab | ||
|
|
2ad1c9078d | ||
|
|
3d99ebb68c | ||
|
|
f37524ef4f | ||
|
|
2743f3d012 | ||
|
|
ce71677156 | ||
|
|
8bfb70ca3f | ||
|
|
59b6ae1cbd | ||
|
|
55de4ca6b5 | ||
|
|
91ee2b19d4 | ||
|
|
e5e141d9b5 | ||
|
|
c446af799e | ||
|
|
6bf6f9e376 | ||
|
|
54e6f564c1 | ||
|
|
178a6da4b9 | ||
|
|
80b211e314 | ||
|
|
578cb21591 | ||
|
|
f6df29cc3d | ||
|
|
d25a67f4eb | ||
|
|
77b70ba193 | ||
|
|
83b743cf96 | ||
|
|
fec396037a | ||
|
|
4e62cefa6e | ||
|
|
4499f98e76 | ||
|
|
0f6251f4d2 | ||
|
|
ec6e0fa5f4 | ||
|
|
335d158ab6 | ||
|
|
2ea1dc405c | ||
|
|
e7611a8476 | ||
|
|
dd9ab01d25 | ||
|
|
cf73bbd678 | ||
|
|
70c97f598b | ||
|
|
cfc3a953ae | ||
|
|
2aebda7718 | ||
|
|
363d2ec436 | ||
|
|
b30f5c0c4f | ||
|
|
15c59e716f | ||
|
|
c9f966d73c | ||
|
|
93906f8f28 | ||
|
|
42071ffe6f | ||
|
|
854c90f547 | ||
|
|
a85406da4c | ||
|
|
e4b559c76a | ||
|
|
2d1731b995 | ||
|
|
7aafa64ab3 | ||
|
|
c9a981fdbe | ||
|
|
80c4533303 | ||
|
|
47b3274665 | ||
|
|
9a6bd304a5 | ||
|
|
e3a7ab1804 | ||
|
|
92ebef16ee | ||
|
|
cc0d1ec076 | ||
|
|
6a145a9262 | ||
|
|
d57b81aac7 | ||
|
|
860ea18a87 | ||
|
|
e6fab847a0 | ||
|
|
72e9be5c20 | ||
|
|
451e3f73d9 | ||
|
|
2046c0d2ae | ||
|
|
cf3174dc74 | ||
|
|
2f56ebfe78 | ||
|
|
6ff46ca373 | ||
|
|
552525cbdd | ||
|
|
a259e43d84 | ||
|
|
38728cef79 | ||
|
|
0dca4c5799 | ||
|
|
c39d6111f2 | ||
|
|
1599b818d9 | ||
|
|
01b25e267b | ||
|
|
9d61e23c80 | ||
|
|
9bfa6ec06e | ||
|
|
87396f43bc | ||
|
|
ae638c0850 | ||
|
|
c3fb624647 | ||
|
|
5a132f9652 | ||
|
|
7166679620 | ||
|
|
f1dfa4bdfa | ||
|
|
ab38f0823d | ||
|
|
80308079ec | ||
|
|
4a6a34db83 | ||
|
|
a6b02ce5a6 | ||
|
|
f6b6204b9e | ||
|
|
933f33bcc1 | ||
|
|
be7c5e1071 | ||
|
|
dc0ea6640e | ||
|
|
933411ba99 | ||
|
|
233144b19d | ||
|
|
fb7e8ef1e6 | ||
|
|
281a0f2730 | ||
|
|
f684e348d4 | ||
|
|
c95c9d9508 | ||
|
|
046c7ebd4a | ||
|
|
f68f1789bd | ||
|
|
e500e8fb48 | ||
|
|
a157940ba6 | ||
|
|
183b3ed6a2 | ||
|
|
668dc42bac | ||
|
|
d31bebdd2d | ||
|
|
4f98ad1054 | ||
|
|
29bf8b1a30 | ||
|
|
43ba3009b2 | ||
|
|
722d3df711 | ||
|
|
837ff6cb49 | ||
|
|
42fbcff149 | ||
|
|
c13142dad2 | ||
|
|
f59b5dbd7c | ||
|
|
82f2e758c7 | ||
|
|
ce9bdbb0bf | ||
|
|
58d74ede4c | ||
|
|
04d39d47f1 | ||
|
|
9b11206ae3 | ||
|
|
38cb6e71ca | ||
|
|
1ff1854107 | ||
|
|
27bc49034c | ||
|
|
1ccd269cdd | ||
|
|
2fe386ff8c | ||
|
|
072e1d2910 | ||
|
|
3b9e66ecba | ||
|
|
98909b1391 | ||
|
|
b90fa996b4 | ||
|
|
23b72eb617 | ||
|
|
393ca4be40 | ||
|
|
c23b6ecc31 | ||
|
|
e2e0b042c1 | ||
|
|
868af3f950 | ||
|
|
5022f9e920 | ||
|
|
87029ac3f9 | ||
|
|
e5314dedde | ||
|
|
d57f87dc40 | ||
|
|
4881ae7527 | ||
|
|
f78f2fcac3 | ||
|
|
5e8ae2d5bc | ||
|
|
d5ff2c3fb9 | ||
|
|
0cb6b6ff4b | ||
|
|
efedef6e65 | ||
|
|
39688a73e4 | ||
|
|
10a766ebd0 | ||
|
|
14e192e5ba | ||
|
|
c541225af0 | ||
|
|
c4d8f40422 | ||
|
|
96bdd7e90f | ||
|
|
390e22a8c6 | ||
|
|
6c2fd9ecc6 | ||
|
|
b149a9bcc4 | ||
|
|
9d2c8798c1 | ||
|
|
d07a58a763 | ||
|
|
c371db6663 | ||
|
|
af645fcbec | ||
|
|
f5831a62fa | ||
|
|
741c836e9d | ||
|
|
46a3b88594 | ||
|
|
e20fcf02c1 | ||
|
|
bf62140377 | ||
|
|
b45d50b690 | ||
|
|
2a938b3eaa | ||
|
|
cfc557f7c7 | ||
|
|
38112aeb20 | ||
|
|
22409b2b5e | ||
|
|
abac6f729c | ||
|
|
1e3c5e10ad | ||
|
|
4abae20172 | ||
|
|
9bab356c37 | ||
|
|
0f035119b1 | ||
|
|
db6152e21d | ||
|
|
d938b89f4f | ||
|
|
d6a039821f | ||
|
|
f12c6c1b5e | ||
|
|
fdb543cbb3 | ||
|
|
1d6216a775 | ||
|
|
206091617a | ||
|
|
777d08a839 | ||
|
|
98192c1079 | ||
|
|
7064d736e3 | ||
|
|
245a9c206b | ||
|
|
1bdc8faa65 | ||
|
|
8f05990d5a | ||
|
|
7fe9e70117 | ||
|
|
6f658f058b | ||
|
|
ca611efc43 | ||
|
|
e5d1536256 | ||
|
|
d7ff346b52 | ||
|
|
903cc38c37 | ||
|
|
3616f2a432 | ||
|
|
7a50dba812 | ||
|
|
19f70a154e | ||
|
|
0a0997a872 | ||
|
|
30cd28b1f8 | ||
|
|
91d783352a | ||
|
|
45a7435788 | ||
|
|
660ff56d40 | ||
|
|
c00755f921 | ||
|
|
013f03e33f | ||
|
|
49db877fbe | ||
|
|
253ac31a64 | ||
|
|
67b5200a0b | ||
|
|
226aaf3547 | ||
|
|
a0b39f886c | ||
|
|
d852640a1e | ||
|
|
425a57080d | ||
|
|
bba144246a | ||
|
|
7061c79c22 | ||
|
|
28997f3acb | ||
|
|
725f4d79f6 | ||
|
|
7521bf9e73 | ||
|
|
47a53e143b | ||
|
|
9cb54218ab | ||
|
|
57f0eed382 | ||
|
|
2fe8571010 | ||
|
|
9cabdaabfd | ||
|
|
39bf41f4eb | ||
|
|
fa7b4f5bd1 | ||
|
|
b883473a6c | ||
|
|
af1153e057 | ||
|
|
2e4b40042a | ||
|
|
42aafc847e | ||
|
|
b51db9f923 | ||
|
|
6fba9601ff | ||
|
|
9e7773a076 | ||
|
|
48a2668239 | ||
|
|
5ffeaa8e33 | ||
|
|
18ccfeb919 | ||
|
|
b5f743cdc3 | ||
|
|
51904e2687 | ||
|
|
ad52387b74 | ||
|
|
6ad0602392 | ||
|
|
1b93066883 | ||
|
|
559b024e1d | ||
|
|
dfa0359b50 | ||
|
|
4f41f2184d | ||
|
|
5bb2275788 | ||
|
|
a8fb68af4b | ||
|
|
1eed7d47bd | ||
|
|
44c87b83ff | ||
|
|
81287b7ec0 | ||
|
|
34b68f1945 | ||
|
|
ab64c746cc | ||
|
|
a81192e0b9 | ||
|
|
27f7ffd4fd | ||
|
|
31dd714081 | ||
|
|
969174e155 | ||
|
|
5b60e5a37d | ||
|
|
0584684a82 | ||
|
|
50937be752 | ||
|
|
3085ac7837 | ||
|
|
63b867bd2f | ||
|
|
0b7737b20a | ||
|
|
818926dbae | ||
|
|
7d25fb0090 | ||
|
|
41b9eb6873 | ||
|
|
00611e9b06 | ||
|
|
2730c66f4a | ||
|
|
c506584174 | ||
|
|
ed485391da | ||
|
|
d5a37de435 | ||
|
|
65f32fad52 | ||
|
|
da45c7c80b | ||
|
|
7341336b1a | ||
|
|
a63b147a93 | ||
|
|
0ba3617e7f | ||
|
|
8af197560e | ||
|
|
98ccbf44b1 | ||
|
|
ebb8c85496 | ||
|
|
4486ad5c9e |
No files matched your search
@@ -8,6 +8,7 @@ AlwaysBreakBeforeMultilineStrings: false
|
||||
AllowShortFunctionsOnASingleLine: false
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
||||
IncludeBlocks: Merge
|
||||
---
|
||||
Language: Cpp
|
||||
AllowShortFunctionsOnASingleLine: false
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
# -*- conf -*-
|
||||
*.gz binary
|
||||
/build/bootstrap/*.com binary
|
||||
/usr/share/zoneinfo/* binary
|
||||
@@ -0,0 +1,31 @@
|
||||
name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
- "flake"
|
||||
pull_request:
|
||||
branches:
|
||||
- "master"
|
||||
|
||||
# run workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
matrix_on_mode:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
mode: ["", tiny, rel, tinylinux, optlinux]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: support ape bins 1
|
||||
run: sudo cp build/bootstrap/ape.elf /usr/bin/ape
|
||||
|
||||
- name: support ape bins 2
|
||||
run: sudo sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register"
|
||||
|
||||
- name: make matrix
|
||||
run: V=0 make -j2 MODE=${{ matrix.mode }}
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
# -*- conf -*-
|
||||
|
||||
/o
|
||||
/.prompt.jtlp
|
||||
|
||||
# TODO: Find some way to have Python write to o/
|
||||
__pycache__
|
||||
@@ -11,4 +12,5 @@ __pycache__
|
||||
/TAGS
|
||||
/bx_enh_dbg.ini
|
||||
/tool/emacs/*.elc
|
||||
/usr/share/dict/words
|
||||
/perf.data
|
||||
/perf.data.old
|
||||
@@ -1,6 +0,0 @@
|
||||
virt: lxd
|
||||
os: linux
|
||||
language: c
|
||||
script: make -j4 V=0
|
||||
notifications:
|
||||
email: false
|
||||
Vendored
+8
-11
@@ -15,7 +15,7 @@
|
||||
"alignas(x)",
|
||||
"alignof(x)",
|
||||
"artificial=",
|
||||
"nodiscard=",
|
||||
"__wur=",
|
||||
"mayalias=",
|
||||
"forceinline=",
|
||||
"forcealign(x)=",
|
||||
@@ -35,20 +35,19 @@
|
||||
"returnstwice=",
|
||||
"textwindows=",
|
||||
"privileged=",
|
||||
"compatfn=",
|
||||
"noinstrument=",
|
||||
"dontinstrument=",
|
||||
"nodebuginfo=",
|
||||
"interruptfn=",
|
||||
"optimizespeed=",
|
||||
"forcealignargpointer=",
|
||||
"noasan=",
|
||||
"noubsan=",
|
||||
"testonly=",
|
||||
"dontasan=",
|
||||
"dontubsan=",
|
||||
"donothing=",
|
||||
"nosideeffect=",
|
||||
"unreachable=",
|
||||
"unreachable=",,
|
||||
"notpossible=",
|
||||
"thatispacked=",
|
||||
"nothrow=",
|
||||
"dontthrow=",
|
||||
"nocallback=",
|
||||
"relegated=",
|
||||
"hidden=",
|
||||
@@ -78,7 +77,6 @@
|
||||
"-Wa,-W",
|
||||
"-Wa,-I.",
|
||||
"-Wa,--noexecstack",
|
||||
"-Wa,--nocompress-debug-sections",
|
||||
"-Og",
|
||||
"-g",
|
||||
"-gdescribe-dies",
|
||||
@@ -103,8 +101,7 @@
|
||||
],
|
||||
"defines": [
|
||||
"COSMO",
|
||||
"MODE=",
|
||||
"IMAGE_BASE_VIRTUAL=0x400000"
|
||||
"MODE="
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#
|
||||
# # basic debugging
|
||||
# make -j8 -O MODE=dbg o/dbg/examples/crashreport.com
|
||||
# o/dbg/examples/crashreport.com
|
||||
# o/examples/crashreport.com
|
||||
# less examples/crashreport.c
|
||||
#
|
||||
# # extremely tiny binaries
|
||||
@@ -59,18 +59,54 @@
|
||||
#
|
||||
# build/config.mk
|
||||
|
||||
SHELL = /bin/sh
|
||||
HOSTS ?= freebsd openbsd netbsd rhel7 rhel5 xnu win7 win10
|
||||
SANITY := $(shell build/sanitycheck $$PPID)
|
||||
GNUMAKEFLAGS += --output-sync
|
||||
SHELL = build/bootstrap/cocmd.com
|
||||
MAKEFLAGS += --no-builtin-rules
|
||||
|
||||
.SUFFIXES:
|
||||
.DELETE_ON_ERROR:
|
||||
.FEATURES: output-sync
|
||||
.PHONY: all o bins check test depend tags
|
||||
.PHONY: all o bins check test depend tags aarch64 clean
|
||||
|
||||
ifneq ($(m),)
|
||||
ifeq ($(MODE),)
|
||||
MODE := $(m)
|
||||
endif
|
||||
endif
|
||||
|
||||
UNAME_M = $(shell uname -m)
|
||||
UNAME_S = $(shell uname -s)
|
||||
|
||||
# apple still distributes a 17 year old version of gnu make
|
||||
ifeq ($(MAKE_VERSION), 3.81)
|
||||
$(error please use build/bootstrap/make.com)
|
||||
endif
|
||||
|
||||
# provide instructions to non-linux users on unbundling gcc
|
||||
ifeq ($(TOOLCHAIN),) # if TOOLCHAIN isn't defined
|
||||
ifeq ("$(wildcard o/third_party/gcc/bin/x86_64-linux-cosmo-*)","") # if our gcc isn't unbundled
|
||||
ifneq ($(UNAME_M)-$(UNAME_S), x86_64-Linux) # if this is not amd64 linux
|
||||
$(error you need to download https://justine.lol/cosmocc-0.0.12.zip and unzip it inside the cosmo directory)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# the default build modes is empty string
|
||||
# on x86_64 hosts, MODE= is the same as MODE=x86_64
|
||||
# on aarch64 hosts, MODE= is changed to MODE=aarch64
|
||||
ifeq ($(MODE),)
|
||||
ifeq ($(UNAME_M),arm64)
|
||||
MODE := aarch64
|
||||
endif
|
||||
ifeq ($(UNAME_M),aarch64)
|
||||
MODE := aarch64
|
||||
endif
|
||||
endif
|
||||
|
||||
# primary build rules
|
||||
all: o
|
||||
o: o/$(MODE)/ape \
|
||||
o: o/$(MODE)
|
||||
o/$(MODE): \
|
||||
o/$(MODE)/ape \
|
||||
o/$(MODE)/dsp \
|
||||
o/$(MODE)/net \
|
||||
o/$(MODE)/libc \
|
||||
@@ -79,6 +115,41 @@ o: o/$(MODE)/ape \
|
||||
o/$(MODE)/examples \
|
||||
o/$(MODE)/third_party
|
||||
|
||||
# check if we're using o//third_party/make/make.com
|
||||
# we added sandboxing to guarantee cosmo's makefile is hermetic
|
||||
# it also shaves away 200ms of startup latency with native $(uniq)
|
||||
ifneq ($(LANDLOCKMAKE_VERSION),)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
ifeq ($(wildcard /usr/bin/ape),)
|
||||
$(warning please run ape/apeinstall.sh if you intend to use landlock make)
|
||||
$(shell sleep .5)
|
||||
endif
|
||||
endif
|
||||
ifeq ($(USE_SYSTEM_TOOLCHAIN),)
|
||||
.STRICT = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
.PLEDGE += stdio rpath wpath cpath fattr proc
|
||||
.UNVEIL += \
|
||||
libc/integral \
|
||||
libc/stdbool.h \
|
||||
libc/disclaimer.inc \
|
||||
rwc:/dev/shm \
|
||||
rx:build/bootstrap \
|
||||
rx:o/third_party/gcc \
|
||||
r:build/portcosmo.h \
|
||||
/proc/stat \
|
||||
rw:/dev/null \
|
||||
rw:/dev/full \
|
||||
w:o/stack.log \
|
||||
/etc/hosts \
|
||||
~/.runit.psk \
|
||||
/proc/self/status \
|
||||
rx:/usr/bin/qemu-aarch64 \
|
||||
rx:o/third_party/qemu/qemu-aarch64 \
|
||||
/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
|
||||
|
||||
PKGS =
|
||||
|
||||
-include ~/.cosmo.mk
|
||||
@@ -86,99 +157,135 @@ include build/functions.mk #─┐
|
||||
include build/definitions.mk # ├──META
|
||||
include build/config.mk # │ You can build
|
||||
include build/rules.mk # │ You can topologically order
|
||||
include build/online.mk # │
|
||||
include libc/stubs/stubs.mk #─┘
|
||||
include build/online.mk #─┘
|
||||
include libc/nexgen32e/nexgen32e.mk #─┐
|
||||
include libc/sysv/sysv.mk # ├──SYSTEM SUPPORT
|
||||
include libc/nt/nt.mk # │ You can do math
|
||||
include libc/intrin/intrin.mk # │ You can use the stack
|
||||
include libc/linux/linux.mk # │ You can manipulate arrays
|
||||
include third_party/compiler_rt/compiler_rt.mk # │ You can manipulate arrays
|
||||
include libc/tinymath/tinymath.mk # │ You can issue raw system calls
|
||||
include third_party/compiler_rt/compiler_rt.mk # │
|
||||
include libc/bits/bits.mk # │
|
||||
include libc/str/str.mk # │
|
||||
include third_party/xed/xed.mk # │
|
||||
include third_party/zlib/zlib.mk # │
|
||||
include third_party/puff/puff.mk # │
|
||||
include libc/elf/elf.mk # │
|
||||
include ape/ape.mk # │
|
||||
include libc/fmt/fmt.mk #─┘
|
||||
include libc/fmt/fmt.mk # │
|
||||
include libc/vga/vga.mk #─┘
|
||||
include libc/calls/calls.mk #─┐
|
||||
include third_party/nsync/nsync.mk # │
|
||||
include libc/runtime/runtime.mk # ├──SYSTEMS RUNTIME
|
||||
include libc/crt/crt.mk # │ You can issue system calls
|
||||
include libc/rand/rand.mk # │
|
||||
include libc/unicode/unicode.mk # │
|
||||
include third_party/double-conversion/dc.mk # │ You can issue system calls
|
||||
include libc/crt/crt.mk # │
|
||||
include third_party/dlmalloc/dlmalloc.mk #─┘
|
||||
include libc/mem/mem.mk #─┐
|
||||
include libc/ohmyplus/ohmyplus.mk # ├──DYNAMIC RUNTIME
|
||||
include libc/zipos/zipos.mk # │ You can now use stdio
|
||||
include third_party/gdtoa/gdtoa.mk # │ You can finally call malloc()
|
||||
include libc/time/time.mk # │
|
||||
include libc/alg/alg.mk # │
|
||||
include third_party/gdtoa/gdtoa.mk # ├──DYNAMIC RUNTIME
|
||||
include third_party/nsync/mem/mem.mk # │ You can now use stdio
|
||||
include libc/proc/proc.mk # │ You can now use threads
|
||||
include libc/thread/thread.mk # │ You can now use processes
|
||||
include tool/hello/hello.mk # │ You can finally call malloc()
|
||||
include third_party/zlib/zlib.mk # │
|
||||
include libc/stdio/stdio.mk # │
|
||||
include libc/time/time.mk # │
|
||||
include net/net.mk # │
|
||||
include third_party/vqsort/vqsort.mk # │
|
||||
include libc/log/log.mk # │
|
||||
include third_party/getopt/getopt.mk # │
|
||||
include third_party/bzip2/bzip2.mk # │
|
||||
include dsp/core/core.mk # │
|
||||
include third_party/musl/musl.mk # │
|
||||
include libc/x/x.mk # │
|
||||
include third_party/stb/stb.mk # │
|
||||
include dsp/scale/scale.mk # │
|
||||
include dsp/mpeg/mpeg.mk # │
|
||||
include dsp/dsp.mk # │
|
||||
include third_party/musl/musl.mk # │
|
||||
include third_party/getopt/getopt.mk # │
|
||||
include third_party/zlib/gz/gz.mk # │
|
||||
include third_party/intel/intel.mk # │
|
||||
include third_party/aarch64/aarch64.mk # │
|
||||
include libc/libc.mk #─┘
|
||||
include libc/sock/sock.mk #─┐
|
||||
include dsp/tty/tty.mk # ├──ONLINE RUNTIME
|
||||
include libc/dns/dns.mk # │ You can communicate with the network
|
||||
include net/http/http.mk # │
|
||||
include third_party/mbedtls/mbedtls.mk # │
|
||||
include third_party/libcxx/libcxx.mk # │
|
||||
include third_party/ggml/ggml.mk # │
|
||||
include third_party/radpajama/radpajama.mk # │
|
||||
include net/https/https.mk # │
|
||||
include third_party/regex/regex.mk #─┘
|
||||
include third_party/tidy/tidy.mk
|
||||
include third_party/third_party.mk
|
||||
include third_party/nsync/testing/testing.mk
|
||||
include libc/testlib/testlib.mk
|
||||
include tool/viz/lib/vizlib.mk
|
||||
include tool/args/args.mk
|
||||
include test/tool/args/test.mk
|
||||
include third_party/linenoise/linenoise.mk
|
||||
include third_party/maxmind/maxmind.mk
|
||||
include net/finger/finger.mk
|
||||
include third_party/double-conversion/test/test.mk
|
||||
include third_party/lua/lua.mk
|
||||
include third_party/tree/tree.mk
|
||||
include third_party/zstd/zstd.mk
|
||||
include third_party/tr/tr.mk
|
||||
include third_party/sed/sed.mk
|
||||
include third_party/awk/awk.mk
|
||||
include third_party/hiredis/hiredis.mk
|
||||
include third_party/make/make.mk
|
||||
include third_party/ctags/ctags.mk
|
||||
include third_party/finger/finger.mk
|
||||
include third_party/argon2/argon2.mk
|
||||
include third_party/smallz4/smallz4.mk
|
||||
include third_party/sqlite3/sqlite3.mk
|
||||
include third_party/mbedtls/test/test.mk
|
||||
include third_party/quickjs/quickjs.mk
|
||||
include third_party/lz4cli/lz4cli.mk
|
||||
include third_party/infozip/infozip.mk
|
||||
include third_party/python/python.mk
|
||||
include third_party/zip/zip.mk
|
||||
include third_party/xxhash/xxhash.mk
|
||||
include third_party/unzip/unzip.mk
|
||||
include tool/build/lib/buildlib.mk
|
||||
include third_party/chibicc/chibicc.mk
|
||||
include third_party/chibicc/test/test.mk
|
||||
include tool/build/emucrt/emucrt.mk
|
||||
include tool/build/emubin/emubin.mk
|
||||
include third_party/python/python.mk
|
||||
include tool/build/build.mk
|
||||
include tool/curl/curl.mk
|
||||
include third_party/qemu/qemu.mk
|
||||
include examples/examples.mk
|
||||
include examples/pyapp/pyapp.mk
|
||||
include examples/pylife/pylife.mk
|
||||
include tool/decode/lib/decodelib.mk
|
||||
include tool/decode/decode.mk
|
||||
include tool/hash/hash.mk
|
||||
include tool/lambda/lib/lib.mk
|
||||
include tool/lambda/lambda.mk
|
||||
include tool/plinko/lib/lib.mk
|
||||
include tool/plinko/plinko.mk
|
||||
include test/tool/plinko/test.mk
|
||||
include tool/net/net.mk
|
||||
include tool/viz/viz.mk
|
||||
include tool/tool.mk
|
||||
include test/libc/alg/test.mk
|
||||
include net/turfwar/turfwar.mk
|
||||
include test/libc/tinymath/test.mk
|
||||
include test/libc/intrin/test.mk
|
||||
include test/libc/mem/test.mk
|
||||
include test/libc/nexgen32e/test.mk
|
||||
include test/libc/runtime/test.mk
|
||||
include test/libc/thread/test.mk
|
||||
include test/libc/sock/test.mk
|
||||
include test/libc/bits/test.mk
|
||||
include test/libc/str/test.mk
|
||||
include test/libc/unicode/test.mk
|
||||
include test/libc/log/test.mk
|
||||
include test/libc/str/test.mk
|
||||
include test/libc/calls/test.mk
|
||||
include test/libc/x/test.mk
|
||||
include test/libc/xed/test.mk
|
||||
include test/libc/fmt/test.mk
|
||||
include test/libc/dns/test.mk
|
||||
include test/libc/rand/test.mk
|
||||
include test/libc/time/test.mk
|
||||
include test/libc/proc/test.mk
|
||||
include test/libc/stdio/test.mk
|
||||
include test/libc/release/test.mk
|
||||
include test/libc/test.mk
|
||||
include test/net/http/test.mk
|
||||
include test/net/https/test.mk
|
||||
include test/net/finger/test.mk
|
||||
include test/net/test.mk
|
||||
include test/tool/build/lib/test.mk
|
||||
include test/tool/build/test.mk
|
||||
@@ -205,136 +312,149 @@ CHECKS = $(foreach x,$(PKGS),$($(x)_CHECKS))
|
||||
|
||||
bins: $(BINS)
|
||||
check: $(CHECKS)
|
||||
test: $(TESTS) all
|
||||
test: $(TESTS)
|
||||
depend: o/$(MODE)/depend
|
||||
tags: TAGS HTAGS
|
||||
|
||||
o/$(MODE)/.x:
|
||||
@mkdir -p $(@D) && touch $@
|
||||
|
||||
ifneq ($(findstring 4.,,$(MAKE_VERSION)),$(MAKE_VERSION))
|
||||
o/$(MODE)/srcs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(SRCS),$(file >>$@,$(x)))
|
||||
o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(HDRS) $(INCS),$(file >>$@,$(x)))
|
||||
o/$(MODE)/incs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(INCS) $(INCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(INCS) $(INCS),$(file >>$@,$(x)))
|
||||
else
|
||||
o/$(MODE)/srcs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x))))
|
||||
$(MAKE) MODE=rel -j8 -pn bopit 2>/dev/null | sed -ne '/^SRCS/ {s/.*:= //;s/ */\n/g;p;q}' >$@
|
||||
o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x))))
|
||||
$(MAKE) MODE=rel -j8 -pn bopit 2>/dev/null | sed -ne '/^HDRS/ {s/.*:= //;s/ */\n/g;p;q}' >$@
|
||||
o/$(MODE)/incs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(INCS) $(INCS),$(dir $(x))))
|
||||
$(MAKE) MODE=rel -j8 -pn bopit 2>/dev/null | sed -ne '/^INCS/ {s/.*:= //;s/ */\n/g;p;q}' >$@
|
||||
endif
|
||||
@$(COMPILE) -AMKDIR -tT$@ $(MKDIR) $(@D)
|
||||
|
||||
o/$(MODE)/srcs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x)))) $(SRCS)
|
||||
$(file >$@,$(SRCS))
|
||||
o/$(MODE)/hdrs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x)))) $(HDRS) $(INCS)
|
||||
$(file >$@,$(HDRS) $(INCS))
|
||||
o/$(MODE)/incs.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(INCS) $(INCS),$(dir $(x)))) $(INCS) $(INCS)
|
||||
$(file >$@,$(INCS))
|
||||
o/$(MODE)/depend: o/$(MODE)/.x o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt o/$(MODE)/incs.txt $(SRCS) $(HDRS) $(INCS)
|
||||
@$(COMPILE) -AMKDEPS $(MKDEPS) -o $@ -r o/$(MODE)/ o/$(MODE)/srcs.txt o/$(MODE)/hdrs.txt o/$(MODE)/incs.txt
|
||||
$(COMPILE) -AMKDEPS -L320 $(MKDEPS) -o $@ -r o/$(MODE)/ @o/$(MODE)/srcs.txt @o/$(MODE)/hdrs.txt @o/$(MODE)/incs.txt
|
||||
|
||||
TAGS: o/$(MODE)/srcs.txt $(SRCS)
|
||||
@rm -f $@
|
||||
@$(COMPILE) -ATAGS -T$@ $(TAGS) $(TAGSFLAGS) -L $< -o $@
|
||||
o/$(MODE)/srcs-old.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(SRCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(SRCS),$(file >>$@,$(x)))
|
||||
o/$(MODE)/hdrs-old.txt: o/$(MODE)/.x $(MAKEFILES) $(call uniq,$(foreach x,$(HDRS) $(INCS),$(dir $(x))))
|
||||
$(file >$@) $(foreach x,$(HDRS) $(INCS),$(file >>$@,$(x)))
|
||||
|
||||
HTAGS: o/$(MODE)/hdrs.txt $(HDRS)
|
||||
@rm -f $@
|
||||
@$(COMPILE) -ATAGS -T$@ build/htags -L $< -o $@
|
||||
TAGS: private .UNSANDBOXED = 1
|
||||
TAGS: o/$(MODE)/srcs-old.txt $(SRCS) #o/$(MODE)/third_party/ctags/ctags.com
|
||||
@$(RM) $@
|
||||
@o/$(MODE)/third_party/ctags/ctags.com $(TAGSFLAGS) -L $< -o $@
|
||||
|
||||
HTAGS: private .UNSANDBOXED = 1
|
||||
HTAGS: o/$(MODE)/hdrs-old.txt $(filter-out third_party/libcxx/%,$(HDRS)) #o/$(MODE)/third_party/ctags/ctags.com
|
||||
@$(RM) $@
|
||||
@build/htags o/$(MODE)/third_party/ctags/ctags.com -L $< -o $@
|
||||
|
||||
loc: private .UNSANDBOXED = 1
|
||||
loc: o/$(MODE)/tool/build/summy.com
|
||||
find -name \*.h -or -name \*.c -or -name \*.S | \
|
||||
$(XARGS) wc -l | grep total | awk '{print $$1}' | $<
|
||||
|
||||
COSMOPOLITAN_OBJECTS = \
|
||||
LIBC_DNS \
|
||||
LIBC_SOCK \
|
||||
LIBC_NT_WS2_32 \
|
||||
LIBC_NT_IPHLPAPI \
|
||||
LIBC_NT_MSWSOCK \
|
||||
LIBC_OHMYPLUS \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_GETOPT \
|
||||
LIBC_LOG \
|
||||
LIBC_UNICODE \
|
||||
LIBC_TIME \
|
||||
LIBC_ZIPOS \
|
||||
THIRD_PARTY_ZLIB \
|
||||
THIRD_PARTY_MUSL \
|
||||
LIBC_STDIO \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_REGEX \
|
||||
LIBC_ALG \
|
||||
LIBC_MEM \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
LIBC_BITS \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_ELF \
|
||||
LIBC_CALLS \
|
||||
LIBC_RAND \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_NT_KERNELBASE \
|
||||
LIBC_NT_SHELL32 \
|
||||
LIBC_NT_GDI32 \
|
||||
LIBC_NT_COMDLG32 \
|
||||
LIBC_NT_NETAPI32 \
|
||||
LIBC_NT_URL \
|
||||
LIBC_NT_USER32 \
|
||||
LIBC_NT_NTDLL \
|
||||
LIBC_NT_ADVAPI32 \
|
||||
LIBC_FMT \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_INTRIN \
|
||||
LIBC_NT_KERNEL32 \
|
||||
# PLEASE: MAINTAIN TOPOLOGICAL ORDER
|
||||
# FROM HIGHEST LEVEL TO LOWEST LEVEL
|
||||
COSMOPOLITAN_OBJECTS = \
|
||||
TOOL_ARGS \
|
||||
NET_HTTP \
|
||||
LIBC_DNS \
|
||||
LIBC_SOCK \
|
||||
LIBC_NT_WS2_32 \
|
||||
LIBC_NT_IPHLPAPI \
|
||||
LIBC_X \
|
||||
THIRD_PARTY_GETOPT \
|
||||
LIBC_LOG \
|
||||
LIBC_TIME \
|
||||
THIRD_PARTY_MUSL \
|
||||
THIRD_PARTY_ZLIB_GZ \
|
||||
LIBC_STDIO \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_REGEX \
|
||||
LIBC_THREAD \
|
||||
LIBC_PROC \
|
||||
THIRD_PARTY_NSYNC_MEM \
|
||||
LIBC_MEM \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
LIBC_RUNTIME \
|
||||
THIRD_PARTY_NSYNC \
|
||||
LIBC_ELF \
|
||||
LIBC_CALLS \
|
||||
LIBC_SYSV_CALLS \
|
||||
LIBC_VGA \
|
||||
LIBC_NT_PSAPI \
|
||||
LIBC_NT_POWRPROF \
|
||||
LIBC_NT_PDH \
|
||||
LIBC_NT_GDI32 \
|
||||
LIBC_NT_COMDLG32 \
|
||||
LIBC_NT_USER32 \
|
||||
LIBC_NT_NTDLL \
|
||||
LIBC_NT_ADVAPI32 \
|
||||
LIBC_NT_SYNCHRONIZATION \
|
||||
LIBC_FMT \
|
||||
THIRD_PARTY_ZLIB \
|
||||
THIRD_PARTY_PUFF \
|
||||
THIRD_PARTY_COMPILER_RT \
|
||||
LIBC_TINYMATH \
|
||||
THIRD_PARTY_XED \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_INTRIN \
|
||||
LIBC_NT_KERNEL32 \
|
||||
LIBC_NEXGEN32E
|
||||
|
||||
COSMOPOLITAN_HEADERS = \
|
||||
LIBC \
|
||||
LIBC_ALG \
|
||||
LIBC_BITS \
|
||||
LIBC_CALLS \
|
||||
LIBC_DNS \
|
||||
LIBC_ELF \
|
||||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_LOG \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_NT \
|
||||
LIBC_OHMYPLUS \
|
||||
LIBC_RAND \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_SOCK \
|
||||
LIBC_STDIO \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_TIME \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_UNICODE \
|
||||
LIBC_X \
|
||||
LIBC_ZIPOS \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_MUSL \
|
||||
THIRD_PARTY_ZLIB \
|
||||
COSMOPOLITAN_HEADERS = \
|
||||
APE \
|
||||
LIBC \
|
||||
LIBC_CALLS \
|
||||
LIBC_DNS \
|
||||
LIBC_ELF \
|
||||
LIBC_FMT \
|
||||
LIBC_INTRIN \
|
||||
LIBC_LOG \
|
||||
LIBC_MEM \
|
||||
LIBC_NEXGEN32E \
|
||||
LIBC_NT \
|
||||
LIBC_RUNTIME \
|
||||
LIBC_SOCK \
|
||||
LIBC_STDIO \
|
||||
LIBC_PROC \
|
||||
THIRD_PARTY_NSYNC \
|
||||
THIRD_PARTY_XED \
|
||||
LIBC_STR \
|
||||
LIBC_SYSV \
|
||||
LIBC_THREAD \
|
||||
LIBC_TIME \
|
||||
LIBC_TINYMATH \
|
||||
LIBC_X \
|
||||
LIBC_VGA \
|
||||
NET_HTTP \
|
||||
TOOL_ARGS \
|
||||
THIRD_PARTY_DLMALLOC \
|
||||
THIRD_PARTY_GDTOA \
|
||||
THIRD_PARTY_GETOPT \
|
||||
THIRD_PARTY_MUSL \
|
||||
THIRD_PARTY_REGEX
|
||||
|
||||
o/$(MODE)/cosmopolitan.a.txt:
|
||||
printf "%s\n" $(call reverse,$(call uniq,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)))))
|
||||
o/$(MODE)/cosmopolitan.a: $(filter-out o/libc/stubs/exit11.o,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_A_OBJS)))
|
||||
o/cosmopolitan.h: \
|
||||
o/$(MODE)/tool/build/rollup.com \
|
||||
libc/integral/normalize.inc \
|
||||
$(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS))
|
||||
@$(COMPILE) -AROLLUP -T$@ $^ >$@
|
||||
o/$(MODE)/cosmopolitan.a: \
|
||||
$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_A_OBJS))
|
||||
|
||||
o/cosmopolitan.h: \
|
||||
o/$(MODE)/tool/build/rollup.com \
|
||||
libc/integral/normalize.inc \
|
||||
$(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS)) \
|
||||
$(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_INCS))
|
||||
$(file >$(TMPDIR)/$(subst /,_,$@),libc/integral/normalize.inc $(foreach x,$(COSMOPOLITAN_HEADERS),$($(x)_HDRS)))
|
||||
@$(ECHO) '#ifndef __STRICT_ANSI__' >$@
|
||||
@$(ECHO) '#define _COSMO_SOURCE' >>$@
|
||||
@$(ECHO) '#endif' >>$@
|
||||
@$(COMPILE) -AROLLUP -T$@ o/$(MODE)/tool/build/rollup.com @$(TMPDIR)/$(subst /,_,$@) >>$@
|
||||
|
||||
o/cosmopolitan.html: private .UNSANDBOXED = 1
|
||||
o/cosmopolitan.html: \
|
||||
o/$(MODE)/third_party/chibicc/chibicc.com.dbg \
|
||||
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS)))
|
||||
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS))) \
|
||||
$(SRCS) \
|
||||
$(HDRS)
|
||||
$(file >$(TMPDIR)/$(subst /,_,$@),$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS))))
|
||||
o/$(MODE)/third_party/chibicc/chibicc.com.dbg -J \
|
||||
-fno-common -include libc/integral/normalize.inc -o $@ \
|
||||
$(filter-out %.s,$(foreach x,$(COSMOPOLITAN_OBJECTS),$($(x)_SRCS)))
|
||||
-DCOSMO @$(TMPDIR)/$(subst /,_,$@)
|
||||
|
||||
$(SRCS): \
|
||||
libc/integral/normalize.inc \
|
||||
@@ -344,6 +464,51 @@ $(SRCS): \
|
||||
libc/integral/lp64arg.inc \
|
||||
libc/integral/lp64.inc
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
TOOLCHAIN_ARTIFACTS = \
|
||||
o/cosmopolitan.h \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/libc/crt/crt.o \
|
||||
o/$(MODE)/ape/ape.elf \
|
||||
o/$(MODE)/ape/ape.o \
|
||||
o/$(MODE)/ape/ape-copy-self.o \
|
||||
o/$(MODE)/ape/ape-no-modify-self.o \
|
||||
o/$(MODE)/cosmopolitan.a \
|
||||
o/$(MODE)/third_party/libcxx/libcxx.a \
|
||||
o/$(MODE)/tool/build/march-native.com \
|
||||
o/$(MODE)/tool/build/ar.com \
|
||||
o/$(MODE)/tool/build/mktemper.com \
|
||||
o/$(MODE)/tool/build/fixupobj.com \
|
||||
o/$(MODE)/tool/build/zipcopy.com \
|
||||
o/$(MODE)/tool/build/apelink.com \
|
||||
o/$(MODE)/tool/build/pecheck.com
|
||||
else
|
||||
TOOLCHAIN_ARTIFACTS = \
|
||||
o/$(MODE)/ape/ape.elf \
|
||||
o/$(MODE)/ape/aarch64.lds \
|
||||
o/$(MODE)/libc/crt/crt.o \
|
||||
o/$(MODE)/cosmopolitan.a \
|
||||
o/$(MODE)/third_party/libcxx/libcxx.a \
|
||||
o/$(MODE)/tool/build/march-native.com \
|
||||
o/$(MODE)/tool/build/fixupobj.com \
|
||||
o/$(MODE)/tool/build/zipcopy.com
|
||||
endif
|
||||
|
||||
.PHONY: toolchain
|
||||
toolchain: $(TOOLCHAIN_ARTIFACTS)
|
||||
|
||||
.PHONY: clean_toolchain
|
||||
clean_toolchain:
|
||||
$(RM) $(TOOLCHAIN_ARTIFACTS)
|
||||
|
||||
aarch64: private .INTERNET = true
|
||||
aarch64: private .UNSANDBOXED = true
|
||||
aarch64:
|
||||
$(MAKE) m=aarch64
|
||||
|
||||
clean:
|
||||
$(RM) -r o
|
||||
|
||||
# UNSPECIFIED PREREQUISITES TUTORIAL
|
||||
#
|
||||
# A build rule must exist for all files that make needs to consider in
|
||||
@@ -368,9 +533,9 @@ $(SRCS):
|
||||
$(HDRS):
|
||||
$(INCS):
|
||||
.DEFAULT:
|
||||
@echo >&2
|
||||
@echo NOTE: deleting o/$(MODE)/depend because of an unspecified prerequisite: $@ >&2
|
||||
@echo >&2
|
||||
rm -f o/$(MODE)/depend
|
||||
@$(ECHO)
|
||||
@$(ECHO) NOTE: deleting o/$(MODE)/depend because of an unspecified prerequisite: $@
|
||||
@$(ECHO)
|
||||
$(RM) o/$(MODE)/depend
|
||||
|
||||
-include o/$(MODE)/depend
|
||||
@@ -1,5 +1,6 @@
|
||||

|
||||
|
||||
[](https://github.com/jart/cosmopolitan/actions/workflows/build.yml)
|
||||
# Cosmopolitan
|
||||
|
||||
[Cosmopolitan Libc](https://justine.lol/cosmopolitan/index.html) makes C
|
||||
@@ -18,31 +19,530 @@ libc](https://justine.lol/cosmopolitan/index.html) website. We also have
|
||||
|
||||
## Getting Started
|
||||
|
||||
If you're doing your development work on Linux or BSD then you need just
|
||||
five files to get started. Here's what you do on Linux:
|
||||
It's recommended that Cosmopolitan be installed to `/opt/cosmo` and
|
||||
`/opt/cosmos` on your computer. The first has the monorepo. The second
|
||||
contains your non-monorepo artifacts.
|
||||
|
||||
```sh
|
||||
wget https://justine.lol/cosmopolitan/cosmopolitan-amalgamation-1.0.zip
|
||||
unzip cosmopolitan-amalgamation-1.0.zip
|
||||
sudo mkdir -p /opt
|
||||
sudo chmod 1777 /opt
|
||||
git clone https://github.com/jart/cosmopolitan /opt/cosmo
|
||||
export PATH="/opt/cosmo/bin:/opt/cosmos/bin:$PATH"
|
||||
echo 'PATH="/opt/cosmo/bin:/opt/cosmos/bin:$PATH"' >>~/.profile
|
||||
ape-install # optionally install a faster systemwide ape loader
|
||||
cosmocc --update # pull cosmo and rebuild toolchain
|
||||
```
|
||||
|
||||
You've now successfully installed your very own cosmos. Now let's build
|
||||
an example program:
|
||||
|
||||
```c
|
||||
// hello.c
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
printf("hello world\n");
|
||||
}
|
||||
```
|
||||
|
||||
To compile the program, you can run the `cosmocc` command. It's
|
||||
important to give it an output path that ends with `.com` so the output
|
||||
format will be Actually Portable Executable. When this happens, a
|
||||
concomitant debug binary is created automatically too.
|
||||
|
||||
```sh
|
||||
cosmocc -o hello.com hello.c
|
||||
./hello.com
|
||||
./hello.com.dbg
|
||||
```
|
||||
|
||||
You can use the `cosmocc` toolchain to build conventional open source
|
||||
projects which use autotools. This strategy normally works:
|
||||
|
||||
```sh
|
||||
export CC=cosmocc
|
||||
export CXX=cosmoc++
|
||||
./configure --prefix=/opt/cosmos
|
||||
make -j
|
||||
make install
|
||||
```
|
||||
|
||||
The Cosmopolitan Libc runtime links some heavyweight troubleshooting
|
||||
features by default, which are very useful for developers and admins.
|
||||
Here's how you can log system calls:
|
||||
|
||||
```sh
|
||||
./hello.com --strace
|
||||
```
|
||||
|
||||
Here's how you can get a much more verbose log of function calls:
|
||||
|
||||
```sh
|
||||
./hello.com --ftrace
|
||||
```
|
||||
|
||||
If you don't want rich runtime features like the above included, and you
|
||||
just want libc, and you want smaller simpler programs. In that case, you
|
||||
can consider using `MODE=tiny`, which is preconfigured by the repo in
|
||||
[build/config.mk](build/config.mk). Using this mode is much more
|
||||
effective at reducing binary footprint than the `-Os` flag alone. You
|
||||
can change your build mode by doing the following:
|
||||
|
||||
```sh
|
||||
export MODE=tiny
|
||||
cosmocc --update
|
||||
```
|
||||
|
||||
We can also make our program slightly smaller by using the system call
|
||||
interface directly, which is fine, since Cosmopolitan polyfills these
|
||||
interfaces across platforms, including Windows. For example:
|
||||
|
||||
```c
|
||||
// hello2.c
|
||||
#include <unistd.h>
|
||||
int main() {
|
||||
write(1, "hello world\n", 12);
|
||||
}
|
||||
```
|
||||
|
||||
Once compiled, your APE binary should be ~36kb in size.
|
||||
|
||||
```sh
|
||||
export MODE=tiny
|
||||
cosmocc -Os -o hello2.com hello2.c
|
||||
./hello2.com
|
||||
```
|
||||
|
||||
But let's say you only care about your binaries running on Linux and you
|
||||
don't want to use up all this additional space for platforms like WIN32.
|
||||
In that case, you can try `MODE=tinylinux` for example which will create
|
||||
executables more on the order of 8kb (similar to Musl Libc).
|
||||
|
||||
```sh
|
||||
export MODE=tinylinux
|
||||
cosmocc --update
|
||||
cosmocc -Os -o hello2.com hello2.c
|
||||
./hello2.com # <-- actually an ELF executable
|
||||
```
|
||||
|
||||
## ARM
|
||||
|
||||
Cosmo supports cross-compiling binaries for machines with ARM
|
||||
microprocessors. For example:
|
||||
|
||||
```sh
|
||||
make -j8 m=aarch64 o/aarch64/third_party/ggml/llama.com
|
||||
make -j8 m=aarch64-tiny o/aarch64-tiny/third_party/ggml/llama.com
|
||||
```
|
||||
|
||||
That'll produce ELF executables that run natively on two operating
|
||||
systems: Linux Arm64 (e.g. Raspberry Pi) and MacOS Arm64 (i.e. Apple
|
||||
Silicon), thus giving you full performance. The catch is you have to
|
||||
compile these executables on an x86_64-linux machine. The second catch
|
||||
is that MacOS needs a little bit of help understanding the ELF format.
|
||||
To solve that, we provide a tiny APE loader you can use on M1 machines.
|
||||
|
||||
```sh
|
||||
scp ape/ape-m1.c macintosh:
|
||||
scp o/aarch64/third_party/ggml/llama.com macintosh:
|
||||
ssh macintosh
|
||||
xcode-install
|
||||
cc -o ape ape-m1.c
|
||||
sudo cp ape /usr/local/bin/ape
|
||||
```
|
||||
|
||||
You can run your ELF AARCH64 executable on Apple Silicon as follows:
|
||||
|
||||
```sh
|
||||
ape ./llama.com
|
||||
```
|
||||
|
||||
If you want to run the `MODE=aarch64` unit tests, you need to have
|
||||
qemu-aarch64 installed as a binfmt_misc interpreter. It needs to be a
|
||||
static binary if you want it to work with Landlock Make's security. You
|
||||
can use the build included in our `third_party/qemu/` folder.
|
||||
|
||||
```
|
||||
doas cp o/third_party/qemu/qemu-aarch64 /usr/bin/qemu-aarch64
|
||||
doas sh -c "echo ':qemu-aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:CF' > /proc/sys/fs/binfmt_misc/register"
|
||||
make -j8 m=aarch64
|
||||
```
|
||||
|
||||
Please note that the qemu-aarch64 binfmt_misc interpreter installation
|
||||
process is *essential* for being able to use the `aarch64-unknown-cosmo`
|
||||
toolchain to build fat APE binaries on your x86-64 machine.
|
||||
|
||||
## AMD64 + ARM64 fat APE binaries
|
||||
|
||||
If you've setup the qemu binfmt_misc interpreter, then you can can use
|
||||
cosmo's toolchains to build fat ape binaries. It works by compiling your
|
||||
program twice, so you can have a native build for both architectures in
|
||||
the same file. The two programs are merged together by apelink.com which
|
||||
also embeds multiple copies of APE loader and multiple symbols tables.
|
||||
|
||||
The easiest way to build fat APE is using `fatcosmocc`. This compiler
|
||||
works by creating a concomitant `.aarch64/foo.o` for every `foo.o` you
|
||||
compile. The only exception is the C preprocessor mode, which actually
|
||||
runs x86-64 GCC except with macros like `__x86_64__` undefined.
|
||||
|
||||
This toolchain works great for C projects that are written in a portable
|
||||
way and don't produce architecture-specific artifacts. One example of a
|
||||
large project that can be easily built is GNU coreutils.
|
||||
|
||||
```sh
|
||||
cd coreutils
|
||||
fatcosmocc --update ||exit
|
||||
./configure CC=fatcosmocc \
|
||||
AR=fatcosmoar \
|
||||
INSTALL=$(command -v fatcosmoinstall) \
|
||||
--prefix=/opt/cosmos \
|
||||
--disable-nls \
|
||||
--disable-dependency-tracking \
|
||||
--disable-silent-rules
|
||||
make -j8
|
||||
```
|
||||
|
||||
You'll then have a bunch of files like `src/ls` which are fat ape
|
||||
binaries. If you want to run them on Windows, then you simply need to
|
||||
rename the file so that it has the `.com` suffix. Better yet, consider
|
||||
making that a symlink (a.k.a. reparse point). The biggest gotcha with
|
||||
`fatcosmocc` though is ensuring builds don't strip binaries. For
|
||||
example, Linux's `install -s` command actually understands Windows'
|
||||
Portable Executable format well enough to remove the MS-DOS stub, which
|
||||
is where the APE shell script is stored. You need to ensure that
|
||||
`fatcosmoinstall` is used instead. Especially if your project needs to
|
||||
install the libraries built by `fatacosmoar` into `/opt/cosmos`.
|
||||
|
||||
## Advanced Fat APE Builds
|
||||
|
||||
Once you get seriously involved in creating fat APE builds of software
|
||||
you're going to eventually outgrow `fatcosmocc`. One example is Emacs
|
||||
which is trickier to build, because it produces architecture-specific
|
||||
files, and it also depends on shared files, e.g. zoneinfo. Since we like
|
||||
having everything in a neat little single-file executable container that
|
||||
doesn't need an "installation wizard", this tutorial will explain how we
|
||||
manage to accomplish that.
|
||||
|
||||
What you're going to do is, instead of using `fatcosmocc`, you're going
|
||||
to use both the `x86_64-unknown-cosmo-cc` and `aarch64-unknown-cosmo-cc`
|
||||
toolchains independently, and then run `apelink` and `zip` to manually
|
||||
build the final files. But there's a few tricks to learn first.
|
||||
|
||||
The first trick is to create a symlink on your system called `/zip`.
|
||||
Cosmopolitan Libc normally uses that as a synthetic folder that lets you
|
||||
access the assets in your zip executable. But since that's a read-only
|
||||
file system, your build system should use the normal one.
|
||||
|
||||
```sh
|
||||
doas ln -sf /opt/cosmos /zip
|
||||
```
|
||||
|
||||
Now create a file named `rebuild-fat.sh` which runs the build twice:
|
||||
|
||||
```sh
|
||||
#!/bin/sh
|
||||
set -ex
|
||||
export MODE=aarch64
|
||||
export COSMOS=/opt/cosmos/aarch64
|
||||
rebuild-cosmos.sh aarch64
|
||||
export MODE=
|
||||
export COSMOS=/opt/cosmos/x86_64
|
||||
rebuild-cosmos.sh x86_64
|
||||
wall.com 'finished building'
|
||||
```
|
||||
|
||||
Then create a second file `rebuild-cosmos.sh` which runs your build:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
set -ex
|
||||
|
||||
ARCH=${1:-x86_64}
|
||||
export COSMO=${COSMO:-/opt/cosmo}
|
||||
export COSMOS=${COSMOS:-/opt/cosmos/$ARCH}
|
||||
export AS=$(command -v $ARCH-unknown-cosmo-as) || exit
|
||||
export CC=$(command -v $ARCH-unknown-cosmo-cc) || exit
|
||||
export CXX=$(command -v $ARCH-unknown-cosmo-c++) || exit
|
||||
export AR=$(command -v $ARCH-unknown-cosmo-ar) || exit
|
||||
export STRIP=$(command -v $ARCH-unknown-cosmo-strip) || exit
|
||||
export INSTALL=$(command -v $ARCH-unknown-cosmo-install) || exit
|
||||
export OBJCOPY=$(command -v $ARCH-unknown-cosmo-objcopy) || exit
|
||||
export OBJDUMP=$(command -v $ARCH-unknown-cosmo-objdump) || exit
|
||||
export ADDR2LINE=$(command -v $ARCH-unknown-cosmo-addr2line) || exit
|
||||
|
||||
$CC --update
|
||||
|
||||
export COSMOPOLITAN_DISABLE_ZIPOS=1
|
||||
|
||||
cd ~/vendor/zlib
|
||||
./configure --prefix=$COSMOS --static
|
||||
make clean
|
||||
make -j
|
||||
make install
|
||||
|
||||
cd ~/vendor/ncurses-6.4
|
||||
./configure --prefix=$COSMOS --sysconfdir=/zip --datarootdir=/zip/share --exec-prefix=/zip/$ARCH --disable-shared
|
||||
make clean
|
||||
make -j
|
||||
make install
|
||||
|
||||
cd ~/vendor/readline-8.2
|
||||
./configure --prefix=$COSMOS --sysconfdir=/zip --datarootdir=/zip/share --exec-prefix=/zip/$ARCH --disable-shared
|
||||
make uninstall || true
|
||||
make clean
|
||||
make -j
|
||||
make install
|
||||
|
||||
# NOTES:
|
||||
# 1. You'll need to patch enum { FOO = x } that fails to build into a #define FOO
|
||||
# 2. You'll need to patch configure.ac so it DOES NOT define USABLE_FIONREAD to 1
|
||||
# 2. You'll need to patch configure.ac so it DOES NOT define INTERRUPT_INPUT to 1
|
||||
cd ~/vendor/emacs-28.2
|
||||
./configure --prefix=$COSMOS --sysconfdir=/zip --datarootdir=/zip/share --exec-prefix=/zip/$ARCH \
|
||||
--without-x --with-threads --without-gnutls --disable-silent-rules --with-file-notification=no
|
||||
make uninstall || true
|
||||
make clean
|
||||
make -j
|
||||
make install
|
||||
```
|
||||
|
||||
Once you've completed this build process, you'll have the ELF files
|
||||
`/opt/cosmos/x86_64/bin/emacs` and `/opt/cosmos/aarch64/bin/emacs`. Your
|
||||
next move is to combine them into a single pristine `emacs.com` file.
|
||||
|
||||
```sh
|
||||
cd /zip
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
mkdir -p /opt/cosmos/bin
|
||||
apelink \
|
||||
-o /opt/cosmos/bin/emacs.com \
|
||||
-l "$COSMO/o//ape/ape.elf" \
|
||||
-l "$COSMO/o/aarch64/ape/ape.elf" \
|
||||
-M "$COSMO/ape/ape-m1.c" \
|
||||
/opt/cosmos/x86_64/bin/emacs \
|
||||
/opt/cosmos/aarch64/bin/emacs
|
||||
cd /zip
|
||||
zip -r /opt/cosmos/bin/emacs.com \
|
||||
aarch64/libexec \
|
||||
x86_64/libexec \
|
||||
share/terminfo \
|
||||
$(find share/emacs -type f |
|
||||
grep -v '\.el.gz$' |
|
||||
grep -v refcards |
|
||||
grep -v images)
|
||||
```
|
||||
|
||||
You can now scp your `emacs.com` build to seven operating systems for
|
||||
two distinct kinds of microprocessors without any dependencies. All the
|
||||
LISP, zoneinfo, and termcap files it needs are stored inside the ZIP
|
||||
structure of the binary, which has performance that's equivalent to the
|
||||
Linux filesystem (even though it decompresses artifacts on the fly!) For
|
||||
this reason, you might actually find that fat APE Emacs goes faster if
|
||||
you're using an operating system like Windows where files are go slow.
|
||||
|
||||
If you like to use Vim instead of Emacs, then you can build that too.
|
||||
However Vim's build system makes it a bit harder, since it's configured
|
||||
to always strip binaries. The `apelink` program needs the symbol tables
|
||||
to still be there when it creates the fat version. Otherwise tools like
|
||||
`--ftrace` won't work.
|
||||
|
||||
## Monolithic Source Builds
|
||||
|
||||
Cosmopolitan can be compiled from source on any Linux distro. First, you
|
||||
need to download or clone the repository.
|
||||
|
||||
```sh
|
||||
wget https://justine.lol/cosmopolitan/cosmopolitan.tar.gz
|
||||
tar xf cosmopolitan.tar.gz # see releases page
|
||||
cd cosmopolitan
|
||||
```
|
||||
|
||||
This will build the entire repository and run all the tests:
|
||||
|
||||
```sh
|
||||
build/bootstrap/make.com
|
||||
o//examples/hello.com
|
||||
find o -name \*.com | xargs ls -rShal | less
|
||||
```
|
||||
|
||||
If you get an error running make.com then it's probably because you have
|
||||
WINE installed to `binfmt_misc`. You can fix that by installing the the
|
||||
APE loader as an interpreter. It'll improve build performance too!
|
||||
|
||||
```sh
|
||||
bin/ape-install
|
||||
```
|
||||
|
||||
Since the Cosmopolitan repository is very large, you might only want to
|
||||
build a particular thing. Cosmopolitan's build config does a good job at
|
||||
having minimal deterministic builds. For example, if you wanted to build
|
||||
only hello.com then you could do that as follows:
|
||||
|
||||
```sh
|
||||
build/bootstrap/make.com o//examples/hello.com
|
||||
```
|
||||
|
||||
Sometimes it's desirable to build a subset of targets, without having to
|
||||
list out each individual one. You can do that by asking make to build a
|
||||
directory name. For example, if you wanted to build only the targets and
|
||||
subtargets of the chibicc package including its tests, you would say:
|
||||
|
||||
```sh
|
||||
build/bootstrap/make.com o//third_party/chibicc
|
||||
o//third_party/chibicc/chibicc.com --help
|
||||
```
|
||||
|
||||
Cosmopolitan provides a variety of build modes. For example, if you want
|
||||
really tiny binaries (as small as 12kb in size) then you'd say:
|
||||
|
||||
```sh
|
||||
build/bootstrap/make.com m=tiny
|
||||
```
|
||||
|
||||
Here's some other build modes you can try:
|
||||
|
||||
```sh
|
||||
build/bootstrap/make.com m=dbg # asan + ubsan + debug
|
||||
build/bootstrap/make.com m=asan # production memory safety
|
||||
build/bootstrap/make.com m=opt # -march=native optimizations
|
||||
build/bootstrap/make.com m=rel # traditional release binaries
|
||||
build/bootstrap/make.com m=optlinux # optimal linux-only performance
|
||||
build/bootstrap/make.com m=fastbuild # build 28% faster w/o debugging
|
||||
build/bootstrap/make.com m=tinylinux # tiniest linux-only 4kb binaries
|
||||
```
|
||||
|
||||
For further details, see [//build/config.mk](build/config.mk).
|
||||
|
||||
## Cosmopolitan Amalgamation
|
||||
|
||||
Another way to use Cosmopolitan is via our amalgamated release, where
|
||||
we've combined everything into a single static archive and a single
|
||||
header file. If you're doing your development work on Linux or BSD then
|
||||
you need just five files to get started. Here's what you do on Linux:
|
||||
|
||||
```sh
|
||||
wget https://justine.lol/cosmopolitan/cosmopolitan-amalgamation-3.0.zip
|
||||
unzip cosmopolitan-amalgamation-3.0.zip
|
||||
printf 'main() { printf("hello world\\n"); }\n' >hello.c
|
||||
gcc -g -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \
|
||||
-fno-omit-frame-pointer -pg -mnop-mcount \
|
||||
-o hello.com.dbg hello.c -fuse-ld=bfd -Wl,-T,ape.lds \
|
||||
-include cosmopolitan.h crt.o ape.o cosmopolitan.a
|
||||
-fno-omit-frame-pointer -pg -mnop-mcount -mno-tls-direct-seg-refs -gdwarf-4 \
|
||||
-o hello.com.dbg hello.c -fuse-ld=bfd -Wl,-T,ape.lds -Wl,--gc-sections \
|
||||
-Wl,-z,common-page-size=0x1000 -Wl,-z,max-page-size=0x1000 \
|
||||
-include cosmopolitan.h crt.o ape-no-modify-self.o cosmopolitan.a
|
||||
objcopy -S -O binary hello.com.dbg hello.com
|
||||
```
|
||||
|
||||
You now have a portable program. Please note that your APE binary will
|
||||
assimilate itself as a conventional resident of your platform after the
|
||||
first run, so it can be fast and efficient for subsequent executions.
|
||||
You now have a portable program.
|
||||
|
||||
```sh
|
||||
./hello.com
|
||||
bash -c './hello.com' # zsh/fish workaround (we upstreamed patches)
|
||||
bash -c './hello.com' # older zsh/fish workaround (patched in zsh 5.9 and fish 3.3.0)
|
||||
```
|
||||
|
||||
So if you intend to copy the binary to Windows or Mac then please do
|
||||
that before you run it, not after.
|
||||
If `./hello.com` executed on Linux throws an error about not finding an
|
||||
interpreter, it should be fixed by running the following command (although
|
||||
note that it may not survive a system restart):
|
||||
|
||||
```sh
|
||||
sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"
|
||||
```
|
||||
|
||||
If the same command produces puzzling errors on WSL or WINE when using
|
||||
Redbean 2.x, they may be fixed by disabling binfmt_misc:
|
||||
|
||||
```sh
|
||||
sudo sh -c 'echo -1 >/proc/sys/fs/binfmt_misc/status'
|
||||
```
|
||||
|
||||
Since we used the `ape-no-modify-self.o` bootloader (rather than
|
||||
`ape.o`) your executable will not modify itself when it's run. What
|
||||
it'll instead do, is extract a 4kb program (the [APE loader](https://justine.lol/apeloader/))
|
||||
to `${TMPDIR:-${HOME:-.}}` that maps your program into memory without
|
||||
needing to copy it. The APE loader must be in an executable location
|
||||
(e.g. not stored on a `noexec` mount) for it to run. See below for
|
||||
alternatives:
|
||||
|
||||
It's possible to install the APE loader systemwide as follows.
|
||||
|
||||
```sh
|
||||
# System-Wide APE Install
|
||||
# for Linux, Darwin, and BSDs
|
||||
# 1. Copies APE Loader to /usr/bin/ape
|
||||
# 2. Registers w/ binfmt_misc too if Linux
|
||||
bin/ape-install
|
||||
|
||||
# System-Wide APE Uninstall
|
||||
# for Linux, Darwin, and BSDs
|
||||
bin/ape-uninstall
|
||||
```
|
||||
|
||||
It's also possible to convert APE binaries into the system-local format
|
||||
by using the `--assimilate` flag. Please note that if binfmt_misc is in
|
||||
play, you'll need to unregister it temporarily before doing this, since
|
||||
the assimilate feature is part of the shell script header.
|
||||
|
||||
```sh
|
||||
$ file hello.com
|
||||
hello.com: DOS/MBR boot sector
|
||||
./hello.com --assimilate
|
||||
$ file hello.com
|
||||
hello.com: ELF 64-bit LSB executable
|
||||
```
|
||||
|
||||
Now that you're up and running with Cosmopolitan Libc and APE, here's
|
||||
some of the most important troubleshooting tools APE offers that you
|
||||
should know, in case you encounter any issues:
|
||||
|
||||
```sh
|
||||
./hello.com --strace # log system calls to stderr
|
||||
./hello.com --ftrace # log function calls to stderr
|
||||
```
|
||||
|
||||
Do you love tiny binaries? If so, you may not be happy with Cosmo adding
|
||||
heavyweight features like tracing to your binaries by default. In that
|
||||
case, you may want to consider using our build system:
|
||||
|
||||
```sh
|
||||
make m=tiny
|
||||
```
|
||||
|
||||
Which will cause programs such as `hello.com` and `life.com` to shrink
|
||||
from 60kb in size to about 16kb. There's also a prebuilt amalgamation
|
||||
online <https://justine.lol/cosmopolitan/cosmopolitan-tiny.zip> hosted
|
||||
on our download page <https://justine.lol/cosmopolitan/download.html>.
|
||||
|
||||
## GDB
|
||||
|
||||
Here's the recommended `~/.gdbinit` config:
|
||||
|
||||
```gdb
|
||||
set host-charset UTF-8
|
||||
set target-charset UTF-8
|
||||
set target-wide-charset UTF-8
|
||||
set osabi none
|
||||
set complaints 0
|
||||
set confirm off
|
||||
set history save on
|
||||
set history filename ~/.gdb_history
|
||||
define asm
|
||||
layout asm
|
||||
layout reg
|
||||
end
|
||||
define src
|
||||
layout src
|
||||
layout reg
|
||||
end
|
||||
src
|
||||
```
|
||||
|
||||
You normally run the `.com.dbg` file under gdb. If you need to debug the
|
||||
`.com` file itself, then you can load the debug symbols independently as
|
||||
|
||||
```sh
|
||||
gdb foo.com -ex 'add-symbol-file foo.com.dbg 0x401000'
|
||||
```
|
||||
|
||||
## Alternative Development Environments
|
||||
|
||||
### MacOS
|
||||
|
||||
@@ -64,32 +564,51 @@ Windows](https://justine.lol/cosmopolitan/windows-compiling.html)
|
||||
tutorial. It's needed because the ELF object format is what makes
|
||||
universal binaries possible.
|
||||
|
||||
## Source Builds
|
||||
|
||||
Cosmopolitan can be compiled from source on any Linux distro. GNU make
|
||||
needs to be installed beforehand. This is a freestanding hermetic
|
||||
repository that bootstraps using a vendored static gcc9 executable.
|
||||
No further dependencies are required.
|
||||
Cosmopolitan officially only builds on Linux. However, one highly
|
||||
experimental (and currently broken) thing you could try, is building the
|
||||
entire cosmo repository from source using the cross9 toolchain.
|
||||
|
||||
```sh
|
||||
wget https://justine.lol/cosmopolitan/cosmopolitan-1.0.tar.gz
|
||||
tar xf cosmopolitan-1.0.tar.gz # see releases page
|
||||
cd cosmopolitan
|
||||
make -j16
|
||||
o//examples/hello.com
|
||||
find o -name \*.com | xargs ls -rShal | less
|
||||
mkdir -p o/third_party
|
||||
rm -rf o/third_party/gcc
|
||||
wget https://justine.lol/linux-compiler-on-windows/cross9.zip
|
||||
unzip cross9.zip
|
||||
mv cross9 o/third_party/gcc
|
||||
build/bootstrap/make.com
|
||||
```
|
||||
|
||||
## Discord Chatroom
|
||||
|
||||
The Cosmopolitan development team collaborates on the Redbean Discord
|
||||
server. You're welcome to join us! <https://discord.gg/FwAVVu7eJ4>
|
||||
|
||||
## Support Vector
|
||||
|
||||
| Platform | Min Version | Circa |
|
||||
| :--- | ---: | ---: |
|
||||
| AMD | K8 Venus | 2005 |
|
||||
| Intel | Core | 2006 |
|
||||
| New Technology | Vista | 2006 |
|
||||
| GNU/Systemd | 2.6.18 | 2007 |
|
||||
| XNU's Not UNIX! | 15.6 | 2018 |
|
||||
| FreeBSD | 12 | 2018 |
|
||||
| OpenBSD | 6.4 | 2018 |
|
||||
| NetBSD | 9.1 | 2020 |
|
||||
| GNU Make | 3.80 | 2010 |
|
||||
| Linux | 2.6.18 | 2007 |
|
||||
| Windows | 8 [1] | 2012 |
|
||||
| Mac OS X | 15.6 | 2018 |
|
||||
| OpenBSD | 7 | 2021 |
|
||||
| FreeBSD | 13 | 2020 |
|
||||
| NetBSD | 9.2 | 2021 |
|
||||
|
||||
[1] See our [vista branch](https://github.com/jart/cosmopolitan/tree/vista)
|
||||
for a community supported version of Cosmopolitan that works on Windows
|
||||
Vista and Windows 7.
|
||||
|
||||
## Special Thanks
|
||||
|
||||
Funding for this project is crowdsourced using
|
||||
[GitHub Sponsors](https://github.com/sponsors/jart) and
|
||||
[Patreon](https://www.patreon.com/jart). Your support is what makes this
|
||||
project possible. Thank you! We'd also like to give special thanks to
|
||||
the following groups and individuals:
|
||||
|
||||
- [Joe Drumgoole](https://github.com/jdrumgoole)
|
||||
- [Rob Figueiredo](https://github.com/robfig)
|
||||
- [Wasmer](https://wasmer.io/)
|
||||
|
||||
For publicly sponsoring our work at the highest tier.
|
||||
+294
@@ -0,0 +1,294 @@
|
||||
/*-*- mode: ld-script; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-│
|
||||
│vi: set et sts=2 tw=2 fenc=utf-8 :vi│
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/thread/tls.h"
|
||||
|
||||
ENTRY(_start)
|
||||
OUTPUT_ARCH(aarch64)
|
||||
OUTPUT_FORMAT("elf64-littleaarch64",
|
||||
"elf64-bigaarch64",
|
||||
"elf64-littleaarch64")
|
||||
|
||||
SECTIONS {
|
||||
|
||||
. = SEGMENT_START("text-segment", 0x010000000000);
|
||||
__executable_start = .;
|
||||
. += SIZEOF_HEADERS;
|
||||
|
||||
.interp : { *(.interp) }
|
||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||
.hash : { *(.hash) }
|
||||
.gnu.hash : { *(.gnu.hash) }
|
||||
.dynsym : { *(.dynsym) }
|
||||
.dynstr : { *(.dynstr) }
|
||||
.gnu.version : { *(.gnu.version) }
|
||||
.gnu.version_d : { *(.gnu.version_d) }
|
||||
.gnu.version_r : { *(.gnu.version_r) }
|
||||
.rela.init : { *(.rela.init) }
|
||||
.rela.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
|
||||
.rela.fini : { *(.rela.fini) }
|
||||
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
|
||||
.rela.data.rel.ro : { *(.rela.data.rel.ro .rela.data.rel.ro.* .rela.gnu.linkonce.d.rel.ro.*) }
|
||||
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
|
||||
.rela.tdata : { *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*) }
|
||||
.rela.tbss : { *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*) }
|
||||
.rela.ctors : { *(.rela.ctors) }
|
||||
.rela.dtors : { *(.rela.dtors) }
|
||||
.rela.got : { *(.rela.got) }
|
||||
.rela.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
|
||||
.rela.ifunc : { *(.rela.ifunc) }
|
||||
|
||||
.rela.plt : {
|
||||
*(.rela.plt)
|
||||
__rela_iplt_start = .;
|
||||
*(.rela.iplt)
|
||||
__rela_iplt_end = .;
|
||||
}
|
||||
|
||||
.init : {
|
||||
*(.start)
|
||||
KEEP(*(.initprologue))
|
||||
KEEP(*(SORT_NONE(.init)))
|
||||
KEEP(*(.initepilogue))
|
||||
} =0x1f2003d5
|
||||
|
||||
.plt : ALIGN(16) {
|
||||
*(.plt)
|
||||
*(.iplt)
|
||||
}
|
||||
|
||||
.text : {
|
||||
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
|
||||
*(.text.antiquity .text.antiquity.*)
|
||||
*(.text.exit .text.exit.*)
|
||||
*(.text.startup .text.startup.*)
|
||||
*(.text.hot .text.hot.*)
|
||||
*(.text.modernity .text.modernity.*)
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
*(.gnu.warning)
|
||||
} =0x1f2003d5
|
||||
|
||||
.fini : {
|
||||
KEEP(*(SORT_NONE(.fini)))
|
||||
} =0x1f2003d5
|
||||
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
|
||||
.privileged : {
|
||||
__privileged_start = ABSOLUTE(.) & -CONSTANT(MAXPAGESIZE);
|
||||
*(.privileged*)
|
||||
} =0x1f2003d6
|
||||
|
||||
.rodata : {
|
||||
KEEP(*(.rodata.pytab.0));
|
||||
KEEP(*(.rodata.pytab.1));
|
||||
KEEP(*(.rodata.pytab.2));
|
||||
KEEP(*(SORT_BY_NAME(.sort.rodata.*)))
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
*(.ubsan.types)
|
||||
*(.ubsan.data)
|
||||
}
|
||||
|
||||
.comment : {
|
||||
__comment_start = .;
|
||||
KEEP(*(.comment))
|
||||
BYTE(0);
|
||||
}
|
||||
|
||||
.eh_frame_hdr : {
|
||||
*(.eh_frame_hdr)
|
||||
*(.eh_frame_entry .eh_frame_entry.*)
|
||||
}
|
||||
|
||||
.eh_frame : ONLY_IF_RO {
|
||||
KEEP(*(.eh_frame))
|
||||
*(.eh_frame.*)
|
||||
}
|
||||
|
||||
.gcc_except_table : ONLY_IF_RO {
|
||||
*(.gcc_except_table .gcc_except_table.*)
|
||||
}
|
||||
|
||||
.gnu_extab : ONLY_IF_RO {
|
||||
*(.gnu_extab*)
|
||||
}
|
||||
|
||||
.exception_ranges : ONLY_IF_RO {
|
||||
*(.exception_ranges*)
|
||||
}
|
||||
|
||||
__etext = .;
|
||||
_etext = .;
|
||||
PROVIDE(etext = .);
|
||||
|
||||
. += CONSTANT(MAXPAGESIZE);
|
||||
. = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE));
|
||||
|
||||
.eh_frame : ONLY_IF_RW {
|
||||
KEEP(*(.eh_frame))
|
||||
*(.eh_frame.*)
|
||||
}
|
||||
|
||||
.gnu_extab : ONLY_IF_RW {
|
||||
*(.gnu_extab)
|
||||
}
|
||||
|
||||
.gcc_except_table : ONLY_IF_RW {
|
||||
*(.gcc_except_table .gcc_except_table.*)
|
||||
}
|
||||
|
||||
.exception_ranges : ONLY_IF_RW {
|
||||
*(.exception_ranges*)
|
||||
}
|
||||
|
||||
.tdata : {
|
||||
_tdata_start = .;
|
||||
__tdata_start = .;
|
||||
*(.tdata .tdata.* .gnu.linkonce.td.*)
|
||||
_tdata_end = .;
|
||||
}
|
||||
|
||||
.tbss : {
|
||||
_tbss_start = .;
|
||||
*(.tbss .tbss.* .gnu.linkonce.tb.*)
|
||||
*(.tcommon)
|
||||
_tbss_end = .;
|
||||
}
|
||||
|
||||
.init_array : {
|
||||
__init_array_start = .;
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
|
||||
__init_array_end = .;
|
||||
}
|
||||
|
||||
.fini_array : {
|
||||
__fini_array_start = .;
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP(*(.fini_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
|
||||
__fini_array_end = .;
|
||||
}
|
||||
|
||||
.data.rel.ro : {
|
||||
KEEP(*(SORT_BY_NAME(.piro.relo.sort.*)))
|
||||
*(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*)
|
||||
*(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*)
|
||||
}
|
||||
|
||||
.dynamic : {
|
||||
*(.dynamic)
|
||||
}
|
||||
|
||||
.got : {
|
||||
*(.got)
|
||||
*(.igot)
|
||||
}
|
||||
|
||||
. = DATA_SEGMENT_RELRO_END(24, .);
|
||||
|
||||
.got.plt : {
|
||||
*(.got.plt)
|
||||
*(.igot.plt)
|
||||
}
|
||||
|
||||
.data : {
|
||||
__data_start = .;
|
||||
KEEP(*(SORT_BY_NAME(.piro.data.sort.*)))
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
KEEP(*(SORT_BY_NAME(.sort.data.*)))
|
||||
SORT(CONSTRUCTORS)
|
||||
}
|
||||
|
||||
_edata = .;
|
||||
PROVIDE(edata = .);
|
||||
|
||||
. = .;
|
||||
__bss_start = .;
|
||||
__bss_start__ = .;
|
||||
|
||||
.bss : {
|
||||
*(.dynbss)
|
||||
*(.bss .bss.* .gnu.linkonce.b.*)
|
||||
KEEP(*(SORT_BY_NAME(.piro.bss.sort.*)))
|
||||
*(COMMON)
|
||||
. = ALIGN(CONSTANT(COMMONPAGESIZE));
|
||||
}
|
||||
|
||||
_bss_end__ = .;
|
||||
__bss_end__ = .;
|
||||
. = ALIGN(64 / 8);
|
||||
. = SEGMENT_START("ldata-segment", .);
|
||||
. = ALIGN(64 / 8);
|
||||
__end__ = .;
|
||||
_end = .;
|
||||
PROVIDE(end = .);
|
||||
|
||||
. = DATA_SEGMENT_END(.);
|
||||
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
.debug_addr 0 : { *(.debug_addr) }
|
||||
.ARM.attributes 0 : { KEEP(*(.ARM.attributes)) KEEP(*(.gnu.attributes)) }
|
||||
.note.gnu.arm.ident 0 : { KEEP(*(.note.gnu.arm.ident)) }
|
||||
|
||||
.zip 0 : {
|
||||
KEEP(*(.zip.file))
|
||||
__zip_cdir_start = .;
|
||||
KEEP(*(.zip.cdir))
|
||||
__zip_cdir_size = . - __zip_cdir_start;
|
||||
KEEP(*(.zip.eocd))
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
*(__patchable_function_entries)
|
||||
*(.GCC.command.line)
|
||||
*(.note.GNU-stack)
|
||||
*(.gnu_debuglink)
|
||||
*(.text.windows)
|
||||
*(.gnu.lto_*)
|
||||
*(.eh_frame)
|
||||
*(.idata.*)
|
||||
*(.yoink)
|
||||
*(.head)
|
||||
}
|
||||
}
|
||||
|
||||
ape_stack_vaddr = DEFINED(ape_stack_vaddr) ? ape_stack_vaddr : 0x700000000000;
|
||||
ape_stack_memsz = DEFINED(ape_stack_memsz) ? ape_stack_memsz : 8 * 1024 * 1024;
|
||||
ape_stack_align = DEFINED(ape_stack_align) ? ape_stack_align : 16;
|
||||
ape_stack_round = -ape_stack_align;
|
||||
|
||||
_tls_size = _tbss_end - _tdata_start;
|
||||
_tdata_size = _tdata_end - _tdata_start;
|
||||
_tbss_size = _tbss_end - _tbss_start;
|
||||
_tbss_offset = _tbss_start - _tdata_start;
|
||||
_tls_content = (_tdata_end - _tdata_start) + (_tbss_end - _tbss_start);
|
||||
_tls_align = MAX(ALIGNOF(.tdata), ALIGNOF(.tbss));
|
||||
|
||||
ASSERT(ALIGNOF(.tdata) <= TLS_ALIGNMENT && ALIGNOF(.tbss) <= TLS_ALIGNMENT,
|
||||
"_Thread_local _Alignof can't exceed TLS_ALIGNMENT");
|
||||
+1063
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,13 @@
|
||||
#ifndef COSMOPOLITAN_APE_APE_H_
|
||||
#define COSMOPOLITAN_APE_APE_H_
|
||||
|
||||
#define APE_VERSION_MAJOR 1
|
||||
#define APE_VERSION_MINOR 8
|
||||
#define APE_VERSION_STR APE_VERSION_STR_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
|
||||
#define APE_VERSION_NOTE APE_VERSION_NOTE_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
|
||||
|
||||
#define APE_VERSION_STR__(x, y) #x "." #y
|
||||
#define APE_VERSION_STR_(x, y) APE_VERSION_STR__(x, y)
|
||||
#define APE_VERSION_NOTE_(x, y) (100000000 * (x) + 1000000 * (y))
|
||||
|
||||
#endif /* COSMOPOLITAN_APE_APE_H_ */
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef COSMOPOLITAN_APE_APE_INTERNAL_H_
|
||||
#define COSMOPOLITAN_APE_APE_INTERNAL_H_
|
||||
#include "libc/dce.h"
|
||||
|
||||
#if SupportsWindows() || SupportsMetal() || SupportsXnu()
|
||||
#define APE_IS_SHELL_SCRIPT
|
||||
#endif
|
||||
|
||||
#endif /* COSMOPOLITAN_APE_APE_INTERNAL_H_ */
|
||||
+306
-186
@@ -177,16 +177,44 @@
|
||||
#include "ape/macros.internal.h"
|
||||
#include "ape/relocations.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/elf/def.h"
|
||||
#include "libc/elf/pf2prot.internal.h"
|
||||
#include "libc/nt/pedef.internal.h"
|
||||
#include "libc/zip.h"
|
||||
#include "libc/thread/tls.h"
|
||||
#include "ape/ape.internal.h"
|
||||
|
||||
/* uncomment if .com.dbg won't execute on your kernel (will break .com file) */
|
||||
/* #define APE_FIX_COM_DBG */
|
||||
|
||||
#ifdef __x86__
|
||||
#define CODE_GRANULE 1
|
||||
#else
|
||||
#define CODE_GRANULE 4
|
||||
#endif
|
||||
|
||||
#ifdef APE_FIX_COM_DBG
|
||||
#define SKEW SIZEOF_HEADERS
|
||||
#else
|
||||
#define SKEW 0
|
||||
#endif
|
||||
|
||||
#ifndef IMAGE_BASE_VIRTUAL
|
||||
#define IMAGE_BASE_VIRTUAL 0x400000
|
||||
#endif
|
||||
|
||||
#if IMAGE_BASE_VIRTUAL > 0xffffffff
|
||||
#error "please use 32-bit addresses for image data"
|
||||
#endif
|
||||
|
||||
ENTRY(_start)
|
||||
|
||||
PHDRS {
|
||||
Head PT_LOAD FLAGS(5);
|
||||
Rom PT_LOAD FLAGS(5);
|
||||
Ram PT_LOAD FLAGS(6);
|
||||
stack PT_GNU_STACK FLAGS(6);
|
||||
Head PT_LOAD FLAGS(PF_X|PF_R);
|
||||
Cod PT_LOAD FLAGS(PF_X|PF_R);
|
||||
Rom PT_LOAD FLAGS(PF_R);
|
||||
Tls PT_TLS FLAGS(PF_W|PF_R);
|
||||
Ram PT_LOAD FLAGS(PF_W|PF_R);
|
||||
stack PT_GNU_STACK FLAGS(PF_W|PF_R);
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
@@ -196,54 +224,62 @@ SECTIONS {
|
||||
/*BEGIN: linux addressability guarantee */
|
||||
/*BEGIN: bsd addressability guarantee */
|
||||
|
||||
.head SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL) : AT(IMAGE_BASE_REAL) {
|
||||
HIDDEN(_base = .);
|
||||
.head SEGMENT_START("text-segment", IMAGE_BASE_VIRTUAL) + SKEW : AT(IMAGE_BASE_REAL) {
|
||||
__executable_start = .;
|
||||
|
||||
/* Real Mode */
|
||||
KEEP(*(.head))
|
||||
KEEP(*(.apesh))
|
||||
KEEP(*(.head2))
|
||||
KEEP(*(.text.head))
|
||||
|
||||
/* Executable & Linkable Format */
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
HIDDEN(ape_phdrs = .);
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
ape_phdrs = .;
|
||||
KEEP(*(.elf.phdrs))
|
||||
HIDDEN(ape_phdrs_end = .);
|
||||
ape_phdrs_end = .;
|
||||
|
||||
KEEP(*(.emushprologue))
|
||||
KEEP(*(.emush))
|
||||
KEEP(*(.emushepilogue))
|
||||
|
||||
/* OpenBSD */
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
HIDDEN(ape_note = .);
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
ape_note = .;
|
||||
KEEP(*(.note.openbsd.ident))
|
||||
KEEP(*(.note.netbsd.ident))
|
||||
HIDDEN(ape_note_end = .);
|
||||
ape_note_end = .;
|
||||
|
||||
/* Portable Executable */
|
||||
KEEP(*(.pe.header))
|
||||
HIDDEN(ape_pe_sections = .);
|
||||
ape_pe_sections = .;
|
||||
KEEP(*(.pe.sections))
|
||||
HIDDEN(ape_pe_sections_end = .);
|
||||
ape_pe_sections_end = .;
|
||||
|
||||
/* Mach-O */
|
||||
KEEP(*(.macho))
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
HIDDEN(ape_macho_end = .);
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
ape_macho_end = .;
|
||||
|
||||
/* APE loader */
|
||||
KEEP(*(.ape.loader))
|
||||
. = ALIGN(. != 0 ? CODE_GRANULE : 0);
|
||||
|
||||
KEEP(*(.ape.pad.head))
|
||||
. = ALIGN(SupportsWindows() || SupportsMetal() ? PAGESIZE : 16);
|
||||
HIDDEN(_ehead = .);
|
||||
. = ALIGN(. != 0 ? (SupportsWindows() || SupportsMetal() ? CONSTANT(COMMONPAGESIZE) : 16) : 0);
|
||||
_ehead = .;
|
||||
} :Head
|
||||
|
||||
/*BEGIN: nt addressability guarantee */
|
||||
|
||||
.text . : {
|
||||
BYTE(0x90) /* TODO: fix blinkenlights symbol __map_phdrs */
|
||||
/* Code that needs to be addressable in Real Mode */
|
||||
*(.text.real)
|
||||
KEEP(*(SORT_BY_NAME(.sort.text.real.*)))
|
||||
HIDDEN(_ereal = .);
|
||||
. += 1;
|
||||
|
||||
_ereal = .;
|
||||
/*END: realmode addressability guarantee */
|
||||
/*BEGIN: morphable code */
|
||||
. += CODE_GRANULE;
|
||||
|
||||
/* Normal Code */
|
||||
*(.start)
|
||||
@@ -265,6 +301,7 @@ SECTIONS {
|
||||
KEEP(*(.textwindowsprologue))
|
||||
*(.text.windows)
|
||||
KEEP(*(.textwindowsepilogue))
|
||||
KEEP(*(.blink))
|
||||
*(SORT_BY_ALIGNMENT(.text.modernity))
|
||||
*(SORT_BY_ALIGNMENT(.text.modernity.*))
|
||||
*(SORT_BY_ALIGNMENT(.text.hot))
|
||||
@@ -279,25 +316,28 @@ SECTIONS {
|
||||
|
||||
/* Privileged code invulnerable to magic */
|
||||
KEEP(*(.ape.pad.privileged));
|
||||
. += . > 0 ? 1 : 0;
|
||||
HIDDEN(__privileged_start = .);
|
||||
. += . > 0 ? 1 : 0;
|
||||
. = ALIGN(__privileged_end > __privileged_start ? CONSTANT(COMMONPAGESIZE) : 0);
|
||||
/*END: morphable code */
|
||||
__privileged_start = .;
|
||||
*(.privileged)
|
||||
HIDDEN(__privileged_end = .);
|
||||
. += . > 0 ? 1 : 0;
|
||||
__privileged_end = .;
|
||||
|
||||
KEEP(*(.ape.pad.text))
|
||||
. = ALIGN(. != 0 ? CONSTANT(COMMONPAGESIZE) : 0);
|
||||
/*END: Read Only Data (only needed for initialization) */
|
||||
} :Cod
|
||||
|
||||
/*BEGIN: Read Only Data */
|
||||
|
||||
KEEP(*(.ape.pad.rodata));
|
||||
.rodata . : {
|
||||
KEEP(*(.rodata.pytab.0));
|
||||
KEEP(*(.rodata.pytab.1));
|
||||
KEEP(*(.rodata.pytab.2));
|
||||
|
||||
*(.rodata .rodata.*)
|
||||
*(.ubsan.types)
|
||||
*(.ubsan.data)
|
||||
|
||||
/* Unit Test & Fixture Registry */
|
||||
|
||||
/*BEGIN: Read only data that needn't be mapped after initialization */
|
||||
|
||||
/* Legal Notices */
|
||||
#if !defined(IM_FEELING_NAUGHTY) || defined(EMBED_NOTICES)
|
||||
KEEP(*(.commentprologue))
|
||||
@@ -305,46 +345,64 @@ SECTIONS {
|
||||
KEEP(*(.commentepilogue))
|
||||
#endif
|
||||
|
||||
/*BEGIN: read-only data that's only needed for initialization */
|
||||
|
||||
#if SupportsWindows()
|
||||
/* Windows DLL Import Directory */
|
||||
KEEP(*(.idata.ro));
|
||||
KEEP(*(SORT_BY_NAME(.idata.ro.*)))
|
||||
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
PROVIDE_HIDDEN(__init_array_start = .);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP(*(.ctors))
|
||||
KEEP(*(.init_array))
|
||||
KEEP(*(.preinit_array))
|
||||
PROVIDE_HIDDEN(__init_array_end = .);
|
||||
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
PROVIDE_HIDDEN(__fini_array_start = .);
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP(*(.dtors))
|
||||
PROVIDE_HIDDEN(__fini_array_end = .);
|
||||
#endif
|
||||
|
||||
/* Encoded Data Structures w/ Linear Initialization Order */
|
||||
KEEP(*(.initroprologue))
|
||||
KEEP(*(SORT_BY_NAME(.initro.*)))
|
||||
KEEP(*(.initroepilogue))
|
||||
KEEP(*(SORT_BY_NAME(.sort.rodata.*)))
|
||||
. = ALIGN(. != 0 ? CONSTANT(COMMONPAGESIZE) : 0); /* don't delete this line :o */
|
||||
|
||||
/*END: read-only data that's only needed for initialization */
|
||||
|
||||
KEEP(*(.ape.pad.text))
|
||||
. = ALIGN(PAGESIZE);
|
||||
HIDDEN(_etext = .);
|
||||
PROVIDE_HIDDEN(etext = .);
|
||||
/*END: Read Only Data (only needed for initialization) */
|
||||
/*END: Read Only Data */
|
||||
} :Rom
|
||||
|
||||
/* initialization image for thread-local storage, this is copied */
|
||||
/* out to actual TLS areas at runtime, so just make it read-only */
|
||||
.tdata . : {
|
||||
_tdata_start = .;
|
||||
*(SORT_BY_ALIGNMENT(.tdata))
|
||||
*(SORT_BY_ALIGNMENT(.tdata.*))
|
||||
_tdata_end = .;
|
||||
KEEP(*(.ape.pad.rodata))
|
||||
. = ALIGN(. != 0 ? CONSTANT(COMMONPAGESIZE) : 0);
|
||||
_etext = .;
|
||||
PROVIDE(etext = .);
|
||||
} :Tls :Rom
|
||||
/*END: Read Only Data */
|
||||
|
||||
. = ALIGN(CONSTANT(COMMONPAGESIZE));
|
||||
|
||||
/* this only tells the linker about the layout of uninitialized */
|
||||
/* TLS data, and does not advance the linker's location counter */
|
||||
.tbss : {
|
||||
_tbss_start = .;
|
||||
*(SORT_BY_ALIGNMENT(.tbss))
|
||||
*(SORT_BY_ALIGNMENT(.tbss.*))
|
||||
KEEP(*(.fstls))
|
||||
/* the %fs register is based on this location */
|
||||
_tbss_end = .;
|
||||
} :Tls
|
||||
|
||||
.data . : {
|
||||
/*BEGIN: Read/Write Data */
|
||||
#if SupportsWindows()
|
||||
KEEP(*(SORT_BY_NAME(.piro.data.sort.iat.*)))
|
||||
#endif
|
||||
/*BEGIN: NT FORK COPYING */
|
||||
KEEP(*(.dataprologue))
|
||||
*(.data .data.*)
|
||||
*(.PyRuntime) /* for python */
|
||||
*(.subrs) /* for emacs */
|
||||
KEEP(*(SORT_BY_NAME(.sort.data.*)))
|
||||
. += . > 0 ? 1 : 0;
|
||||
. += . > 0 ? CODE_GRANULE : 0;
|
||||
|
||||
KEEP(*(.gotprologue))
|
||||
*(.got)
|
||||
@@ -354,35 +412,51 @@ SECTIONS {
|
||||
*(.got.plt)
|
||||
KEEP(*(.gotpltepilogue))
|
||||
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
__init_array_start = .;
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.ctors.*)))
|
||||
KEEP(*(.ctors))
|
||||
KEEP(*(.init_array))
|
||||
KEEP(*(.preinit_array))
|
||||
__init_array_end = .;
|
||||
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
__fini_array_start = .;
|
||||
KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*)
|
||||
SORT_BY_INIT_PRIORITY(.dtors.*)))
|
||||
KEEP(*(.fini_array))
|
||||
KEEP(*(.dtors))
|
||||
__fini_array_end = .;
|
||||
|
||||
/*BEGIN: Post-Initialization Read-Only */
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
KEEP(*(SORT_BY_NAME(.piro.relo.sort.*)))
|
||||
PROVIDE_HIDDEN(__relo_end = .);
|
||||
. = ALIGN(__SIZEOF_POINTER__);
|
||||
. = ALIGN(. != 0 ? __SIZEOF_POINTER__ : 0);
|
||||
KEEP(*(SORT_BY_NAME(.piro.data.sort.*)))
|
||||
KEEP(*(.piro.pad.data))
|
||||
. = ALIGN(PAGESIZE);
|
||||
HIDDEN(_edata = .);
|
||||
PROVIDE_HIDDEN(edata = .);
|
||||
KEEP(*(.dataepilogue))
|
||||
. = ALIGN(. != 0 ? CONSTANT(COMMONPAGESIZE) : 0);
|
||||
/*END: NT FORK COPYING */
|
||||
_edata = .;
|
||||
PROVIDE(edata = .);
|
||||
_ezip = .; /* <-- very deprecated */
|
||||
} :Ram
|
||||
|
||||
. = ALIGN(CONSTANT(COMMONPAGESIZE));
|
||||
|
||||
/*END: file content that's loaded by o/s */
|
||||
/*BEGIN: bss memory void */
|
||||
|
||||
.zip . : {
|
||||
KEEP(*(SORT_BY_NAME(.zip.*)))
|
||||
HIDDEN(_ezip = .);
|
||||
}
|
||||
|
||||
/*END: file content */
|
||||
/*BEGIN: bss memory that's addressable */
|
||||
|
||||
.bss ALIGN(64) : {
|
||||
.bss : {
|
||||
/*BEGIN: NT FORK COPYING */
|
||||
KEEP(*(.bssprologue))
|
||||
KEEP(*(SORT_BY_NAME(.piro.bss.init.*)))
|
||||
*(.piro.bss)
|
||||
KEEP(*(SORT_BY_NAME(.piro.bss.sort.*)))
|
||||
HIDDEN(__piro_end = .);
|
||||
. += . > 0 ? 1 : 0;
|
||||
__piro_end = .;
|
||||
. += . > 0 ? CODE_GRANULE : 0;
|
||||
/*END: Post-Initialization Read-Only */
|
||||
|
||||
/* Statically Allocated Empty Space */
|
||||
@@ -392,10 +466,16 @@ SECTIONS {
|
||||
|
||||
KEEP(*(SORT_BY_NAME(.sort.bss.*)))
|
||||
|
||||
. = ALIGN(FRAMESIZE); /* for brk()/sbrk() allocation */
|
||||
HIDDEN(_end = .);
|
||||
PROVIDE_HIDDEN(end = .);
|
||||
}
|
||||
KEEP(*(.bssepilogue))
|
||||
|
||||
. = ALIGN(. != 0 ? CONSTANT(COMMONPAGESIZE) : 0);
|
||||
|
||||
/*END: NT FORK COPYING */
|
||||
} :Ram
|
||||
|
||||
. = ALIGN(CONSTANT(COMMONPAGESIZE));
|
||||
_end = .;
|
||||
PROVIDE(end = .);
|
||||
|
||||
/*END: nt addressability guarantee */
|
||||
/*END: bsd addressability guarantee */
|
||||
@@ -423,6 +503,7 @@ SECTIONS {
|
||||
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_line_str 0 : { *(.debug_line_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
@@ -431,19 +512,38 @@ SECTIONS {
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.debug_rnglists 0 : { *(.debug_rnglists) }
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
.debug_addr 0 : { *(.debug_addr) }
|
||||
.gnu.attributes 0 : { KEEP(*(.gnu.attributes)) }
|
||||
.GCC.command.line 0 : { *(.GCC.command.line) }
|
||||
|
||||
.zip 0 : {
|
||||
KEEP(*(.zip.file))
|
||||
__zip_cdir_start = .;
|
||||
KEEP(*(.zip.cdir))
|
||||
__zip_cdir_size = . - __zip_cdir_start;
|
||||
KEEP(*(.zip.eocd))
|
||||
}
|
||||
|
||||
/DISCARD/ : {
|
||||
#if !SupportsWindows()
|
||||
*(.idata.ro);
|
||||
*(.idata.ro.*)
|
||||
*(.piro.data.sort.iat.*)
|
||||
#endif
|
||||
*(__patchable_function_entries)
|
||||
*(__mcount_loc)
|
||||
*(.discard)
|
||||
*(.yoink)
|
||||
*(.*)
|
||||
}
|
||||
}
|
||||
|
||||
ape_pe_filealignment = 512;
|
||||
ape_pe_sectionalignment = 4096;
|
||||
ape_pe_sizeofheaders = SIZEOF(.head);
|
||||
ape_pe_sizeofimage = ROUNDUP(_end - __executable_start, ape_pe_sectionalignment);
|
||||
|
||||
PFSTUB8(ape_elf_entry, _start);
|
||||
PFSTUB8(ape_elf_phoff, RVA(ape_phdrs));
|
||||
PFSTUB8(ape_elf_shoff, 0);
|
||||
@@ -451,106 +551,101 @@ PFSTUB4(ape_elf_phnum, (ape_phdrs_end - ape_phdrs) / 56);
|
||||
PFSTUB4(ape_elf_shnum, 0);
|
||||
PFSTUB4(ape_elf_shstrndx, 0);
|
||||
|
||||
HIDDEN(__privileged_addr = ROUNDDOWN(__privileged_start, PAGESIZE));
|
||||
HIDDEN(__privileged_size = (ROUNDUP(__privileged_end, PAGESIZE) -
|
||||
ROUNDDOWN(__privileged_start, PAGESIZE)));
|
||||
_tls_size = _tbss_end - _tdata_start;
|
||||
_tdata_size = _tdata_end - _tdata_start;
|
||||
_tbss_size = _tbss_end - _tbss_start;
|
||||
_tbss_offset = _tbss_start - _tdata_start;
|
||||
_tls_content = (_tdata_end - _tdata_start) + (_tbss_end - _tbss_start);
|
||||
_tls_align = 1;
|
||||
|
||||
HIDDEN(ape_rom_offset = 0);
|
||||
HIDDEN(ape_rom_vaddr = ADDR(.head));
|
||||
HIDDEN(ape_rom_paddr = LOADADDR(.head));
|
||||
HIDDEN(ape_rom_filesz = LOADADDR(.data) - ape_rom_paddr);
|
||||
HIDDEN(ape_rom_memsz = ADDR(.data) - ADDR(.head));
|
||||
HIDDEN(ape_rom_align = PAGESIZE);
|
||||
HIDDEN(ape_rom_rva = RVA(ape_rom_vaddr));
|
||||
ape_cod_offset = 0;
|
||||
ape_cod_vaddr = ADDR(.head);
|
||||
ape_cod_paddr = LOADADDR(.head);
|
||||
ape_cod_filesz = ADDR(.rodata) - ADDR(.head);
|
||||
ape_cod_memsz = ape_cod_filesz;
|
||||
ape_cod_align = CONSTANT(COMMONPAGESIZE);
|
||||
ape_cod_rva = RVA(ape_cod_vaddr);
|
||||
|
||||
HIDDEN(ape_ram_offset = ape_rom_offset + ape_rom_filesz);
|
||||
HIDDEN(ape_ram_vaddr = ADDR(.data));
|
||||
HIDDEN(ape_ram_paddr = LOADADDR(.data));
|
||||
HIDDEN(ape_ram_filesz = SIZEOF(.data));
|
||||
HIDDEN(ape_ram_memsz = ADDR(.bss) + SIZEOF(.bss) - ape_ram_vaddr);
|
||||
HIDDEN(ape_ram_align = PAGESIZE);
|
||||
HIDDEN(ape_ram_rva = RVA(ape_ram_vaddr));
|
||||
ape_rom_vaddr = ADDR(.rodata);
|
||||
ape_rom_offset = ape_rom_vaddr - __executable_start;
|
||||
ape_rom_paddr = LOADADDR(.rodata);
|
||||
ape_rom_filesz = ADDR(.tbss) - ADDR(.rodata);
|
||||
ape_rom_memsz = ape_rom_filesz;
|
||||
ape_rom_align = CONSTANT(COMMONPAGESIZE);
|
||||
ape_rom_rva = RVA(ape_rom_vaddr);
|
||||
|
||||
HIDDEN(ape_stack_offset = ape_ram_offset + ape_ram_filesz);
|
||||
HIDDEN(ape_stack_vaddr = 0x700000000000 - STACKSIZE);
|
||||
HIDDEN(ape_stack_paddr = ape_ram_paddr + ape_ram_filesz);
|
||||
HIDDEN(ape_stack_filesz = 0);
|
||||
HIDDEN(ape_stack_memsz = STACKSIZE);
|
||||
HIDDEN(ape_stack_align = 16);
|
||||
ape_ram_vaddr = ADDR(.data);
|
||||
ape_ram_offset = ape_ram_vaddr - __executable_start;
|
||||
ape_ram_paddr = LOADADDR(.data);
|
||||
ape_ram_filesz = ADDR(.bss) - ADDR(.data);
|
||||
ape_ram_memsz = _end - ADDR(.data);
|
||||
ape_ram_align = CONSTANT(COMMONPAGESIZE);
|
||||
ape_ram_rva = RVA(ape_ram_vaddr);
|
||||
|
||||
HIDDEN(ape_note_offset = ape_rom_offset + (ape_note - ape_rom_vaddr));
|
||||
HIDDEN(ape_note_vaddr = ape_note);
|
||||
HIDDEN(ape_note_paddr = ape_rom_paddr + ape_note_offset);
|
||||
HIDDEN(ape_note_filesz = ape_note_end - ape_note);
|
||||
HIDDEN(ape_note_memsz = ape_note_filesz);
|
||||
HIDDEN(ape_note_align = __SIZEOF_POINTER__);
|
||||
ape_stack_pf = DEFINED(ape_stack_pf) ? ape_stack_pf : PF_R | PF_W;
|
||||
ape_stack_prot = _PF2PROT(ape_stack_pf);
|
||||
ape_stack_offset = 0;
|
||||
ape_stack_vaddr = DEFINED(ape_stack_vaddr) ? ape_stack_vaddr : 0x700000000000;
|
||||
ape_stack_paddr = ape_ram_paddr + ape_ram_filesz;
|
||||
ape_stack_filesz = 0;
|
||||
ape_stack_memsz = DEFINED(ape_stack_memsz) ? ape_stack_memsz : 8 * 1024 * 1024;
|
||||
ape_stack_align = DEFINED(ape_stack_align) ? ape_stack_align : 16;
|
||||
ape_stack_round = -ape_stack_align;
|
||||
|
||||
HIDDEN(ape_text_offset = ape_rom_offset + LOADADDR(.text) - ape_rom_paddr);
|
||||
HIDDEN(ape_text_paddr = LOADADDR(.text));
|
||||
HIDDEN(ape_text_vaddr = ADDR(.text));
|
||||
HIDDEN(ape_text_filesz = SIZEOF(.text));
|
||||
HIDDEN(ape_text_memsz = SIZEOF(.text));
|
||||
HIDDEN(ape_text_align = PAGESIZE);
|
||||
HIDDEN(ape_text_rva = RVA(ape_text_vaddr));
|
||||
ape_note_offset = ape_cod_offset + (ape_note - ape_cod_vaddr);
|
||||
ape_note_filesz = ape_note_end - ape_note;
|
||||
ape_note_memsz = ape_note_filesz;
|
||||
|
||||
HIDDEN(ape_data_offset = ape_ram_offset + LOADADDR(.data) - ape_ram_paddr);
|
||||
HIDDEN(ape_data_paddr = LOADADDR(.data));
|
||||
HIDDEN(ape_data_vaddr = ADDR(.data));
|
||||
HIDDEN(ape_data_filesz = SIZEOF(.data));
|
||||
HIDDEN(ape_data_memsz = SIZEOF(.data));
|
||||
HIDDEN(ape_data_align = PAGESIZE);
|
||||
HIDDEN(ape_data_rva = RVA(ape_data_vaddr));
|
||||
ape_text_vaddr = ADDR(.text);
|
||||
ape_text_offset = ape_text_vaddr - __executable_start;
|
||||
ape_text_paddr = LOADADDR(.text);
|
||||
ape_text_filesz = ADDR(.rodata) - ADDR(.text);
|
||||
ape_text_memsz = ape_text_filesz;
|
||||
ape_text_align = CONSTANT(COMMONPAGESIZE);
|
||||
ape_text_rva = RVA(ape_text_vaddr);
|
||||
|
||||
HIDDEN(ape_bss_offset = ape_ram_offset + LOADADDR(.bss) - ape_ram_paddr);
|
||||
HIDDEN(ape_bss_paddr = LOADADDR(.bss));
|
||||
HIDDEN(ape_bss_vaddr = ADDR(.bss));
|
||||
HIDDEN(ape_bss_filesz = 0);
|
||||
HIDDEN(ape_bss_memsz = SIZEOF(.bss));
|
||||
HIDDEN(ape_bss_align = PAGESIZE);
|
||||
/* we roundup here because xnu wants the file load segments page-aligned */
|
||||
/* but we don't want to add the nop padding to the ape program, so we'll */
|
||||
/* let ape.S dd read past the end of the file into the wrapping binaries */
|
||||
SHSTUB2(ape_loader_dd_skip, DEFINED(ape_loader) ? RVA(ape_loader) / 64 : 0);
|
||||
SHSTUB2(ape_loader_dd_count,
|
||||
DEFINED(ape_loader_end)
|
||||
? ROUNDUP(ape_loader_end - ape_loader, CONSTANT(COMMONPAGESIZE)) / 64
|
||||
: 0);
|
||||
|
||||
#if SupportsXnu()
|
||||
SHSTUB2(ape_macho_dd_skip, RVA(ape_macho) / 8);
|
||||
SHSTUB2(ape_macho_dd_count, (ape_macho_end - ape_macho) / 8);
|
||||
#endif
|
||||
#if defined(APE_IS_SHELL_SCRIPT) && !IsTiny()
|
||||
|
||||
#if SupportsWindows() || SupportsMetal()
|
||||
#define LINK_WINDOWS (SupportsWindows() && !DEFINED(EfiMain))
|
||||
PFSTUB4(ape_pe_offset, ape_pe - ape_mz);
|
||||
HIDDEN(ape_pe_optsz = ape_pe_sections - (ape_pe + 24));
|
||||
HIDDEN(ape_pe_shnum = (ape_pe_sections_end - ape_pe_sections) / 40);
|
||||
HIDDEN(ape_pe_base = IMAGE_BASE_VIRTUAL);
|
||||
HIDDEN(ape_idata = LINK_WINDOWS ? RVA(ape_idata_iat) : 0);
|
||||
HIDDEN(ape_idata_iatsize = LINK_WINDOWS ? ape_idata_iatend - ape_idata_iat : 0);
|
||||
HIDDEN(ape_idata = LINK_WINDOWS ? RVA(ape_idata_idt) : 0);
|
||||
HIDDEN(ape_idata_idtsize = LINK_WINDOWS ? ape_idata_idtend - ape_idata_idt : 0);
|
||||
HIDDEN(v_ntversion = LINK_WINDOWS ? 6 : 1);
|
||||
HIDDEN(v_ntdllchar = LINK_WINDOWS ? 288 : 0);
|
||||
HIDDEN(v_ntsubversion = LINK_WINDOWS ? 6 : 5);
|
||||
HIDDEN(v_ntsubsystem = (LINK_WINDOWS
|
||||
? (DEFINED(GetMessage)
|
||||
? kNtImageSubsystemWindowsGui
|
||||
: kNtImageSubsystemWindowsCui)
|
||||
: kNtImageSubsystemEfiApplication));
|
||||
HIDDEN(ape_pe_entry = LINK_WINDOWS ? WinMain : EfiMain);
|
||||
#endif
|
||||
#define IDENTITY(X) X
|
||||
|
||||
#define APE_DECLARE_FIXED_DECIMAL(F, X) \
|
||||
X##_quad = DEFINED(X) ? ((F(X) < 1000000000 ? 32 : F(X) / 1000000000 % 10 + 48) << 000 | \
|
||||
(F(X) < 100000000 ? 32 : F(X) / 100000000 % 10 + 48) << 010 | \
|
||||
(F(X) < 10000000 ? 32 : F(X) / 10000000 % 10 + 48) << 020 | \
|
||||
(F(X) < 1000000 ? 32 : F(X) / 1000000 % 10 + 48) << 030 | \
|
||||
(F(X) < 100000 ? 32 : F(X) / 100000 % 10 + 48) << 040 | \
|
||||
(F(X) < 10000 ? 32 : F(X) / 10000 % 10 + 48) << 050 | \
|
||||
(F(X) < 1000 ? 32 : F(X) / 1000 % 10 + 48) << 060 | \
|
||||
(F(X) < 100 ? 32 : F(X) / 100 % 10 + 48) << 070) : 0; \
|
||||
X##_short = DEFINED(X) ? ((F(X) < 10 ? 32 : F(X) / 10 % 10 + 48) << 000 | \
|
||||
(F(X) % 10 + 48) << 010) : 0
|
||||
|
||||
APE_DECLARE_FIXED_DECIMAL(RVA, blink_linux_aarch64);
|
||||
APE_DECLARE_FIXED_DECIMAL(IDENTITY, blink_linux_aarch64_size);
|
||||
APE_DECLARE_FIXED_DECIMAL(RVA, blink_xnu_aarch64);
|
||||
APE_DECLARE_FIXED_DECIMAL(IDENTITY, blink_xnu_aarch64_size);
|
||||
|
||||
#endif /* APE_IS_SHELL_SCRIPT */
|
||||
|
||||
#if SupportsMetal()
|
||||
HIDDEN(v_ape_realsectors =
|
||||
MIN(0x70000 - IMAGE_BASE_REAL,
|
||||
ROUNDUP(RVA(_edata), 4096)) / 512);
|
||||
HIDDEN(v_ape_realpages = v_ape_realsectors / (4096 / 512));
|
||||
HIDDEN(v_ape_highsectors =
|
||||
(ROUNDUP(RVA(_edata), 512) / 512) - v_ape_realsectors);
|
||||
v_ape_realsectors = MIN(0x70000 - IMAGE_BASE_REAL, ROUNDUP(RVA(_ezip), 512)) / 512;
|
||||
v_ape_realbytes = v_ape_realsectors * 512;
|
||||
v_ape_realdwords = v_ape_realsectors * (512 / 4);
|
||||
v_ape_allsectors = ROUNDUP(RVA(_ezip), 512) / 512;
|
||||
v_ape_allbytes = v_ape_allsectors * 512;
|
||||
v_ape_highsectors = MIN(0xffff, v_ape_allsectors - v_ape_realsectors);
|
||||
TSSDESCSTUB2(_tss, _tss, _tss_end ? _tss_end - _tss - 1 : 0);
|
||||
#endif
|
||||
|
||||
/* ZIP End of Central Directory header */
|
||||
#define ZIPCONST(NAME, VAL) HIDDEN(NAME = DEFINED(__zip_start) ? VAL : 0);
|
||||
ZIPCONST(v_zip_cdoffset, __zip_start - IMAGE_BASE_VIRTUAL);
|
||||
ZIPCONST(v_zip_cdirsize, __zip_end - __zip_start);
|
||||
ASSERT(v_zip_cdirsize % kZipCdirHdrLinkableSize == 0, "bad zip cdir");
|
||||
ZIPCONST(v_zip_records, v_zip_cdirsize / kZipCdirHdrLinkableSize);
|
||||
ZIPCONST(v_zip_commentsize, _ezip - __zip_end - kZipCdirHdrMinSize);
|
||||
|
||||
#if SupportsXnu()
|
||||
/* Generates deterministic ID. */
|
||||
#define PHI 0x9e3779b9925d4c17
|
||||
@@ -569,19 +664,8 @@ ZIPCONST(v_zip_commentsize, _ezip - __zip_end - kZipCdirHdrMinSize);
|
||||
KMH(ape_uuid1, X); \
|
||||
XORSHIFT(ape_uuid2, X); \
|
||||
KMH(ape_uuid2, X)
|
||||
HIDDEN(ape_uuid1 = 88172645463325252);
|
||||
HIDDEN(ape_uuid2 = 88172645463325252);
|
||||
CHURN(ape_bss_align);
|
||||
CHURN(ape_bss_filesz);
|
||||
CHURN(ape_bss_memsz);
|
||||
CHURN(ape_bss_offset);
|
||||
CHURN(ape_bss_paddr);
|
||||
CHURN(ape_data_filesz);
|
||||
CHURN(ape_data_memsz);
|
||||
CHURN(ape_data_offset);
|
||||
CHURN(ape_data_paddr);
|
||||
CHURN(ape_data_rva);
|
||||
CHURN(ape_data_vaddr);
|
||||
ape_uuid1 = 88172645463325252;
|
||||
ape_uuid2 = 88172645463325252;
|
||||
CHURN(ape_elf_entry);
|
||||
CHURN(ape_elf_phnum);
|
||||
CHURN(ape_elf_phoff);
|
||||
@@ -590,13 +674,10 @@ CHURN(ape_elf_shoff);
|
||||
CHURN(ape_elf_shstrndx);
|
||||
CHURN(ape_macho_end);
|
||||
CHURN(ape_note);
|
||||
CHURN(ape_note_align);
|
||||
CHURN(ape_note_end);
|
||||
CHURN(ape_note_filesz);
|
||||
CHURN(ape_note_memsz);
|
||||
CHURN(ape_note_offset);
|
||||
CHURN(ape_note_paddr);
|
||||
CHURN(ape_note_vaddr);
|
||||
CHURN(ape_ram_align);
|
||||
CHURN(ape_ram_filesz);
|
||||
CHURN(ape_ram_memsz);
|
||||
@@ -610,7 +691,14 @@ CHURN(ape_rom_memsz);
|
||||
CHURN(ape_rom_offset);
|
||||
CHURN(ape_rom_paddr);
|
||||
CHURN(ape_rom_rva);
|
||||
CHURN(ape_rom_vaddr);
|
||||
CHURN(ape_cod_vaddr);
|
||||
CHURN(ape_cod_align);
|
||||
CHURN(ape_cod_filesz);
|
||||
CHURN(ape_cod_memsz);
|
||||
CHURN(ape_cod_offset);
|
||||
CHURN(ape_cod_paddr);
|
||||
CHURN(ape_cod_rva);
|
||||
CHURN(ape_cod_vaddr);
|
||||
CHURN(ape_text_align);
|
||||
CHURN(ape_text_filesz);
|
||||
CHURN(ape_text_memsz);
|
||||
@@ -622,7 +710,7 @@ CHURN(ADDR(.bss));
|
||||
CHURN(_start);
|
||||
CHURN(ape_phdrs);
|
||||
#if SupportsMetal()
|
||||
CHURN(v_ape_realsectors);
|
||||
CHURN(v_ape_allsectors);
|
||||
#endif
|
||||
#if SupportsXnu()
|
||||
CHURN(ape_macho);
|
||||
@@ -640,6 +728,33 @@ CHURN(WinMain);
|
||||
#endif /* SupportsWindows() */
|
||||
#endif /* SupportsXnu() */
|
||||
|
||||
#if SupportsWindows() || SupportsMetal()
|
||||
#define LINK_WINDOWS (SupportsWindows() && !DEFINED(EfiMain))
|
||||
PFSTUB4(ape_pe_offset, ape_pe - ape_mz);
|
||||
ape_pe_optsz = ape_pe_sections - (ape_pe + 24);
|
||||
ASSERT(ape_pe_optsz % 8 == 0, "SizeOfOptionalHeader must be multiple of 8");
|
||||
ape_pe_shnum = (ape_pe_sections_end - ape_pe_sections) / 40;
|
||||
ape_pe_base = IMAGE_BASE_VIRTUAL;
|
||||
ape_idataz = LINK_WINDOWS ? RVA(ape_idata_iat) : 0;
|
||||
ape_idata_iatsize = LINK_WINDOWS ? ape_idata_iatend - ape_idata_iat : 0;
|
||||
ape_idata = LINK_WINDOWS ? RVA(ape_idata_idt) : 0;
|
||||
ape_idata_idtsize = LINK_WINDOWS ? ape_idata_idtend - ape_idata_idt : 0;
|
||||
v_ntversion = LINK_WINDOWS ? 6 : 1;
|
||||
v_ntdllchar = LINK_WINDOWS ? 288 : 0;
|
||||
v_ntsubversion = LINK_WINDOWS ? 6 : 5;
|
||||
v_ntsubsystem = (LINK_WINDOWS
|
||||
? (DEFINED(GetMessage)
|
||||
? kNtImageSubsystemWindowsGui
|
||||
: kNtImageSubsystemWindowsCui)
|
||||
: kNtImageSubsystemEfiApplication);
|
||||
ape_pe_entry = LINK_WINDOWS ? WinMain : EfiMain;
|
||||
#endif
|
||||
|
||||
#if SupportsXnu()
|
||||
SHSTUB2(ape_macho_dd_skip, RVA(ape_macho) / 8);
|
||||
SHSTUB2(ape_macho_dd_count, (ape_macho_end - ape_macho) / 8);
|
||||
#endif
|
||||
|
||||
ASSERT(DEFINED(ape_mz) ? ape_mz == IMAGE_BASE_VIRTUAL : 1, "linker panic");
|
||||
ASSERT((DEFINED(__init_bss_end) ? __init_bss_end : 0) % __SIZEOF_POINTER__ == 0,
|
||||
"__init_bss misalign");
|
||||
@@ -650,11 +765,16 @@ ASSERT(((DEFINED(__init_rodata_end) ? __init_rodata_end : 0) %
|
||||
ASSERT((!DEFINED(ape_grub) ? 1 : RVA(ape_grub) < 8192),
|
||||
"grub stub needs to be in first 8kb of image");
|
||||
|
||||
ASSERT(DEFINED(_start) || DEFINED(_start16),
|
||||
"please link a _start() or _start16() entrypoint");
|
||||
ASSERT(IS2POW(ape_stack_memsz),
|
||||
"ape_stack_memsz must be a two power");
|
||||
|
||||
ASSERT(!DEFINED(_start16) || REAL(_end) < 65536,
|
||||
"ape won't support non-tiny real mode programs");
|
||||
ASSERT(ape_stack_vaddr % ape_stack_memsz == 0,
|
||||
"ape_stack_vaddr must have ape_stack_memsz alignment; try using STATIC_STACK_ADDR(0x700000040000 & -ape_stack_memsz);");
|
||||
|
||||
ASSERT(ALIGNOF(.tdata) <= TLS_ALIGNMENT && ALIGNOF(.tbss) <= TLS_ALIGNMENT,
|
||||
"_Thread_local _Alignof can't exceed TLS_ALIGNMENT");
|
||||
|
||||
ASSERT(DEFINED(main), "main() function not defined");
|
||||
|
||||
/* Let's not be like Knight Capital. */
|
||||
/* NOCROSSREFS_TO(.test .text) */
|
||||
|
||||
+260
-36
@@ -15,49 +15,273 @@
|
||||
|
||||
PKGS += APE
|
||||
|
||||
APE = $(APE_DEPS) \
|
||||
$(APE_OBJS) \
|
||||
o/$(MODE)/ape/ape.lds
|
||||
|
||||
APE_BUILDSAFE = \
|
||||
$(APE_DEPS) \
|
||||
o/$(MODE)/ape/ape-buildsafe.o \
|
||||
o/$(MODE)/ape/ape.lds
|
||||
|
||||
APELINK = \
|
||||
$(COMPILE) \
|
||||
-ALINK.ape \
|
||||
$(LINK) \
|
||||
$(LINKARGS) \
|
||||
$(OUTPUT_OPTION)
|
||||
|
||||
APE_FILES := $(wildcard ape/*.*)
|
||||
APE_HDRS = $(filter %.h,$(APE_FILES))
|
||||
APE_INCS = $(filter %.inc,$(APE_FILES))
|
||||
APE_SRCS = $(filter %.S,$(APE_FILES))
|
||||
APE_OBJS = $(APE_SRCS:%.S=o/$(MODE)/%.o)
|
||||
APE_CHECKS = $(APE_HDRS:%=o/%.ok)
|
||||
|
||||
o/$(MODE)/ape/ape.lds: \
|
||||
ape/ape.lds \
|
||||
ape/macros.internal.h \
|
||||
libc/dce.h \
|
||||
libc/zip.h
|
||||
ifeq ($(ARCH), aarch64)
|
||||
|
||||
o/ape/idata.inc: \
|
||||
ape/idata.internal.h \
|
||||
ape/relocations.h
|
||||
APE = o/$(MODE)/ape/aarch64.lds
|
||||
|
||||
$(APE_OBJS): $(BUILD_FILES) \
|
||||
ape/ape.mk
|
||||
APELINK = \
|
||||
$(COMPILE) \
|
||||
-ALINK.ape \
|
||||
$(LINK) \
|
||||
$(LINKARGS) \
|
||||
$(OUTPUT_OPTION) && \
|
||||
$(COMPILE) \
|
||||
-AFIXUP.ape \
|
||||
-wT$@ \
|
||||
$(FIXUPOBJ) \
|
||||
$@
|
||||
|
||||
o/$(MODE)/ape/ape-no-modify-self.o: ape/ape.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_NO_MODIFY_SELF $<
|
||||
|
||||
o/$(MODE)/ape/ape-buildsafe.o: ape/ape.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -DAPE_BUILDSAFE $<
|
||||
APE_SRCS = ape/ape.S ape/start.S ape/launch.S ape/systemcall.S
|
||||
APE_OBJS = o/$(MODE)/ape/ape.o
|
||||
APE_NO_MODIFY_SELF = $(APE)
|
||||
APE_COPY_SELF = $(APE)
|
||||
|
||||
.PHONY: o/$(MODE)/ape
|
||||
o/$(MODE)/ape: $(APE) \
|
||||
$(APE_CHECKS) \
|
||||
o/$(MODE)/ape: $(APE)
|
||||
|
||||
o/$(MODE)/ape/aarch64.lds: \
|
||||
ape/aarch64.lds \
|
||||
libc/zip.internal.h \
|
||||
libc/intrin/bits.h \
|
||||
libc/thread/tls.h \
|
||||
libc/calls/struct/timespec.h \
|
||||
libc/macros.internal.h \
|
||||
libc/str/str.h
|
||||
|
||||
APE_LOADER_LDFLAGS = \
|
||||
-pie \
|
||||
-static \
|
||||
-nostdlib \
|
||||
--no-dynamic-linker \
|
||||
-z norelro \
|
||||
-z common-page-size=0x4000 \
|
||||
-z max-page-size=0x4000
|
||||
|
||||
APE_LOADER_FLAGS = \
|
||||
-DNDEBUG \
|
||||
-iquote. \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-fpie \
|
||||
-Os \
|
||||
-ffreestanding \
|
||||
-mgeneral-regs-only \
|
||||
-fno-asynchronous-unwind-tables \
|
||||
-fno-stack-protector \
|
||||
-fno-ident \
|
||||
-fno-gnu-unique \
|
||||
-c \
|
||||
$(OUTPUT_OPTION) \
|
||||
$<
|
||||
|
||||
o/$(MODE)/ape/ape.elf: o/$(MODE)/ape/ape.elf.dbg
|
||||
$(COMPILE) -AOBJCOPY -T$@ $(OBJCOPY) -g $< $@
|
||||
|
||||
o/$(MODE)/ape/ape.elf.dbg: \
|
||||
o/$(MODE)/ape/start.o \
|
||||
o/$(MODE)/ape/loader.o \
|
||||
o/$(MODE)/ape/launch.o \
|
||||
o/$(MODE)/ape/systemcall.o
|
||||
@$(COMPILE) -ALINK.elf $(LD) $(APE_LOADER_LDFLAGS) -o $@ $(patsubst %.lds,-T %.lds,$^)
|
||||
|
||||
o/$(MODE)/ape/loader.o: ape/loader.c ape/ape.h
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CC) -DSUPPORT_VECTOR=1 -g $(APE_LOADER_FLAGS)
|
||||
o/$(MODE)/ape/start.o: ape/start.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/ape/launch.o: ape/launch.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
o/$(MODE)/ape/systemcall.o: ape/systemcall.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
.PHONY: o/$(MODE)/ape
|
||||
o/$(MODE)/ape: o/$(MODE)/ape/ape.elf
|
||||
|
||||
else
|
||||
|
||||
APE = o/$(MODE)/ape/ape.o \
|
||||
o/$(MODE)/ape/ape.lds
|
||||
|
||||
APELINK = \
|
||||
$(COMPILE) \
|
||||
-ALINK.ape \
|
||||
$(LINK) \
|
||||
$(LINKARGS) \
|
||||
$(OUTPUT_OPTION) && \
|
||||
$(COMPILE) \
|
||||
-AFIXUP.ape \
|
||||
-wT$@ \
|
||||
$(FIXUPOBJ) \
|
||||
$@
|
||||
|
||||
APE_NO_MODIFY_SELF = \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/ape/ape-no-modify-self.o
|
||||
|
||||
APE_COPY_SELF = \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/ape/ape-copy-self.o
|
||||
|
||||
APE_LOADER_FLAGS = \
|
||||
-DNDEBUG \
|
||||
-iquote. \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Werror \
|
||||
-pedantic-errors \
|
||||
-fpie \
|
||||
-Os \
|
||||
-ffreestanding \
|
||||
-mgeneral-regs-only \
|
||||
-fno-stack-protector \
|
||||
-fno-ident \
|
||||
-fno-gnu-unique \
|
||||
-c \
|
||||
$(OUTPUT_OPTION) \
|
||||
$<
|
||||
|
||||
APE_SRCS_C = ape/loader.c
|
||||
APE_SRCS_S = $(filter %.S,$(APE_FILES))
|
||||
APE_SRCS = $(APE_SRCS_C) $(APE_SRCS_S)
|
||||
APE_OBJS = $(APE_SRCS_S:%.S=o/$(MODE)/%.o)
|
||||
APE_CHECKS = $(APE_HDRS:%=o/%.ok)
|
||||
|
||||
o/ape/idata.inc: \
|
||||
ape/idata.internal.h \
|
||||
ape/relocations.h
|
||||
|
||||
o/$(MODE)/ape/ape-no-modify-self.o: \
|
||||
ape/ape.S \
|
||||
ape/ape.h \
|
||||
ape/macros.internal.h \
|
||||
ape/notice.inc \
|
||||
ape/relocations.h \
|
||||
ape/ape.internal.h \
|
||||
libc/dce.h \
|
||||
libc/elf/def.h \
|
||||
libc/thread/tls.h \
|
||||
libc/intrin/asancodes.h \
|
||||
libc/macho.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/nexgen32e/uart.internal.h \
|
||||
libc/calls/metalfile.internal.h \
|
||||
libc/nexgen32e/vidya.internal.h \
|
||||
libc/nt/pedef.internal.h \
|
||||
libc/runtime/e820.internal.h \
|
||||
libc/runtime/mman.internal.h \
|
||||
libc/runtime/pc.internal.h \
|
||||
libc/sysv/consts/prot.h \
|
||||
ape/blink-linux-aarch64.gz \
|
||||
ape/blink-xnu-aarch64.gz \
|
||||
o/$(MODE)/ape/ape.elf
|
||||
@$(COMPILE) \
|
||||
-AOBJECTIFY.S \
|
||||
$(OBJECTIFY.S) \
|
||||
$(OUTPUT_OPTION) \
|
||||
-DAPE_NO_MODIFY_SELF \
|
||||
-DAPE_LOADER='"o/$(MODE)/ape/ape.elf"' $<
|
||||
|
||||
o/$(MODE)/ape/ape-copy-self.o: \
|
||||
ape/ape.S \
|
||||
ape/ape.h \
|
||||
ape/macros.internal.h \
|
||||
ape/notice.inc \
|
||||
ape/relocations.h \
|
||||
ape/ape.internal.h \
|
||||
libc/dce.h \
|
||||
libc/elf/def.h \
|
||||
libc/thread/tls.h \
|
||||
libc/intrin/asancodes.h \
|
||||
libc/macho.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/nexgen32e/uart.internal.h \
|
||||
libc/calls/metalfile.internal.h \
|
||||
libc/nexgen32e/vidya.internal.h \
|
||||
libc/nt/pedef.internal.h \
|
||||
libc/runtime/e820.internal.h \
|
||||
libc/runtime/mman.internal.h \
|
||||
libc/runtime/pc.internal.h \
|
||||
libc/sysv/consts/prot.h \
|
||||
ape/blink-linux-aarch64.gz \
|
||||
ape/blink-xnu-aarch64.gz
|
||||
@$(COMPILE) \
|
||||
-AOBJECTIFY.S \
|
||||
$(OBJECTIFY.S) \
|
||||
$(OUTPUT_OPTION) \
|
||||
-DAPE_NO_MODIFY_SELF $<
|
||||
|
||||
o/$(MODE)/ape/loader.o: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CC) -DSUPPORT_VECTOR=121 -g $(APE_LOADER_FLAGS)
|
||||
o/$(MODE)/ape/loader-gcc.asm: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CC) -DSUPPORT_VECTOR=121 -S -g0 $(APE_LOADER_FLAGS)
|
||||
o/$(MODE)/ape/loader-clang.asm: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CLANG) -DSUPPORT_VECTOR=121 -S -g0 $(APE_LOADER_FLAGS)
|
||||
|
||||
o/$(MODE)/ape/loader-xnu.o: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CC) -DSUPPORT_VECTOR=8 -g $(APE_LOADER_FLAGS)
|
||||
o/$(MODE)/ape/loader-xnu-gcc.asm: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CC) -DSUPPORT_VECTOR=8 -S -g0 $(APE_LOADER_FLAGS)
|
||||
o/$(MODE)/ape/loader-xnu-clang.asm: ape/loader.c
|
||||
@$(COMPILE) -AOBJECTIFY.c $(CLANG) -DSUPPORT_VECTOR=8 -S -g0 $(APE_LOADER_FLAGS)
|
||||
|
||||
o/$(MODE)/ape/ape.elf: o/$(MODE)/ape/ape.elf.dbg
|
||||
@$(COMPILE) -AOBJBINCOPY -w build/bootstrap/objbincopy.com -f -o $@ $<
|
||||
|
||||
o/$(MODE)/ape/ape.macho: o/$(MODE)/ape/ape.elf.dbg
|
||||
@$(COMPILE) -AOBJBINCOPY -w build/bootstrap/objbincopy.com -fm -o $@ $<
|
||||
|
||||
APE_LOADER_LDFLAGS = \
|
||||
-static \
|
||||
-nostdlib \
|
||||
--no-dynamic-linker \
|
||||
-z separate-code \
|
||||
-z common-page-size=0x1000 \
|
||||
-z max-page-size=0x10000
|
||||
|
||||
o/$(MODE)/ape/ape.elf.dbg: \
|
||||
o/$(MODE)/ape/loader-macho.o \
|
||||
o/$(MODE)/ape/start.o \
|
||||
o/$(MODE)/ape/loader.o \
|
||||
o/$(MODE)/ape/launch.o \
|
||||
o/$(MODE)/ape/systemcall.o \
|
||||
ape/loader.lds
|
||||
@$(COMPILE) -ALINK.elf $(LD) $(APE_LOADER_LDFLAGS) -o $@ $(patsubst %.lds,-T %.lds,$^)
|
||||
|
||||
.PHONY: o/$(MODE)/ape
|
||||
o/$(MODE)/ape: $(APE_CHECKS) \
|
||||
o/$(MODE)/ape/ape.o \
|
||||
o/$(MODE)/ape/ape.lds \
|
||||
o/$(MODE)/ape/ape.elf \
|
||||
o/$(MODE)/ape/ape.macho \
|
||||
o/$(MODE)/ape/ape-copy-self.o \
|
||||
o/$(MODE)/ape/ape-no-modify-self.o
|
||||
|
||||
endif
|
||||
|
||||
# these assembly files are safe to build on aarch64
|
||||
o/$(MODE)/ape/ape.o: ape/ape.S
|
||||
@$(COMPILE) -AOBJECTIFY.S $(OBJECTIFY.S) $(OUTPUT_OPTION) -c $<
|
||||
|
||||
o/$(MODE)/ape/ape.o: \
|
||||
ape/blink-linux-aarch64.gz \
|
||||
ape/blink-xnu-aarch64.gz
|
||||
|
||||
o/$(MODE)/ape/ape.lds: \
|
||||
ape/ape.lds \
|
||||
ape/macros.internal.h \
|
||||
ape/relocations.h \
|
||||
ape/ape.internal.h \
|
||||
libc/intrin/bits.h \
|
||||
libc/thread/tls.h \
|
||||
libc/calls/struct/timespec.h \
|
||||
libc/thread/thread.h \
|
||||
libc/dce.h \
|
||||
libc/elf/def.h \
|
||||
libc/elf/pf2prot.internal.h \
|
||||
libc/macros.internal.h \
|
||||
libc/nt/pedef.internal.h \
|
||||
libc/str/str.h \
|
||||
libc/zip.internal.h
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../bin/ape-install
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../bin/ape-uninstall
|
||||
Binary file not shown.
Executable
BIN
Binary file not shown.
+49
-45
@@ -31,80 +31,84 @@
|
||||
// @see libc/nt/master.sh
|
||||
// @see ape/ape.lds
|
||||
// @see winimp
|
||||
.macro .imp dll:req fn:req actual:req hint
|
||||
.dll \dll
|
||||
.section .piro.data.sort.iat.2.\dll\().2.\actual,"aw",@progbits
|
||||
.macro .imp dll:req fn:req actual:req
|
||||
#ifdef __x86_64__
|
||||
.dll "\dll"
|
||||
.section ".piro.data.sort.iat.2.\dll\().2.\actual","aw",@progbits
|
||||
.type \fn,@object
|
||||
.align __SIZEOF_POINTER__
|
||||
\fn: .quad RVA((\dll\().\actual))
|
||||
\fn: .quad RVA(("\dll\().\actual"))
|
||||
.size \fn,.-\fn
|
||||
.globl \fn
|
||||
.hidden \fn
|
||||
.previous
|
||||
.section .idata.ro.ilt.\dll\().2.\actual,"a",@progbits
|
||||
.Lidata.ilt.\dll\().\actual:
|
||||
.quad RVA((\dll\().\actual))
|
||||
.type .Lidata.ilt.\dll\().\actual,@object
|
||||
.size .Lidata.ilt.\dll\().\actual,.-.Lidata.ilt.\dll\().\actual
|
||||
.section ".idata.ro.ilt.\dll\().2.\actual","a",@progbits
|
||||
"idata.ilt.\dll\().\actual":
|
||||
.quad RVA("\dll\().\actual")
|
||||
.type "idata.ilt.\dll\().\actual",@object
|
||||
.size "idata.ilt.\dll\().\actual",.-"idata.ilt.\dll\().\actual"
|
||||
.previous
|
||||
.section .idata.ro.hnt.\dll\().2.\actual,"a",@progbits
|
||||
\dll\().\actual:
|
||||
.ifnb \hint # hint i.e. guess function ordinal
|
||||
.short \hint
|
||||
.else
|
||||
.short 0
|
||||
.endif
|
||||
.section ".idata.ro.hnt.\dll\().2.\actual","a",@progbits
|
||||
"\dll\().\actual":
|
||||
.short 0 // hint
|
||||
.asciz "\actual"
|
||||
.align 2 # documented requirement
|
||||
.globl \dll\().\actual
|
||||
.hidden \dll\().\actual
|
||||
.type \dll\().\actual,@object
|
||||
.size \dll\().\actual,.-\dll\().\actual
|
||||
.align 2 // documented requirement
|
||||
.globl "\dll\().\actual"
|
||||
.hidden "\dll\().\actual"
|
||||
.type "\dll\().\actual",@object
|
||||
.size "\dll\().\actual",.-"\dll\().\actual"
|
||||
.previous
|
||||
#else
|
||||
.section ".data.nt.\actual","aw",@progbits
|
||||
.globl "\fn"
|
||||
.balign 8
|
||||
.weak "\actual"
|
||||
"\fn": .quad "\actual"
|
||||
#endif
|
||||
.endm
|
||||
|
||||
// Defines DLL import.
|
||||
// @note this is an implementation detail of .imp
|
||||
.macro .dll name:req
|
||||
.section .idata.ro.idt.2.\name,"aG",@progbits,\name,comdat
|
||||
.equ .Lidata.idt.\name,.
|
||||
.long RVA(idata.ilt.\name) # ImportLookupTable
|
||||
.long 0 # TimeDateStamp
|
||||
.long 0 # ForwarderChain
|
||||
.long RVA(.Lidata.str.\name) # DllNameRva
|
||||
.long RVA(idata.iat.\name) # ImportAddressTable
|
||||
.type .Lidata.idt.\name,@object
|
||||
.size .Lidata.idt.\name,.-.Lidata.idt.\name
|
||||
.section ".idata.ro.idt.2.\name","aG",@progbits,"\name",comdat
|
||||
.equ ".Lidata.idt.\name",.
|
||||
.long RVA("idata.ilt.\name") // ImportLookupTable
|
||||
.long 0 // TimeDateStamp
|
||||
.long 0 // ForwarderChain
|
||||
.long RVA(".Lidata.str.\name") // DllNameRva
|
||||
.long RVA("idata.iat.\name") // ImportAddressTable
|
||||
.type ".Lidata.idt.\name",@object
|
||||
.size ".Lidata.idt.\name",.-".Lidata.idt.\name"
|
||||
.previous
|
||||
.section .idata.ro.ilt.\name\().1,"aG",@progbits,\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.ilt.\name,@object
|
||||
idata.ilt.\name:
|
||||
.section ".idata.ro.ilt.\name\().1","aG",@progbits,"\name",comdat
|
||||
.balign __SIZEOF_POINTER__
|
||||
.type "idata.ilt.\name",@object
|
||||
"idata.ilt.\name":
|
||||
.previous/*
|
||||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .idata.ro.ilt.\name\().3,"aG",@progbits,\name,comdat
|
||||
*/.section ".idata.ro.ilt.\name\().3","aG",@progbits,"\name",comdat
|
||||
.quad 0
|
||||
.previous
|
||||
.section .idata.ro.hnt.\name\().1,"aG",@progbits,\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.hnt.\name,@object
|
||||
.equ idata.hnt.\name,.
|
||||
.section ".idata.ro.hnt.\name\().1","aG",@progbits,"\name",comdat
|
||||
.balign __SIZEOF_POINTER__
|
||||
.type "idata.hnt.\name",@object
|
||||
.equ "idata.hnt.\name",.
|
||||
.previous
|
||||
.section .piro.data.sort.iat.2.\name\().1,"awG",@progbits,\name,comdat
|
||||
.align __SIZEOF_POINTER__
|
||||
.type idata.iat.\name,@object
|
||||
idata.iat.\name:
|
||||
.section ".piro.data.sort.iat.2.\name\().1","awG",@progbits,"\name",comdat
|
||||
.balign __SIZEOF_POINTER__
|
||||
.type "idata.iat.\name",@object
|
||||
"idata.iat.\name":
|
||||
.previous/*
|
||||
...
|
||||
decentralized content
|
||||
...
|
||||
*/.section .piro.data.sort.iat.2.\name\().3,"awG",@progbits,\name,comdat
|
||||
*/.section ".piro.data.sort.iat.2.\name\().3","awG",@progbits,"\name",comdat
|
||||
.quad 0
|
||||
.previous
|
||||
.section .rodata.str1.1,"aSM",@progbits,1
|
||||
.Lidata.str.\name:
|
||||
".Lidata.str.\name":
|
||||
.asciz "\name\().dll"
|
||||
.previous
|
||||
.endm
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Calls _start() function of loaded program.
|
||||
//
|
||||
// When the program entrypoint is called, all registers shall be
|
||||
// cleared, with the exception of (1) %rdi will be equal to %rsp
|
||||
// on FreeBSD and (2) %cl will contain the detected host OS code
|
||||
//
|
||||
// We clear all the general registers we can to have some wiggle
|
||||
// room, to extend the behavior of this loader in the future. We
|
||||
// don't need to clear the XMM registers because your APE loader
|
||||
// should be compiled using gcc/clang's -mgeneral-regs-only flag
|
||||
//
|
||||
// @param rdi is passed through as-is
|
||||
// @param rsi is address of entrypoint (becomes zero)
|
||||
// @param rdx is stack pointer (becomes zero)
|
||||
// @param rcx is passed through as-is
|
||||
// @noreturn
|
||||
Launch:
|
||||
#ifdef __aarch64__
|
||||
|
||||
mov x16,x1
|
||||
mov sp,x2
|
||||
mov x1,0
|
||||
mov x2,0
|
||||
mov x3,0
|
||||
mov x4,0
|
||||
mov x5,0
|
||||
mov x6,0
|
||||
mov x7,0
|
||||
mov x8,0
|
||||
mov x9,0
|
||||
mov x10,0
|
||||
mov x11,0
|
||||
mov x12,0
|
||||
mov x13,0
|
||||
mov x14,0
|
||||
mov x15,0
|
||||
mov x17,0
|
||||
mov x19,0
|
||||
mov x20,0
|
||||
mov x21,0
|
||||
mov x22,0
|
||||
mov x23,0
|
||||
mov x24,0
|
||||
mov x25,0
|
||||
mov x26,0
|
||||
mov x27,0
|
||||
mov x28,0
|
||||
mov x29,0
|
||||
mov x30,0
|
||||
br x16
|
||||
|
||||
#else
|
||||
|
||||
xor %r8d,%r8d
|
||||
xor %r9d,%r9d
|
||||
xor %r10d,%r10d
|
||||
xor %r11d,%r11d
|
||||
xor %r12d,%r12d
|
||||
xor %r13d,%r13d
|
||||
xor %r14d,%r14d
|
||||
xor %r15d,%r15d
|
||||
mov %rdx,%rsp
|
||||
xor %edx,%edx
|
||||
push %rsi
|
||||
xor %esi,%esi
|
||||
xor %ebp,%ebp
|
||||
xor %ebx,%ebx
|
||||
xor %eax,%eax
|
||||
ret
|
||||
|
||||
#endif
|
||||
.endfn Launch,globl
|
||||
@@ -0,0 +1,95 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2021 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macho.internal.h"
|
||||
#include "libc/sysv/consts/prot.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Apple Mach-O Executable Headers
|
||||
// Fixups are applied by objbincopy.com
|
||||
// There must exist a MAC_LC_SEGMENT_64 for every PT_LOAD
|
||||
|
||||
.section .macho,"a",@progbits
|
||||
.balign 64
|
||||
.long 0xFEEDFACE+1
|
||||
.long MAC_CPU_NEXGEN32E
|
||||
.long MAC_CPU_NEXGEN32E_ALL
|
||||
.long MAC_EXECUTE
|
||||
.long 5 // number of load commands
|
||||
.long 60f-10f // size of all load commands
|
||||
.long MAC_NOUNDEFS|MAC_SPLIT_SEGS // flags
|
||||
.long 0 // reserved
|
||||
10: .long MAC_LC_SEGMENT_64
|
||||
.long 20f-10b // unmaps first page dir
|
||||
.ascin "__PAGEZERO",16 // consistent with linux
|
||||
.quad 0,0x200000,0,0 // which forbids mem <2m
|
||||
.long 0,0,0,0
|
||||
20: .long MAC_LC_SEGMENT_64
|
||||
.long 30f-20b
|
||||
.ascin "__TEXT",16
|
||||
.quad 0 // vaddr
|
||||
.quad 0 // memsz
|
||||
.quad 0 // file offset
|
||||
.quad 0 // file size
|
||||
.long 0 // maxprot
|
||||
.long 0 // initprot
|
||||
.long 0 // segment section count
|
||||
.long 0 // flags
|
||||
30: .long MAC_LC_SEGMENT_64
|
||||
.long 40f-30b
|
||||
.ascin "__RODATA",16
|
||||
.quad 0 // vaddr
|
||||
.quad 0 // memsz
|
||||
.quad 0 // file offset
|
||||
.quad 0 // file size
|
||||
.long 0 // maxprot
|
||||
.long 0 // initprot
|
||||
.long 0 // segment section count
|
||||
.long 0 // flags
|
||||
40: .long MAC_LC_UUID
|
||||
.long 50f-40b
|
||||
.quad 0x4527148ba7a513ef // uuid1
|
||||
.quad 0x56fa865940665e8f // uuid2
|
||||
50: .long MAC_LC_UNIXTHREAD
|
||||
.long 60f-50b // cmdsize
|
||||
.long MAC_THREAD_NEXGEN32E // flavaflav
|
||||
.long (520f-510f)/4 // count
|
||||
510: .quad 0 // rax
|
||||
.quad 0 // rbx
|
||||
.quad 0 // rcx
|
||||
.quad 0 // rdx
|
||||
.quad 0 // rdi
|
||||
.quad 0 // rsi
|
||||
.quad 0 // rbp
|
||||
.quad 0 // rsp
|
||||
.quad 0 // r8
|
||||
.quad 0 // r9
|
||||
.quad 0 // r10
|
||||
.quad 0 // r11
|
||||
.quad 0 // r12
|
||||
.quad 0 // r13
|
||||
.quad 0 // r14
|
||||
.quad 0 // r15
|
||||
.quad XnuEntrypoint // rip
|
||||
.quad 0 // rflags
|
||||
.quad 0 // cs
|
||||
.quad 0 // fs
|
||||
.quad 0 // gs
|
||||
520:
|
||||
60:
|
||||
+1083
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,95 @@
|
||||
/*-*- mode: ld-script; indent-tabs-mode: nil; tab-width: 2; coding: utf-8 -*-│
|
||||
│vi: set et sts=2 tw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
|
||||
ENTRY(ElfEntrypoint)
|
||||
|
||||
PHDRS {
|
||||
text PT_LOAD FLAGS(1) FILEHDR PHDRS; /* PF_X */
|
||||
rodata PT_LOAD FLAGS(4); /* PF_R */
|
||||
stack PT_GNU_STACK FLAGS(6); /* PF_W|PF_R */
|
||||
note PT_NOTE FLAGS(4); /* PF_R */
|
||||
}
|
||||
|
||||
SECTIONS {
|
||||
|
||||
. = SEGMENT_START("text-segment", 0x7f000000);
|
||||
__executable_start = .;
|
||||
. += SIZEOF_HEADERS;
|
||||
|
||||
.macho : {
|
||||
KEEP(*(.macho))
|
||||
} :text
|
||||
|
||||
.note : {
|
||||
KEEP(*(.note))
|
||||
} :text :note
|
||||
|
||||
.text : {
|
||||
*(.text .text.* .gnu.linkonce.t.*)
|
||||
} :text
|
||||
|
||||
.rodata ALIGN(CONSTANT(COMMONPAGESIZE)) : {
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
} :rodata
|
||||
|
||||
.stack : {
|
||||
*(.stack)
|
||||
} :stack
|
||||
|
||||
_end = .;
|
||||
|
||||
.stab 0 : { *(.stab) }
|
||||
.stabstr 0 : { *(.stabstr) }
|
||||
.stab.excl 0 : { *(.stab.excl) }
|
||||
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||
.stab.index 0 : { *(.stab.index) }
|
||||
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||
.gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
|
||||
.debug 0 : { *(.debug) }
|
||||
.line 0 : { *(.line) }
|
||||
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||
.debug_aranges 0 : { *(.debug_aranges) }
|
||||
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||
.debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
|
||||
.debug_frame 0 : { *(.debug_frame) }
|
||||
.debug_str 0 : { *(.debug_str) }
|
||||
.debug_loc 0 : { *(.debug_loc) }
|
||||
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||
.debug_typenames 0 : { *(.debug_typenames) }
|
||||
.debug_varnames 0 : { *(.debug_varnames) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.debug_ranges 0 : { *(.debug_ranges) }
|
||||
.debug_macro 0 : { *(.debug_macro) }
|
||||
.debug_addr 0 : { *(.debug_addr) }
|
||||
.debug_loclists 0 : { *(.debug_loclists) }
|
||||
.debug_rnglists 0 : { *(.debug_rnglists) }
|
||||
.debug_line_str 0 : { *(.debug_line_str) }
|
||||
.debug_extra 0 : { *(.debug_line_str) }
|
||||
.debug_pubtypes 0 : { *(.debug_pubtypes) }
|
||||
.gnu.attributes 0 : { KEEP(*(.gnu.attributes)) }
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.*)
|
||||
}
|
||||
}
|
||||
+66
-38
@@ -54,7 +54,7 @@
|
||||
jmp 297f
|
||||
.byte 0xbf # mov $0x????xxxx,%edi
|
||||
.long \address
|
||||
297:
|
||||
297:
|
||||
.endm
|
||||
|
||||
// Loads 16-bit CONSTEXPR into Qw-register w/ optional zero-extend.
|
||||
@@ -180,6 +180,20 @@
|
||||
.stub \name\()_bcs\n,long
|
||||
.endm
|
||||
|
||||
// Task State Segment Descriptor Entries.
|
||||
.macro .tssdescstub name:req
|
||||
.ifndef \name
|
||||
.weak \name
|
||||
.set \name,0
|
||||
.endif
|
||||
.ifndef \name\()_end
|
||||
.weak \name\()_end
|
||||
.set \name\()_end,0
|
||||
.endif
|
||||
.stub \name\()_desc_ent0,quad
|
||||
.stub \name\()_desc_ent1,quad
|
||||
.endm
|
||||
|
||||
/* clang-format on */
|
||||
#elif defined(__LINKER__)
|
||||
|
||||
@@ -221,44 +235,58 @@
|
||||
/**
|
||||
* Binary coded decimal support.
|
||||
*
|
||||
* <p>This allows linker scripts to generate dd commands. Leading spaces
|
||||
* need to be inserted so Mac doesn't consider them octal; therefore,
|
||||
* parameters must be quoted; and eight digits should be good enough.
|
||||
* <p>This allows linker scripts to generate dd commands, e.g. ape.lds.
|
||||
* There are a few ways to pad each number to the necessary 8 bytes.
|
||||
* Spaces cannot be prepended because busybox refuses to parse them.
|
||||
* Zeros cannot be prepended because Mac will take numbers as octal.
|
||||
* That leaves appending spaces. The user's shell ought to treat any
|
||||
* unquoted run of spaces as if there was only one, so this is safe.
|
||||
*/
|
||||
#define SHSTUB2(SYM, X) \
|
||||
HIDDEN(SYM##_bcs0 = BCD10K(X)); \
|
||||
HIDDEN(SYM##_bcs1 = BCD(X))
|
||||
#define BCD(X) \
|
||||
((X) == 0 \
|
||||
? 0x20202030 \
|
||||
: (X) < 10 ? 0x30202020 + (((X) % 10) << 24) \
|
||||
: (X) < 100 ? 0x30302020 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) \
|
||||
: (X) < 1000 ? 0x30303020 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) + \
|
||||
(((X) / 100 % 10) << 8) \
|
||||
: 0x30303030 + (((X) % 10) << 24) + \
|
||||
(((X) / 10 % 10) << 16) + \
|
||||
(((X) / 100 % 10) << 8) + \
|
||||
(((X) / 1000 % 10) << 0))
|
||||
#define BCD10K(X) \
|
||||
((X) < 10000 \
|
||||
? 0x20202020 \
|
||||
: (X) < 100000 \
|
||||
? 0x30202020 + (((X) / 10000 % 10) << 24) \
|
||||
: (X) < 1000000 \
|
||||
? 0x30302020 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) \
|
||||
: (X) < 10000000 \
|
||||
? 0x30303020 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) + \
|
||||
(((X) / 1000000 % 10) << 8) \
|
||||
: (X) < 100000000 \
|
||||
? 0x30303030 + (((X) / 10000 % 10) << 24) + \
|
||||
(((X) / 100000 % 10) << 16) + \
|
||||
(((X) / 1000000 % 10) << 8) + \
|
||||
(((X) / 10000000 % 10) << 0) \
|
||||
: 0xffffffffffffffff)
|
||||
#define SHSTUB2(SYM, X) \
|
||||
HIDDEN(SYM##_bcs0 = BCD_LEFT(X)); \
|
||||
HIDDEN(SYM##_bcs1 = BCD_RIGHT(X))
|
||||
#define BCD_SMEAR(X) ((X) + (X) * 10000)
|
||||
#define BCD_LEFT(X) \
|
||||
(((X)) < 10000 ? BCD_RIGHT(BCD_SMEAR(X)) | 0x10 \
|
||||
: (X) < 100000 ? BCD_RIGHT(BCD_SMEAR((X) / 10)) \
|
||||
: (X) < 1000000 ? BCD_RIGHT(BCD_SMEAR((X) / 100)) \
|
||||
: (X) < 10000000 ? BCD_RIGHT(BCD_SMEAR((X) / 1000)) \
|
||||
: (X) < 100000000 ? BCD_RIGHT(BCD_SMEAR((X) / 10000)) \
|
||||
: 0xffffffffffffffff)
|
||||
#define BCD_RIGHT(X) \
|
||||
(((X)) < 10000 ? 0x20202020 \
|
||||
: (X) < 100000 ? 0x20202030 + \
|
||||
(X) % 10 \
|
||||
: (X) < 1000000 ? 0x20203030 + \
|
||||
((X) / 10) % 10 + \
|
||||
(X) % 10 * 0x100 \
|
||||
: (X) < 10000000 ? 0x20303030 + \
|
||||
((X) / 100) % 10 + \
|
||||
((X) / 10) % 10 * 0x100 + \
|
||||
(X) % 10 * 0x10000 \
|
||||
: (X) < 100000000 ? 0x30303030 + \
|
||||
((X) / 1000) % 10 + \
|
||||
((X) / 100) % 10 * 0x100 + \
|
||||
((X) / 10) % 10 * 0x10000 + \
|
||||
(X) % 10 * 0x1000000 \
|
||||
: 0xffffffffffffffff)
|
||||
|
||||
/**
|
||||
* Laying out the GDT entries for a TSS for bare metal operation.
|
||||
*/
|
||||
#define TSSDESCSTUB2(SYM, BASE, LIM) \
|
||||
HIDDEN(SYM##_desc_ent0 = TSSDESC_ENT0(BASE, LIM)); \
|
||||
HIDDEN(SYM##_desc_ent1 = TSSDESC_ENT1(BASE)); \
|
||||
ASSERT((LIM) >= 0 && (LIM) <= 0xffff, "bare metal TSS is suspiciously fat")
|
||||
#define TSSDESC_ENT0(BASE, LIM) \
|
||||
(((LIM) << 0 & 0x000000000000ffff) | \
|
||||
((BASE) << 16 & 0x000000ffffff0000) | \
|
||||
0x89 << 40 | \
|
||||
((LIM) >> 16 << 48 & 0x000f000000000000) | \
|
||||
0x2 << 52 | \
|
||||
((BASE) >> 24 << 56 & 0xff00000000000000))
|
||||
#define TSSDESC_ENT1(BASE) \
|
||||
((BASE) >> 32 << 0 & 0x00000000ffffffff)
|
||||
|
||||
#endif /* __ASSEMBLER__ */
|
||||
#endif /* APE_MACROS_H_ */
|
||||
@@ -0,0 +1 @@
|
||||
#include "ape/ape.lds"
|
||||
+2
-2
@@ -36,8 +36,8 @@
|
||||
*/
|
||||
#define REAL(x) ((x) - (IMAGE_BASE_VIRTUAL - IMAGE_BASE_REAL))
|
||||
|
||||
#if IMAGE_BASE_VIRTUAL % 0x200000 != 0
|
||||
#error "IMAGE_BASE_VIRTUAL must be 2mb aligned"
|
||||
#if IMAGE_BASE_VIRTUAL % 0x1000 != 0
|
||||
#error "IMAGE_BASE_VIRTUAL must be 4kb aligned"
|
||||
#endif
|
||||
#if IMAGE_BASE_PHYSICAL % 0x1000 != 0
|
||||
#error "IMAGE_BASE_PHYSICAL must be 4kb aligned"
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef COSMOPOLITAN_APE_SECTIONS_INTERNAL_H_
|
||||
#define COSMOPOLITAN_APE_SECTIONS_INTERNAL_H_
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
extern const char __comment_start[] __attribute__((__weak__));
|
||||
extern unsigned char __executable_start[] __attribute__((__weak__));
|
||||
extern unsigned char __privileged_start[] __attribute__((__weak__));
|
||||
extern unsigned char _ehead[] __attribute__((__weak__));
|
||||
extern unsigned char _etext[] __attribute__((__weak__));
|
||||
extern unsigned char _edata[] __attribute__((__weak__));
|
||||
extern unsigned char _ezip[] __attribute__((__weak__));
|
||||
extern unsigned char _end[] __attribute__((__weak__));
|
||||
extern unsigned char _ereal[] __attribute__((__weak__));
|
||||
extern unsigned char _tdata_start[] __attribute__((__weak__));
|
||||
extern unsigned char _tdata_end[] __attribute__((__weak__));
|
||||
extern unsigned char _tbss_start[] __attribute__((__weak__));
|
||||
extern unsigned char _tbss_end[] __attribute__((__weak__));
|
||||
extern unsigned char _tls_align[] __attribute__((__weak__));
|
||||
extern unsigned char __test_start[] __attribute__((__weak__));
|
||||
extern unsigned char __ro[] __attribute__((__weak__));
|
||||
extern uint8_t __data_start[] __attribute__((__weak__));
|
||||
extern uint8_t __data_end[] __attribute__((__weak__));
|
||||
extern uint8_t __bss_start[] __attribute__((__weak__));
|
||||
extern uint8_t __bss_end[] __attribute__((__weak__));
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_APE_SECTIONS_INTERNAL_H_ */
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "ape/ape.h"
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
#ifdef __aarch64__
|
||||
|
||||
_start: mov x1,sp
|
||||
mov x29,0
|
||||
bl ApeLoader
|
||||
.endfn _start,globl
|
||||
|
||||
#else
|
||||
|
||||
XnuEntrypoint:
|
||||
mov $_HOSTXNU,%dl // xnu's not unix!
|
||||
ElfEntrypoint:
|
||||
mov %rsp,%rsi // save real stack
|
||||
call ApeLoader
|
||||
.endfn ElfEntrypoint,globl
|
||||
.endfn XnuEntrypoint,globl
|
||||
|
||||
.section .note,"a",@progbits
|
||||
.balign 4
|
||||
openbsd.ident:
|
||||
.long 2f-1f
|
||||
.long 4f-3f
|
||||
.long 1
|
||||
1: .asciz "OpenBSD"
|
||||
2: .balign 4
|
||||
3: .long 0
|
||||
4: .size openbsd.ident,.-openbsd.ident
|
||||
.type openbsd.ident,@object
|
||||
.balign 4
|
||||
netbsd.ident:
|
||||
.long 2f-1f
|
||||
.long 4f-3f
|
||||
.long 1
|
||||
1: .asciz "NetBSD"
|
||||
2: .balign 4
|
||||
3: .long 901000000
|
||||
4: .size netbsd.ident,.-netbsd.ident
|
||||
.type netbsd.ident,@object
|
||||
.balign 4
|
||||
ape.ident:
|
||||
.long 2f-1f
|
||||
.long 4f-3f
|
||||
.long 1
|
||||
1: .asciz "APE"
|
||||
2: .balign 4
|
||||
3: .long APE_VERSION_NOTE
|
||||
4: .size ape.ident,.-ape.ident
|
||||
.type ape.ident,@object
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,49 @@
|
||||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2023 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
// Invokes system call.
|
||||
//
|
||||
// This function has eight parameters. The first seven are for
|
||||
// arguments passed along to the system call. The eight is for
|
||||
// the magic number that indicates which system call is called
|
||||
//
|
||||
// The return value follows the Linux kernel convention, where
|
||||
// errors are returned as `-errno`. BSD systems are normalized
|
||||
// to follow this convention automatically.
|
||||
SystemCall:
|
||||
#ifdef __aarch64__
|
||||
mov x8,x7
|
||||
mov x9,0
|
||||
adds x9,x9,0
|
||||
svc 0
|
||||
bcs 1f
|
||||
ret
|
||||
1: neg x0,x0
|
||||
ret
|
||||
#else
|
||||
mov %rcx,%r10
|
||||
mov 16(%rsp),%eax
|
||||
clc
|
||||
syscall
|
||||
jnc 1f
|
||||
neg %rax
|
||||
1: ret
|
||||
#endif
|
||||
.endfn SystemCall,globl
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-${m:-aarch64}}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos/aarch64}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-addr2line"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: aarch64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
+1
@@ -0,0 +1 @@
|
||||
apecopy
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
PROG=${0##*/}
|
||||
MODE=${MODE:-${m:-aarch64}}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
|
||||
fatal_error() {
|
||||
echo "$PROG: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
if [ ! -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-ar" ]; then
|
||||
fatal_error "you need to run: aarch64-unknown-cosmo-cc --update"
|
||||
fi
|
||||
|
||||
exec "$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-ar" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-${m:-aarch64}}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos/aarch64}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-as"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: aarch64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
cosmocc
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
cosmocc
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
FIRST=1
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ x"$x" = x"-s" ]; then
|
||||
continue
|
||||
fi
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
exec install "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-${m:-aarch64}}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos/aarch64}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-nm"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: aarch64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-${m:-aarch64}}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos/aarch64}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-objcopy"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: aarch64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-${m:-aarch64}}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos/aarch64}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-objdump"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: aarch64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-${m:-aarch64}}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos/aarch64}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/aarch64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-strip"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: aarch64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
+134
@@ -0,0 +1,134 @@
|
||||
#!/bin/sh
|
||||
|
||||
PROG=${0##*/}
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ ! -f ape/loader.c ]; then
|
||||
cd "$COSMO" || exit
|
||||
fi
|
||||
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
SUDO=
|
||||
else
|
||||
SUDO=sudo
|
||||
fi
|
||||
|
||||
echo "Actually Portable Executable (APE) Installer" >&2
|
||||
echo "Author: Justine Tunney <[email protected]>" >&2
|
||||
|
||||
################################################################################
|
||||
# INSTALL APE LOADER SYSTEMWIDE
|
||||
|
||||
if [ -f o/depend ] && make -j8 o//ape; then
|
||||
echo "successfully recompiled ape loader" >&2
|
||||
elif [ -x o//ape/ape.elf ] && [ -x o//ape/ape.macho ]; then
|
||||
echo "using ape loader you compiled earlier" >&2
|
||||
elif [ -d build/bootstrap ]; then
|
||||
# if make isn't being used then it's unlikely the user changed the sources
|
||||
# in that case the prebuilt binaries should be completely up-to-date
|
||||
echo "using prebuilt ape loader from cosmo repo" >&2
|
||||
mkdir -p o//ape || exit
|
||||
cp -af build/bootstrap/ape.elf o//ape/ape.elf || exit
|
||||
cp -af build/bootstrap/ape.macho o//ape/ape.macho || exit
|
||||
else
|
||||
echo "no cosmopolitan libc repository here" >&2
|
||||
echo "fetching ape loader from justine.lol" >&2
|
||||
mkdir -p o//ape || exit
|
||||
if command -v wget >/dev/null 2>&1; then
|
||||
wget -qO o//ape/ape.elf https://justine.lol/ape.elf || exit
|
||||
wget -qO o//ape/ape.macho https://justine.lol/ape.macho || exit
|
||||
else
|
||||
curl -Rso o//ape/ape.elf https://justine.lol/ape.elf || exit
|
||||
curl -Rso o//ape/ape.macho https://justine.lol/ape.macho || exit
|
||||
fi
|
||||
chmod +x o//ape/ape.elf || exit
|
||||
chmod +x o//ape/ape.macho || exit
|
||||
fi
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
if ! [ /usr/bin/ape -nt o//ape/ape.macho ]; then
|
||||
echo >&2
|
||||
echo "installing o//ape/ape.elf to /usr/bin/ape" >&2
|
||||
echo "$SUDO mv -f o//ape/ape.elf /usr/bin/ape" >&2
|
||||
$SUDO cp -f o//ape/ape.macho /usr/bin/ape || exit
|
||||
echo "done" >&2
|
||||
fi
|
||||
else
|
||||
if ! [ /usr/bin/ape -nt o//ape/ape.elf ]; then
|
||||
echo >&2
|
||||
echo "installing o//ape/ape.elf to /usr/bin/ape" >&2
|
||||
echo "$SUDO mv -f o//ape/ape.elf /usr/bin/ape" >&2
|
||||
$SUDO cp -f o//ape/ape.elf /usr/bin/ape || exit
|
||||
echo "done" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
# REGISTER APE LOADER WITH BINFMT_MISC TOO (LINUX-ONLY)
|
||||
|
||||
if [ x"$(uname -s)" = xLinux ]; then
|
||||
|
||||
if [ -e /proc/sys/fs/binfmt_misc/APE ]; then
|
||||
echo >&2
|
||||
echo it looks like APE is already registered with binfmt_misc >&2
|
||||
echo To reinstall please run ape/apeuninstall.sh first >&2
|
||||
echo please check that it is mapped to ape not /bin/sh >&2
|
||||
echo cat /proc/sys/fs/binfmt_misc/APE >&2
|
||||
cat /proc/sys/fs/binfmt_misc/APE >&2
|
||||
exit
|
||||
fi
|
||||
|
||||
if ! [ -e /proc/sys/fs/binfmt_misc ]; then
|
||||
echo >&2
|
||||
echo loading binfmt_misc into your kernel >&2
|
||||
echo you may need to edit configs to persist across reboot >&2
|
||||
echo $SUDO modprobe binfmt_misc >&2
|
||||
$SUDO modprobe binfmt_misc || exit
|
||||
echo done >&2
|
||||
fi
|
||||
|
||||
if ! [ -e /proc/sys/fs/binfmt_misc/register ]; then
|
||||
echo >&2
|
||||
echo mounting binfmt_misc into your kernel >&2
|
||||
echo you may need to edit configs to persist across reboot >&2
|
||||
echo $SUDO mount -t binfmt_misc none /proc/sys/fs/binfmt_misc >&2
|
||||
$SUDO mount -t binfmt_misc none /proc/sys/fs/binfmt_misc || exit
|
||||
echo done >&2
|
||||
fi
|
||||
|
||||
echo >&2
|
||||
echo registering APE with binfmt_misc >&2
|
||||
echo you may need to edit configs to persist across reboot >&2
|
||||
echo '$SUDO sh -c "echo '"'"':APE:M::MZqFpD::/usr/bin/ape:'"'"' >/proc/sys/fs/binfmt_misc/register"' >&2
|
||||
$SUDO sh -c "echo ':APE:M::MZqFpD::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register" || exit
|
||||
echo '$SUDO sh -c "echo '"'"':APE-jart:M::jartsr::/usr/bin/ape:'"'"' >/proc/sys/fs/binfmt_misc/register"' >&2
|
||||
$SUDO sh -c "echo ':APE-jart:M::jartsr::/usr/bin/ape:' >/proc/sys/fs/binfmt_misc/register" || exit
|
||||
echo done >&2
|
||||
|
||||
if [ x"$(cat /proc/sys/fs/binfmt_misc/status)" = xdisabled ]; then
|
||||
echo >&2
|
||||
echo enabling binfmt_misc >&2
|
||||
echo you may need to edit configs to persist across reboot >&2
|
||||
echo $SUDO sh -c 'echo 1 >/proc/sys/fs/binfmt_misc/status' >&2
|
||||
$SUDO sh -c 'echo 1 >/proc/sys/fs/binfmt_misc/status' || exit
|
||||
echo done >&2
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
|
||||
{
|
||||
echo
|
||||
echo "------------------------------------------------------------------"
|
||||
echo
|
||||
echo "APE INSTALL COMPLETE"
|
||||
echo
|
||||
echo "If you decide to uninstall APE later on"
|
||||
echo "you may do so using ape/apeuninstall.sh"
|
||||
echo
|
||||
echo "Enjoy your APE loader (>'.')>"
|
||||
echo
|
||||
} >&2
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
|
||||
PROG=${0##*/}
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ ! -f ape/loader.c ]; then
|
||||
cd "$COSMO" || exit
|
||||
fi
|
||||
|
||||
if [ "$UID" = "0" ]; then
|
||||
SUDO=
|
||||
else
|
||||
SUDO=sudo
|
||||
fi
|
||||
|
||||
{
|
||||
echo
|
||||
echo "APE Uninstaller intends to run (in pseudo-shell)"
|
||||
echo
|
||||
echo " sudo echo -1 into /proc/sys/fs/binfmt_misc/APE*"
|
||||
echo " sudo rm -f /usr/bin/ape ~/.ape /tmp/.ape # etc."
|
||||
echo
|
||||
echo "You may then use ape/apeinstall.sh to reinstall it"
|
||||
echo
|
||||
} >&2
|
||||
|
||||
set -ex
|
||||
for f in /proc/sys/fs/binfmt_misc/APE*; do
|
||||
if [ -f $f ]; then
|
||||
$SUDO sh -c "echo -1 >$f" || exit
|
||||
fi
|
||||
done
|
||||
|
||||
# system installation
|
||||
if [ -f /usr/bin/ape ]; then
|
||||
$SUDO rm -f /usr/bin/ape
|
||||
fi
|
||||
|
||||
# legacy installations
|
||||
rm -f o/tmp/ape /tmp/ape "${TMPDIR:-/tmp}/ape"
|
||||
|
||||
# ad-hoc installations
|
||||
for x in .ape \
|
||||
.ape-1.1 \
|
||||
.ape-1.3 \
|
||||
.ape-1.4 \
|
||||
.ape-1.5 \
|
||||
.ape-1.6 \
|
||||
.ape-1.7 \
|
||||
.ape-1.8 \
|
||||
.ape-blink-0.9.2 \
|
||||
.ape-blink-1.0.0; do
|
||||
rm -f \
|
||||
~/$x \
|
||||
/tmp/$x \
|
||||
o/tmp/$x \
|
||||
"${TMPDIR:-/tmp}/$x"
|
||||
done
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/sh
|
||||
PROG=${0##*/}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
|
||||
if [ x"$1" = x"--version" ]; then
|
||||
cat <<EOF
|
||||
$PROG 0.1
|
||||
Copyright (c) 2023 Justine Alexandra Roberts Tunney
|
||||
Cosmopolitan Libc and LLVM libcxx/compiler-rt are subject to non-GPL
|
||||
notice licenses, e.g. ISC, MIT, etc. Your compiled programs must embed
|
||||
our copyright notices. This toolchain is configured to do so default.
|
||||
Cosmopolitan comes with absolutely NO WARRANTY of any kind.
|
||||
For more information, see the Cosmopolitan LICENSE files.
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
This launches GNU GCC/Binutils subprocesses, which is free software; see
|
||||
Cosmopolitan's third_party/gcc/ for source code and copying conditions.
|
||||
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ x"$1" = x"--help" ]; then
|
||||
cat <<EOF
|
||||
Usage: $PROG INPUT OUTPUT
|
||||
Converts an executable linked by cosmocc to the Actually Portable
|
||||
Executable file format. See $PROG --version for other details.
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
|
||||
fatal_error() {
|
||||
echo "$PROG: fatal error: $1" >&2
|
||||
echo "operation terminated." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
CROSS=1
|
||||
ARCH=${PROG%%-*} # split(prog, '-')[0]
|
||||
if [ x"$ARCH" = x"$PROG" ]; then
|
||||
ARCH=x86_64
|
||||
CROSS=0
|
||||
fi
|
||||
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
MODE=${MODE:-$m}
|
||||
else
|
||||
MODE=${MODE:-${m:-$ARCH}}
|
||||
fi
|
||||
|
||||
if [ $CROSS -eq 0 ]; then
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
else
|
||||
COSMOS=${COSMOS:-/opt/cosmos/$ARCH}
|
||||
fi
|
||||
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
OBJCOPYFLAGS="-S -O binary"
|
||||
elif [ x"$ARCH" = x"aarch64" ]; then
|
||||
OBJCOPYFLAGS="-S"
|
||||
else
|
||||
fatal_error "$ARCH: unsupported architecture"
|
||||
fi
|
||||
|
||||
if [ ! -d "$COSMO" ]; then
|
||||
fatal_error "you need to clone cosmopolitan to your $COSMO directory"
|
||||
fi
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
if [ ! -f "$COSMO/o//tool/build/zipcopy.com" ] ||
|
||||
[ ! -f "$COSMO/o/third_party/gcc/bin/$ARCH-linux-$BRAND-objcopy" ]; then
|
||||
if [ $CROSS -eq 0 ]; then
|
||||
fatal_error "you need to run: cosmocc --update"
|
||||
else
|
||||
fatal_error "you need to run: $ARCH-unknown-cosmo-cosmocc --update"
|
||||
fi
|
||||
fi
|
||||
|
||||
INPUT=$1
|
||||
OUTPUT=$2
|
||||
if [ ! -f "$INPUT" ]; then
|
||||
fatal_error "$INPUT: missing input and output arguments"
|
||||
elif [ ! -f "$INPUT" ]; then
|
||||
fatal_error "$INPUT: no such file"
|
||||
elif [ ! -f "$INPUT" ]; then
|
||||
fatal_error "$INPUT: missing output argument"
|
||||
elif [ x"$INPUT" = x"$OUTPUT" ]; then
|
||||
fatal_error "$INPUT: input and output file can't be the same"
|
||||
fi
|
||||
|
||||
"$COSMO/o/third_party/gcc/bin/$ARCH-linux-$BRAND-objcopy" \
|
||||
$OBJCOPYFLAGS \
|
||||
"$INPUT" \
|
||||
"$OUTPUT" || exit
|
||||
"$COSMO/o//tool/build/zipcopy.com" \
|
||||
"$INPUT" \
|
||||
"$OUTPUT" || exit
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
exec "$COSMO/o//tool/build/apelink.com" "$@"
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
|
||||
set -- -apifCe "$@"
|
||||
|
||||
if [ -n "$ADDR2LINE" ]; then
|
||||
exec "$ADDR2LINE" "$@"
|
||||
fi
|
||||
|
||||
find_addr2line() {
|
||||
if [ -x o/third_party/gcc/bin/$1-linux-cosmo-addr2line ]; then
|
||||
ADDR2LINE=o/third_party/gcc/bin/$1-linux-cosmo-addr2line
|
||||
elif [ -x o/third_party/gcc/bin/$1-linux-musl-addr2line ]; then
|
||||
ADDR2LINE=o/third_party/gcc/bin/$1-linux-musl-addr2line
|
||||
elif [ -x "$COSMO/o/third_party/gcc/bin/$1-linux-cosmo-addr2line" ]; then
|
||||
ADDR2LINE="$COSMO/o/third_party/gcc/bin/$1-linux-cosmo-addr2line"
|
||||
elif [ -x "$COSMO/o/third_party/gcc/bin/$1-linux-musl-addr2line" ]; then
|
||||
ADDR2LINE="$COSMO/o/third_party/gcc/bin/$1-linux-musl-addr2line"
|
||||
else
|
||||
echo "error: toolchain not found (try running 'cosmocc --update' or 'make' in the cosmo monorepo)" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
for ARCH in x86_64 aarch64; do
|
||||
find_addr2line $ARCH
|
||||
"$ADDR2LINE" "$@" 2>/dev/null && exit
|
||||
done
|
||||
|
||||
echo "error: addr2line failed" >&2
|
||||
exit 1
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
cosmocc
|
||||
Executable
+381
@@ -0,0 +1,381 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# cosmopolitan c/c++ compiler
|
||||
#
|
||||
# getting started
|
||||
#
|
||||
# sudo chmod 1777 /opt # sticky bit isn't required
|
||||
# git clone https://github.com/jart/cosmopolitan /opt/cosmo
|
||||
# export PATH="/opt/cosmo/bin:/opt/cosmos/bin:$PATH"
|
||||
# echo 'export PATH="/opt/cosmo/bin:/opt/cosmos/bin:$PATH"' >>~/.profile
|
||||
# ape-install # optionally install a faster systemwide ape loader
|
||||
# cosmocc --update # pull and rebuild toolchain artifacts
|
||||
#
|
||||
# getting started synopsis
|
||||
#
|
||||
# cosmocc -o hello.com hello.c
|
||||
# ./foo.com
|
||||
# ./foo.com --strace
|
||||
# ./foo.com --ftrace
|
||||
#
|
||||
# how to build a project like lua 5.4.6
|
||||
#
|
||||
# make all test CC=cosmocc
|
||||
# src/lua -e 'print("hi")'
|
||||
# make install INSTALL_TOP=/opt/cosmos
|
||||
# apecopy src/lua src/lua.com # convert to portable ape binary
|
||||
#
|
||||
# how to cross compile a project like lua 5.4.6
|
||||
#
|
||||
# aarch64-unknown-cosmo-cc --update
|
||||
# make clean all test CC=aarch64-unknown-cosmo-cc AR='aarch64-unknown-cosmo-ar rc' -j8
|
||||
# qemu-aarch64 src/lua -e 'print("hi")'
|
||||
# make install INSTALL_TOP=/opt/cosmos/aarch64
|
||||
#
|
||||
# building in tiny mode
|
||||
#
|
||||
# export MODE=tiny
|
||||
# cosmocc --update
|
||||
# cosmocc -Os -o foo.com foo.c
|
||||
#
|
||||
# building in tiniest mode (linux only)
|
||||
#
|
||||
# export MODE=tinylinux
|
||||
# cosmocc --update
|
||||
# cosmocc -Os -o foo.com foo.c
|
||||
#
|
||||
# hardening programs with memory safety
|
||||
#
|
||||
# export MODE=asan
|
||||
# cosmocc --update
|
||||
# cosmocc -o foo.com foo.c
|
||||
#
|
||||
# detecting this environment
|
||||
#
|
||||
# - `__COSMOCC__` is defined when this compiler is in play
|
||||
# - `__COSMOPOLITAN__` is always defined by Cosmopolitan Libc
|
||||
#
|
||||
# some notes on this compiler
|
||||
#
|
||||
# - the underlying compiler itself is gcc
|
||||
# - we use cosmopoiltan libc rather than glibc
|
||||
# - we use llvm's compiler-rt and libcxx runtimes
|
||||
# - we patched gcc so switch case can have symbols
|
||||
# - our scanf() implementation is somewhat troubled
|
||||
#
|
||||
# compiler flags that aren't supported
|
||||
#
|
||||
# - `-r` partial linking not implemented yet (todo)
|
||||
# - `-S` you need to put your assembly behind #ifdefs instead
|
||||
# - `-fexceptions` cosmopolitan doesn't support c++ exceptions yet
|
||||
# - `-frtti` cosmopolitan doesn't support c++ runtime reflection yet
|
||||
# - `-mred-zone` the system v red zone doesn't exist on windows and metal
|
||||
# - `-fpic`, '-fPIC', `-shared`, `-pie`, etc. no shared object support yet
|
||||
# - `-fsanitize=thread` cosmopolitan doesn't have thread sanitizer runtime yet
|
||||
# - `-fomit-frame-pointer` is partially supported (apple forbids full removal)
|
||||
#
|
||||
# for further details, run `man gcc`
|
||||
|
||||
PROG=${0##*/}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
GCC_VERSION=11.2.0
|
||||
|
||||
if [ "$1" = "--version" ]; then
|
||||
cat <<EOF
|
||||
$PROG (GCC) $GCC_VERSION
|
||||
Copyright (c) 2023 Justine Alexandra Roberts Tunney
|
||||
Cosmopolitan Libc and LLVM libcxx/compiler-rt are subject to non-GPL
|
||||
notice licenses, e.g. ISC, MIT, etc. Your compiled programs must embed
|
||||
our copyright notices. This toolchain is configured to do so default.
|
||||
Cosmopolitan comes with absolutely NO WARRANTY of any kind.
|
||||
For more information, see the Cosmopolitan LICENSE files.
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
This launches GNU GCC/Binutils subprocesses, which is free software; see
|
||||
Cosmopolitan's third_party/gcc/ for source code and copying conditions.
|
||||
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
|
||||
fatal_error() {
|
||||
echo "$PROG: fatal error: $1" >&2
|
||||
echo "compilation terminated." >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
log_command() {
|
||||
if [ -n "$BUILDLOG" ]; then
|
||||
printf '# %s\n(cd %s; %s)\n' "$ORIGINAL" "$PWD" "$*" >>"$BUILDLOG"
|
||||
fi
|
||||
}
|
||||
|
||||
ORIGINAL="$0 $*"
|
||||
PLATFORM="-D__COSMOPOLITAN__ -D__COSMOCC__"
|
||||
PREDEF="-include libc/integral/normalize.inc"
|
||||
CFLAGS="-fportcosmo -fno-dwarf2-cfi-asm -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-semantic-interposition"
|
||||
CPPFLAGS="-fno-pie -nostdinc -fno-math-errno -iquote $COSMO"
|
||||
LDFLAGS="-static -no-pie -nostdlib -fuse-ld=bfd"
|
||||
APEFLAGS="-Wl,--gc-sections"
|
||||
PRECIOUS="-fno-omit-frame-pointer"
|
||||
|
||||
CROSS=1
|
||||
ARCH=${PROG%%-*} # split(prog, '-')[0]
|
||||
if [ x"$ARCH" = x"$PROG" ]; then
|
||||
ARCH=x86_64
|
||||
CROSS=0
|
||||
fi
|
||||
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
MODE=${MODE:-$m}
|
||||
else
|
||||
MODE=${MODE:-${m:-$ARCH}}
|
||||
fi
|
||||
|
||||
if [ $CROSS -eq 0 ]; then
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
else
|
||||
COSMOS=${COSMOS:-/opt/cosmos/$ARCH}
|
||||
fi
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
CC="$COSMO/o/third_party/gcc/bin/$ARCH-linux-$BRAND-gcc"
|
||||
CRT="$COSMO/o/$MODE/libc/crt/crt.o"
|
||||
LDLIBS="$COSMO/o/$MODE/cosmopolitan.a"
|
||||
CPPFLAGS="$CPPFLAGS -isystem $COSMOS/include -isystem $COSMO/libc/isystem"
|
||||
LDFLAGS="$LDFLAGS -L$COSMOS/lib"
|
||||
if [ x"$PROG" != x"${PROG%++}" ]; then
|
||||
CC="$COSMO/o/third_party/gcc/bin/$ARCH-linux-$BRAND-g++"
|
||||
CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit"
|
||||
LDLIBS="$COSMO/o/$MODE/third_party/libcxx/libcxx.a $LDLIBS"
|
||||
fi
|
||||
|
||||
PAGESZ=4096
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
OBJCOPYFLAGS="-S -O binary"
|
||||
CRT="$COSMO/o/$MODE/ape/ape-no-modify-self.o $CRT"
|
||||
CPPFLAGS="$CPPFLAGS -mno-red-zone"
|
||||
CFLAGS="$CFLAGS -mno-tls-direct-seg-refs"
|
||||
LDFLAGS="$LDFLAGS -Wl,-T,$COSMO/o/$MODE/ape/ape.lds"
|
||||
if [ x"$MODE" = x"aarch64" ]; then
|
||||
fatal_error '$MODE must not be aarch64 when using x86_64 cross compiler'
|
||||
elif [ x"$MODE" != x"${MODE#* }" ]; then
|
||||
fatal_error '$MODE must not contain hyphens when targeting x86_64'
|
||||
fi
|
||||
elif [ x"$ARCH" = x"aarch64" ]; then
|
||||
OBJCOPYFLAGS="-S"
|
||||
PAGESZ=16384
|
||||
CFLAGS="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
|
||||
LDFLAGS="$LDFLAGS -Wl,-T,$COSMO/o/$MODE/ape/aarch64.lds"
|
||||
if [ x"$MODE" != x"aarch64" ] && [ x"$MODE" = x"${MODE#aarch64-*}" ]; then
|
||||
fatal_error '$MODE must be either "aarch64" or "aarch64-FOO" when using aarch64 cross compiler'
|
||||
fi
|
||||
else
|
||||
fatal_error "$ARCH: unsupported architecture"
|
||||
fi
|
||||
|
||||
LDFLAGS="$LDFLAGS -Wl,-z,common-page-size=$PAGESZ -Wl,-z,max-page-size=16384"
|
||||
|
||||
if [ ! -d "$COSMO" ]; then
|
||||
fatal_error "you need to clone cosmopolitan to your $COSMO directory"
|
||||
fi
|
||||
|
||||
if [ "$1" = "--update" ]; then
|
||||
cd $COSMO || exit
|
||||
echo "building cosmo host toolchain..." >&2
|
||||
make --silent -j toolchain MODE= ARCH=x86_64 || exit
|
||||
echo "building cosmo target (MODE=$MODE) toolchain..." >&2
|
||||
make --silent -j toolchain MODE="$MODE" || exit
|
||||
echo "setting up your cosmos..." >&2
|
||||
mkdir -p "$COSMOS/lib" || exit
|
||||
for lib in c dl gcc_s m pthread resolv rt dl z stdc++; do
|
||||
if [ ! -f "$COSMOS/lib/lib${lib}.a" ]; then
|
||||
printf '\041\074\141\162\143\150\076\012' >"$COSMOS/lib/lib${lib}.a" || exit
|
||||
fi
|
||||
done
|
||||
echo "successfully updated your cosmo toolchain" >&2
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -f "$COSMOS/lib/libc.a" ] ||
|
||||
[ ! -f "$COSMO/o/$MODE/cosmopolitan.a" ]; then
|
||||
fatal_error "you need to run: $PROG --update"
|
||||
fi
|
||||
|
||||
OPT=
|
||||
FIRST=1
|
||||
OUTPUT=
|
||||
SFLAG=0
|
||||
INTENT=ld
|
||||
GOT_SOME=0
|
||||
NEED_OUTPUT=
|
||||
RELOCATABLE=0
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ -n "$NEED_OUTPUT" ]; then
|
||||
NEED_OUTPUT=
|
||||
OUTPUT=$x
|
||||
set -- "$@" "$x"
|
||||
continue
|
||||
fi
|
||||
if [ x"$x" = x"-" ] || # is an argument
|
||||
[ x"$x" = x"${x#-*}" ]; then # !startswith(x, "-")
|
||||
GOT_SOME=1
|
||||
elif [ x"$x" = x"-static-libstdc++" ]; then
|
||||
continue
|
||||
elif [ x"$x" = x"-static-libgcc" ]; then
|
||||
continue
|
||||
elif [ x"$x" != x"${x#-O}" ]; then
|
||||
OPT=$x
|
||||
elif [ x"$x" = x"-c" ]; then
|
||||
INTENT=cc
|
||||
elif [ x"$x" = x"-s" ]; then
|
||||
SFLAG=1
|
||||
continue
|
||||
elif [ x"$x" = x"-r" ]; then
|
||||
RELOCATABLE=1
|
||||
elif [ x"$x" = x"-E" ]; then
|
||||
INTENT=cpp
|
||||
elif [ x"$x" = x"-o" ]; then
|
||||
NEED_OUTPUT=1
|
||||
elif [ x"$x" = x"-mcosmo" ]; then
|
||||
CPPFLAGS="$CPPFLAGS -D_COSMO_SOURCE"
|
||||
continue
|
||||
elif [ x"$x" != x"${x#-o}" ]; then
|
||||
OUTPUT=${x#-o}
|
||||
elif [ x"$x" = x"-fpic" ]; then
|
||||
continue
|
||||
elif [ x"$x" = x"-fPIC" ]; then
|
||||
continue
|
||||
elif [ x"$x" = x"-r" ] ||
|
||||
[ x"$x" = x"-pie" ] ||
|
||||
[ x"$x" = x"-frtti" ] ||
|
||||
[ x"$x" = x"-shared" ] ||
|
||||
[ x"$x" = x"-nostdlib" ] ||
|
||||
[ x"$x" = x"-mred-zone" ] ||
|
||||
[ x"$x" = x"-fexceptions" ] ||
|
||||
[ x"$x" = x"-fsanitize=thread" ]; then
|
||||
echo "$PROG: $x not supported" >&2
|
||||
exit 1
|
||||
elif [ x"$x" = x"-fsanitize=all" ] ||
|
||||
[ x"$x" = x"-fsanitize=address" ] ||
|
||||
[ x"$x" = x"-fsanitize=undefined" ]; then
|
||||
echo "$PROG: use cosmo MODE=dbg or MODE=asan rather than passing $x" >&2
|
||||
exit 1
|
||||
elif [ x"$x" = x"-fomit-frame-pointer" ]; then
|
||||
# Quoth Apple "The frame pointer register must always address a
|
||||
# valid frame record. Some functions — such as leaf functions or
|
||||
# tail calls — may opt not to create an entry in this list. As a
|
||||
# result, stack traces are always meaningful, even without debug
|
||||
# information."
|
||||
set -- "$@" -momit-leaf-frame-pointer -foptimize-sibling-calls
|
||||
continue
|
||||
elif [ x"$x" != x"${x#-Werror}" ] || \
|
||||
[ x"$x" = x"-pedantic-errors" ]; then
|
||||
# this toolchain is intended for building other people's code
|
||||
# elevating warnings into errors, should only be done by devs
|
||||
continue
|
||||
elif [ x"$x" = x"-march=native" ]; then
|
||||
if [ $CROSS -eq 0 ]; then
|
||||
set -- "$@" $("$COSMO/o//tool/build/march-native.com")
|
||||
else
|
||||
fatal_error "-march=native can't be used when cross compiling"
|
||||
fi
|
||||
continue
|
||||
elif [ x"$x" = x"-dumpversion" ]; then
|
||||
echo $GCC_VERSION
|
||||
exit 0
|
||||
fi
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
if [ "$GOT_SOME" -eq 0 ]; then
|
||||
fatal_error "no input files"
|
||||
fi
|
||||
|
||||
if [ $RELOCATABLE -eq 1 ]; then
|
||||
LDFLAGS="$LDFLAGS -r"
|
||||
fi
|
||||
|
||||
if [ x"$MODE" = x"nox87" ]; then
|
||||
CPPFLAGS="$CPPFLAGS -mlong-double-64"
|
||||
fi
|
||||
|
||||
# support --ftrace unless optimizing for size
|
||||
if [ x"$OPT" != x"-Os" ] && # $OPT != -Os
|
||||
[ x"${MODE%tiny}" = x"${MODE}" ]; then # $MODE not in (tiny, aarch64-tiny)
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
CFLAGS="$CFLAGS -fpatchable-function-entry=18,16"
|
||||
elif [ x"$ARCH" = x"aarch64" ]; then
|
||||
CFLAGS="$CFLAGS -fpatchable-function-entry=7,6"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ask compiler to generate sanitization code in debug mode
|
||||
if [ x"$MODE" != x"${MODE%*dbg}" ]; then # endswith($MODE, "dbg")
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
|
||||
else
|
||||
CPPFLAGS="$CPPFLAGS -fsanitize=undefined"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ask compiler to generate memory safety code in asan mode
|
||||
if [ x"$MODE" != x"${MODE%*asan}" ]; then # endswith($MODE, "asan")
|
||||
if [ x"$ARCH" = x"x86_64" ]; then
|
||||
CPPFLAGS="$CPPFLAGS -fsanitize=address"
|
||||
else
|
||||
fatal_error "address sanitizer not supported on non-x86 yet"
|
||||
fi
|
||||
fi
|
||||
|
||||
# maximize frame pointers unless optimizing for size
|
||||
if [ x"$OPT" != x"-Os" ] && # $OPT != "-Os"
|
||||
[ x"$MODE" != x"${MODE%tiny}" ]; then # endswith($MODE, "tiny")
|
||||
CFLAGS="$CFLAGS -fno-optimize-sibling-calls -mno-omit-leaf-frame-pointer"
|
||||
fi
|
||||
|
||||
if [ $INTENT = cpp ]; then
|
||||
set -- "$CC" $PLATFORM $CPPFLAGS "$@"
|
||||
elif [ $INTENT = cc ]; then
|
||||
set -- "$CC" $PLATFORM $PREDEF $CFLAGS $CPPFLAGS "$@" $PRECIOUS
|
||||
else
|
||||
set -- "$CC" $PLATFORM $PREDEF $CFLAGS $CPPFLAGS $CRT "$@" $LDFLAGS $LDLIBS $PRECIOUS
|
||||
fi
|
||||
|
||||
log_command "$@"
|
||||
"$@" || exit
|
||||
|
||||
if [ -n "$OUTPUT" ] && [ -f "$OUTPUT" ]; then
|
||||
if [ $INTENT = cc ] || [ $INTENT = ld ]; then
|
||||
"$COSMO/o//tool/build/fixupobj.com" \
|
||||
"$OUTPUT" || exit
|
||||
fi
|
||||
if [ $INTENT = ld ]; then
|
||||
if [ x"$OUTPUT" != x"${OUTPUT%.com}" ] ||
|
||||
[ x"$OUTPUT" != x"${OUTPUT%.exe}" ]; then
|
||||
# cosmocc -o foo.com ...
|
||||
# -> foo.com (ape)
|
||||
# -> foo.com.dbg (elf)
|
||||
mv -f "$OUTPUT" "$OUTPUT.dbg" || exit
|
||||
"$COSMO/o/third_party/gcc/bin/$ARCH-linux-$BRAND-objcopy" \
|
||||
$OBJCOPYFLAGS \
|
||||
"$OUTPUT.dbg" \
|
||||
"$OUTPUT" || exit
|
||||
"$COSMO/o//tool/build/zipcopy.com" \
|
||||
"$OUTPUT.dbg" \
|
||||
"$OUTPUT" || exit
|
||||
elif [ $SFLAG -eq 1 ]; then
|
||||
"$COSMO/o/third_party/gcc/bin/$ARCH-linux-$BRAND-strip" \
|
||||
"$OUTPUT" || exit
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
Executable
+119
@@ -0,0 +1,119 @@
|
||||
#!/bin/sh
|
||||
PROG=${0##*/}
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
|
||||
fatal_error() {
|
||||
echo "$PROG: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
if [ ! -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-ar" ]; then
|
||||
fatal_error "you need to run: fatcosmocc --update"
|
||||
fi
|
||||
|
||||
AR_X86_64="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-ar"
|
||||
AR_AARCH64="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-ar"
|
||||
if [ "$1" = "--version" ]; then
|
||||
# note: only the underlying gnu compiler binaries are gpl
|
||||
# our shell script is released with the isc license
|
||||
cat <<EOF
|
||||
$PROG (GNU Binutils) 2.38
|
||||
Copyright (C) 2022 Free Software Foundation, Inc.
|
||||
This program is free software; you may redistribute it under the terms of
|
||||
the GNU General Public License version 3 or (at your option) any later version.
|
||||
This program has absolutely no warranty.
|
||||
EOF
|
||||
exit 0
|
||||
elif [ "$1" = "--help" ]; then
|
||||
"$AR_X86_64" --help |
|
||||
sed "s!$AR_X86_64!$PROG!g" 2>/dev/null ||
|
||||
"$AR_X86_64" --help
|
||||
exit
|
||||
fi
|
||||
|
||||
FIRST=1
|
||||
STATE=0
|
||||
OUTPUT_X86_64=
|
||||
OUTPUT_AARCH64=
|
||||
INPUTS=
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ $STATE -eq 0 ]; then
|
||||
if [ x"$x" != x"${x#--*}" ]; then # startswith(x, "--")
|
||||
set -- "$@" "$x" # this is a flag
|
||||
else
|
||||
set -- "$@" "$x" # command argument, e.g. rcu, rcsD
|
||||
STATE=1
|
||||
fi
|
||||
elif [ $STATE -eq 1 ]; then
|
||||
OUTPUT_X86_64=$x
|
||||
STATE=2
|
||||
elif [ x"$x" != x"${x#* }" ]; then
|
||||
fatal_error "input arguments containing spaces unsupported"
|
||||
elif [ x"$x" != x"${x#@}" ]; then
|
||||
fatal_error "input argument @file not supported yet"
|
||||
elif [ -z "$INPUTS" ]; then
|
||||
INPUTS=$x
|
||||
else
|
||||
INPUTS="$INPUTS $x"
|
||||
fi
|
||||
done
|
||||
if [ -z "$OUTPUT_X86_64" ]; then
|
||||
fatal_error "missing output path"
|
||||
fi
|
||||
|
||||
mangle_object_path() {
|
||||
path=$1
|
||||
arch=$2
|
||||
outdir=${path%/*}
|
||||
outbas=${path##*/}
|
||||
if [ x"$outdir" = x"$path" ]; then
|
||||
outdir=
|
||||
elif [ -n "$outdir" ]; then
|
||||
outdir="$outdir/"
|
||||
fi
|
||||
if [ ! -d "$outdir.$arch" ]; then
|
||||
mkdir -p "$outdir.$arch" || Exit
|
||||
fi
|
||||
mangled_path="${outdir}.$arch/$outbas"
|
||||
}
|
||||
|
||||
OBJECTS_X86_64=
|
||||
OBJECTS_AARCH64=
|
||||
for x in $INPUTS; do
|
||||
if [ ! -f "$x" ]; then
|
||||
fatal_error "$x: no such file"
|
||||
fi
|
||||
mangle_object_path "$x" aarch64
|
||||
if [ ! -f "$mangled_path" ]; then
|
||||
fatal_error "$x: missing concomitant $mangled_path file"
|
||||
fi
|
||||
OBJECTS_X86_64="${OBJECTS_X86_64} $x"
|
||||
OBJECTS_AARCH64="${OBJECTS_AARCH64} $mangled_path"
|
||||
done
|
||||
|
||||
mangle_object_path "$OUTPUT_X86_64" aarch64
|
||||
OUTPUT_AARCH64="$mangled_path"
|
||||
|
||||
"$AR_X86_64" "$@" "$OUTPUT_X86_64" $OBJECTS_X86_64 &
|
||||
pid1=$!
|
||||
|
||||
"$AR_AARCH64" "$@" "$OUTPUT_AARCH64" $OBJECTS_AARCH64 &
|
||||
pid2=$!
|
||||
|
||||
if ! wait $pid1; then
|
||||
kill $pid2 2>/dev/null
|
||||
wait
|
||||
exit 1
|
||||
fi
|
||||
wait $pid2 || exit
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
fatcosmocc
|
||||
Executable
+650
@@ -0,0 +1,650 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# fat cosmopolitan c/c++ compiler
|
||||
#
|
||||
# - this command is a drop-in replacement for the cc or gcc command.
|
||||
# the difference is that (1) your binaries will be linked with the
|
||||
# cosmopolitan c library, rather than your system specific tooling
|
||||
# and (2) they'll be fat ape executables that run on the platforms
|
||||
#
|
||||
# * amd64
|
||||
# + linux
|
||||
# + macos
|
||||
# + windows
|
||||
# + freebsd
|
||||
# + openbsd
|
||||
# + netbsd
|
||||
# * arm64
|
||||
# + linux
|
||||
# + macos
|
||||
# + windows (non-native)
|
||||
#
|
||||
# - you need to use linux to build your binaries currently, but you
|
||||
# can scp and distribute the output files to the above platforms!
|
||||
#
|
||||
# installation
|
||||
#
|
||||
# sudo chmod 1777 /opt # sticky bit isn't required
|
||||
# git clone https://github.com/jart/cosmopolitan /opt/cosmo
|
||||
# export PATH="/opt/cosmo/bin:/opt/cosmos/bin:$PATH"
|
||||
# echo 'export PATH="/opt/cosmo/bin:/opt/cosmos/bin:$PATH"' >>~/.profile
|
||||
# ape-install # optionally install a faster systemwide ape loader
|
||||
# fatcosmocc --update # pull and rebuild toolchain artifacts
|
||||
#
|
||||
# getting started
|
||||
#
|
||||
# fatcosmocc -o hello.com hello.c
|
||||
# ./foo.com
|
||||
# unzip -vl ./foo.com
|
||||
# ./foo.com --strace
|
||||
# ./foo.com --ftrace
|
||||
#
|
||||
# building in tiny mode
|
||||
#
|
||||
# export MODE=tiny
|
||||
# fatcosmocc --update
|
||||
# fatcosmocc -Os -o foo.com foo.c
|
||||
#
|
||||
# building in debug mode
|
||||
#
|
||||
# export MODE=dbg
|
||||
# fatcosmocc --update
|
||||
# fatcosmocc -g -o foo.com foo.c
|
||||
#
|
||||
# how to build a project like lua 5.4.6
|
||||
#
|
||||
# make all test CC=fatcosmocc AR='fatcosmoar rcu'
|
||||
# make install INSTALL_TOP=/opt/cosmos INSTALL=fatcosmoinstall
|
||||
#
|
||||
# how to build a project like ncurses 6.4
|
||||
#
|
||||
# ./configure CC=fatcosmocc \
|
||||
# CXX=fatcosmoc++ \
|
||||
# AR=fatcosmoar \
|
||||
# INSTALL="$(command -v fatcosmoinstall)" \
|
||||
# --prefix=/opt/cosmos \
|
||||
# --disable-shared
|
||||
# make -j8
|
||||
# make install
|
||||
#
|
||||
# detecting this environment
|
||||
#
|
||||
# - `__FATCOSMOCC__` is defined by fatcosmocc
|
||||
# - `__COSMOCC__` is defined by cosmocc and fatcosmocc
|
||||
# - `__COSMOPOLITAN__` is always defined by cosmopolitan
|
||||
#
|
||||
# some notes on this compiler
|
||||
#
|
||||
# - the underlying compiler itself is gcc
|
||||
# - we use cosmopolitan libc rather than glibc
|
||||
# - we use llvm's compiler-rt and libcxx runtimes
|
||||
# - we patched gcc so switch case can have symbols
|
||||
# - our scanf() implementation is somewhat troubled
|
||||
# - you may need to recalibrate `make -jN` as `N/2`
|
||||
#
|
||||
# compiler flags that work differently
|
||||
#
|
||||
# - `-v` will log fatcosmocc subcommands to stderr
|
||||
# you can also use `export BUILDLOG=/tmp/build.log`
|
||||
# - `-s` will ask apelink to not embed symbol tables in zip
|
||||
# - `-E` can't be fat and runs once with x86_64 macros undefined
|
||||
# - `-save-temps` will prevent deleting your arch-specific executables
|
||||
#
|
||||
# compiler flags that aren't supported
|
||||
#
|
||||
# - `-fexceptions` cosmopolitan doesn't support c++ exceptions yet
|
||||
# - `-frtti` cosmopolitan doesn't support c++ runtime reflection yet
|
||||
# - `-mred-zone` the system v red zone doesn't exist on windows and metal
|
||||
# - `-fpic`, '-fPIC', `-shared`, `-pie`, etc. no shared object support yet
|
||||
# - `-fsanitize=thread` cosmopolitan doesn't have thread sanitizer runtime yet
|
||||
# - `-fomit-frame-pointer` is partially supported (apple forbids full removal)
|
||||
#
|
||||
# for further details, run `man gcc`
|
||||
|
||||
PROG=${0##*/}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
ORIGINAL="$0 $*"
|
||||
TMPDIR=${TMPDIR:-/tmp}
|
||||
GCC_VERSION=11.2.0
|
||||
|
||||
if [ "$1" = "--version" ]; then
|
||||
cat <<EOF
|
||||
$PROG (GCC) $GCC_VERSION
|
||||
Copyright (c) 2023 Justine Alexandra Roberts Tunney
|
||||
Cosmopolitan Libc and LLVM libcxx/compiler-rt are subject to non-GPL
|
||||
notice licenses, e.g. ISC, MIT, etc. Your compiled programs must embed
|
||||
our copyright notices. This toolchain is configured to do so default.
|
||||
Cosmopolitan comes with absolutely NO WARRANTY of any kind.
|
||||
For more information, see the Cosmopolitan LICENSE files.
|
||||
Copyright (C) 2019 Free Software Foundation, Inc.
|
||||
This launches GNU GCC/Binutils subprocesses, which is free software; see
|
||||
Cosmopolitan's third_party/gcc/ for source code and copying conditions.
|
||||
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
PARTICULAR PURPOSE.
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ "$1" = "--help" ]; then
|
||||
if [ -t 1 ]; then
|
||||
exec less "$0"
|
||||
else
|
||||
exec cat "$0"
|
||||
fi
|
||||
fi
|
||||
|
||||
MODE=${MODE:-$m}
|
||||
if [ x"$MODE" = x"" ]; then
|
||||
MODE_AARCH64=aarch64
|
||||
elif [ x"$MODE" = x"tiny" ]; then
|
||||
MODE_AARCH64=aarch64-tiny
|
||||
elif [ x"$MODE" = x"zero" ]; then
|
||||
MODE_AARCH64=aarch64-zero
|
||||
elif [ x"$MODE" = x"dbg" ]; then
|
||||
MODE_AARCH64=aarch64-dbg
|
||||
else
|
||||
echo "$PROG: build MODE=$MODE not supported by fatcosmocc" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$1" = "--update" ]; then
|
||||
cd $COSMO || exit
|
||||
echo "building cosmo host toolchain..." >&2
|
||||
make --silent -j toolchain MODE= || exit
|
||||
echo "building cosmo x86_64 target (MODE=$MODE) toolchain..." >&2
|
||||
make --silent -j toolchain MODE="$MODE" || exit
|
||||
echo "building cosmo aarch64 target (MODE=$MODE_AARCH64) toolchain..." >&2
|
||||
make --silent -j toolchain MODE="$MODE_AARCH64" || exit
|
||||
echo "setting up your cosmos..." >&2
|
||||
for arch in "" .aarch64/; do
|
||||
mkdir -p "$COSMOS/lib/$arch" || exit
|
||||
for lib in c dl gcc_s m pthread resolv rt dl z stdc++; do
|
||||
if [ ! -f "$COSMOS/lib/${arch}lib${lib}.a" ]; then
|
||||
printf '\041\074\141\162\143\150\076\012' >"$COSMOS/lib/${arch}lib${lib}.a" || exit
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo "successfully updated your cosmo toolchain" >&2
|
||||
exit
|
||||
fi
|
||||
|
||||
if [ ! -d "$COSMO" ]; then
|
||||
echo "$PROG: you need to clone cosmopolitan to your $COSMO directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -f "$COSMOS/lib/libc.a" ] ||
|
||||
[ ! -f "$COSMOS/lib/.aarch64/libc.a" ] ||
|
||||
[ ! -f "$COSMO/o/$MODE/cosmopolitan.a" ] ||
|
||||
[ ! -f "$COSMO/o/$MODE_AARCH64/cosmopolitan.a" ]; then
|
||||
echo "$PROG: you need to run: $PROG --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
FIXUPOBJ="$COSMO/o//tool/build/fixupobj.com"
|
||||
TEMP_FILES=
|
||||
SAVE_TEMPS=0
|
||||
|
||||
Exit() {
|
||||
rc=${1:-$?}
|
||||
if [ $SAVE_TEMPS -eq 0 ]; then
|
||||
rm -f $TEMP_FILES
|
||||
fi
|
||||
exit $rc
|
||||
}
|
||||
|
||||
show_warning() {
|
||||
echo "$PROG: warning: $1" >&2
|
||||
}
|
||||
|
||||
fatal_error() {
|
||||
echo "$PROG: fatal error: $1" >&2
|
||||
echo "compilation terminated." >&2
|
||||
Exit 1
|
||||
}
|
||||
|
||||
log_original() {
|
||||
if [ -n "$BUILDLOG" ]; then
|
||||
printf '# %s\n' "$ORIGINAL" >>"$BUILDLOG"
|
||||
fi
|
||||
}
|
||||
|
||||
log_command() {
|
||||
if [ -n "$BUILDLOG" ]; then
|
||||
printf '(cd %s; %s)\n' "$PWD" "$*" >>"$BUILDLOG"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ x"$TMPDIR" != x"${TMPDIR#* }" ]; then
|
||||
fatal_error '$TMPDIR containing spaces not supported'
|
||||
elif [ ! -d "$TMPDIR" ]; then
|
||||
if ! mkdir -p "$TMPDIR" 2>/dev/null; then
|
||||
fatal_error "$TMPDIR: not a directory"
|
||||
fi
|
||||
fi
|
||||
|
||||
OPT=
|
||||
ARGS=
|
||||
FLAGS=
|
||||
OUTPUT=
|
||||
MCOSMO=0
|
||||
INTENT=ld
|
||||
NEED_JOIN=
|
||||
NEED_EQUAL=
|
||||
NEED_OUTPUT=
|
||||
APELINKFLAGS=
|
||||
INPUT_FILE_COUNT=0
|
||||
for x; do
|
||||
if [ x"$x" != x"${x#* }" ]; then
|
||||
fatal_error "arguments containing spaces unsupported: $x"
|
||||
fi
|
||||
if [ -n "$NEED_OUTPUT" ]; then
|
||||
NEED_OUTPUT=
|
||||
OUTPUT=$x
|
||||
continue
|
||||
elif [ -n "$NEED_JOIN" ]; then
|
||||
x="${NEED_JOIN}${x}"
|
||||
NEED_JOIN=
|
||||
elif [ -n "$NEED_EQUAL" ]; then
|
||||
x="${NEED_EQUAL}=${x}"
|
||||
NEED_EQUAL=
|
||||
elif [ x"$x" = x"-" ] || # is alias for stdin
|
||||
[ x"$x" = x"${x#-*}" ]; then # !startswith(x, "-")
|
||||
if [ x"$x" != x"${x%.s}" ] ||
|
||||
[ x"$x" != x"${x%.S}" ]; then
|
||||
fatal_error "$x: assembler input files not supported"
|
||||
elif [ x"$x" != x"${x%.so}" ] ||
|
||||
[ x"$x" != x"${x%.dll}" ] ||
|
||||
[ x"$x" != x"${x%.dylib}" ]; then
|
||||
fatal_error "$x: dynamic shared object input files not supported"
|
||||
elif [ x"$x" != x"-" ] && [ ! -f "$x" ]; then
|
||||
fatal_error "$x: no such file"
|
||||
fi
|
||||
INPUT_FILE_COUNT=$((INPUT_FILE_COUNT + 1))
|
||||
ARGS="$ARGS $x" # don't add to $FLAGS array
|
||||
continue
|
||||
elif [ x"$x" = x"-o" ]; then
|
||||
NEED_OUTPUT=1
|
||||
continue
|
||||
elif [ x"$x" != x"${x#-o}" ]; then # startswith(x, "-o")
|
||||
OUTPUT=${x#-o}
|
||||
continue
|
||||
elif [ x"$x" != x"${x#-O}" ]; then # startswith(x, "-O")
|
||||
OPT=$x
|
||||
elif [ x"$x" = x"-c" ]; then
|
||||
INTENT=cc
|
||||
elif [ x"$x" = x"-E" ]; then
|
||||
INTENT=cpp
|
||||
elif [ x"$x" = x"-s" ]; then
|
||||
APELINKFLAGS="$APELINKFLAGS -s"
|
||||
continue
|
||||
elif [ x"$x" = x"-v" ]; then
|
||||
exec 3<&2 # dup2(2, 3) b/c stderr will be redirected later
|
||||
BUILDLOG=/dev/fd/3
|
||||
continue
|
||||
elif [ x"$x" = x"-save-temps" ]; then
|
||||
SAVE_TEMPS=1
|
||||
elif [ x"$x" = x"-mcosmo" ]; then
|
||||
MCOSMO=1
|
||||
continue
|
||||
elif [ x"$x" = x"-fomit-frame-pointer" ]; then
|
||||
# Quoth Apple: "The frame pointer register must always address a
|
||||
# valid frame record. Some functions — such as leaf functions or
|
||||
# tail calls — may opt not to create an entry in this list. As a
|
||||
# result, stack traces are always meaningful, even without debug
|
||||
# information."
|
||||
x="-momit-leaf-frame-pointer -foptimize-sibling-calls"
|
||||
elif [ x"$x" = x"-r" ] ||
|
||||
[ x"$x" = x"-S" ] ||
|
||||
[ x"$x" = x"-pie" ] ||
|
||||
[ x"$x" = x"-frtti" ] ||
|
||||
[ x"$x" = x"-shared" ] ||
|
||||
[ x"$x" = x"-nostdlib" ] ||
|
||||
[ x"$x" = x"-mred-zone" ] ||
|
||||
[ x"$x" = x"-fexceptions" ] ||
|
||||
[ x"$x" = x"-fsanitize=thread" ]; then
|
||||
fatal_error "$x flag not supported"
|
||||
elif [ x"$x" = x"-fsanitize=all" ] ||
|
||||
[ x"$x" = x"-fsanitize=address" ] ||
|
||||
[ x"$x" = x"-fsanitize=undefined" ]; then
|
||||
fatal_error "use cosmo MODE=dbg rather than passing $x"
|
||||
elif [ x"$x" = x"-mno-red-zone" ]; then
|
||||
# "Any memory below the stack beyond the red zone is considered
|
||||
# volatile and may be modified by the operating system at any time."
|
||||
# https://devblogs.microsoft.com/oldnewthing/20190111-00/?p=100685
|
||||
continue
|
||||
elif [ x"$x" = x"-fpic" ] || [ x"$x" = x"-fPIC" ]; then
|
||||
# no support for building dynamic shared objects yet. reports
|
||||
# indicate that ignoring these flags, helps let autoconf know
|
||||
continue
|
||||
elif [ x"$x" = x"-Werror" ] || \
|
||||
[ x"$x" = x"-pedantic-errors" ]; then
|
||||
# this toolchain is intended for building other people's code
|
||||
# elevating warnings into errors, should only be done by devs
|
||||
continue
|
||||
elif [ x"$x" = x"-static-libgcc" ] || \
|
||||
[ x"$x" = x"-shared-libgcc" ]; then
|
||||
# cosmopolitan.a always has llvm compiler runtime static code
|
||||
continue
|
||||
elif [ x"$x" = x"-march=native" ]; then
|
||||
fatal_error "-march=native can't be used when building fat binaries"
|
||||
elif [ x"$x" = x"-dumpversion" ]; then
|
||||
echo $GCC_VERSION
|
||||
Exit 0
|
||||
elif [ x"$x" = x"-e" ] ||
|
||||
[ x"$x" = x"-z" ] ||
|
||||
[ x"$x" = x"-T" ] ||
|
||||
[ x"$x" = x"-L" ] ||
|
||||
[ x"$x" = x"-I" ] ||
|
||||
[ x"$x" = x"-D" ] ||
|
||||
[ x"$x" = x"-U" ] ||
|
||||
[ x"$x" = x"-iquote" ] ||
|
||||
[ x"$x" = x"-isystem" ] ||
|
||||
[ x"$x" = x"-include" ]; then
|
||||
NEED_JOIN=$x
|
||||
continue
|
||||
elif [ x"$x" = x"--param" ]; then
|
||||
NEED_EQUAL=$x
|
||||
continue
|
||||
fi
|
||||
FLAGS="$FLAGS $x"
|
||||
ARGS="$ARGS $x"
|
||||
done
|
||||
|
||||
if [ $INPUT_FILE_COUNT -eq 0 ]; then
|
||||
fatal_error "no input files"
|
||||
elif [ -z "$INPUT" ] &&
|
||||
[ $INTENT != ld ] &&
|
||||
[ $INPUT_FILE_COUNT -gt 1 ]; then
|
||||
fatal_error "cannot specify '-o' with '-c', or '-E' with multiple files"
|
||||
fi
|
||||
|
||||
PLATFORM="-D__COSMOPOLITAN__ -D__COSMOCC__ -D__FATCOSMOCC__"
|
||||
PREDEF="-include libc/integral/normalize.inc"
|
||||
CPPFLAGS="-fno-pie -nostdinc -fno-math-errno -iquote $COSMO -isystem $COSMOS/include -isystem $COSMO/libc/isystem"
|
||||
CFLAGS="-fportcosmo -fno-dwarf2-cfi-asm -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-semantic-interposition"
|
||||
LDFLAGS="-static -nostdlib -no-pie -fuse-ld=bfd -Wl,-z,norelro -Wl,--gc-sections"
|
||||
PRECIOUS="-fno-omit-frame-pointer"
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ]; then
|
||||
CFLAGS="$CFLAGS -fno-optimize-sibling-calls -mno-omit-leaf-frame-pointer"
|
||||
fi
|
||||
|
||||
CC_X86_64="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-gcc"
|
||||
CC_AARCH64="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-gcc"
|
||||
if [ x"$PROG" != x"${PROG%++}" ]; then
|
||||
CC_X86_64="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-g++"
|
||||
CC_AARCH64="$COSMO/o/third_party/gcc/bin/aarch64-linux-$BRAND-g++"
|
||||
CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -fuse-cxa-atexit"
|
||||
fi
|
||||
|
||||
CRT_X86_64="$COSMO/o/$MODE/ape/ape.o $COSMO/o/$MODE/libc/crt/crt.o"
|
||||
CPPFLAGS_X86_64="$CPPFLAGS -mno-red-zone"
|
||||
CFLAGS_X86_64="$CFLAGS -mno-tls-direct-seg-refs"
|
||||
LDFLAGS_X86_64="$LDFLAGS -L$COSMOS/lib -Wl,-T,$COSMO/o/$MODE/ape/ape.lds -Wl,-z,common-page-size=4096 -Wl,-z,max-page-size=16384"
|
||||
LDLIBS_X86_64="$COSMO/o/$MODE/cosmopolitan.a"
|
||||
if [ $MCOSMO -eq 1 ]; then
|
||||
CPPFLAGS_X86_64="${CPPFLAGS_X86_64} -D_COSMO_SOURCE"
|
||||
fi
|
||||
|
||||
CRT_AARCH64="$COSMO/o/$MODE_AARCH64/libc/crt/crt.o"
|
||||
CPPFLAGS_AARCH64="$CPPFLAGS"
|
||||
CFLAGS_AARCH64="$CFLAGS -ffixed-x18 -ffixed-x28 -mno-outline-atomics"
|
||||
LDFLAGS_AARCH64="$LDFLAGS -L$COSMOS/lib/.aarch64 -Wl,-T,$COSMO/o/${MODE_AARCH64}/ape/aarch64.lds -Wl,-z,common-page-size=16384 -Wl,-z,max-page-size=16384"
|
||||
LDLIBS_AARCH64="$COSMO/o/${MODE_AARCH64}/cosmopolitan.a"
|
||||
|
||||
if [ x"$OPT" != x"-Os" ] && [ x"$MODE" != x"tiny" ]; then
|
||||
CFLAGS_X86_64="${CFLAGS_X86_64} -fpatchable-function-entry=18,16"
|
||||
CFLAGS_AARCH64="${CFLAGS_AARCH64} -fpatchable-function-entry=7,6"
|
||||
fi
|
||||
|
||||
if [ x"$PROG" != x"${PROG%++}" ]; then
|
||||
LDLIBS_X86_64="$COSMO/o/$MODE/third_party/libcxx/libcxx.a ${LDLIBS_X86_64}"
|
||||
LDLIBS_AARCH64="$COSMO/o/${MODE_AARCH64}/third_party/libcxx/libcxx.a ${LDLIBS_AARCH64}"
|
||||
fi
|
||||
|
||||
if [ x"$MODE" = x"dbg" ]; then
|
||||
CPPFLAGS_X86_64="${CPPFLAGS_X86_64} -fsanitize=address -fsanitize=undefined"
|
||||
CPPFLAGS_AARCH64="${CPPFLAGS_AARCH64} -fsanitize=undefined"
|
||||
fi
|
||||
|
||||
log_original
|
||||
|
||||
if [ $INTENT = cpp ]; then
|
||||
if [ -n "$OUTPUT" ]; then
|
||||
ARGS="$ARGS -o$OUTPUT"
|
||||
fi
|
||||
set -- \
|
||||
"$CC_X86_64" \
|
||||
-U__k8 \
|
||||
-U__k8__ \
|
||||
-U__amd64 \
|
||||
-U__amd64__ \
|
||||
-U__x86_64 \
|
||||
-U__x86_64__ \
|
||||
-U__SSE__ \
|
||||
-U__SSE2__ \
|
||||
-U__SSE2_MATH__ \
|
||||
-mno-red-zone \
|
||||
$PLATFORM \
|
||||
$CPPFLAGS \
|
||||
$ARGS
|
||||
log_command "$@"
|
||||
MODE="$MODE" exec "$@"
|
||||
fi
|
||||
|
||||
mangle_object_path() {
|
||||
path=$1
|
||||
arch=$2
|
||||
outdir=${path%/*}
|
||||
outbas=${path##*/}
|
||||
if [ x"$outdir" = x"$path" ]; then
|
||||
outdir=
|
||||
elif [ -n "$outdir" ]; then
|
||||
outdir="$outdir/"
|
||||
fi
|
||||
if [ ! -d "$outdir.$arch" ]; then
|
||||
mkdir -p "$outdir.$arch" || Exit
|
||||
fi
|
||||
mangled_path="${outdir}.$arch/$outbas"
|
||||
}
|
||||
|
||||
mktemper() {
|
||||
"$COSMO/o//tool/build/mktemper.com" \
|
||||
"$TMPDIR/fatcosmocc.XXXXXXXXXXXXX$1"
|
||||
}
|
||||
|
||||
build_object() {
|
||||
out2=$(mktemper .txt) || Exit
|
||||
TEMP_FILES="${TEMP_FILES} $out2"
|
||||
(
|
||||
set -- \
|
||||
"$CC_X86_64" \
|
||||
-o"$OUTPUT_X86_64" \
|
||||
$PLATFORM \
|
||||
$PREDEF \
|
||||
$CFLAGS_X86_64 \
|
||||
$CPPFLAGS_X86_64 \
|
||||
"$@" \
|
||||
$PRECIOUS
|
||||
log_command "$@"
|
||||
"$@" || exit
|
||||
set -- \
|
||||
"$COSMO/o//tool/build/fixupobj.com" \
|
||||
"$OUTPUT_X86_64"
|
||||
log_command "$@"
|
||||
exec "$@"
|
||||
) &
|
||||
pid1=$!
|
||||
(
|
||||
set -- \
|
||||
"$CC_AARCH64" \
|
||||
-o"$OUTPUT_AARCH64" \
|
||||
$PLATFORM \
|
||||
$PREDEF \
|
||||
$CFLAGS_AARCH64 \
|
||||
$CPPFLAGS_AARCH64 \
|
||||
"$@" \
|
||||
$PRECIOUS &&
|
||||
log_command "$@"
|
||||
"$@" || exit
|
||||
set -- \
|
||||
"$COSMO/o//tool/build/fixupobj.com" \
|
||||
"$OUTPUT_AARCH64"
|
||||
log_command "$@"
|
||||
exec "$@"
|
||||
) 2>"$out2" &
|
||||
pid2=$!
|
||||
if ! wait $pid1; then
|
||||
kill $pid2 2>/dev/null
|
||||
wait
|
||||
Exit 1
|
||||
fi
|
||||
if ! wait $pid2; then
|
||||
echo "$PROG: x86_64 succeeded but aarch64 failed to build object" >&2
|
||||
cat "$out2" >&2
|
||||
Exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# turn source files into objects
|
||||
LDARGS_X86_64=
|
||||
LDARGS_AARCH64=
|
||||
for x in $ARGS; do
|
||||
if [ x"$x" != x"-" ] && # is alias for stdin
|
||||
[ x"$x" != x"${x#-*}" ]; then # startswith(x, "-")
|
||||
# this argument is a flag
|
||||
LDARGS_X86_64="${LDARGS_X86_64} $x"
|
||||
if [ x"$x" != x"${x#-L}" ]; then # startswith(x, "-L")
|
||||
x="$x/.aarch64"
|
||||
fi
|
||||
LDARGS_AARCH64="${LDARGS_AARCH64} $x"
|
||||
else
|
||||
# this argument is an input file
|
||||
if [ x"$x" != x"${x%.o}" ] ||
|
||||
[ x"$x" != x"${x%.a}" ]; then
|
||||
if [ $INTENT = cc ]; then
|
||||
show_warning "$x: linker input file unused because linking not done"
|
||||
else
|
||||
mangle_object_path "$x" aarch64
|
||||
if [ ! -f "$mangled_path" ]; then
|
||||
fatal_error "$x: linker input missing concomitant $mangled_path file"
|
||||
fi
|
||||
LDARGS_X86_64="${LDARGS_X86_64} $x"
|
||||
LDARGS_AARCH64="${LDARGS_AARCH64} $mangled_path"
|
||||
fi
|
||||
elif [ $INTENT = cc ]; then
|
||||
if [ -n "$OUTPUT" ]; then
|
||||
# e.g. `cc -c -o bar.o foo.c` is specified by user
|
||||
OUTPUT_X86_64=$OUTPUT
|
||||
mangle_object_path "$OUTPUT" aarch64
|
||||
OUTPUT_AARCH64="$mangled_path"
|
||||
build_object $FLAGS -c "$x"
|
||||
else
|
||||
# e.g. `cc -c dir/foo.c` builds foo.o
|
||||
o=${x##*/}
|
||||
OUTPUT_X86_64="${o%.*}.o"
|
||||
mangle_object_path "${o%.*}.o" aarch64
|
||||
OUTPUT_AARCH64="$mangled_path"
|
||||
build_object $FLAGS -c "$x"
|
||||
fi
|
||||
else
|
||||
# e.g. `cc foo.c` should build a.out
|
||||
if [ -z "$OUTPUT" ]; then
|
||||
OUTPUT=a.out
|
||||
fi
|
||||
# e.g. `cc -o foo foo.c` should *not* build foo.o
|
||||
OUTPUT_X86_64=$(mktemper .o) || Exit
|
||||
OUTPUT_AARCH64=$(mktemper .o) || Exit
|
||||
TEMP_FILES="${TEMP_FILES} ${OUTPUT_X86_64} ${OUTPUT_AARCH64}"
|
||||
build_object $FLAGS -c "$x"
|
||||
LDARGS_X86_64="${LDARGS_X86_64} ${OUTPUT_X86_64}"
|
||||
LDARGS_AARCH64="${LDARGS_AARCH64} ${OUTPUT_AARCH64}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $INTENT != ld ]; then
|
||||
Exit
|
||||
fi
|
||||
|
||||
OUTPUT_X86_64=$(mktemper ".com.dbg") || Exit
|
||||
OUTPUT_AARCH64=$(mktemper ".aarch64.elf") || Exit
|
||||
|
||||
out2=$(mktemper .txt) || Exit
|
||||
TEMP_FILES="${TEMP_FILES} $out2"
|
||||
(
|
||||
set -- \
|
||||
"$CC_X86_64" \
|
||||
-o"$OUTPUT_X86_64"\
|
||||
$CRT_X86_64 \
|
||||
$LDFLAGS_X86_64 \
|
||||
$LDARGS_X86_64 \
|
||||
$LDLIBS_X86_64
|
||||
log_command "$@"
|
||||
"$@" || exit
|
||||
set -- \
|
||||
"$COSMO/o//tool/build/fixupobj.com" \
|
||||
"$OUTPUT_X86_64"
|
||||
log_command "$@"
|
||||
exec "$@"
|
||||
) &
|
||||
pid1=$!
|
||||
(
|
||||
set -- \
|
||||
"$CC_AARCH64" \
|
||||
-o"$OUTPUT_AARCH64"\
|
||||
$CRT_AARCH64 \
|
||||
$LDFLAGS_AARCH64 \
|
||||
$LDARGS_AARCH64 \
|
||||
$LDLIBS_AARCH64
|
||||
log_command "$@"
|
||||
"$@" || exit
|
||||
set -- \
|
||||
"$COSMO/o//tool/build/fixupobj.com" \
|
||||
"$OUTPUT_AARCH64"
|
||||
log_command "$@"
|
||||
exec "$@"
|
||||
) 2>"$out2" &
|
||||
pid2=$!
|
||||
if ! wait $pid1; then
|
||||
kill $pid2 2>/dev/null
|
||||
wait
|
||||
Exit 1
|
||||
fi
|
||||
if ! wait $pid2; then
|
||||
echo "$PROG: x86_64 succeeded but aarch64 failed to link executable" >&2
|
||||
cat "$out2" >&2
|
||||
Exit 1
|
||||
fi
|
||||
|
||||
set -- \
|
||||
"$COSMO/o//tool/build/apelink.com" \
|
||||
-l "$COSMO/o/$MODE/ape/ape.elf" \
|
||||
-l "$COSMO/o/$MODE_AARCH64/ape/ape.elf" \
|
||||
-M "$COSMO/ape/ape-m1.c" \
|
||||
-o "$OUTPUT" \
|
||||
$APELINKFLAGS \
|
||||
"$OUTPUT_X86_64" \
|
||||
"$OUTPUT_AARCH64"
|
||||
log_command "$@"
|
||||
"$@" || Exit
|
||||
|
||||
set -- \
|
||||
"$COSMO/o//tool/build/pecheck.com" "$OUTPUT"
|
||||
log_command "$@"
|
||||
"$@" || Exit
|
||||
|
||||
if [ $INTENT = ld ] && [ $SAVE_TEMPS -eq 0 ]; then
|
||||
mv -f "$OUTPUT_X86_64" "${OUTPUT%.com}.com.dbg" || Exit
|
||||
mv -f "$OUTPUT_AARCH64" "${OUTPUT%.com}.aarch64.elf" || Exit
|
||||
fi
|
||||
|
||||
Exit
|
||||
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
|
||||
# the `install -s` strip flag provided by gnu coreutils surprisngly
|
||||
# enough understands the portable executable format however it will
|
||||
# silently corrupt any actually portable executable it touches, due
|
||||
# to how it overwrites the whole mz header and removes the dos stub
|
||||
FIRST=1
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ x"$x" = x"-s" ]; then
|
||||
continue
|
||||
fi
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
# now magically copy multi-architecture build artifacts
|
||||
if [ $# -gt 1 ]; then
|
||||
|
||||
# parse `install [$flags]... $src $dst`
|
||||
i=0
|
||||
n=$(( $# - 2 ))
|
||||
dst=
|
||||
src=
|
||||
flags=
|
||||
for x; do
|
||||
if [ x"$x" != x"${x#* }" ]; then
|
||||
# give up if any arguments contain spaces
|
||||
exec install "$@"
|
||||
fi
|
||||
src=$dst
|
||||
dst=$x
|
||||
if [ $i -lt $n ]; then
|
||||
flags="$flags $x"
|
||||
fi
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
|
||||
arch=aarch64
|
||||
|
||||
# turn:
|
||||
# install -c -m 644 foo.a /usr/lib/foo.a
|
||||
# into:
|
||||
# install -c -m 644 foo.a /usr/lib/foo.a
|
||||
# install -c -m 644 .aarch/foo.a /usr/lib/.aarch/foo.a
|
||||
if [ x"${dst##*/}" = x"${src##*/}" ] && # basenames are equal
|
||||
[ x"$dst" != x"${dst%.a}" ]; then # specifies static archive
|
||||
srcdir=${src%/*}
|
||||
srcbas=${dst##*/}
|
||||
if [ x"$srcdir" = x"$src" ]; then
|
||||
srcdir=
|
||||
elif [ -n "$srcdir" ]; then
|
||||
srcdir="$srcdir/"
|
||||
fi
|
||||
if [ -f "$srcdir.$arch/$srcbas" ]; then
|
||||
dstdir=${dst%/*}
|
||||
dstbas=${dst##*/}
|
||||
if [ x"$dstdir" = x"$dst" ]; then
|
||||
dstdir=
|
||||
elif [ -n "$dstdir" ]; then
|
||||
dstdir="$dstdir/"
|
||||
fi
|
||||
if [ ! -d "$dstdir.$arch" ]; then
|
||||
mkdir -p "$dstdir.$arch" || exit
|
||||
fi
|
||||
install $flags $src $dst || exit
|
||||
exec install $flags \
|
||||
"$srcdir.$arch/$srcbas" \
|
||||
"$dstdir.$arch/$dstbas"
|
||||
fi
|
||||
fi
|
||||
|
||||
# turn:
|
||||
# install -c -m 644 foo.a /usr/lib
|
||||
# into:
|
||||
# install -c -m 644 foo.a /usr/lib
|
||||
# install -c -m 644 .aarch/foo.a /usr/lib/.aarch
|
||||
arch=aarch64
|
||||
if [ x"$src" != x"${src%.a}" ] && [ -d "$dst" ]; then
|
||||
srcdir=${src%/*}
|
||||
srcbas=${dst##*/}
|
||||
if [ x"$srcdir" = x"$src" ]; then
|
||||
srcdir=
|
||||
elif [ -n "$srcdir" ]; then
|
||||
srcdir="$srcdir/"
|
||||
fi
|
||||
if [ -f "$srcdir.$arch/$srcbas" ]; then
|
||||
if [ ! -d "$dst/.$arch" ]; then
|
||||
mkdir -p "$dst/.$arch" || exit
|
||||
fi
|
||||
install $flags $src $dst || exit
|
||||
exec install $flags "$srcdir.$arch/$srcbas" "$dst/.$arch"
|
||||
fi
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
exec install "$@"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
fatcosmoar
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
fatcosmocc
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
fatcosmocc
|
||||
+1
@@ -0,0 +1 @@
|
||||
fatcosmoinstall
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-addr2line"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: x86_64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
apecopy
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
|
||||
PROG=${0##*/}
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
|
||||
fatal_error() {
|
||||
echo "$PROG: $1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
if [ ! -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-ar" ]; then
|
||||
fatal_error "you need to run: x86_64-unknown-cosmo-cc --update"
|
||||
fi
|
||||
|
||||
exec "$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-ar" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-as"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: x86_64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
cosmocc
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
cosmocc
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
FIRST=1
|
||||
for x; do
|
||||
if [ $FIRST -eq 1 ]; then
|
||||
set --
|
||||
FIRST=0
|
||||
fi
|
||||
if [ x"$x" = x"-s" ]; then
|
||||
continue
|
||||
fi
|
||||
set -- "$@" "$x"
|
||||
done
|
||||
|
||||
exec install "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-nm"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: x86_64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-objcopy"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: x86_64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-objdump"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: x86_64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
MODE=${MODE:-$m}
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
COSMOS=${COSMOS:-/opt/cosmos}
|
||||
|
||||
if [ -x "$COSMO/o/third_party/gcc/bin/x86_64-linux-musl-gcc" ]; then
|
||||
BRAND=musl
|
||||
else
|
||||
BRAND=cosmo
|
||||
fi
|
||||
|
||||
TOOL="$COSMO/o/third_party/gcc/bin/x86_64-linux-$BRAND-strip"
|
||||
|
||||
if [ ! -x "$TOOL" ]; then
|
||||
echo "$0: you need to run: x86_64-unknown-cosmo-cc --update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec "$TOOL" "$@"
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
+279
-102
@@ -4,22 +4,67 @@
|
||||
# Default Mode
|
||||
#
|
||||
# - `make`
|
||||
# - Optimized
|
||||
# - Backtraces
|
||||
# - Syscall tracing
|
||||
# - Function tracing
|
||||
# - Reasonably small
|
||||
# - Reasonably optimized
|
||||
# - Reasonably debuggable
|
||||
|
||||
#
|
||||
ifeq ($(MODE),)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CCFLAGS += -O2 $(BACKTRACES)
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG
|
||||
TARGET_ARCH ?= -msse3
|
||||
endif
|
||||
ifeq ($(MODE), x86_64)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CCFLAGS += -O2 $(BACKTRACES)
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG
|
||||
endif
|
||||
ifeq ($(MODE), aarch64)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CCFLAGS += -O2 $(BACKTRACES)
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG
|
||||
endif
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-Og
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
# Zero Optimization Mode
|
||||
#
|
||||
# - Goes 2x slower
|
||||
# - Supports --strace
|
||||
# - Unsupports --ftrace
|
||||
# - Better GDB debugging
|
||||
#
|
||||
ifeq ($(MODE), zero)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
OVERRIDE_CFLAGS += -O0
|
||||
OVERRIDE_CXXFLAGS += -O0
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG
|
||||
endif
|
||||
ifeq ($(MODE), aarch64-zero)
|
||||
CONFIG_OFLAGS ?= -g
|
||||
OVERRIDE_CFLAGS += -O0 -fdce
|
||||
OVERRIDE_CXXFLAGS += -O0 -fdce
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG
|
||||
endif
|
||||
|
||||
# Fast Build Mode
|
||||
#
|
||||
# - `make MODE=fastbuild`
|
||||
# - No debugging
|
||||
# - Syscall tracing
|
||||
# - Function tracing
|
||||
# - Some optimizations
|
||||
# - Limited Backtraces
|
||||
#
|
||||
ifeq ($(MODE), fastbuild)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG -DDWARFLESS
|
||||
CONFIG_LDFLAGS += -S
|
||||
TARGET_ARCH ?= -msse3
|
||||
endif
|
||||
|
||||
# Optimized Mode
|
||||
@@ -27,25 +72,37 @@ endif
|
||||
# - `make MODE=opt`
|
||||
# - Backtraces
|
||||
# - More optimized
|
||||
# - Syscall tracing
|
||||
# - Function tracing
|
||||
# - Reasonably small
|
||||
# - No memory corruption detection
|
||||
# - assert() / CHECK_xx() may leak code into binary for debuggability
|
||||
# - GCC 8+ hoists check fails into .text.cold, thus minimizing impact
|
||||
|
||||
#
|
||||
ifeq ($(MODE), opt)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CPPFLAGS += -DNDEBUG -DSYSDEBUG
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O3 -fmerge-all-constants
|
||||
TARGET_ARCH ?= -march=native
|
||||
endif
|
||||
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DNDEBUG \
|
||||
-msse2avx \
|
||||
-Wa,-msse2avx
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O3
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-march=native
|
||||
|
||||
# Optimized Linux Mode
|
||||
# The Fastest Mode of All
|
||||
#
|
||||
# - `make MODE=optlinux`
|
||||
# - Turns on red zone
|
||||
# - Turns off backtraces
|
||||
# - Turns off function tracing
|
||||
# - Turns off support for older cpu models
|
||||
# - Turns off support for other operating systems
|
||||
#
|
||||
ifeq ($(MODE), optlinux)
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CPPFLAGS += -DNDEBUG -DSYSDEBUG -DSUPPORT_VECTOR=1
|
||||
CONFIG_CCFLAGS += -O3 -fmerge-all-constants
|
||||
CONFIG_COPTS += -mred-zone
|
||||
TARGET_ARCH ?= -march=native
|
||||
endif
|
||||
|
||||
# Release Mode
|
||||
@@ -56,24 +113,18 @@ endif
|
||||
# - More optimized
|
||||
# - Reasonably small
|
||||
# - Numeric backtraces
|
||||
# - No DWARF data bloat
|
||||
# - Toilsome debuggability
|
||||
# - assert() statements removed
|
||||
# - DCHECK_xx() statements removed
|
||||
# - No memory corruption detection
|
||||
# - CHECK_xx() won't leak strings into binary
|
||||
|
||||
#
|
||||
ifeq ($(MODE), rel)
|
||||
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DNDEBUG
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O2
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
CONFIG_CPPFLAGS += -DNDEBUG -DDWARFLESS
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O2
|
||||
TARGET_ARCH ?= -msse3
|
||||
PYFLAGS += -O1
|
||||
endif
|
||||
|
||||
# Asan Mode
|
||||
@@ -86,19 +137,15 @@ endif
|
||||
# - Backtraces
|
||||
# - Debuggability
|
||||
# - Larger binaries
|
||||
|
||||
#
|
||||
ifeq ($(MODE), asan)
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
-O2
|
||||
|
||||
CONFIG_COPTS += \
|
||||
-fsanitize=address
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CPPFLAGS += -D__SANITIZE_ADDRESS__
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O2 -DSYSDEBUG
|
||||
CONFIG_COPTS += -fsanitize=address
|
||||
TARGET_ARCH ?= -msse3
|
||||
QUOTA ?= -C64 -L300
|
||||
endif
|
||||
|
||||
# Debug Mode
|
||||
@@ -106,30 +153,46 @@ endif
|
||||
# - `make MODE=dbg`
|
||||
# - Backtraces
|
||||
# - Enables asan
|
||||
# - Enables ubsan (TODO)
|
||||
# - Enables ubsan
|
||||
# - Stack canaries
|
||||
# - No optimization (TODO)
|
||||
# - No optimization
|
||||
# - Enormous binaries
|
||||
|
||||
#
|
||||
ifeq ($(MODE), dbg)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CPPFLAGS += -DMODE_DBG -D__SANITIZE_ADDRESS__ -D__SANITIZE_UNDEFINED__
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -DSYSDEBUG -O0 -fno-inline
|
||||
CONFIG_COPTS += -fsanitize=address -fsanitize=undefined
|
||||
TARGET_ARCH ?= -msse3
|
||||
OVERRIDE_CCFLAGS += -fno-pie
|
||||
QUOTA ?= -C64 -L300
|
||||
endif
|
||||
ifeq ($(MODE), aarch64-dbg)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CPPFLAGS += -DMODE_DBG -D__SANITIZE_UNDEFINED__
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -DSYSDEBUG -O0 -fno-inline -fdce
|
||||
CONFIG_COPTS += -fsanitize=undefined
|
||||
QUOTA ?= -C64 -L300
|
||||
endif
|
||||
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DMODE_DBG
|
||||
|
||||
CONFIG_CCFLAGS += \
|
||||
$(BACKTRACES) \
|
||||
$(FTRACE) \
|
||||
-O2
|
||||
|
||||
CONFIG_COPTS += \
|
||||
-fsanitize=address
|
||||
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
|
||||
OVERRIDE_CCFLAGS += \
|
||||
-fno-pie
|
||||
|
||||
# System Five Mode
|
||||
#
|
||||
# - `make MODE=sysv`
|
||||
# - Optimized
|
||||
# - Backtraces
|
||||
# - Debuggable
|
||||
# - Syscall tracing
|
||||
# - Function tracing
|
||||
# - No Windows bloat!
|
||||
#
|
||||
ifeq ($(MODE), sysv)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_OFLAGS ?= -g
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O2
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG -DSUPPORT_VECTOR=121
|
||||
TARGET_ARCH ?= -msse3
|
||||
endif
|
||||
|
||||
# Tiny Mode
|
||||
@@ -143,20 +206,47 @@ endif
|
||||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
#
|
||||
ifeq ($(MODE), tiny)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops
|
||||
TARGET_ARCH ?= \
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops \
|
||||
-fschedule-insns2 \
|
||||
-momit-leaf-frame-pointer \
|
||||
-foptimize-sibling-calls \
|
||||
-DDWARFLESS
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
PYFLAGS += \
|
||||
-O2 \
|
||||
-B
|
||||
endif
|
||||
ifeq ($(MODE), aarch64-tiny)
|
||||
# TODO(jart): -mcmodel=tiny
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops \
|
||||
-fschedule-insns2 \
|
||||
-momit-leaf-frame-pointer \
|
||||
-foptimize-sibling-calls \
|
||||
-DDWARFLESS
|
||||
PYFLAGS += \
|
||||
-O2 \
|
||||
-B
|
||||
endif
|
||||
|
||||
# Linux-Only Tiny Mode
|
||||
@@ -171,20 +261,21 @@ endif
|
||||
# - No portability
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
#
|
||||
ifeq ($(MODE), tinylinux)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=1
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=1 \
|
||||
-DDWARFLESS
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
-fno-align-jumps \
|
||||
-fno-align-labels \
|
||||
-fno-align-loops
|
||||
TARGET_ARCH ?= \
|
||||
TARGET_ARCH ?= \
|
||||
-msse3
|
||||
endif
|
||||
|
||||
@@ -201,13 +292,14 @@ endif
|
||||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
#
|
||||
ifeq ($(MODE), tinylinuxbsd)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=113
|
||||
-DSUPPORT_VECTOR=113 \
|
||||
-DDWARFLESS
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
@@ -230,13 +322,14 @@ endif
|
||||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
#
|
||||
ifeq ($(MODE), tinysysv)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=121
|
||||
-DSUPPORT_VECTOR=121 \
|
||||
-DDWARFLESS
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
@@ -259,13 +352,14 @@ endif
|
||||
# - No backtraces
|
||||
# - No algorithmics
|
||||
# - YOLO
|
||||
|
||||
#
|
||||
ifeq ($(MODE), tinynowin)
|
||||
CONFIG_CPPFLAGS += \
|
||||
-DTINY \
|
||||
-DNDEBUG \
|
||||
-DTRUSTWORTHY \
|
||||
-DSUPPORT_VECTOR=251
|
||||
-DSUPPORT_VECTOR=251 \
|
||||
-DDWARFLESS
|
||||
CONFIG_CCFLAGS += \
|
||||
-Os \
|
||||
-fno-align-functions \
|
||||
@@ -276,10 +370,40 @@ TARGET_ARCH ?= \
|
||||
-msse3
|
||||
endif
|
||||
|
||||
# LLVM Mode
|
||||
ifeq ($(MODE), llvm)
|
||||
# no x87 instructions mode
|
||||
#
|
||||
# export MODE=nox87
|
||||
# make -j8 toolchain
|
||||
# cosmocc -o /tmp/hello.com hello.c
|
||||
#
|
||||
# lets you shave ~23kb off blink
|
||||
#
|
||||
# git clone https://github.com/jart/blink
|
||||
# cd blink
|
||||
# ./configure --disable-x87
|
||||
# make -j8
|
||||
# o//blink/blink /tmp/hello.com
|
||||
#
|
||||
ifeq ($(MODE), nox87)
|
||||
ENABLE_FTRACE = 1
|
||||
CONFIG_COPTS += -mlong-double-64
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -O2
|
||||
CONFIG_CPPFLAGS += -DSYSDEBUG -DNOX87
|
||||
TARGET_ARCH ?= -msse3
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) $(FTRACE) -O2
|
||||
endif
|
||||
|
||||
# LLVM Mode
|
||||
#
|
||||
# We aim to support:
|
||||
#
|
||||
# make -j8 m=llvm o/llvm/libc
|
||||
#
|
||||
# The rest of the monorepo may not work with llvm.
|
||||
#
|
||||
ifeq ($(MODE), llvm)
|
||||
.STRICT = 0
|
||||
TARGET_ARCH ?= -msse3
|
||||
CONFIG_CCFLAGS += $(BACKTRACES) -DSYSDEBUG -O2
|
||||
AS = clang
|
||||
CC = clang
|
||||
CXX = clang++
|
||||
@@ -317,12 +441,65 @@ endif
|
||||
# such as MSVC or XCode. You can run your binary objects through a tool
|
||||
# like objconv to convert them to COFF or MachO. Then use ANSI mode to
|
||||
# rollup one header file that'll enable linkage with minimal issues.
|
||||
|
||||
ifeq ($(MODE), ansi)
|
||||
|
||||
CONFIG_CFLAGS += -std=c11
|
||||
#CONFIG_CPPFLAGS += -ansi
|
||||
CONFIG_CXXFLAGS += -std=c++11
|
||||
TARGET_ARCH ?= -msse3
|
||||
endif
|
||||
|
||||
ifneq ($(ENABLE_FTRACE),)
|
||||
CONFIG_CPPFLAGS += -DFTRACE
|
||||
FTRACE_CCFLAGS = -fno-inline-functions-called-once
|
||||
OVERRIDE_CFLAGS += $(FTRACE_CCFLAGS)
|
||||
OVERRIDE_CXXFLAGS += $(FTRACE_CCFLAGS)
|
||||
# function prologue nops for --ftrace
|
||||
ifeq ($(ARCH), x86_64)
|
||||
# this flag causes gcc to generate functions like this
|
||||
#
|
||||
# nop nop nop nop nop nop nop nop nop
|
||||
# func:
|
||||
# nop nop
|
||||
# ...
|
||||
#
|
||||
# which tool/build/fixupobj.c improves at build time like this
|
||||
#
|
||||
# nop nop nop nop nop nop nop nop nop
|
||||
# func:
|
||||
# xchg %ax,%ax
|
||||
# ...
|
||||
#
|
||||
# which --ftrace morphs at runtime like this
|
||||
#
|
||||
# ud2 # 2 bytes
|
||||
# call ftrace_hook # 5 bytes
|
||||
# jmp +2 # 2 bytes
|
||||
# func:
|
||||
# jmp -7 # 2 bytes
|
||||
# ...
|
||||
#
|
||||
CONFIG_CCFLAGS += -fpatchable-function-entry=18,16
|
||||
endif
|
||||
ifeq ($(ARCH), aarch64)
|
||||
# this flag causes gcc to generate functions like this
|
||||
#
|
||||
# nop nop nop nop nop nop
|
||||
# func:
|
||||
# nop
|
||||
# ...
|
||||
#
|
||||
# which --ftrace morphs at runtime like this
|
||||
#
|
||||
# brk #31337
|
||||
# stp x29,x30,[sp,#-16]!
|
||||
# mov x29,sp
|
||||
# bl ftrace_hook
|
||||
# ldp x29,x30,[sp],#16
|
||||
# b +1
|
||||
# func:
|
||||
# b -5
|
||||
# ...
|
||||
#
|
||||
CONFIG_CCFLAGS += -fpatchable-function-entry=7,6
|
||||
endif
|
||||
endif
|
||||
+154
-137
@@ -33,71 +33,132 @@
|
||||
#
|
||||
# VARIABLES
|
||||
#
|
||||
# CCFLAGS gcc frontend flags (.i, .c, .cc, .f, .S, .lds, etc.)
|
||||
# Our configuration variables, ordered by increasing preference:
|
||||
#
|
||||
# CCFLAGS frontend flags (.i, .c, .cc, .f, .S, .lds, etc.)
|
||||
# OFLAGS objectify flags (precludes -S and -E)
|
||||
# CPPFLAGS preprocessor flags (.h, .c, .cc, .S, .inc, .lds, etc.)
|
||||
# TARGET_ARCH microarchitecture flags (e.g. -march=native)
|
||||
# COPTS c/c++ flags (.c, .cc)
|
||||
# CFLAGS c flags (.c only)
|
||||
# CXXFLAGS c++ flags (.cc only)
|
||||
# COPTS c/c++ flags (.c, .cc)
|
||||
# LDFLAGS linker flags (don't use -Wl, frontend prefix)
|
||||
# ASFLAGS assembler flags (don't use -Wa, frontend prefix)
|
||||
# TARGET_ARCH microarchitecture flags (e.g. -march=native)
|
||||
#
|
||||
# For each FOO above, there exists (by increasing preference)
|
||||
#
|
||||
# DEFAULT_FOO see build/definitions.mk
|
||||
# CONFIG_FOO see build/config.mk
|
||||
# FOO set ~/.cosmo.mk and target-specific
|
||||
# OVERRIDE_FOO set ~/.cosmo.mk and target-specific (use rarely)
|
||||
#
|
||||
|
||||
V ?= 1
|
||||
LC_ALL = C
|
||||
SOURCE_DATE_EPOCH = 0
|
||||
|
||||
TAGS ?= /usr/bin/ctags # emacs source builds or something breaks it
|
||||
ARFLAGS = rcsD
|
||||
ZFLAGS ?=
|
||||
XARGS ?= xargs -P4 -rs8000
|
||||
DOT ?= dot
|
||||
GZ ?= gzip
|
||||
CLANG = clang
|
||||
FC = gfortran #/opt/cross9f/bin/x86_64-linux-musl-gfortran
|
||||
TMPDIR = o/tmp
|
||||
|
||||
# see build/compile, etc. which run third_party/gcc/unbundle.sh
|
||||
AR = build/bootstrap/ar.com
|
||||
CP = build/bootstrap/cp.com
|
||||
RM = build/bootstrap/rm.com -f
|
||||
GZIP = build/bootstrap/gzip.com
|
||||
ECHO = build/bootstrap/echo.com
|
||||
CHMOD = build/bootstrap/chmod.com
|
||||
TOUCH = build/bootstrap/touch.com
|
||||
PKG = build/bootstrap/package.com
|
||||
MKDEPS = build/bootstrap/mkdeps.com
|
||||
ZIPOBJ = build/bootstrap/zipobj.com
|
||||
AS = o/third_party/gcc/bin/x86_64-linux-musl-as
|
||||
CC = o/third_party/gcc/bin/x86_64-linux-musl-gcc
|
||||
CXX = o/third_party/gcc/bin/x86_64-linux-musl-g++
|
||||
CXXFILT = o/third_party/gcc/bin/x86_64-linux-musl-c++filt
|
||||
LD = o/third_party/gcc/bin/x86_64-linux-musl-ld.bfd
|
||||
NM = o/third_party/gcc/bin/x86_64-linux-musl-nm
|
||||
GCC = o/third_party/gcc/bin/x86_64-linux-musl-gcc
|
||||
STRIP = o/third_party/gcc/bin/x86_64-linux-musl-strip
|
||||
OBJCOPY = o/third_party/gcc/bin/x86_64-linux-musl-objcopy
|
||||
OBJDUMP = o/third_party/gcc/bin/x86_64-linux-musl-objdump
|
||||
ADDR2LINE = o/third_party/gcc/bin/x86_64-linux-musl-addr2line
|
||||
ZIPCOPY = build/bootstrap/zipcopy.com
|
||||
PECHECK = build/bootstrap/pecheck.com
|
||||
FIXUPOBJ = build/bootstrap/fixupobj.com
|
||||
MKDIR = build/bootstrap/mkdir.com -p
|
||||
COMPILE = build/bootstrap/compile.com -V9 -P4096 $(QUOTA)
|
||||
|
||||
COMMA := ,
|
||||
PWD := $(shell pwd)
|
||||
IMAGE_BASE_VIRTUAL ?= 0x400000
|
||||
HELLO := $(shell build/hello)
|
||||
TMPDIR := $(shell build/findtmp)
|
||||
SPAWNER := $(shell build/getcompile) -V$(shell build/getccversion $(CC))
|
||||
COMPILE = $(SPAWNER) $(QUOTA)
|
||||
PWD := $(shell build/bootstrap/pwd.com)
|
||||
|
||||
IGNORE := $(shell $(MKDIR) $(TMPDIR))
|
||||
|
||||
ifneq ($(findstring aarch64,$(MODE)),)
|
||||
ARCH = aarch64
|
||||
HOSTS ?= pi silicon
|
||||
else
|
||||
ARCH = x86_64
|
||||
HOSTS ?= freebsd rhel7 xnu win10 openbsd netbsd
|
||||
endif
|
||||
|
||||
ifeq ($(PREFIX),)
|
||||
ifeq ($(USE_SYSTEM_TOOLCHAIN),)
|
||||
ifeq ($(ARCH),x86_64)
|
||||
ifneq ("$(wildcard o/third_party/gcc/bin/x86_64-linux-cosmo-*)","")
|
||||
PREFIX = o/third_party/gcc/bin/x86_64-linux-cosmo-
|
||||
else
|
||||
IGNORE := $(shell build/bootstrap/unbundle.com)
|
||||
PREFIX = o/third_party/gcc/bin/x86_64-linux-musl-
|
||||
endif
|
||||
endif # ($(ARCH),x86_64))
|
||||
ifeq ($(ARCH),aarch64)
|
||||
ifneq ("$(wildcard o/third_party/gcc/bin/aarch64-linux-cosmo-*)","")
|
||||
PREFIX = o/third_party/gcc/bin/aarch64-linux-cosmo-
|
||||
else
|
||||
IGNORE := $(shell build/bootstrap/unbundle.com)
|
||||
PREFIX = o/third_party/gcc/bin/aarch64-linux-musl-
|
||||
endif
|
||||
endif # ($(ARCH),aarch64)
|
||||
endif # ($(USE_SYSTEM_TOOLCHAIN),)
|
||||
endif # ($(PREFIX),)
|
||||
|
||||
AS = $(PREFIX)as
|
||||
CC = $(PREFIX)gcc
|
||||
CXX = $(PREFIX)g++
|
||||
CXXFILT = $(PREFIX)c++filt
|
||||
LD = $(PREFIX)ld.bfd
|
||||
NM = $(PREFIX)nm
|
||||
GCC = $(PREFIX)gcc
|
||||
STRIP = $(PREFIX)strip
|
||||
OBJCOPY = $(PREFIX)objcopy
|
||||
OBJDUMP = $(PREFIX)objdump
|
||||
ifneq ($(wildcard $(PWD)/$(PREFIX)addr2line),)
|
||||
ADDR2LINE = $(PWD)/$(PREFIX)addr2line
|
||||
else
|
||||
ADDR2LINE = $(PREFIX)addr2line
|
||||
endif
|
||||
|
||||
export ADDR2LINE
|
||||
export LC_ALL
|
||||
export MKDIR
|
||||
export MODE
|
||||
export SOURCE_DATE_EPOCH
|
||||
export TMPDIR
|
||||
export V
|
||||
|
||||
FTRACE = \
|
||||
-pg
|
||||
ifeq ($(LANDLOCKMAKE_VERSION),)
|
||||
TMPSAFE = $(join $(TMPDIR),$(subst /,_,$@)).tmp
|
||||
else
|
||||
TMPSAFE = $(TMPDIR)/
|
||||
endif
|
||||
|
||||
BACKTRACES = \
|
||||
-fno-optimize-sibling-calls \
|
||||
-mno-omit-leaf-frame-pointer
|
||||
|
||||
ifneq ($(ARCH), aarch64)
|
||||
BACKTRACES += -fno-schedule-insns2
|
||||
endif
|
||||
|
||||
SANITIZER = \
|
||||
-fsanitize=address
|
||||
|
||||
NO_MAGIC = \
|
||||
-mno-fentry \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fwrapv \
|
||||
-fno-sanitize=all \
|
||||
-fwrapv
|
||||
-fpatchable-function-entry=0,0
|
||||
|
||||
OLD_CODE = \
|
||||
-fno-strict-aliasing \
|
||||
@@ -108,75 +169,102 @@ TRADITIONAL = \
|
||||
-Wno-return-type \
|
||||
-Wno-pointer-sign
|
||||
|
||||
DEFAULT_CCFLAGS = \
|
||||
DEFAULT_CCFLAGS += \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-fdebug-prefix-map="$(PWD)"= \
|
||||
-fno-omit-frame-pointer \
|
||||
-frecord-gcc-switches
|
||||
|
||||
DEFAULT_OFLAGS = \
|
||||
-g \
|
||||
-gdescribe-dies
|
||||
|
||||
DEFAULT_COPTS = \
|
||||
-mno-red-zone \
|
||||
DEFAULT_COPTS ?= \
|
||||
-fno-math-errno \
|
||||
-fno-trapping-math \
|
||||
-fno-fp-int-builtin-inexact \
|
||||
-fno-ident \
|
||||
-fno-common \
|
||||
-fno-gnu-unique \
|
||||
-fstrict-aliasing \
|
||||
-fstrict-overflow \
|
||||
-fno-omit-frame-pointer \
|
||||
-fno-semantic-interposition \
|
||||
-mno-omit-leaf-frame-pointer
|
||||
-fno-dwarf2-cfi-asm \
|
||||
-fno-unwind-tables \
|
||||
-fno-asynchronous-unwind-tables
|
||||
|
||||
ifeq ($(ARCH), x86_64)
|
||||
# Microsoft says "[a]ny memory below the stack beyond the red zone
|
||||
# [note: Windows defines the x64 red zone size as 0] is considered
|
||||
# volatile and may be modified by the operating system at any time."
|
||||
# https://devblogs.microsoft.com/oldnewthing/20190111-00/?p=100685
|
||||
DEFAULT_COPTS += \
|
||||
-mno-red-zone \
|
||||
-mno-tls-direct-seg-refs
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH), aarch64)
|
||||
#
|
||||
# - Apple says in "Writing ARM64 code for Apple platforms" that we're
|
||||
# not allowed to use the x18 register.
|
||||
#
|
||||
# - Cosmopolitan Libc uses x28 for thread-local storage because Apple
|
||||
# forbids us from using tpidr_el0 too.
|
||||
#
|
||||
# - Cosmopolitan currently lacks an implementation of the runtime
|
||||
# libraries needed by the -moutline-atomics flag
|
||||
#
|
||||
DEFAULT_COPTS += \
|
||||
-ffixed-x18 \
|
||||
-ffixed-x28 \
|
||||
-mno-outline-atomics
|
||||
endif
|
||||
|
||||
MATHEMATICAL = \
|
||||
-O3 \
|
||||
-fwrapv
|
||||
|
||||
DEFAULT_CPPFLAGS = \
|
||||
-DCOSMO \
|
||||
DEFAULT_CPPFLAGS += \
|
||||
-D_COSMO_SOURCE \
|
||||
-DMODE='"$(MODE)"' \
|
||||
-DIMAGE_BASE_VIRTUAL=$(IMAGE_BASE_VIRTUAL) \
|
||||
-nostdinc \
|
||||
-iquote.
|
||||
-iquote .
|
||||
|
||||
DEFAULT_CFLAGS = \
|
||||
-std=gnu2x
|
||||
|
||||
DEFAULT_CXXFLAGS = \
|
||||
-std=gnu++11 \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-fuse-cxa-atexit \
|
||||
-fno-threadsafe-statics \
|
||||
-Wno-int-in-bool-context \
|
||||
-Wno-narrowing
|
||||
-Wno-narrowing \
|
||||
-Wno-literal-suffix
|
||||
|
||||
DEFAULT_ASFLAGS = \
|
||||
-W \
|
||||
-I. \
|
||||
--noexecstack \
|
||||
--nocompress-debug-sections
|
||||
--noexecstack
|
||||
|
||||
DEFAULT_LDFLAGS = \
|
||||
-static \
|
||||
-nostdlib \
|
||||
-m elf_x86_64 \
|
||||
-znorelro \
|
||||
--gc-sections \
|
||||
--build-id=none \
|
||||
--no-dynamic-linker \
|
||||
-z max-page-size=0x1000
|
||||
--no-dynamic-linker
|
||||
|
||||
ZIPOBJ_FLAGS = \
|
||||
-b$(IMAGE_BASE_VIRTUAL)
|
||||
# # generate linker report files
|
||||
# DEFAULT_LDFLAGS += --cref [email protected]
|
||||
|
||||
ifeq ($(ARCH), aarch64)
|
||||
DEFAULT_LDFLAGS += \
|
||||
-zmax-page-size=0x4000 \
|
||||
-zcommon-page-size=0x4000 \
|
||||
-znorelro
|
||||
else
|
||||
DEFAULT_LDFLAGS += \
|
||||
-zmax-page-size=0x4000 \
|
||||
-zcommon-page-size=0x1000
|
||||
endif
|
||||
|
||||
ASONLYFLAGS = \
|
||||
-c \
|
||||
-g \
|
||||
--debug-prefix-map="$(PWD)"=
|
||||
-g
|
||||
|
||||
DEFAULT_LDLIBS =
|
||||
|
||||
@@ -250,40 +338,31 @@ LD.libs = \
|
||||
$(CONFIG_LIBS) \
|
||||
$(LIBS)
|
||||
|
||||
COMPILE.c.flags = $(cc.flags) $(cpp.flags) $(copt.flags) $(c.flags)
|
||||
COMPILE.cxx.flags = $(cc.flags) $(cpp.flags) $(copt.flags) $(cxx.flags)
|
||||
COMPILE.f.flags = $(cc.flags) $(copt.flags) $(f.flags)
|
||||
COMPILE.F.flags = $(cc.flags) $(cpp.flags) $(copt.flags) $(f.flags)
|
||||
COMPILE.c.flags = $(cc.flags) $(copt.flags) $(cpp.flags) $(c.flags)
|
||||
COMPILE.cxx.flags = $(cc.flags) $(copt.flags) $(cpp.flags) $(cxx.flags)
|
||||
COMPILE.i.flags = $(cc.flags) $(copt.flags) $(c.flags)
|
||||
COMPILE.ii.flags = $(cc.flags) $(copt.flags) $(cxx.flags)
|
||||
LINK.flags = $(DEFAULT_LDFLAGS) $(CONFIG_LDFLAGS) $(LDFLAGS)
|
||||
OBJECTIFY.c.flags = $(OBJECTIFY.S.flags) $(copt.flags) $(c.flags)
|
||||
OBJECTIFY.cxx.flags = $(OBJECTIFY.S.flags) $(copt.flags) $(cxx.flags)
|
||||
OBJECTIFY.c.flags = $(cc.flags) $(o.flags) $(S.flags) $(cpp.flags) $(copt.flags) $(c.flags)
|
||||
OBJECTIFY.cxx.flags = $(cc.flags) $(o.flags) $(S.flags) $(cpp.flags) $(copt.flags) $(cxx.flags)
|
||||
OBJECTIFY.s.flags = $(ASONLYFLAGS) $(s.flags)
|
||||
OBJECTIFY.S.flags = $(copt.flags) $(cc.flags) $(o.flags) $(cpp.flags) $(S.flags)
|
||||
OBJECTIFY.f.flags = $(copt.flags) $(cc.flags) $(o.flags) $(copt.flags) $(S.flags) $(f.flags)
|
||||
OBJECTIFY.F.flags = $(OBJECTIFY.f.flags) $(cpp.flags)
|
||||
OBJECTIFY.S.flags = $(cc.flags) $(o.flags) $(S.flags) $(cpp.flags)
|
||||
PREPROCESS.flags = -E $(copt.flags) $(cc.flags) $(cpp.flags)
|
||||
PREPROCESS.lds.flags = -D__LINKER__ $(filter-out -g%,$(PREPROCESS.flags)) -P -xc
|
||||
|
||||
COMPILE.c = $(CC) -S $(COMPILE.c.flags)
|
||||
COMPILE.cxx = $(CXX) -S $(COMPILE.cxx.flags)
|
||||
COMPILE.i = $(CC) -S $(COMPILE.i.flags)
|
||||
COMPILE.f = $(FC) -S $(COMPILE.f.flags)
|
||||
COMPILE.F = $(FC) -S $(COMPILE.F.flags)
|
||||
OBJECTIFY.s = $(AS) $(OBJECTIFY.s.flags)
|
||||
OBJECTIFY.S = $(CC) $(OBJECTIFY.S.flags) -c
|
||||
OBJECTIFY.f = $(FC) $(OBJECTIFY.f.flags) -c
|
||||
OBJECTIFY.F = $(FC) $(OBJECTIFY.F.flags) -c
|
||||
OBJECTIFY.c = $(CC) $(OBJECTIFY.c.flags) -c
|
||||
OBJECTIFY.cxx = $(CXX) $(OBJECTIFY.cxx.flags) -c
|
||||
PREPROCESS = $(CC) $(PREPROCESS.flags)
|
||||
PREPROCESS.lds = $(CC) $(PREPROCESS.lds.flags)
|
||||
LINK = $(LD) $(LINK.flags)
|
||||
ELF = o/libc/elf/elf.lds
|
||||
ELFLINK = $(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION)
|
||||
ELFLINK = $(COMPILE) -ALINK.elf $(LINK) $(LINKARGS) $(OUTPUT_OPTION) && $(COMPILE) -AFIXUP.ape -T$@ $(FIXUPOBJ) $@
|
||||
LINKARGS = $(patsubst %.lds,-T %.lds,$(call uniqr,$(LD.libs) $(filter-out %.pkg,$^)))
|
||||
LOLSAN = build/lolsan -b $(IMAGE_BASE_VIRTUAL)
|
||||
|
||||
# The compiler won't generate %xmm code for sources extensioned .greg.c,
|
||||
# which is needed for C modules wanting to run at the executive level or
|
||||
@@ -297,70 +376,8 @@ OBJECTIFY.greg.c = \
|
||||
-fno-instrument-functions \
|
||||
-fno-optimize-sibling-calls \
|
||||
-fno-sanitize=all \
|
||||
-c
|
||||
|
||||
OBJECTIFY.ansi.c = $(CC) $(OBJECTIFY.c.flags) -ansi -Wextra -Werror -pedantic-errors -c
|
||||
OBJECTIFY.c99.c = $(CC) $(OBJECTIFY.c.flags) -std=c99 -Wextra -Werror -pedantic-errors -c
|
||||
OBJECTIFY.c11.c = $(CC) $(OBJECTIFY.c.flags) -std=c11 -Wextra -Werror -pedantic-errors -c
|
||||
OBJECTIFY.c2x.c = $(CC) $(OBJECTIFY.c.flags) -std=c2x -Wextra -Werror -pedantic-errors -c
|
||||
|
||||
OBJECTIFY.real.c = \
|
||||
$(GCC) \
|
||||
-x-no-pg \
|
||||
$(OBJECTIFY.c.flags) \
|
||||
-wrapper build/realify.sh \
|
||||
-D__REAL_MODE__ \
|
||||
-ffixed-r8 \
|
||||
-ffixed-r9 \
|
||||
-ffixed-r10 \
|
||||
-ffixed-r11 \
|
||||
-ffixed-r12 \
|
||||
-ffixed-r13 \
|
||||
-ffixed-r14 \
|
||||
-ffixed-r15 \
|
||||
-mno-red-zone \
|
||||
-fcall-used-rbx \
|
||||
-fno-jump-tables \
|
||||
-fno-shrink-wrap \
|
||||
-fno-schedule-insns2 \
|
||||
-flive-range-shrinkage \
|
||||
-fno-omit-frame-pointer \
|
||||
-momit-leaf-frame-pointer \
|
||||
-mpreferred-stack-boundary=3 \
|
||||
-fno-delete-null-pointer-checks \
|
||||
-c
|
||||
|
||||
OBJECTIFY.ncabi.c = \
|
||||
$(GCC) \
|
||||
$(OBJECTIFY.c.flags) \
|
||||
-mno-sse \
|
||||
-mfpmath=387 \
|
||||
-mno-fentry \
|
||||
-fno-stack-protector \
|
||||
-fno-instrument-functions \
|
||||
-fno-optimize-sibling-calls \
|
||||
-fno-sanitize=all \
|
||||
-fcall-saved-rcx \
|
||||
-fcall-saved-rdx \
|
||||
-fcall-saved-rdi \
|
||||
-fcall-saved-rsi \
|
||||
-fcall-saved-r8 \
|
||||
-fcall-saved-r9 \
|
||||
-fcall-saved-r10 \
|
||||
-fcall-saved-r11 \
|
||||
-c \
|
||||
-xc
|
||||
|
||||
OBJECTIFY.initabi.c = \
|
||||
$(GCC) \
|
||||
$(OBJECTIFY.c.flags) \
|
||||
-mno-fentry \
|
||||
-fno-stack-protector \
|
||||
-fno-instrument-functions \
|
||||
-fno-optimize-sibling-calls \
|
||||
-fno-sanitize=all \
|
||||
-fcall-saved-rdi \
|
||||
-fcall-saved-rsi \
|
||||
-ffreestanding \
|
||||
-fwrapv \
|
||||
-c
|
||||
|
||||
TAGSFLAGS = \
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# Temporary Directory Discovery
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# We call this script once per build to ideally find a folder that's
|
||||
# backed by an in-memory file system. We then export it to the TMPDIR
|
||||
# environment variable. Many programs use it under the hood, e.g. gcc,
|
||||
# so it grants many small performance improvements.
|
||||
|
||||
mkdir -p o/tmp
|
||||
echo o/tmp
|
||||
+5
-1
@@ -12,5 +12,9 @@
|
||||
|
||||
tail = $(wordlist 2,$(words $1),$1)
|
||||
reverse = $(if $1,$(call reverse,$(call tail,$1)) $(firstword $1))
|
||||
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
||||
uniqr = $(if $1,$(call uniqr,$(filter-out $(firstword $1),$1)) $(firstword $1))
|
||||
|
||||
# polyfill uniq native (landlock make 1.4)
|
||||
ifneq ($(call uniq,c b c a),c b a)
|
||||
uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1)))
|
||||
endif
|
||||
@@ -1,39 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# Compiler Version Discovery
|
||||
#
|
||||
# DESCRIPTION
|
||||
#
|
||||
# Cosmopolitan itself may be built using either GCC and Clang, and our
|
||||
# build irons out many of the differences between the two. This script
|
||||
# is used by build/definitions.mk alongside build/getccname to support
|
||||
# the different versions folks use.
|
||||
#
|
||||
# Our aim is to support GCC 4.2.1+ since that's the last GPLv2 version
|
||||
# with any sort of industry consensus. Please note, Cosmopolitan never
|
||||
# links GCC runtimes when using later versions, so some concerns might
|
||||
# not apply.
|
||||
|
||||
if [ ! -d o/third_party/gcc ]; then
|
||||
third_party/gcc/unbundle.sh
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
MAJOR_VERSION=$(
|
||||
$1 --version |
|
||||
head -n1 |
|
||||
sed -n '
|
||||
s!^[^(]*([^)]*) \([[:digit:]][[:digit:]]*\).*!\1!p
|
||||
s!^.*clang.*version \([[:digit:]][[:digit:]]*\).*!\1!p
|
||||
')
|
||||
|
||||
if [ -z "$MAJOR_VERSION" ]; then
|
||||
echo 6
|
||||
else
|
||||
printf '%s\n' "$MAJOR_VERSION"
|
||||
fi
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
|
||||
if ! [ o/build/bootstrap/compile.com -nt build/bootstrap/compile.com ]; then
|
||||
mkdir -p o/build/bootstrap/
|
||||
cp -f build/bootstrap/compile.com o/build/bootstrap/compile.$$.com
|
||||
o/build/bootstrap/compile.$$.com -n
|
||||
mv -f o/build/bootstrap/compile.$$.com o/build/bootstrap/compile.com
|
||||
fi
|
||||
|
||||
echo o/build/bootstrap/compile.com
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
#!/bin/sh
|
||||
#-*-mode:sh;indent-tabs-mode:nil;tab-width:2;coding:utf-8-*-┐
|
||||
#───vi: set net ft=sh ts=2 sts=2 fenc=utf-8 :vi─────────────┘
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# HELLO BUILD
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# We generate a line at the start of each Makefile run, because if we
|
||||
# use `make V=0` mode then the terminal logging trick we use in
|
||||
# tool/build/compile.c will delete the previous line, and we'd rather
|
||||
# have that line not be the bash prompt that ran make.
|
||||
#
|
||||
# This script is also useful for giving us an indicator each time the
|
||||
# build restarts itself from scratch, which can happen in cases like
|
||||
# when dependencies need to be regenerated by tool/build/mkdeps.c
|
||||
|
||||
echo ♥cosmo >&2
|
||||
+9
-2
@@ -43,12 +43,19 @@
|
||||
# '(progn
|
||||
# (add-hook 'c-mode-common-hook 'jart-c-mode-common-hook)))
|
||||
|
||||
TAGS="$1"
|
||||
shift
|
||||
|
||||
# ctags doesn't understand atomics, e.g.
|
||||
# extern char **environ;
|
||||
set -- --regex-c='/_Atomic(\([^)]*\))/\1/b' "$@"
|
||||
|
||||
# ctags doesn't understand variable prototypes, e.g.
|
||||
# extern char **environ;
|
||||
set -- --regex-c='/^\(\(hidden\|extern\|const\) \)*[_[:alpha:]][_[:alnum:]]*[ *][ *]*\([_[:alpha:]][_[:alnum:]]*[ *][ *]*\)*\([_[:alpha:]][_$[:alnum:]]*\)/\4/b' "$@"
|
||||
|
||||
# ctags doesn't understand function prototypes, e.g.
|
||||
# bool isheap(void *p) nothrow nocallback;
|
||||
# bool isheap(void *p) dontthrow nocallback;
|
||||
set -- --regex-c='/^[_[:alpha:]][_[:alnum:]]*[ *][ *]*\([_[:alpha:]][_[:alnum:]]*[ *][ *]*\)*\([_[:alpha:]][_$[:alnum:]]*\)(.*/\2/b' "$@"
|
||||
|
||||
# ctags doesn't understand function pointers, e.g.
|
||||
@@ -59,7 +66,7 @@ set -- --regex-c='/^extern [^(]*(\*const \([^)]*\))(/\1/b' "$@"
|
||||
# struct WorstSoftwareEver;
|
||||
set -- --regex-c='/^struct.*;$/uehocruehcroue/b' "$@"
|
||||
|
||||
exec ${TAGS:-ctags} \
|
||||
exec $TAGS \
|
||||
-e \
|
||||
--langmap=c:.c.h \
|
||||
--exclude=libc/nt/struct/imagefileheader.internal.h \
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
COSMO=${COSMO:-/opt/cosmo}
|
||||
|
||||
if [ -n "$OBJDUMP" ]; then
|
||||
exec "$OBJDUMP" "$@"
|
||||
fi
|
||||
|
||||
find_objdump() {
|
||||
if [ -x o/third_party/gcc/bin/$1-linux-cosmo-objdump ]; then
|
||||
OBJDUMP=o/third_party/gcc/bin/$1-linux-cosmo-objdump
|
||||
elif [ -x o/third_party/gcc/bin/$1-linux-musl-objdump ]; then
|
||||
OBJDUMP=o/third_party/gcc/bin/$1-linux-musl-objdump
|
||||
elif [ -x "$COSMO/o/third_party/gcc/bin/$1-linux-cosmo-objdump" ]; then
|
||||
OBJDUMP="$COSMO/o/third_party/gcc/bin/$1-linux-cosmo-objdump"
|
||||
elif [ -x "$COSMO/o/third_party/gcc/bin/$1-linux-musl-objdump" ]; then
|
||||
OBJDUMP="$COSMO/o/third_party/gcc/bin/$1-linux-musl-objdump"
|
||||
else
|
||||
echo "error: toolchain not found (try running 'cosmocc --update' or 'make' in the cosmo monorepo)" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if printf '%s\n' "$*" | grep aarch64 >/dev/null 2>&1; then
|
||||
find_objdump aarch64
|
||||
exec "$OBJDUMP" "$@"
|
||||
else
|
||||
find_objdump x86_64
|
||||
exec "$OBJDUMP" "$@"
|
||||
fi
|
||||
+5
-1
@@ -23,8 +23,12 @@
|
||||
# - tool/build/runitd.c
|
||||
|
||||
.PRECIOUS: o/$(MODE)/%.com.ok
|
||||
o/$(MODE)/%.com.ok: private .PLEDGE = stdio rpath wpath cpath proc fattr inet
|
||||
o/$(MODE)/%.com.ok: \
|
||||
o/$(MODE)/tool/build/runit.com \
|
||||
o/$(MODE)/tool/build/runitd.com \
|
||||
o/$(MODE)/%.com
|
||||
@$(COMPILE) -ATEST -tT$@ $^ $(HOSTS)
|
||||
@$(COMPILE) -wATEST -tT$@ $^ $(HOSTS)
|
||||
|
||||
.PHONY:
|
||||
o/tiny/tool/build/runit.com:
|
||||
Loaded 100 of 21347 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user