Skip to content

Commit c8c5ece

Browse files
committed
protobuf: fix compilation on armv6l (libatomic)
1 parent 4f99a88 commit c8c5ece

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

releases.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3346,6 +3346,7 @@
33463346
"protoc"
33473347
],
33483348
"versions": [
3349+
"25.2-4",
33493350
"25.2-3",
33503351
"25.2-2",
33513352
"25.2-1",

subprojects/packagefiles/protobuf/meson.build

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,39 @@ absl_string_view_dep = dependency(
3737
default_options: ['cpp_std=c++17'],
3838
)
3939

40+
if meson.version().version_compare('>=1.7.0')
41+
atomic_dep = dependency(
42+
'atomic',
43+
required: false,
44+
)
45+
else
46+
atomic_dep = cc.find_library(
47+
'atomic',
48+
required: false,
49+
)
50+
endif
51+
52+
# Make reasonable effort (volatile) to prevent the compiler from optimizing the atomic away without using tested
53+
# functionality.
54+
if not cc.links(
55+
'''
56+
#include <atomic>
57+
#include <cstdint>
58+
59+
int main() {
60+
volatile std::atomic<std::uint64_t> testvar;
61+
// The line below will lead to
62+
// undefined reference to `__atomic_fetch_add_8'
63+
// on armv6l to give an example.
64+
volatile auto unused = testvar.fetch_add(0);
65+
}
66+
''',
67+
name: 'Check if libatomic is required',
68+
dependencies: atomic_dep,
69+
)
70+
error('Host machine cannot handle atomics!')
71+
endif
72+
4073
deps = [
4174
dependency('absl_base'),
4275
dependency('absl_cord'),
@@ -58,6 +91,7 @@ deps = [
5891
'dbghelp',
5992
required: host_machine.system() == 'windows',
6093
),
94+
atomic_dep,
6195
]
6296

6397
incdir = include_directories('src')
@@ -136,6 +170,7 @@ protobuf_lite_dep = declare_dependency(
136170
compile_args: imp,
137171
link_with: libprotobuf_lite,
138172
include_directories: incdir,
173+
dependencies: atomic_dep,
139174
)
140175

141176
libprotobuf_src = files(
@@ -218,8 +253,8 @@ libprotobuf_src = files(
218253
'src/google/protobuf/wrappers.pb.cc',
219254
)
220255
libprotobuf_linker_args = (is_msvc ? [
221-
'/export:??$MergeFrom@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@RepeatedPtrFieldBase@internal@protobuf@google@@QEAAXAEBV0123@@Z',
222-
] : []
256+
'/export:??$MergeFrom@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@RepeatedPtrFieldBase@internal@protobuf@google@@QEAAXAEBV0123@@Z',
257+
] : []
223258
)
224259
libprotobuf = library(
225260
'protobuf',

0 commit comments

Comments
 (0)