-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate LocateNativeCompiler target
- Loading branch information
Showing
9 changed files
with
49 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<Project> | ||
<!-- | ||
Use init-compiler.sh to locate the compiler toolchain which was resolved for rest of the build. | ||
This target is essentially an override hook which is called before `SetupOSSpecificProps` in | ||
`Microsoft.NETCore.Native.Unix.targets`. Note that the input is `CppCompilerAndLinker` | ||
and the output is `CppLinker`, because from `SetupOSSpecificProps` onwards, we only use `CppLinker` | ||
(when alternative compiler, i.e. gcc, is not selected) | ||
--> | ||
<Target Name="LocateNativeCompiler" | ||
Condition="!$(RuntimeIdentifier.StartsWith('win-'))" | ||
BeforeTargets="SetupOSSpecificProps"> | ||
<PropertyGroup> | ||
<CppCompilerAndLinker Condition="'$(CppCompilerAndLinker)' == ''">clang</CppCompilerAndLinker> | ||
<SysRoot Condition="'$(CrossBuild)' == 'true'">$(ROOTFS_DIR)</SysRoot> | ||
</PropertyGroup> | ||
|
||
<Exec Command="sh -c 'build_arch="$(TargetArchitecture)" compiler="$(CppCompilerAndLinker)" . "$(RepositoryEngineeringDir)/common/native/init-compiler.sh" && echo "$CC;$LDFLAGS"' 2>/dev/null" | ||
EchoOff="true" | ||
ConsoleToMsBuild="true" | ||
StandardOutputImportance="Low"> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="_CC_LDFLAGS" /> | ||
</Exec> | ||
|
||
<Exec Command=""$(CppCompilerAndLinker)" -dumpversion" Condition="'$(_IsApplePlatform)' == 'true'" IgnoreExitCode="true" StandardOutputImportance="Low" ConsoleToMSBuild="true"> | ||
<Output TaskParameter="ExitCode" PropertyName="_AppleClangVersionStringExitCode" /> | ||
<Output TaskParameter="ConsoleOutput" PropertyName="_AppleClangVersionString" /> | ||
</Exec> | ||
|
||
<ItemGroup> | ||
<CustomLinkerArg Condition="'$(_IsApplePlatform)' == 'true' and '$(_AppleClangVersionStringExitCode)' == '0' and $([MSBuild]::VersionGreaterThanOrEquals('$(_AppleClangVersionString)', '15.0'))" Include="-ld_classic" /> | ||
<CustomLinkerArg Condition="'$(CrossBuild)' == 'true' and $(CppCompilerAndLinker.Contains('clang')) and '$(_IsApplePlatform)' != 'true'" Include="--gcc-toolchain=$(ROOTFS_DIR)/usr" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<CppLinker>$(_CC_LDFLAGS.SubString(0, $(_CC_LDFLAGS.IndexOf(';'))))</CppLinker> | ||
<_LDFLAGS>$(_CC_LDFLAGS.SubString($([MSBuild]::Add($(_CC_LDFLAGS.IndexOf(';')), 1))))</_LDFLAGS> | ||
<LinkerFlavor Condition="$(_LDFLAGS.Contains('lld'))">lld</LinkerFlavor> | ||
</PropertyGroup> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.