Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# TODO: fixup shared library usage.
build --noexperimental_link_static_libraries_once

# Raise the macOS deployment target. The default (10.11) is no longer supported
# by the current SDK's libc++, which turns into a -Werror build failure. Applies
# to both target and exec (host) configurations. No effect on non-macOS builds.
build --macos_minimum_os=11.0
build --host_macos_minimum_os=11.0

# Graphics testing environments options:
#
# * <default>
Expand Down
89 changes: 83 additions & 6 deletions .github/workflows/presubmit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
branches-ignore:
- main # push events to main branch occur after PRs are merged, when the same checks were run

permissions:
contents: read

concurrency:
# limits the workflow to a single run per branch/PR
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -18,8 +21,12 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
# No step needs the token afterwards, so do not leave it
# behind in .git/config.
persist-credentials: false
- name: Install go
uses: actions/setup-go@v6
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
Comment thread
utzcoz marked this conversation as resolved.
with:
go-version: '1.23.1'
- name: Install buildozer
Expand Down Expand Up @@ -50,7 +57,7 @@ jobs:
with:
# TODO(b/475886246): fix and remove `detect_leaks=0`
# TODO(b/475885975): fix and remove `detect_odr_violation=0`
additional-bazel-args: --config=asan --test_env="ASAN_OPTIONS=detect_leaks=0:detect_odr_violation=0"
additional-bazel-args: --config=asan --test_env=ASAN_OPTIONS=detect_leaks=0:detect_odr_violation=0
runner: ubuntu-22.04

run-gfxstream-bazel-tests-arm:
Expand All @@ -60,15 +67,36 @@ jobs:
# The arm runner is too slow:
run-tests: false

run-gfxstream-bazel-build-macos:
uses: ./.github/workflows/presubmit_bazel.yml
with:
runner: macos-26
# macOS can not build the full target graph: the Linux-only mesa/libdrm
# guest dependencies and swiftshader's bundled LLVM (which has no macOS
# config) do not build on Darwin. Build the host backend libraries, which
# are the macOS deliverable and mirror the CMake/Meson host builds below.
build-targets: >-
//host:gfxstream_backend_static
//host:gfxstream_backend_shared
//host:gfxstream_backend
# Nothing is run yet: this job exists to keep the macOS host build
# compiling. Tests need a graphics driver environment that macOS does not
# have here yet.
run-tests: false

run-gfxstream-cmake-build:
runs-on: ubuntu-22.04
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@v1.3.1
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
tool-cache: true
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
# No step needs the token afterwards, so do not leave it
# behind in .git/config.
persist-credentials: false
- name: Install toolchain dependencies
run: sudo bash toolchain/cmake/install_toolchain_dependencies.sh
- name: Configure Build
Expand All @@ -81,15 +109,40 @@ jobs:
cd build && \
ninja

run-gfxstream-cmake-build-macos:
runs-on: macos-26
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
# No step needs the token afterwards, so do not leave it
# behind in .git/config.
persist-credentials: false
- name: Install toolchain dependencies
run: brew install cmake ninja
- name: Configure Build
run: |
mkdir build && \
cd build && \
cmake .. -G Ninja
- name: Build
run: |
cd build && \
ninja

run-gfxstream-meson-build:
runs-on: ubuntu-22.04
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@v1.3.1
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
tool-cache: true
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
# No step needs the token afterwards, so do not leave it
# behind in .git/config.
persist-credentials: false
- name: Install toolchain dependencies
run: sudo bash toolchain/meson/install_toolchain_dependencies.sh
- name: Configure Build
Expand All @@ -102,17 +155,41 @@ jobs:
run: |
meson compile -C build

run-gfxstream-meson-build-macos:
runs-on: macos-26
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
# No step needs the token afterwards, so do not leave it
# behind in .git/config.
persist-credentials: false
- name: Install toolchain dependencies
run: brew install meson ninja molten-vk vulkan-loader
- name: Configure Build
run: |
meson setup \
-Ddefault_library=static \
-Dgfxstream-build=host \
build
- name: Build
run: |
meson compile -C build

run-gfxstream-meson-build-windows:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- name: Checkout current PR branch
uses: actions/checkout@v6
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: msys2/setup-msys2@v2
# No step needs the token afterwards, so do not leave it
# behind in .git/config.
persist-credentials: false
- uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2.32.0
with:
msystem: UCRT64
update: true
Expand Down
47 changes: 39 additions & 8 deletions .github/workflows/presubmit_bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,59 @@ on:
type: string
default: ''

# Which targets to build. Defaults to everything, but platforms that can
# not build the full target graph (e.g. macOS, which lacks the Linux-only
# mesa/libdrm/guest dependencies) can override this with a curated list.
build-targets:
type: string
default: '...'

# Whether or not to run the `bazel test` step:
run-tests:
type: boolean
default: true

permissions:
contents: read

jobs:
presubmit_bazel_workflow:
runs-on: ${{ inputs.runner }}
steps:
- name: Free disk space
uses: jlumbroso/free-disk-space@v1.3.1
if: runner.os == 'Linux'
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
tool-cache: true

- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
# No step needs the token afterwards, so do not leave it
# behind in .git/config.
persist-credentials: false

- name: Install bazel
- name: Install bazel (Linux)
if: runner.os == 'Linux'
run: sudo bash toolchain/bazel/install_bazel.sh

- name: Install toolchain dependencies
- name: Install toolchain dependencies (Linux)
if: runner.os == 'Linux'
run: sudo bash toolchain/bazel/install_toolchain_dependencies.sh

- name: Install runtime dependencies
- name: Install runtime dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libvulkan1

- name: Install bazel (macOS)
if: runner.os == 'macOS'
run: brew install bazelisk

- name: Load cache config
run: cat .config/cache-config.env >> $GITHUB_ENV

- name: Mount Bazel cache
uses: actions/cache/restore@v5
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: "~/bazel-disk-cache"
key: ${{ format('{0}-{1}-bazel-disk-cache-{2}-{3}-{4}-', runner.os, runner.arch, env.CACHE_VERSION, github.ref_name, github.sha) }}
Expand All @@ -53,15 +75,24 @@ jobs:
${{ format('{0}-{1}-bazel-disk-cache-{2}-', runner.os, runner.arch, env.CACHE_VERSION) || '' }}

- name: Build
# Workflow inputs reach the script through the environment rather than
# being expanded into it, so that their contents can never be parsed as
# shell code. They are deliberately left unquoted below so that the shell
# still splits them into separate arguments.
env:
BUILD_TARGETS: ${{ inputs.build-targets }}
ADDITIONAL_BAZEL_ARGS: ${{ inputs.additional-bazel-args }}
run: |
bazel build ... \
bazel build $BUILD_TARGETS \
--disk_cache=$HOME/bazel-disk-cache \
--graphics_drivers=gles_angle_vulkan_swiftshader \
--verbose_failures \
${{ inputs.additional-bazel-args }}
$ADDITIONAL_BAZEL_ARGS

- name: Test
if: ${{ inputs.run-tests }}
env:
ADDITIONAL_BAZEL_ARGS: ${{ inputs.additional-bazel-args }}
run: |
bazel test \
--disk_cache=$HOME/bazel-disk-cache \
Expand All @@ -74,4 +105,4 @@ jobs:
host/vulkan:vk_common_operations_tests \
host/vulkan:vk_format_utils_tests \
tests/end2end:gfxstream_end2end_tests \
${{ inputs.additional-bazel-args }}
$ADDITIONAL_BAZEL_ARGS
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ option(BUILD_GRAPHICS_DETECTOR "Build the graphics detector utility" OFF)
if (WIN32)
add_definitions("-DUNICODE -D_UNICODE -DNOMINMAX -DEMUGL_BUILD -DVK_USE_PLATFORM_WIN32_KHR -DBUILDING_EMUGL_COMMON_SHARED")
endif()
if (APPLE)
add_definitions("-DVK_USE_PLATFORM_METAL_EXT -DVK_USE_PLATFORM_MACOS_MVK")
endif()

option(VIRGL_RENDERER_UNSTABLE_APIS "Use unstable virglrenderer APIs" ON)
if(VIRGL_RENDERER_UNSTABLE_APIS)
Expand Down
18 changes: 18 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,29 @@ bazel_dep(name = "abseil-cpp", version = "20260107.0", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.22.5", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.7.1", dev_dependency = True)
bazel_dep(name = "toolchains_llvm", version = "1.6.0", dev_dependency = True)
bazel_dep(name = "apple_support", version = "1.21.0", repo_name = "build_bazel_apple_support", dev_dependency = True)
bazel_dep(name = "rules_python", version = "1.5.0", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.6.1", dev_dependency = True)
bazel_dep(name = "rules_rust", version = "0.68.1", dev_dependency = True)
bazel_dep(name = "zlib", version = "1.3.1.bcr.3", dev_dependency = True)

# Register the Apple CC (Xcode) toolchain so that `objc_library`/`.mm` targets can
# be compiled on macOS. The hermetic LLVM toolchain registered below does not
# support Objective-C compilation. This must be registered before the LLVM
# toolchain so that it is selected first when targeting macOS; the Apple toolchain
# is constrained to Apple platforms, so Linux/other builds still use LLVM.
apple_cc_configure = use_extension(
"@build_bazel_apple_support//crosstool:setup.bzl",
"apple_cc_configure_extension",
dev_dependency = True,
)
use_repo(apple_cc_configure, "local_config_apple_cc_toolchains")

register_toolchains(
"@local_config_apple_cc_toolchains//:all",
dev_dependency = True,
)

llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
llvm.toolchain(
llvm_version = "18.1.8",
Expand Down
3 changes: 3 additions & 0 deletions common/base/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ objc_library(
srcs = [
"system-native-mac.mm",
],
# These sources use manual reference counting (retain/release, CFRelease),
# so disable ARC which objc_library enables by default.
copts = ["-fno-objc-arc"],
sdk_frameworks = [
"IOKit",
"AppKit",
Expand Down
9 changes: 7 additions & 2 deletions common/base/SharedMemory_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ SharedMemory::SharedMemory(const std::string& name, size_t size) {
mName = PathUtils::recompose(PathUtils::decompose(std::move(path)));
} else {
mShareType = ShareType::SHARED_MEMORY;
mName = name;
// POSIX.1-2017 (System Interfaces) requires shm_open() names to begin
// with a '/' character to avoid implementation-defined behavior.
// Normalize unconditionally so callers don't need to care about it.
mName = (!name.empty() && name[0] != '/') ? ("/" + name) : name;
}
}

Expand Down Expand Up @@ -111,7 +114,9 @@ int SharedMemory::openInternal(int oflag, int mode, bool doMapping) {
int err = 0;
struct stat sb;
if (mShareType == ShareType::SHARED_MEMORY) {
#if defined(HAVE_MEMFD_CREATE)
#if defined(__APPLE__)
mFd = ::shm_open(mName.c_str(), oflag, mode);
#elif defined(HAVE_MEMFD_CREATE)
mFd = memfd_create(mName.c_str(), MFD_CLOEXEC | MFD_ALLOW_SEALING);
#else
mFd = syscall(__NR_memfd_create, mName.c_str(), FD_CLOEXEC);
Expand Down
5 changes: 5 additions & 0 deletions common/base/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ if host_machine.system() == 'windows'
files_lib_common_base += 'SharedMemory_win32.cpp'
files_lib_common_base += 'Thread_win32.cpp'
files_lib_common_base += 'Win32UnicodeString.cpp'
elif host_machine.system() == 'darwin'
files_lib_common_base += 'SharedMemory_posix.cpp'
files_lib_common_base += 'Thread_pthread.cpp'
files_lib_common_base += 'system-native-mac.mm'
common_base_deps += dependency('appleframeworks', modules: ['Foundation', 'AppKit', 'IOKit'])
else
files_lib_common_base += 'SharedMemory_posix.cpp'
files_lib_common_base += 'Thread_pthread.cpp'
Expand Down
3 changes: 3 additions & 0 deletions host/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ objc_library(
],
copts = GFXSTREAM_HOST_COPTS + [
"-Wno-deprecated-declarations",
# These sources use manual reference counting, so disable ARC which
# objc_library enables by default.
"-fno-objc-arc",
],
defines = GFXSTREAM_HOST_DEFINES,
sdk_frameworks = [
Expand Down
14 changes: 6 additions & 8 deletions host/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,12 @@ target_link_libraries(
gfxstream_openglesdispatch
gfxstream-gl-server
gfxstream-vulkan-server
gfxstream_xcb_headers
GLES_CM_translator_static
renderControl_dec
)
if(NOT APPLE AND NOT WIN32)
target_link_libraries(gfxstream_backend_static PUBLIC gfxstream_xcb_headers)
endif()

target_include_directories(
gfxstream_backend_static
Expand Down Expand Up @@ -357,18 +359,14 @@ endfunction()
Vulkan_unittests
PUBLIC
"-framework AppKit")
endif()
discover_tests(
Vulkan_unittests
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

if (APPLE)
target_compile_definitions(Vulkan_unittests PRIVATE -DVK_USE_PLATFORM_METAL_EXT)
elseif (QNX)
target_compile_definitions(Vulkan_unittests PRIVATE -DVK_USE_PLATFORM_SCREEN_QNX)
elseif (UNIX)
target_compile_definitions(Vulkan_unittests PRIVATE -DVK_USE_PLATFORM_XCB_KHR)
endif()
discover_tests(
Vulkan_unittests
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})


file(GLOB Vulkan_unittests_datafiles "vulkan/testdata/*.png")
Expand Down
Loading
Loading