Skip to content

Commit

Permalink
Fix broken build on Alpine (#4264)
Browse files Browse the repository at this point in the history
  • Loading branch information
ManickaP authored May 14, 2024
1 parent df793df commit 0576776
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .azure/obtemplates/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ jobs:
target: ubuntu_2004_x86_64
${{ else }}:
target: ubuntu_2204_x86_64
xdp: true
inputs:
pwsh: true
filePath: scripts/build.ps1
arguments: -Tls ${{ parameters.tls }} -Config ${{ parameters.config }} -Platform ${{ parameters.platform }} -Arch x64 -CI -UseSystemOpenSSLCrypto -OneBranch -OfficialRelease
arguments: -Tls ${{ parameters.tls }} -Config ${{ parameters.config }} -Platform ${{ parameters.platform }} -EnableLinuxXDP ${{ xdp }} -Arch x64 -CI -UseSystemOpenSSLCrypto -OneBranch -OfficialRelease
- task: PowerShell@2
displayName: arm64
${{ if eq(parameters.tls, 'openssl') }}:
Expand Down
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ elseif (APPLE)
set(CX_PLATFORM "darwin")
elseif (UNIX)
set(CX_PLATFORM "linux")
file(STRINGS "/etc/lsb-release" LSB_RELEASE_CONTENT)
string(REGEX MATCH "DISTRIB_RELEASE=([0-9]+\\.[0-9]+)" _ ${LSB_RELEASE_CONTENT})
set(UBUNTU_VERSION ${CMAKE_MATCH_1})
endif()
message(STATUS "QUIC Platform: ${CX_PLATFORM}")

Expand All @@ -93,6 +90,7 @@ option(QUIC_STATIC_LINK_PARTIAL_CRT "Statically links the compiler-specific port
option(QUIC_UWP_BUILD "Build for UWP" OFF)
option(QUIC_GAMECORE_BUILD "Build for GameCore" OFF)
option(QUIC_PGO "Enables profile guided optimizations" OFF)
option(QUIC_LINUX_XDP_ENABLED "Enables XDP support" OFF)
option(QUIC_SOURCE_LINK "Enables source linking on MSVC" ON)
option(QUIC_EMBED_GIT_HASH "Embed git commit hash in the binary" ON)
option(QUIC_PDBALTPATH "Enable PDBALTPATH setting on MSVC" ON)
Expand Down
2 changes: 1 addition & 1 deletion docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Linux XDP is experimentally supported on amd64 && Ubuntu 22.04LTS.
Commands below automatically install dependencies and setup runtime environment.
```sh
pwsh ./scripts/prepare-machine.ps1 -UseXdp
pwsh ./scripts/build.ps1
pwsh ./scripts/build.ps1 -EnableLinuxXDP
```

`./scripts/prepare-machine.ps1` internally does the below commands:
Expand Down
15 changes: 15 additions & 0 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ This script provides helpers for building msquic.
.PARAMETER PGO
Builds msquic with profile guided optimization support (Windows-only).
.PARAMETER EnableLinuxXDP
Enables XDP support (Linux-only).
.PARAMETER Generator
Specifies a specific cmake generator (Only supported on unix)
Expand Down Expand Up @@ -166,6 +169,9 @@ param (
[Parameter(Mandatory = $false)]
[switch]$PGO = $false,

[Parameter(Mandatory = $false)]
[switch]$EnableLinuxXDP = $false,

[Parameter(Mandatory = $false)]
[string]$Generator = "",

Expand Down Expand Up @@ -265,6 +271,12 @@ if ($Arch -eq "arm64ec") {
}
}

if ($IsLinux -And $Arch -ne "x64") {
if ($EnableLinuxXDP) {
Write-Error "Linux XDP is supported only on x64 platforms"
}
}

if ($Platform -eq "ios" -and !$Static) {
$Static = $true
Write-Host "iOS can only be built as static"
Expand Down Expand Up @@ -457,6 +469,9 @@ function CMake-Generate {
if ($PGO) {
$Arguments += " -DQUIC_PGO=on"
}
if ($EnableLinuxXDP) {
$Arguments += " -DQUIC_LINUX_XDP_ENABLED=on"
}
if ($Platform -eq "uwp") {
$Arguments += " -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0 -DQUIC_UWP_BUILD=on"
}
Expand Down
3 changes: 1 addition & 2 deletions scripts/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ fn main() {
config
.define("QUIC_ENABLE_LOGGING", logging_enabled)
.define("QUIC_TLS", "openssl")
.define("QUIC_OUTPUT_DIR", "../lib")
.define("QUIC_CARGO_BUILD", "on");
.define("QUIC_OUTPUT_DIR", "../lib");

match target.as_str() {
"x86_64-apple-darwin" => config
Expand Down
17 changes: 5 additions & 12 deletions src/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@ if("${CX_PLATFORM}" STREQUAL "windows")
set(SOURCES ${SOURCES} datapath_raw.c datapath_raw_win.c datapath_raw_socket.c datapath_raw_socket_win.c datapath_raw_xdp_win.c)
endif()
else()
set(LINUX_XDP_ENABLED FALSE)
set(SOURCES ${SOURCES} inline.c platform_posix.c storage_posix.c cgroup.c datapath_unix.c)
if(CX_PLATFORM STREQUAL "linux" AND NOT CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(SOURCES ${SOURCES} datapath_linux.c datapath_epoll.c)
if ((${UBUNTU_VERSION} STREQUAL "20.04") OR
(${CMAKE_TARGET_ARCHITECTURE} STREQUAL "arm64") OR
(${CMAKE_TARGET_ARCHITECTURE} STREQUAL "arm") OR
(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm") OR
(ANDROID) OR
(QUIC_CARGO_BUILD))
set(SOURCES ${SOURCES} datapath_xplat.c datapath_raw_dummy.c)
else()
set(LINUX_XDP_ENABLED TRUE)
if (QUIC_LINUX_XDP_ENABLED)
set(SOURCES ${SOURCES} datapath_xplat.c datapath_raw.c datapath_raw_linux.c datapath_raw_socket.c datapath_raw_socket_linux.c datapath_raw_xdp_linux.c)
else()
set(SOURCES ${SOURCES} datapath_xplat.c datapath_raw_dummy.c)
endif()
else()
set(SOURCES ${SOURCES} datapath_kqueue.c)
Expand Down Expand Up @@ -68,7 +61,7 @@ if("${CX_PLATFORM}" STREQUAL "windows")
PUBLIC
wbemuuid)
target_link_libraries(platform PUBLIC winmm)
elseif(LINUX_XDP_ENABLED)
elseif(QUIC_LINUX_XDP_ENABLED)
find_library(NL_LIB nl-3)
find_library(NL_ROUTE_LIB nl-route-3)
find_library(XDP_LIB libxdp.so)
Expand Down Expand Up @@ -118,7 +111,7 @@ if ("${CX_PLATFORM}" STREQUAL "windows")
PRIVATE
${EXTRA_PLATFORM_INCLUDE_DIRECTORIES}
${PROJECT_SOURCE_DIR}/submodules/xdp-for-windows/published/external)
elseif(LINUX_XDP_ENABLED)
elseif(QUIC_LINUX_XDP_ENABLED)
include_directories(/usr/include/libnl3)
target_include_directories(platform PRIVATE ${EXTRA_PLATFORM_INCLUDE_DIRECTORIES})
endif()
Expand Down

0 comments on commit 0576776

Please sign in to comment.