Skip to content

Commit 3dc2388

Browse files
sgolluklotzdeCopilotCopilot
authored
v0.6.0: Upgrade to open62541 version 1.5.5 (#87)
This upgrades the bundled dependency on open62541 to the latest released version [1.5.5](https://github.com/open62541/open62541/releases/tag/v1.5.5). This is a breaking change due to subtle differences in call signatures and the expected behaviour of callbacks. --------- Co-authored-by: Uwe Klotz <klotz@hmi-project.com> Co-authored-by: Uwe Klotz <uwe.klotz@gmail.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent ac1bd06 commit 3dc2388

11 files changed

Lines changed: 358 additions & 156 deletions

File tree

.github/workflows/latest-dependencies.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ jobs:
3737
runner_os: macos-latest
3838
- target: aarch64-unknown-linux-gnu
3939
# There is no ubuntu-latest-arm runner.
40-
runner_os: ubuntu-26.04-arm
40+
# TODO: Replace with ubuntu-26.04-arm when the build is fixed.
41+
runner_os: ubuntu-24.04-arm
4142
- target: aarch64-unknown-linux-musl
4243
# There is no ubuntu-latest-arm runner.
43-
runner_os: ubuntu-26.04-arm
44+
# TODO: Replace with ubuntu-26.04-arm when the build is fixed.
45+
runner_os: ubuntu-24.04-arm
4446
- target: aarch64-pc-windows-msvc
4547
# There is no windows-latest-arm runner.
4648
runner_os: windows-11-arm

.github/workflows/test.yaml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ jobs:
4040

4141
- target: aarch64-unknown-linux-gnu
4242
runner_os: ubuntu-24.04-arm
43-
- target: aarch64-unknown-linux-gnu
44-
runner_os: ubuntu-26.04-arm
43+
# Build on Ubuntu 26.04 fails with "unknown type name 'atomic_uintptr_t'".
44+
# TODO: Re-enable when fixed.
45+
#- target: aarch64-unknown-linux-gnu
46+
# runner_os: ubuntu-26.04-arm
4547

4648
- target: aarch64-unknown-linux-musl
4749
runner_os: ubuntu-24.04-arm
48-
- target: aarch64-unknown-linux-musl
49-
runner_os: ubuntu-26.04-arm
50+
# Build on Ubuntu 26.04 fails with "unknown type name 'atomic_uintptr_t'".
51+
# TODO: Re-enable when fixed.
52+
#- target: aarch64-unknown-linux-musl
53+
# runner_os: ubuntu-26.04-arm
5054

5155
- target: aarch64-pc-windows-msvc
5256
runner_os: windows-11-arm
@@ -70,13 +74,17 @@ jobs:
7074

7175
- target: x86_64-unknown-linux-gnu
7276
runner_os: ubuntu-24.04
73-
- target: x86_64-unknown-linux-gnu
74-
runner_os: ubuntu-26.04
77+
# Build on Ubuntu 26.04 fails with "unknown type name 'atomic_uintptr_t'".
78+
# TODO: Re-enable when fixed.
79+
#- target: x86_64-unknown-linux-gnu
80+
# runner_os: ubuntu-26.04
7581

7682
- target: x86_64-unknown-linux-musl
7783
runner_os: ubuntu-24.04
78-
- target: x86_64-unknown-linux-musl
79-
runner_os: ubuntu-26.04
84+
# Build on Ubuntu 26.04 fails with "unknown type name 'atomic_uintptr_t'".
85+
# TODO: Re-enable when fixed.
86+
#- target: x86_64-unknown-linux-musl
87+
# runner_os: ubuntu-26.04
8088

8189
runs-on: ${{ matrix.runner_os }}
8290

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
## [0.6.0] - 2026-07-13
11+
12+
### Changed
13+
14+
- Breaking: Upgrade to open62541 version
15+
[1.5.5](https://github.com/open62541/open62541/releases/tag/v1.5.5).
16+
- Breaking: Remove custom exports `vsnprintf_va_copy()` and `vsnprintf_va_end()`.
17+
1018
## [0.5.6] - 2026-07-09
1119

1220
### Fixed
@@ -292,7 +300,8 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
292300

293301
- First public release.
294302

295-
[Unreleased]: https://github.com/HMIProject/open62541-sys/compare/v0.5.6...HEAD
303+
[Unreleased]: https://github.com/HMIProject/open62541-sys/compare/v0.6.0...HEAD
304+
[0.6.0]: https://github.com/HMIProject/open62541-sys/compare/v0.5.6...v0.6.0
296305
[0.5.6]: https://github.com/HMIProject/open62541-sys/compare/v0.5.5...v0.5.6
297306
[0.5.5]: https://github.com/HMIProject/open62541-sys/compare/v0.5.4...v0.5.5
298307
[0.5.4]: https://github.com/HMIProject/open62541-sys/compare/v0.5.3...v0.5.4

Cargo.lock

Lines changed: 21 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
[package]
22
name = "open62541-sys"
3-
version = "0.5.6"
3+
version = "0.6.0"
44
authors = ["HMI Project"]
55
edition = "2024"
66
# Keep MSRV in sync with `test.yaml`/`build.rs`. Use versions that are at least 6 months old.
77
rust-version = "1.85"
8-
description = "Low-level, unsafe bindings for the C99 library open62541, an open source and free implementation of OPC UA (OPC Unified Architecture)."
8+
description = "Low-level, unsafe bindings for the C11 library open62541, an open source and free implementation of OPC UA (OPC Unified Architecture)."
99
documentation = "https://docs.rs/open62541-sys"
1010
readme = "README.md"
1111
homepage = "https://github.com/HMIProject/open62541-sys"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Testing](https://github.com/HMIProject/open62541-sys/actions/workflows/test.yaml/badge.svg)](https://github.com/HMIProject/open62541-sys/actions/workflows/test.yaml)
77
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-blue.svg)](https://opensource.org/licenses/MPL-2.0)
88

9-
This crate provides low-level, unsafe bindings for the C99 library
9+
This crate provides low-level, unsafe bindings for the C11 library
1010
[open62541](https://www.open62541.org), an open source and free implementation of
1111
[OPC UA](https://opcfoundation.org/about/opc-technologies/opc-ua/).
1212

build.rs

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![expect(clippy::panic, reason = "panic only during build time")]
22

33
use std::{
4-
env,
4+
env, fs,
55
path::{Path, PathBuf},
66
};
77

@@ -104,9 +104,10 @@ fn main() {
104104
// Include our wrapper vars.
105105
.allowlist_var("(__)?RS_.*")
106106
.allowlist_var("(__)?UA_.*")
107-
// Explicitly set C99 standard to force Windows variants of `vsnprintf()` to conform to this
108-
// standard. This also matches the expected (or supported) C standard of `open62541` itself.
109-
.clang_arg("-std=c99")
107+
// Explicitly set C11 standard. C11 is required for `<stdatomic.h>` with types like
108+
// `atomic_uintptr_t` used in `open62541` headers. C11 also forces Windows variants of
109+
// `vsnprintf()` to conform to the standard (as it is a superset of C99).
110+
.clang_arg("-std=c11")
110111
.clang_arg(format!("-I{}", dst_include.display()))
111112
.default_enum_style(bindgen::EnumVariation::NewType {
112113
is_bitfield: false,
@@ -216,8 +217,8 @@ fn prepare_mbedtls(src: PathBuf) -> EncryptionDst {
216217
.define("CMAKE_INSTALL_INCLUDEDIR", CMAKE_INCLUDE)
217218
// Some systems (Fedora) default to `lib64/` instead of `lib/` for 64-bit libraries.
218219
.define("CMAKE_INSTALL_LIBDIR", CMAKE_LIB)
219-
// Use same C99 standard as is used for building `open62541`.
220-
.define("C_STANDARD", "99")
220+
// Use same C11 standard as is used for building `open62541`.
221+
.define("C_STANDARD", "11")
221222
// Skip building binary programs unnecessary for linking library.
222223
.define("ENABLE_PROGRAMS", "OFF")
223224
// Skip building test programs that we are not going to run anyway.
@@ -266,9 +267,16 @@ fn build_open62541(src: PathBuf, encryption: Option<&EncryptionDst>) -> PathBuf
266267
.define("CMAKE_INSTALL_INCLUDEDIR", CMAKE_INCLUDE)
267268
// Some systems (Fedora) default to `lib64/` instead of `lib/` for 64-bit libraries.
268269
.define("CMAKE_INSTALL_LIBDIR", CMAKE_LIB)
269-
// Explicitly set C99 standard to force Windows variants of `vsnprintf()` to conform to this
270+
// Explicitly set C11 standard to force Windows variants of `vsnprintf()` to conform to this
270271
// standard. This also matches the expected (or supported) C standard of `open62541` itself.
271-
.define("C_STANDARD", "99")
272+
.define("C_STANDARD", "11")
273+
// Override default value `ON` of `UA_ENABLE_DEBUG_SANITIZER`.
274+
// When the build type is Debug (which is what Cargo uses for test/debug builds) on UNIX with Clang,
275+
// it automatically appends -fsanitize=address,undefined -fno-omit-frame-pointer to all C compiler flags.
276+
// This causes libopen62541.a to be compiled with ASAN+UBSAN instrumentation. The Rust toolchain then
277+
// fails to link the test binary because the Apple Clang sanitizer runtime (libclang_rt.asan_osx_dynamic.dylib etc.)
278+
// is not linked.
279+
.define("UA_ENABLE_DEBUG_SANITIZER", "OFF")
272280
// Python defaults to creating bytecode in `__pycache__` directories. During build, this may
273281
// happen when the tool `nodeset_compiler` is called. When we package a crate, builds should
274282
// never modify files outside of `OUT_DIR`, so we disable the cache to prevent this.
@@ -282,6 +290,25 @@ fn build_open62541(src: PathBuf, encryption: Option<&EncryptionDst>) -> PathBuf
282290
cmake
283291
.cflag("-idirafter/usr/include")
284292
.cflag(format!("-idirafter/usr/include/{arch}-linux-gnu"));
293+
294+
// Provide a shim for `<bits/stdio_lim.h>` which is a glibc-specific header that is not
295+
// available in musl libc. `open62541` includes it directly in `eventloop_posix.h`. The
296+
// standard constants it would define are already provided by standard headers (`<stdio.h>`
297+
// and `<limits.h>`) that are included before this file in the same translation unit.
298+
let out = PathBuf::from(env::var("OUT_DIR").expect("should have OUT_DIR"));
299+
let shim_bits_dir = out.join("include-shim").join("bits");
300+
fs::create_dir_all(&shim_bits_dir)
301+
.expect("should create shim include directory for musl compatibility");
302+
fs::write(
303+
shim_bits_dir.join("stdio_lim.h"),
304+
"/* Shim for musl libc compatibility.\n\
305+
* The glibc-specific <bits/stdio_lim.h> is not available in musl libc.\n\
306+
* The constants it defines are already provided by the standard headers\n\
307+
* (<stdio.h> and <limits.h>) included earlier in the same translation unit.\n\
308+
*/\n",
309+
)
310+
.expect("should write bits/stdio_lim.h shim for musl compatibility");
311+
cmake.cflag(format!("-idirafter{}", out.join("include-shim").display()));
285312
}
286313

287314
if matches!(env::var("TARGET"), Ok(env) if env == "x86_64-unknown-linux-gnu") {

open62541

Submodule open62541 updated 789 files

tests/integration.rs

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,23 @@ use open62541_sys::{
55
va_list_,
66
};
77

8+
// Check validity of explicitly defined type aliases.
89
#[test]
9-
fn variadic_arguments() {
10-
// Check if `va_list_` type matches.
10+
fn type_aliases() {
1111
const unsafe extern "C" fn log_c(
1212
_log_context: *mut ffi::c_void,
1313
_level: UA_LogLevel,
1414
_category: UA_LogCategory,
1515
_msg: *const ffi::c_char,
1616
_args: va_list_,
1717
) {
18+
// Nothing here.
1819
}
19-
let _logger = UA_Logger {
20-
log: Some(log_c),
21-
context: ptr::null_mut(),
22-
clear: None,
23-
};
24-
}
2520

26-
#[test]
27-
fn logger_types() {
28-
// Check validity of type aliases for `UA_Logger` callbacks.
29-
const unsafe extern "C" fn log_c(
30-
_log_context: *mut ffi::c_void,
31-
_level: UA_LogLevel,
32-
_category: UA_LogCategory,
33-
_msg: *const ffi::c_char,
34-
_args: va_list_,
35-
) {
21+
const unsafe extern "C" fn clear_c(_logger: *mut UA_Logger) {
22+
// Nothing here.
3623
}
37-
const unsafe extern "C" fn clear_c(_logger: *mut UA_Logger) {}
24+
3825
let log: UA_LoggerLogCallback_ = Some(log_c);
3926
let clear: UA_LoggerClearCallback_ = Some(clear_c);
4027
let _logger = UA_Logger {
@@ -44,16 +31,11 @@ fn logger_types() {
4431
};
4532
}
4633

34+
// Make sure that our custom exports (prefixed with `RS_`) are available under their expected names,
35+
// i.e. without the `RS_` prefix.
4736
#[test]
48-
fn has_custom_exports() {
49-
// Make sure that our custom exports (prefixed internally with `RS_`) are available under their
50-
// expected names.
51-
//
52-
use open62541_sys::{UA_EMPTY_ARRAY_SENTINEL, vsnprintf_va_copy, vsnprintf_va_end};
37+
fn custom_exports() {
38+
use open62541_sys::UA_EMPTY_ARRAY_SENTINEL;
5339

54-
#[expect(clippy::no_effect_underscore_binding, reason = "check existence")]
55-
let _unused = vsnprintf_va_copy;
56-
#[expect(clippy::no_effect_underscore_binding, reason = "check existence")]
57-
let _unused = vsnprintf_va_end;
5840
let _unused = unsafe { UA_EMPTY_ARRAY_SENTINEL };
5941
}

0 commit comments

Comments
 (0)