Skip to content

Commit 6732d8d

Browse files
committed
Fix building in Linux glibc with gcc14 and clang19
1 parent e15d2fb commit 6732d8d

File tree

3 files changed

+112
-0
lines changed

3 files changed

+112
-0
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,46 @@ name: build
33
on: [push, pull_request]
44

55
jobs:
6+
7+
linux:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
include:
13+
- os: "archlinux:base"
14+
pkgs: "gcc"
15+
env: "CC=gcc CXX=g++"
16+
- os: "archlinux:base"
17+
pkgs: "clang"
18+
env: "CC=clang CXX=clang++"
19+
container:
20+
image: ${{ matrix.os }}
21+
steps:
22+
- name: prep archlinux
23+
if: startsWith(matrix.os, 'archlinux')
24+
run: |
25+
pacman -Syu --needed --noconfirm \
26+
${{ matrix.pkgs }} bison cmake expat flex fmt git gtest \
27+
libpng ninja pkgconf protobuf
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
submodules: true
32+
- name: Prepare
33+
run: |
34+
git config --global user.email "[email protected]"
35+
git config --global user.name "Your Name"
36+
- name: Build
37+
run: |
38+
test -n "${{ matrix.env }}" && export ${{ matrix.env }}
39+
cmake -B build -G Ninja
40+
cmake --build build
41+
- name: Check
42+
run: |
43+
./build/vendor/aapt version
44+
./build/vendor/aapt2 version
45+
646
mingw:
747
runs-on: windows-latest
848
strategy:
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
From 3bea7c9d6f6c7750fcd180f84f5b32c76d35e56e Mon Sep 17 00:00:00 2001
2+
From: Biswapriyo Nath <[email protected]>
3+
Date: Wed, 1 Jan 2025 00:00:00 +0000
4+
Subject: [PATCH] base: Fix variable initialization
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
This fixes the following compiler error with g++
10+
11+
AssetsProvider.cpp:140:18: error: expected primary-expression before ‘.’ token
12+
140 | struct stat sb{.st_mtime = -1};
13+
| ^
14+
---
15+
libs/androidfw/AssetsProvider.cpp | 6 ++++--
16+
1 file changed, 4 insertions(+), 2 deletions(-)
17+
18+
diff --git a/libs/androidfw/AssetsProvider.cpp b/libs/androidfw/AssetsProvider.cpp
19+
index 2d3c06506..aeee8dd22 100644
20+
--- a/libs/androidfw/AssetsProvider.cpp
21+
+++ b/libs/androidfw/AssetsProvider.cpp
22+
@@ -104,7 +104,8 @@ std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(std::string path,
23+
return {};
24+
}
25+
26+
- struct stat sb{.st_mtime = -1};
27+
+ struct stat sb{};
28+
+ sb.st_mtime = -1;
29+
// Skip all up-to-date checks if the file won't ever change.
30+
if (!isReadonlyFilesystem(path.c_str())) {
31+
if ((released_fd < 0 ? stat(path.c_str(), &sb) : fstat(released_fd, &sb)) < 0) {
32+
@@ -137,7 +138,8 @@ std::unique_ptr<ZipAssetsProvider> ZipAssetsProvider::Create(base::unique_fd fd,
33+
return {};
34+
}
35+
36+
- struct stat sb{.st_mtime = -1};
37+
+ struct stat sb{};
38+
+ sb.st_mtime = -1;
39+
// Skip all up-to-date checks if the file won't ever change.
40+
if (!isReadonlyFilesystem(released_fd)) {
41+
if (fstat(released_fd, &sb) < 0) {
42+
--
43+
2.48.1
44+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From dad694acb458b626445ebd8e220af6d3fbfa3de9 Mon Sep 17 00:00:00 2001
2+
From: Biswapriyo Nath <[email protected]>
3+
Date: Wed, 1 Jan 2025 00:00:00 +0000
4+
Subject: [PATCH] core: Workaround clang nullability specifiers
5+
6+
---
7+
libutils/Threads.cpp | 5 +++++
8+
1 file changed, 5 insertions(+)
9+
10+
diff --git a/libutils/Threads.cpp b/libutils/Threads.cpp
11+
index d8d75ac..5b8ca78 100644
12+
--- a/libutils/Threads.cpp
13+
+++ b/libutils/Threads.cpp
14+
@@ -42,6 +42,11 @@
15+
# define __android_unused __attribute__((__unused__))
16+
#endif
17+
18+
+#ifndef __clang__
19+
+#define _Nonnull
20+
+#define _Nullable
21+
+#endif
22+
+
23+
/*
24+
* ===========================================================================
25+
* Thread wrappers
26+
--
27+
2.48.1
28+

0 commit comments

Comments
 (0)