llvm / llvm/llvm-project

`import std` fails with Bionic

Open
#198,297 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

libc++
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Related to https://github.com/termux/termux-packages/issues/23870

In Termux I tried to compile a program that uses import std with cmake and clang.

~ $ clang --version
clang version 21.1.8
Target: aarch64-unknown-linux-android30
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin
~ $ cmake --version
cmake version 4.3.2

CMake suite maintained and supported by Kitware (kitware.com/cmake).

The CMake configure succedded after manually copying *.modules.json and *.cppm from the android ndk. But the compilation fails on std.cppm

[59/595] Building CXX object CMakeFiles/__cmake_cxx_std_26.dir/data/data/com.termux/files/usr/share/libc++/v1/std.cppm.o
FAILED: [code=1] CMakeFiles/__cmake_cxx_std_26.dir/data/data/com.termux/files/usr/share/libc++/v1/std.cppm.o CMakeFiles/__cmake_cxx_std_26.dir/std.pcm
/data/data/com.termux/files/usr/bin/clang++  -I/data/data/com.termux/files/usr/share/libc++/v1 -O2 -g -DNDEBUG -std=gnu++26 -Wp,-D_FORTIFY_SOURCE=0 -Wno-macro-redefined -fno-rtti -MD -MT CMakeFiles/__cmake_cxx_std_26.dir/data/data/com.termux/files/usr/share/libc++/v1/std.cppm.o -MF CMakeFiles/__cmake_cxx_std_26.dir/data/data/com.termux/files/usr/share/libc++/v1/std.cppm.o.d @CMakeFiles/__cmake_cxx_std_26.dir/data/data/com.termux/files/usr/share/libc++/v1/std.cppm.o.modmap -o CMakeFiles/__cmake_cxx_std_26.dir/data/data/com.termux/files/usr/share/libc++/v1/std.cppm.o -c /data/data/com.termux/files/usr/share/libc++/v1/std.cppm
/data/data/com.termux/files/usr/share/libc++/v1/std.cppm:197:15: warning: 'std' is a reserved name for a module [-Wreserved-module-identifier]
  197 | export module std;
      |               ^
In file included from /data/data/com.termux/files/usr/share/libc++/v1/std.cppm:208:
/data/data/com.termux/files/usr/share/libc++/v1/std/cctype.inc:11:14: error: using declaration referring to 'isalnum' with internal linkage cannot be exported
   11 |   using std::isalnum _LIBCPP_USING_IF_EXISTS;
      |              ^
/data/data/com.termux/files/usr/bin/../../usr/include/ctype.h:153:27: note: target of using declaration
  153 | __BIONIC_CTYPE_INLINE int isalnum(int __ch) {
      |                           ^
In file included from /data/data/com.termux/files/usr/share/libc++/v1/std.cppm:208:
/data/data/com.termux/files/usr/share/libc++/v1/std/cctype.inc:12:14: error: using declaration referring to 'isalpha' with internal linkage cannot be exported
   12 |   using std::isalpha _LIBCPP_USING_IF_EXISTS;
      |              ^
/data/data/com.termux/files/usr/bin/../../usr/include/ctype.h:103:27: note: target of using declaration
  103 | __BIONIC_CTYPE_INLINE int isalpha(int __ch) {
      |                           ^
In file included from /data/data/com.termux/files/usr/share/libc++/v1/std.cppm:208:
/data/data/com.termux/files/usr/share/libc++/v1/std/cctype.inc:13:14: error: using declaration referring to 'isblank' with internal linkage cannot be exported
   13 |   using std::isblank _LIBCPP_USING_IF_EXISTS;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the shown clang++ and CMake setup, then inspect libc++/v1/std.cppm around line 208 and libc++/v1/std/cctype.inc alongside Bionic's ctype.h. The issue is done when compiling a program that uses import std succeeds on Bionic without the internal-linkage export errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, cmake, cpp
Domain
build-system, compilers, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.