Skip to content

Commit

Permalink
Provide MSBuild properties to use the new libc++ configuration we pla…
Browse files Browse the repository at this point in the history
…n on using in our builds (#101773)

Co-authored-by: Sven Boemer <sbomer@gmail.com>
  • Loading branch information
jkoritzinsky and sbomer authored May 15, 2024
1 parent f0edcd8 commit 44d919d
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
<!-- Runtime doesn't support Arcade-driven target framework filtering. -->
<NoTargetFrameworkFiltering>true</NoTargetFrameworkFiltering>

<NativeBuildPartitionPropertiesToRemove>ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;ClrDebugSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs</NativeBuildPartitionPropertiesToRemove>
<NativeBuildPartitionPropertiesToRemove>ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;ClrDebugSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs;CxxStandardLibrary;CxxStandardLibraryStatic;CxxAbiLibrary</NativeBuildPartitionPropertiesToRemove>
</PropertyGroup>

<!-- RepositoryEngineeringDir isn't set when Installer tests import this file. -->
Expand Down
11 changes: 9 additions & 2 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@
<UseNativeAotCoreLib Condition="'$(TestNativeAot)' == 'true' or ($(_subset.Contains('+clr.nativeaotlibs+')) and !$(_subset.Contains('+clr.native+')) and !$(_subset.Contains('+clr.runtime+')) and !$(_subset.Contains('+clr.corelib+')))">true</UseNativeAotCoreLib>
</PropertyGroup>

<!-- Configure build properties for C++ runtime library references. -->
<PropertyGroup>
<TargetCxxLibraryProperties Condition="'$(TargetCxxStandardLibrary)' != ''">CxxStandardLibrary=$(TargetCxxStandardLibrary)</TargetCxxLibraryProperties>
<TargetCxxLibraryProperties Condition="'$(TargetCxxStandardLibraryStatic)' != ''">$(TargetCxxLibraryProperties);CxxStandardLibraryStatic=$(TargetCxxStandardLibraryStatic)</TargetCxxLibraryProperties>
<TargetCxxLibraryProperties Condition="'$(TargetCxxAbiLibrary)' != ''">$(TargetCxxLibraryProperties);CxxAbiLibrary=$(TargetCxxAbiLibrary)</TargetCxxLibraryProperties>
</PropertyGroup>

<ItemGroup>
<!-- CoreClr -->
<SubsetName Include="Clr" Description="The full CoreCLR runtime. Equivalent to: $(DefaultCoreClrSubsets)" />
Expand Down Expand Up @@ -265,7 +272,7 @@
<ItemGroup Condition="'$(ClrRuntimeBuildSubsets)' != ''">
<ProjectToBuild
Include="$(CoreClrProjectRoot)runtime.proj"
AdditionalProperties="%(AdditionalProperties);$(ClrRuntimeBuildSubsets)"
AdditionalProperties="%(AdditionalProperties);$(ClrRuntimeBuildSubsets);$(TargetCxxLibraryProperties)"
Category="clr" />
</ItemGroup>

Expand Down Expand Up @@ -455,7 +462,7 @@
<!-- Host sets -->
<ItemGroup Condition="$(_subset.Contains('+host.native+'))">
<CorehostProjectToBuild Include="$(SharedNativeRoot)corehost\corehost.proj" SignPhase="Binaries" />
<ProjectToBuild Include="@(CorehostProjectToBuild)" Pack="true" Category="host" />
<ProjectToBuild Include="@(CorehostProjectToBuild)" AdditionalProperties="$(TargetCxxLibraryProperties)" Pack="true" Category="host" />
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+host.tools+'))">
Expand Down
24 changes: 20 additions & 4 deletions eng/pipelines/common/global-build-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,26 @@ jobs:
- name: crossArg
value: '-cross'

- ${{ if ne(parameters.jobParameters.crossrootfsDir, '') }}:
# This is only required for cross builds.
- name: ROOTFS_DIR
value: ${{ parameters.jobParameters.crossrootfsDir }}
- name: CxxStandardLibraryArg
value: ''
- ${{ if ne(parameters.cxxStandardLibrary, '') }}:
- name: CxxStandardLibraryArg
value: /p:TargetCxxStandardLibrary=${{ parameters.cxxStandardLibrary }}

- name: CxxStandardLibraryStaticArg
value: ''
- ${{ if ne(parameters.cxxStandardLibraryStatic, '') }}:
- name: CxxStandardLibraryStaticArg
value: /p:TargetCxxStandardLibraryStatic=${{ parameters.cxxStandardLibraryStatic }}

- name: CxxAbiLibraryArg
value: ''
- ${{ if ne(parameters.cxxAbiLibrary, '') }}:
- name: CxxAbiLibraryArg
value: /p:TargetCxxAbiLibrary=${{ parameters.cxxAbiLibrary }}

- name: TargetCxxLibraryConfigurationArgs
value: $(CxxStandardLibraryArg) $(CxxStandardLibraryStaticArg) $(CxxAbiLibraryArg)

- name: _officialBuildParameter
${{ if eq(parameters.isOfficialBuild, true) }}:
Expand Down
22 changes: 22 additions & 0 deletions eng/pipelines/common/platform-matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,28 @@ jobs:
crossBuild: true
${{ insert }}: ${{ parameters.jobParameters }}

- ${{ if containsValue(parameters.platforms, 'linux_x64_sanitizer') }}:
- template: xplat-setup.yml
parameters:
jobTemplate: ${{ parameters.jobTemplate }}
helixQueuesTemplate: ${{ parameters.helixQueuesTemplate }}
variables: ${{ parameters.variables }}
osGroup: linux
archType: x64
targetRid: linux-x64
platform: linux_x64
shouldContinueOnError: ${{ parameters.shouldContinueOnError }}
container: linux_x64_sanitizer
jobParameters:
runtimeFlavor: ${{ parameters.runtimeFlavor }}
buildConfig: ${{ parameters.buildConfig }}
helixQueueGroup: ${{ parameters.helixQueueGroup }}
crossBuild: true
cxxStandardLibrary: libc++
cxxStandardLibraryStatic: true
cxxAbiLibrary: libstdc++
${{ insert }}: ${{ parameters.jobParameters }}

# Linux x86

- ${{ if containsValue(parameters.platforms, 'linux_x86') }}:
Expand Down
3 changes: 2 additions & 1 deletion eng/pipelines/common/templates/global-build-step.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ parameters:
shouldContinueOnError: false
archParameter: $(_archParameter)
crossArg: $(crossArg)
targetCxxLibraryConfigurationArgs: $(TargetCxxLibraryConfigurationArgs)
displayName: Build product
container: ''
condition: succeeded()

steps:
- script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -ci ${{ parameters.archParameter }} $(_osParameter) ${{ parameters.crossArg }} ${{ parameters.buildArgs }} $(_officialBuildParameter) $(_buildDarwinFrameworksParameter) $(_overrideTestScriptWindowsCmdParameter)
- script: $(Build.SourcesDirectory)$(dir)build$(scriptExt) -ci ${{ parameters.archParameter }} $(_osParameter) ${{ parameters.crossArg }} ${{ parameters.buildArgs }} ${{ parameters.targetCxxLibraryConfigurationArgs }} $(_officialBuildParameter) $(_buildDarwinFrameworksParameter) $(_overrideTestScriptWindowsCmdParameter)
displayName: ${{ parameters.displayName }}
${{ if eq(parameters.useContinueOnErrorDuringBuild, true) }}:
continueOnError: ${{ parameters.shouldContinueOnError }}
Expand Down
5 changes: 5 additions & 0 deletions eng/pipelines/common/templates/pipeline-with-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ extends:
linux_musl_x64_dev_innerloop:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.19-WithNode

linux_x64_sanitizer:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-cross-amd64-net9.0-sanitizer
env:
ROOTFS_DIR: /crossrootfs/x64

# We use a CentOS Stream 8 image here to test building from source on CentOS Stream 8.
SourceBuild_centos_x64:
image: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8
Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/runtime-sanitized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extends:
buildConfig: Checked
runtimeFlavor: coreclr
platforms:
- linux_x64
- linux_x64_sanitizer
- osx_x64
- windows_x64
variables:
Expand Down Expand Up @@ -63,7 +63,7 @@ extends:
buildConfig: Debug
runtimeFlavor: coreclr
platforms:
- linux_x64
- linux_x64_sanitizer
- osx_x64
variables:
- name: _nativeSanitizersArg
Expand Down Expand Up @@ -123,7 +123,7 @@ extends:
helixQueuesTemplate: /eng/pipelines/coreclr/templates/helix-queues-setup.yml
buildConfig: release
platforms:
- linux_x64
- linux_x64_sanitizer
- osx_x64
- windows_x64
variables:
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@
<_CoreClrBuildArg Include="-cmakeargs &quot;-DCDAC_BUILD_TOOL_BINARY_PATH=$(RuntimeBinDir)cdac-build-tool\cdac-build-tool.dll&quot;" />
</ItemGroup>

<ItemGroup Condition="'$(CxxStandardLibrary)' != ''">
<_CoreClrBuildArg Include="-cmakeargs -DCLR_CMAKE_CXX_STANDARD_LIBRARY=$(CxxStandardLibrary)" />
</ItemGroup>

<ItemGroup Condition="'$(CxxStandardLibraryStatic)' == 'true'">
<_CoreClrBuildArg Include="-cmakeargs -DCLR_CMAKE_CXX_STANDARD_LIBRARY_STATIC=ON" />
</ItemGroup>

<ItemGroup Condition="'$(CxxAbiLibrary)' != ''">
<_CoreClrBuildArg Include="-cmakeargs -DCLR_CMAKE_CXX_ABI_LIBRARY=$(CxxAbiLibrary)" />
</ItemGroup>

<ItemGroup Condition="'$(ClrFullNativeBuild)' != 'true'">
<_CoreClrBuildArg Condition="'$(ClrHostsSubset)' == 'true'" Include="-component hosts" />
<_CoreClrBuildArg Condition="'$(ClrRuntimeSubset)' == 'true'" Include="-component runtime" />
Expand Down
14 changes: 14 additions & 0 deletions src/native/corehost/corehost.proj
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@
<_CoreHostUnixTargetOS Condition="'$(TargetsLinuxBionic)' == 'true'">linux-bionic</_CoreHostUnixTargetOS>
<BuildArgs>$(Configuration) $(TargetArchitecture) -commithash "$([MSBuild]::ValueOrDefault('$(SourceRevisionId)', 'N/A'))" -os $(_CoreHostUnixTargetOS)</BuildArgs>
<BuildArgs>$(BuildArgs) -cmakeargs "-DVERSION_FILE_PATH=$(NativeVersionFile)"</BuildArgs>
</PropertyGroup>
<PropertyGroup Condition="'$(CxxStandardLibrary)' != ''">
<BuildArgs>$(BuildArgs) -cmakeargs -DCLR_CMAKE_CXX_STANDARD_LIBRARY=$(CxxStandardLibrary)</BuildArgs>
</PropertyGroup>

<PropertyGroup Condition="'$(CxxStandardLibraryStatic)' == 'true'">
<BuildArgs>$(BuildArgs) -cmakeargs -DCLR_CMAKE_CXX_STANDARD_LIBRARY_STATIC=ON</BuildArgs>
</PropertyGroup>

<PropertyGroup Condition="'$(CxxAbiLibrary)' != ''">
<BuildArgs>$(BuildArgs) -cmakeargs -DCLR_CMAKE_CXX_ABI_LIBRARY=$(CxxAbiLibrary)</BuildArgs>
</PropertyGroup>

<PropertyGroup>
<BuildArgs Condition="'$(ConfigureOnly)' == 'true'">$(BuildArgs) -configureonly</BuildArgs>
<BuildArgs Condition="'$(PortableBuild)' != 'true'">$(BuildArgs) -portablebuild=false</BuildArgs>
<BuildArgs Condition="'$(KeepNativeSymbols)' != 'false'">$(BuildArgs) -keepnativesymbols</BuildArgs>
Expand Down

0 comments on commit 44d919d

Please sign in to comment.