-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2_0_compile_linux.ps1
More file actions
112 lines (106 loc) · 3.32 KB
/
Copy path2_0_compile_linux.ps1
File metadata and controls
112 lines (106 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# cleanup
rm *exe
rm *.obj
$csFile = $args[0]
if($args.Length -eq 0) {
Write-Host "specify a source file"
return
}
$program = $csFile.Replace(".cs", "")
$cwd = $(Get-Location).Path
# .cs -> IL [csc.exe]
$refFolder = "./libs/refs"
$refs = @()
foreach($dll in Get-ChildItem $refFolder | Where-Object -Property Name -Like "*dll")
{
$refs += "/r:$($dll.FullName) "
}
$extrasFolder = "./libs/extras"
$extras = @()
foreach($dll in Get-ChildItem $extrasFolder | Where-Object -Property Name -Like "*dll")
{
$extras += "/r:$($dll.FullName) "
}
$ilexe = "$program.il.exe";
.\csc\csc $csFile @refs @extras "/out:$ilexe"
# IL -> Bytecode [ILCompiler dotnet\runtime\artifacts\bin\coreclr\windows.x64.Release\x64\ilc\ilc.exe]
$aotsdk = "$cwd/libs/aotsdk"
$obj = "$program.obj"
.\ilc\ilc `
$ilexe `
--out $obj `
-r:"$aotsdk/*.dll" `
-r:"$cwd/libs/runtime/*.dll" `
-r:"$cwd/libs/extras/*.dll" `
-g `
--generateunmanagedentrypoints:System.Private.CoreLib,HIDDEN `
--dehydrate `
--initassembly:System.Private.CoreLib `
--initassembly:System.Private.StackTraceMetadata `
--initassembly:System.Private.TypeLoader `
--initassembly:System.Private.Reflection.Execution `
--directpinvoke:libSystem.Native `
--directpinvoke:libSystem.Globalization.Native `
--directpinvoke:libSystem.IO.Compression.Native `
--directpinvoke:libSystem.Net.Security.Native `
--directpinvoke:libSystem.Security.Cryptography.Native.OpenSsl `
--stacktracedata `
--scanreflection `
--feature:System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=false `
--feature:System.Diagnostics.Tracing.EventSource.IsSupported=false `
--feature:System.Resources.ResourceManager.AllowCustomResourceTypes=false `
--feature:System.Linq.Expressions.CanEmitObjectArrayDelegate=false `
--feature:System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported=false `
--feature:System.Globalization.Invariant=true `
--feature:System.Diagnostics.Debugger.IsSupported=false `
--feature:System.StartupHookProvider.IsSupported=false `
$glibc = "/lib/x86_64-linux-gnu";
$gcclibs = (Get-Item /usr/lib/gcc/x86_64-linux-gnu/*/crtbeginS.o |
Sort-Object { [int]$_.Directory.Name } -Descending |
Select-Object -First 1).Directory.FullName;
ld.bfd `
"$glibc/crt1.o" `
"$glibc/crti.o" `
"$gcclibs/crtbeginS.o" `
$obj `
"$aotsdk/libbootstrapper.o" `
"$aotsdk/libRuntime.WorkstationGC.a" `
"$aotsdk/libeventpipe-disabled.a" `
"$aotsdk/libRuntime.VxsortEnabled.a" `
"$aotsdk/libstandalonegc-disabled.a" `
"$aotsdk/libstdc++compat.a" `
"$aotsdk/libSystem.Native.a" `
"$aotsdk/libSystem.Globalization.Native.a" `
"$aotsdk/libSystem.IO.Compression.Native.a" `
"$aotsdk/libSystem.Net.Security.Native.a" `
"$aotsdk/libSystem.Security.Cryptography.Native.OpenSsl.a" `
"$aotsdk/libz.a" `
"$aotsdk/libaotminipal.a" `
"$aotsdk/libbrotlicommon.a" `
"$aotsdk/libbrotlidec.a" `
"$aotsdk/libbrotlienc.a" `
"$glibc/libc.so" `
"$glibc/libc.so.6" `
"$glibc/libpthread.so.0" `
"$glibc/libm.so" `
"$glibc/libm.so.6" `
"$glibc/libdl.so.2" `
"$glibc/librt.so.1" `
"$gcclibs/crtendS.o" `
"$glibc/crtn.o" `
--output=$program.exe `
--dynamic-linker=/lib64/ld-linux-x86-64.so.2 `
--nostdlib `
--compress-debug-sections=zlib `
--discard-all `
--gc-sections `
--as-needed `
--strip-all `
-pie `
-z relro `
-z now `
--eh-frame-hdr `
--export-dynamic `
# cleanup
rm "$program.il.exe"
rm "$program.obj"