Bug: Cannot build SOCI (static, SQLite3 only) – libc++ aligned_storage / aligned_union breakage

Author: baziorekCreated Sep 23, 2026Updated Sep 23, 2026
Labelslow severity

Contact Details

No response

What happened?

I tried to build SOCI (static library, SQLite3 backend only, no tests) with the Cosmopolitan toolchain.

Build setup

bash
export PATH="$PWD/bin:$PATH"

cd soci
mkdir build-cosmo && cd build-cosmo

CC=cosmocc CXX=cosmoc++ \
cmake \
  -DCMAKE_SYSTEM_NAME=Generic \
  -UCMAKE_SYSTEM_PROCESSOR \
  -DCMAKE_USER_MAKE_RULES_OVERRIDE=.../cosmocc-override.cmake \
  -DCMAKE_AR="$(command -v cosmoar)" \
  -DCMAKE_RANLIB="$(command -v cosmoranlib)" \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
  -DCMAKE_CXX_STANDARD=17 \
  -DSOCI_SHARED=OFF \
  -DSOCI_TESTS=OFF \
  -DWITH_BOOST=OFF \
  -DSOCI_EMPTY=OFF \
  -DSOCI_SQLITE3=ON \
  -DSOCI_SQLITE3_BUILTIN=ON \
  -DFMT_OS=OFF \
  ...

Issues encountered

  1. fmt
    3rdparty/fmt failed with:

    error: unable to substitute constant
    CREATE = FMT_POSIX(O_CREAT),

    Fixed by adding -DFMT_OS=OFF.

  2. backend-loader.cpp
    Dl_info / dladdr not available.
    Worked around with a simple #if defined(__COSMOPOLITAN__) guard that returns an empty string.

  3. Main blocker – libc++ type_traits
    After the above, the build fails with hundreds of errors starting from:

    include/third_party/libcxx/__type_traits/aligned_union.h:41:20:
    error: expected nested-name-specifier before 'aligned_storage'

    This cascades into the entire standard library becoming unusable. Subsequent name lookup treats std:: as soci::std, producing errors such as:

    'make_signed' in namespace 'soci::std' does not name a template type
    'string' is not a member of 'soci::std'
    'vector' is not a member of 'soci::std'
    ...

Trying different C++ standards (14/17) and defining _LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS / _LIBCPP_DISABLE_DEPRECATION_WARNINGS did not help.

It looks like Cosmopolitan’s bundled libc++ has an inconsistency between aligned_union.h and the (deprecated/removed) aligned_storage declaration.

Happy to provide full logs or test any suggested workarounds.

logs.txt

Version

➜  cosmocc ./bin/cosmoc++ --version
cosmoc++ (GCC) 14.1.0
Copyright (c) 2024 Justine Alexandra Roberts Tunney
Cosmopolitan Libc and LLVM libcxx/compiler-rt are subject to non-GPL
notice licenses, e.g. ISC, MIT, etc. Your compiled programs must embed
our copyright notices. This toolchain is configured to do so by default.
Cosmopolitan comes with absolutely NO WARRANTY of any kind.
For more information, see the Cosmopolitan LICENSE files.
Copyright (C) 2022 Free Software Foundation, Inc.
This launches GNU GCC/Binutils subprocesses, which is free software; see
cosmocc's LICENSE files for source code and copying conditions. There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   

What operating system are you seeing the problem on?

Linux

Relevant log output

bash