Skip to content

Commit

Permalink
Add support for building ARM64 native only eBPF for Windows.
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Jowett <[email protected]>
  • Loading branch information
Alan Jowett committed Oct 10, 2024
1 parent 8fb3a7e commit 4e3faa3
Show file tree
Hide file tree
Showing 16 changed files with 1,274 additions and 1,933 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,24 @@ jobs:


onebranch:
strategy:
matrix:
Architecture: ['x64', 'ARM64']
# Always run this job.
if: github.event_name == 'schedule' || github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'merge_group' || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/reusable-build.yml
with:
ref: ${{ github.ref }}
repository: ${{ github.repository }}
build_artifact: Build-x64-onebranch
build_artifact: Build-${{ matrix.Architecture }}-onebranch
generate_release_package: true
build_msi: true
build_nuget: true
configurations: '["NativeOnlyDebug", "NativeOnlyRelease"]'
build_options: /p:BuildOneBranch='True' /t:tools\onebranch
build_options: /p:BuildOneBranch='True' /t:tools\onebranch /t:installer\ebpf-for-windows
solution_file: "ebpf-for-windows.sln"
architecture: ${{ matrix.Architecture }}
download_demo_repository: false

# Perform the native-only build.
regular_native-only:
Expand Down
24 changes: 16 additions & 8 deletions .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ on:
required: false
type: string
default: 'ebpf-for-windows.sln'
architecture:
required: false
type: string
default: 'x64'
download_demo_repository:
required: false
type: boolean
default: true
outputs:
should_skip:
description: 'Whether build was skipped due to duplicate action.'
Expand Down Expand Up @@ -82,7 +90,7 @@ jobs:
SOLUTION_FILE_PATH: ${{inputs.solution_file}}
BUILD_ARTIFACT_NAME: ${{inputs.build_artifact}}
BUILD_CONFIGURATION: ${{matrix.configurations}}
BUILD_PLATFORM: x64
BUILD_PLATFORM: ${{inputs.architecture}}
BUILD_OPTIONS: ${{inputs.build_options}}
CXX_FLAGS: ${{inputs.cxx_flags}}
LD_FLAGS: ${{inputs.ld_flags}}
Expand Down Expand Up @@ -161,7 +169,7 @@ jobs:
cache-name: cache-verifier-project
with:
path: external/ebpf-verifier/build
key: ${{ runner.os }}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}-${{env.BUILD_ARTIFACT_NAME}}-${{ hashFiles('.git/modules/external/ebpf-verifier/HEAD') }}-${{ hashFiles('external/Directory.Build.props')}}-${{env.msvc_tools_version}}
key: ${{ runner.os }}-${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}-${{env.BUILD_ARTIFACT_NAME}}-${{ hashFiles('.git/modules/external/ebpf-verifier/HEAD') }}-${{ hashFiles('external/Directory.Build.props')}}-${{env.msvc_tools_version}}-${{ hashFiles('scripts/initialize_ebpf_repo.ps1')}}

- name: Configuring repo for first build
if: steps.skip_check.outputs.should_skip != 'true'
Expand All @@ -170,7 +178,7 @@ jobs:
CXXFLAGS: /ZH:SHA_256 ${{env.CXX_FLAGS}}
LDFLAGS: ${{env.LD_FLAGS}}
run: |
.\scripts\initialize_ebpf_repo.ps1
.\scripts\initialize_ebpf_repo.ps1 ${{env.BUILD_PLATFORM}}
- name: Build
if: steps.skip_check.outputs.should_skip != 'true'
Expand All @@ -197,12 +205,12 @@ jobs:
copy "${{env.msvc_tools_path}}\bin\Hostx64\x64\clang*" .
- name: Download demo Debug repository
if: steps.skip_check.outputs.should_skip != 'true' && (matrix.configurations == 'Debug' || matrix.configurations == 'NativeOnlyDebug')
if: steps.skip_check.outputs.should_skip != 'true' && inputs.download_demo_repository == true && (matrix.configurations == 'Debug' || matrix.configurations == 'NativeOnlyDebug')
working-directory: ${{env.GITHUB_WORKSPACE}}
run: Invoke-WebRequest https://github.com/microsoft/ebpf-for-windows-demo/releases/download/v0.0.2/${{env.BUILD_PLATFORM}}-Debug-cilium-xdp.zip -OutFile x64-${{env.BUILD_CONFIGURATION}}-cilium-xdp.zip

- name: Download demo Release repository
if: steps.skip_check.outputs.should_skip != 'true' && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease')
if: steps.skip_check.outputs.should_skip != 'true' && inputs.download_demo_repository == true && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease')
working-directory: ${{env.GITHUB_WORKSPACE}}
run: Invoke-WebRequest https://github.com/microsoft/ebpf-for-windows-demo/releases/download/v0.0.2/${{env.BUILD_PLATFORM}}-Release-cilium-xdp.zip -OutFile x64-${{env.BUILD_CONFIGURATION}}-cilium-xdp.zip

Expand All @@ -215,7 +223,7 @@ jobs:
Invoke-WebRequest https://github.com/microsoft/bpf_performance/releases/download/v0.0.6/build-Release-windows-2022.zip -OutFile bpf_performance.zip
- name: Extract artifacts to build path
if: steps.skip_check.outputs.should_skip != 'true' && matrix.configurations != 'FuzzerDebug'
if: steps.skip_check.outputs.should_skip != 'true' && inputs.download_demo_repository == true && matrix.configurations != 'FuzzerDebug'
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
cd ${{github.workspace}}/${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}
Expand Down Expand Up @@ -243,12 +251,12 @@ jobs:
path: ${{github.workspace}}/${{env.BUILD_PLATFORM}}/${{env.BUILD_CONFIGURATION}}/ebpf-for-windows.msi

- name: Build the NuGet package
if: inputs.build_nuget == true && matrix.configurations == 'Release' && steps.skip_check.outputs.should_skip != 'true'
if: inputs.build_nuget == true && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease') && steps.skip_check.outputs.should_skip != 'true'
working-directory: ${{env.GITHUB_WORKSPACE}}
run: msbuild /m /p:Configuration=${{env.BUILD_CONFIGURATION}} /p:Platform=${{env.BUILD_PLATFORM}} ${{env.SOLUTION_FILE_PATH}} ${{env.BUILD_OPTIONS}} /t:tools\nuget

- name: Upload the NuGet package
if: inputs.build_nuget == true && matrix.configurations == 'Release' && steps.skip_check.outputs.should_skip != 'true'
if: inputs.build_nuget == true && (matrix.configurations == 'Release' || matrix.configurations == 'NativeOnlyRelease') && steps.skip_check.outputs.should_skip != 'true'
uses: actions/upload-artifact@604373da6381bf24206979c74d06a550515601b9
with:
name: ebpf-for-windows - NuGet package (${{inputs.build_artifact}}_${{env.BUILD_CONFIGURATION}})
Expand Down
39 changes: 37 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="NativeOnlyDebug|ARM64">
<Configuration>NativeOnlyDebug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="FuzzerDebug|ARM64">
<Configuration>FuzzerDebug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="NativeOnlyRelease|ARM64">
<Configuration>NativeOnlyRelease</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Condition="'$(Analysis)'=='True'">
<RunCodeAnalysis>true</RunCodeAnalysis>
Expand All @@ -44,10 +64,11 @@
<DisableJIT>true</DisableJIT>
<DisableInterpreter>true</DisableInterpreter>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release' Or '$(Configuration)'=='NativeOnlyRelease'">
<!-- Libsancov.lib not supported on arm64 -->
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' Or '$(Configuration)|$(Platform)'=='NativeOnlyRelease|x64'">
<FuzzerLibs>libsancov.lib;clang_rt.fuzzer_MD-x86_64.lib</FuzzerLibs>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='FuzzerDebug' Or '$(Configuration)'=='NativeOnlyDebug'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' Or '$(Configuration)|$(Platform)'=='FuzzerDebug|x64' Or '$(Configuration)|$(Platform)'=='NativeOnlyDebug|x64'">
<FuzzerLibs>libsancov.lib;clang_rt.fuzzer_MDd-x86_64.lib</FuzzerLibs>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Fuzzer)'=='Release|True'">
Expand Down Expand Up @@ -81,6 +102,7 @@
<Link>
<CETCompat Condition="'$(Platform)'=='x64'">true</CETCompat>
<AdditionalLibraryDirectories Condition="'$(Platform)'=='x64'">$(VC_LibraryPath_VC_x64_Desktop);%(Link.AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories Condition="'$(Platform)'=='ARM64'">$(VC_LibraryPath_VC_ARM64_Desktop);%(Link.AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(DisableJIT)'=='True'">
Expand Down Expand Up @@ -123,4 +145,17 @@
<PreprocessorDefinitions>_AMD64_;_WIN32_WINNT=0x0a00;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
<ClCompile>
<PreprocessorDefinitions>_X86_;_WIN32_WINNT=0x0a00;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Platform)'=='ARM64'">
<ClCompile>
<!-- Set the _ARM64_ as it is required by winnt.h for correct compilation rather than the standard _M_ARM64 -->
<PreprocessorDefinitions>_ARM64_;_WIN32_WINNT=0x0a00;_WINDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<!-- Set the option to emit both armv8.0 atomics and armv8.1 atomics with processor detection to select the best performing one.-->
<AdditionalOptions>/d2overrideInterlockedIntrinsArm64 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
</Project>
Loading

0 comments on commit 4e3faa3

Please sign in to comment.