Skip to content

Commit 4ac15d3

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

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-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: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,32 @@ absl_string_view_dep = dependency(
3737
default_options: ['cpp_std=c++17'],
3838
)
3939

40+
# Make reasonable effort (volatile) to prevent the compiler from optimizing the atomic away without using tested
41+
# functionality.
42+
if cc.links('''
43+
#include <atomic>
44+
#include <cstdint>
45+
46+
int main() {
47+
volatile std::atomic<std::uint64_t> testvar;
48+
// The line below will lead to
49+
// undefined reference to `__atomic_fetch_add_8'
50+
// on armv6l to give an example.
51+
volatile auto unused = testvar.fetch_add(0);
52+
}
53+
''', name: 'Check if libatomic is required')
54+
if meson.version().version_compare('>=1.7.0')
55+
atomic_dep = dependency('atomic')
56+
else
57+
atomic_dep = cc.find_library(
58+
'atomic',
59+
required: true,
60+
)
61+
endif
62+
else
63+
atomic_dep = []
64+
endif
65+
4066
deps = [
4167
dependency('absl_base'),
4268
dependency('absl_cord'),
@@ -58,6 +84,7 @@ deps = [
5884
'dbghelp',
5985
required: host_machine.system() == 'windows',
6086
),
87+
atomic_dep,
6188
]
6289

6390
incdir = include_directories('src')
@@ -136,6 +163,7 @@ protobuf_lite_dep = declare_dependency(
136163
compile_args: imp,
137164
link_with: libprotobuf_lite,
138165
include_directories: incdir,
166+
dependencies: atomic_dep,
139167
)
140168

141169
libprotobuf_src = files(
@@ -218,8 +246,8 @@ libprotobuf_src = files(
218246
'src/google/protobuf/wrappers.pb.cc',
219247
)
220248
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-
] : []
249+
'/export:??$MergeFrom@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@RepeatedPtrFieldBase@internal@protobuf@google@@QEAAXAEBV0123@@Z',
250+
] : []
223251
)
224252
libprotobuf = library(
225253
'protobuf',

0 commit comments

Comments
 (0)