Skip to content

Commit c79e4c5

Browse files
committed
Add UseMicrosoftAbi property to switch between gnu/msvc ABIs.
Closes #52.
1 parent ec49263 commit c79e4c5

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

doc/configuration/properties.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,12 @@ historical reasons.
149149
* `SymbolVisibility` (`Default`, `Hidden`): Specifies the symbol visibility in
150150
C/C++ projects when `__attribute__((visibility(...)))` is not specified.
151151
`Default` (the default 😉) means public, while `Hidden` means private.
152-
* `EagerBinding` (`true`, `false`): Enables/disables eager binding of symbols
153-
when performing dynamic linking at run time. Eager binding has security
154-
benefits, especially in combination with `RelocationHardening`. It is also
155-
more reliable if calling external functions from signal handlers. Defaults to
156-
`true`.
157-
* `RelocationHardening` (`true`, `false`): Enables/disables marking relocations
158-
as read-only. This has security benefits, especially in combination with
152+
* `EagerBinding` (`true`, `false`): Enable/disable eager binding of symbols when
153+
performing dynamic linking at run time. Eager binding has security benefits,
154+
especially in combination with `RelocationHardening`. It is also more reliable
155+
if calling external functions from signal handlers. Defaults to `true`.
156+
* `RelocationHardening` (`true`, `false`): Enable/disable marking relocations as
157+
read-only. This has security benefits, especially in combination with
159158
`EagerBinding`. Defaults to `true`.
160159
* `Sanitizers`: A semicolon-separated list of
161160
[sanitizers](https://github.com/google/sanitizers) to instrument code with.
@@ -168,8 +167,13 @@ historical reasons.
168167
specified in `RuntimeIdentifiers`. Usually specified by the user as e.g.
169168
`dotnet build -r linux-x64`. Unset by default.
170169
* `RuntimeIdentifiers`: A semicolon-separated list of runtime identifiers that
171-
the project supports. All targets on this list will be cross-compiled as
170+
the project supports. All targets in this list will be cross-compiled as
172171
necessary. Defaults to all targets that the Zig compiler has known-good
173172
support for.
173+
* `UseMicrosoftAbi` (`true`, `false`): Enable/disable using the Microsoft ABI
174+
when targeting Windows. This may be necessary when linking to static libraries
175+
containing C++ code that was compiled for the Microsoft ABI. Note that it is
176+
currently not possible to cross-compile from non-Windows platforms when using
177+
the Microsoft ABI. Unset by default.
174178
* `UseEmulator` (`true`, `false`): Enable/disable usage of an appropriate binary
175179
emulator when cross-compiling. Defaults to `true`.

src/sdk/Sdk/Sdk.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<Import Project="Sdk.props"
1010
Sdk="Microsoft.NET.Sdk" />
11+
1112
<Import Project="../build/Vezel.Zig.Sdk.Core.props" />
1213
<Import Project="../build/Vezel.Zig.Sdk.Items.props" />
1314
<Import Project="../build/Vezel.Zig.Sdk.Build.props" />

src/sdk/Sdk/Sdk.targets

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
<Import Project="../build/Vezel.Zig.Sdk.Overrides.targets" />
1010
<Import Project="../build/Vezel.Zig.Sdk.Cross.targets" />
1111
<Import Project="../build/Vezel.Zig.Sdk.Symbols.targets" />
12+
1213
<Import Project="Sdk.targets"
1314
Sdk="Microsoft.NET.Sdk" />
15+
1416
<Import Project="../build/Vezel.Zig.Sdk.Hacks.targets" />
1517
<Import Project="../build/Vezel.Zig.Sdk.Defaults.targets" />
1618
<Import Project="../build/Vezel.Zig.Sdk.Defines.targets" />

src/sdk/build/Vezel.Zig.Sdk.Cross.Host.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828

2929
<PropertyGroup>
3030
<HostAbi>gnu</HostAbi>
31+
<HostAbi Condition="'$(HostSystem)' == 'windows'">msvc</HostAbi>
3132
<HostAbi Condition="$(HostRuntimeIdentifier.Contains('-musl-'))">musl</HostAbi>
32-
<HostAbi Condition="'$(HostArchitecture)' == 'arm'">$(HostAbi)eabihf</HostAbi>
33+
<HostAbi Condition="'$(HostArchitecture)' == 'arm' and '$(HostAbi)' != 'msvc'">$(HostAbi)eabihf</HostAbi>
3334
</PropertyGroup>
3435

3536
<PropertyGroup>

src/sdk/build/Vezel.Zig.Sdk.Cross.Target.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@
3737

3838
<PropertyGroup>
3939
<TargetAbi>gnu</TargetAbi>
40+
<TargetAbi Condition="'$(TargetSystem)' == 'windows' and '$(UseMicrosoftAbi)' == 'true'">msvc</TargetAbi>
4041
<TargetAbi Condition="$(TargetRuntimeIdentifier.Contains('-musl-'))">musl</TargetAbi>
41-
<TargetAbi Condition="'$(TargetArchitecture)' == 'arm'">$(TargetAbi)eabihf</TargetAbi>
42+
<TargetAbi Condition="'$(TargetArchitecture)' == 'arm' and '$(TargetAbi)' != 'msvc'">$(TargetAbi)eabihf</TargetAbi>
4243
</PropertyGroup>
4344

4445
<PropertyGroup>

0 commit comments

Comments
 (0)