Compilation errors in pkg/libsignalgo due to CFixedBytes() type mismatch
When building the Go wrapper (pkg/libsignalgo), I encounter multiple errors like:
cannot use NewACIServiceID(aci).CFixedBytes() (value of pointer type cPNIType)
as *_Ctype_SignalServiceIdFixedWidthBinaryBytes in variable declaration
It appears that CFixedBytes() currently returns a *cPNIType, whereas the C functions expect a *_Ctype_SignalServiceIdFixedWidthBinaryBytes. This mismatch was introduced by a recent change in the libsignal bridge code.
Steps to Reproduce:
- Clone the repository and checkout the
mainbranch (or tagv0.8.1).git clone https://github.com/mautrix/signal.git cd signal - Initialize and update submodules:
git submodule update --init --recursive - Build the Rust bridge:
cd rust/bridge cargo build --release - Return to the project root and build the Go wrapper:
cd ../../ CGO_CFLAGS="-I/usr/local/include" CGO_LDFLAGS="-L/usr/local/lib" go build ./pkg/libsignalgo - Observe the compilation errors as shown above.
Expected Behavior:
pkg/libsignalgo should compile successfully, with CFixedBytes() returning the correct pointer type (*C.SignalServiceIdFixedWidthBinaryBytes) so that the C FFI calls match their signatures.
Environment:
- OS: HardenedBSD (FreeBSD fork)
- Go: go1.20.4 freebsd/amd64
- Rust: rustc 1.70.0
-
Submodule (libsignal) pinned at:
efe13e9b363d2c115dba61b76e5e53bbfc2874bc(pre-breaking change) -
Repo tag:
v0.8.1(Commit03d675c)
Workaround:
Manually pinning the libsignal submodule to the pre-update commit (efe13e9b…) restores compatibility and allows the build to succeed.
Proposed Fix:
- Update
CFixedBytes()inpkg/libsignalgoto explicitly return*C.SignalServiceIdFixedWidthBinaryBytes(for example, via anunsafe.Pointercast). - Alternatively, adjust the underlying C type definitions in the
libsignalbridge so they remain compatible with the existing Go bindings.
Thank you for your help!
There haven't been any breaking changes. efe13e9b is the last commit of upstream libsignal, so not sure how you figured it's "pre-breaking change"
The bridge just doesn't currently support using clang outside macOS. Support for that could perhaps be added using a custom build tag, or assuming that gcc is only used on linux (see serviceid_gcc.go)
Other notes:
- Compiling the bridge with anything else than the pinned libsignal version is completely unsupported, so you should never change it yourself. The release notes also include the expected libsignal version for your convenience.
- v0.8.1 is not the latest release. Old releases are completely unsupported.
- Go 1.20 is EOL and can't be used to compile the bridge: https://endoflife.date/go
- Rust 1.70 is quite old too, it's best to use the version that upstream libsignal has pinned https://github.com/signalapp/libsignal/blob/main/rust-toolchain