Skip to content

Commit fa94626

Browse files
committed
Add support for a NoEntryPoint property (-fno-entry / -Wl,--no-entry).
1 parent 7de0720 commit fa94626

File tree

5 files changed

+11
-0
lines changed

5 files changed

+11
-0
lines changed

doc/configuration/properties.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ historical reasons.
9999
Microsoft C/C++ extensions. Defaults to `false`, but note that the compiler
100100
itself always enables some parts of this when targeting Windows as Win32
101101
headers require it.
102+
* `NoEntryPoint` (`true`, `false`): Enable/disable the omission of an entry
103+
point function when building executables. Defaults to `false`.
102104
* `UnicodeEnvironment` (`true`, `false`): Enable/disable compiling for a Unicode
103105
environment when targeting Windows in C/C++ projects. This causes the
104106
`UNICODE` and `_UNICODE` macros to be defined, and makes it so that

src/sdk/ZigCompile.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public int ImageBase
104104
[Required]
105105
public bool MicrosoftExtensions { get; set; }
106106

107+
[Required]
108+
public bool NoEntryPoint { get; set; }
109+
107110
[Required]
108111
public bool NullabilityAnalysis { get; set; }
109112

@@ -251,6 +254,9 @@ protected override string GenerateCommandLineCommands()
251254
if (!TargetTriple.StartsWith("wasm", StringComparison.Ordinal))
252255
builder.AppendSwitch("-fPIE");
253256

257+
if (NoEntryPoint)
258+
builder.AppendSwitch(isZig ? "-fno-entry" : "-Wl,--no-entry");
259+
254260
if (_symbolExports == ZigSymbolExports.All)
255261
builder.AppendSwitch("-rdynamic");
256262
}

src/sdk/build/Vezel.Zig.Sdk.Build.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
LinkerReferences="@(LinkerReference)"
7575
LinkTimeOptimization="$(LinkTimeOptimization)"
7676
MicrosoftExtensions="$(MicrosoftExtensions)"
77+
NoEntryPoint="$(NoEntryPoint)"
7778
NullabilityAnalysis="$(NullabilityAnalysis)"
7879
OutputBinary="@(IntermediateAssembly)"
7980
OutputType="$(OutputType)"

src/sdk/build/Vezel.Zig.Sdk.Defaults.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<CxxExceptions Condition="'$(CxxExceptions)' == ''">true</CxxExceptions>
3636
<CxxReflection Condition="'$(CxxReflection)' == ''">true</CxxReflection>
3737
<MicrosoftExtensions Condition="'$(MicrosoftExtensions)' == ''">false</MicrosoftExtensions>
38+
<NoEntryPoint Condition="'$(NoEntryPoint)' == ''">false</NoEntryPoint>
3839
<UnicodeEnvironment Condition="'$(UnicodeEnvironment)' == ''">false</UnicodeEnvironment>
3940
<ZigVersion Condition="'$(ZigVersion)' == ''">0.13.0</ZigVersion>
4041
</PropertyGroup>

src/sdk/build/Vezel.Zig.Sdk.Test.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
LinkerReferences="@(LinkerReference)"
4747
LinkTimeOptimization="$(LinkTimeOptimization)"
4848
MicrosoftExtensions="$(MicrosoftExtensions)"
49+
NoEntryPoint="$(NoEntryPoint)"
4950
NullabilityAnalysis="$(NullabilityAnalysis)"
5051
OutputBinary="@(TestAssembly)"
5152
OutputType="$(OutputType)"

0 commit comments

Comments
 (0)