Skip to content

Build fails on Ubuntu 22.02 #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Unaimend opened this issue May 4, 2025 · 4 comments
Open

Build fails on Ubuntu 22.02 #14

Unaimend opened this issue May 4, 2025 · 4 comments

Comments

@Unaimend
Copy link

Unaimend commented May 4, 2025

The build fails on my machine. The error message can be found below.
I assumed it was some mismatch due to my compiler. sadly I tried multiple steps at the same time so I am not sure which exactly fixed it.

If this problem is of interest to you I can try to make a more detailed analysis and figure out what exactly fixed the problem.

Steps to fix

conda create -n sbml_env gcc_linux-64 gxx_linux-64 make cmake pkg-config -c conda-forge
export CC=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-cc
export CXX=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-c++
export AR=$CONDA_PREFIX/bin/x86_64-conda-linux-gnu-ar
export CFLAGS="--sysroot=$CONDA_PREFIX/x86_64-conda-linux-gnu/sysroot"
export CXXFLAGS="--sysroot=$CONDA_PREFIX/x86_64-conda-linux-gnu/sysroot"
export BINDGEN_EXTRA_CLANG_ARGS="--target=x86_64-unknown-linux-gnu"
export RUSTFLAGS="--cfg=bindgen"

System information

(ins)td:sbml_examples $ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy
(ins)td:sbml_examples $ uname -a
Linux td-XPS-9320 5.15.0-138-generic #148-Ubuntu SMP Fri Mar 14 19:05:48 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
(ins)td:~ $ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Error

error: failed to run custom build command for `libsbml v0.1.0`

Caused by:
  process didn't exit successfully: `/home/td/Projects/PetriNets/SBMLtoPetri/target/debug/build/libsbml-2287329fa5bf9f0c/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-changed=build.rs
  cargo:rerun-if-changed=src/lib.rs
      Fetching vcpkg
      Checkout rev ce613c41372b23b1f51333815feb3edd87ef8a8b
    Installing libsbml[core,expat,zlib]
      Finished in 0.57s
  cargo:rustc-link-search=native=/home/td/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libsbml-0.1.0/target/vcpkg/installed/x64-linux/lib
  cargo:rustc-link-lib=sbml-static
  cargo:rustc-link-lib=z
  cargo:rustc-link-lib=expat

  --- stderr
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:148:11: error: no member named 'fwide' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:149:11: error: no member named 'fwprintf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:150:11: error: no member named 'fwscanf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:160:11: error: no member named 'swprintf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:162:11: error: no member named 'swscanf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:164:11: error: no member named 'vfwprintf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:169:11: error: no member named 'vswprintf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:174:11: error: no member named 'vwprintf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:204:11: error: no member named 'wprintf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cwchar:205:11: error: no member named 'wscanf' in the global namespace
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/c++locale.h:52:23: error: use of undeclared identifier 'uselocale'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/c++locale.h:62:11: error: unknown type name '__locale_t'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:4163:51: error: no member named 'vswprintf' in namespace 'std'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:4168:51: error: no member named 'vswprintf' in namespace 'std'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:4174:51: error: no member named 'vswprintf' in namespace 'std'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:4179:51: error: no member named 'vswprintf' in namespace 'std'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:4185:51: error: no member named 'vswprintf' in namespace 'std'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:4191:51: error: no member named 'vswprintf' in namespace 'std'
  /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:4200:51: error: no member named 'vswprintf' in namespace 'std'
  fatal error: too many errors emitted, stopping now [-ferror-limit=]

  thread 'main' panicked at /home/td/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/autocxx-bindgen-0.72.0/lib.rs:893:13:
  assertion `left == right` failed: "x86_64-unknown-linux-gnu" "x86_64-unknown-linux-gnu"
    left: 4
   right: 8
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace```
@Unaimend Unaimend changed the title Build files on Ubuntu 22.02 Build fails on Ubuntu 22.02 May 4, 2025
@Unaimend
Copy link
Author

Unaimend commented May 4, 2025

I was able to confirm that using the conda env and setting one flag is enough

conda create -n sbml_env gcc_linux-64 gxx_linux-64 make cmake pkg-config -c conda-forge
export BINDGEN_EXTRA_CLANG_ARGS="--target=x86_64-unknown-linux-gnu"

@JR-1991
Copy link
Member

JR-1991 commented May 4, 2025

@Unaimend thank you for trying it out, and sorry you had to dig so deep to track this down. It’s great that you distilled the fix to the bare minimum.

I’m new to setting up C++ tool-chains with Conda, so I didn’t realise bindgen would end up reading a different set of headers. Pointing it at the right ones by forcing the target triple to x86_64-unknown-linux-gnu makes perfect sense.

I can’t reproduce the issue on my macOS machine, but once I get access to an Ubuntu machine, I’ll experiment with implementing the workaround directly into build.rs. If you already have a concrete idea, feel free to open a PR, and we can wire the CI to cover this case.

@Unaimend
Copy link
Author

Unaimend commented May 4, 2025

Just setting export BINDGEN_EXTRA_CLANG_ARGS="--target=x86_64-unknown-linux-gnu" was indeed enough

@Unaimend
Copy link
Author

Unaimend commented May 4, 2025

I dug out the responsible snippet from the bindgen source

        if is_host_build {
            debug_assert_eq!(
                context.target_pointer_size(),
                size_of::<*mut ()>(),
                "{effective_target:?} {HOST_TARGET:?}"
            );
        }

Seems to compare some pointer sizes. I am not sure why the effective_target would a a 4-byte pointer size.
But apparently, the autocxx-bindgen crates GitHub repo does not allow issues so I can't ask

Create.io links to this repo https://github.com/adetaylor/rust-bindgen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants