termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.34k stars 3.07k forks source link

[Bug]: `/data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/malloc.h:85:10: fatal error: 'mm_malloc.h' file not found` #21720

Closed SwuduSusuwu closed 1 month ago

SwuduSusuwu commented 1 month ago

Problem description

Termux does not have mingw-w64 (MinGW of Gnu), just llvm-mingw-w64 (Clang's MinGW); the default causes calls to malloc to redirect to _mmalloc (which is not in the llvm-mingw-* packages).

What steps will reproduce the bug?

$ apt install *mingw*
Note, selecting 'llvm-mingw-w64-ucrt' for glob '*mingw*'
Note, selecting 'llvm-mingw-w64-tools' for glob '*mingw*'
Note, selecting 'mingw-w64' for glob '*mingw*'
Note, selecting 'llvm-mingw-w64' for glob '*mingw*'
Note, selecting 'llvm-mingw-w64-libcompiler-rt' for glob '*mingw*'
llvm-mingw-w64 is already the newest version (20241001).
llvm-mingw-w64-libcompiler-rt is already the newest version (20241001).
llvm-mingw-w64-ucrt is already the newest version (20241001).
llvm-mingw-w64-tools is already the newest version (12.0.0).
$ git clone https://github.com/SwuduSusuwu/SubStack.git
fatal: destination path 'SubStack' already exists and is not an empty directory.
~ $ cd SubStack
~/SubStack $ ./build.sh --mingw
# /* Dual licenses: choose "Creative Commons" or "Apache 2" (allows all uses) */
# /* `./build.sh` defaults to `./build.sh --debug`. Use `./build.sh --release` if you want fast executables */
+ x86_64-w64-mingw32-clang++ -Wall -Wno-unused -Wno-unused-function -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -fsanitize=address -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -fno-omit-frame-pointer -g -x c -c ./cxx//../c/rfc6234/sha1.c
+ x86_64-w64-mingw32-clang++ -Wall -Wno-unused -Wno-unused-function -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -fsanitize=address -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -fno-omit-frame-pointer -g -x c -c ./cxx//../c/rfc6234/sha224-256.c
+ x86_64-w64-mingw32-clang++ -Wall -Wno-unused -Wno-unused-function -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -fsanitize=address -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -fno-omit-frame-pointer -g -x c -c ./cxx//../c/rfc6234/sha384-512.c
+ x86_64-w64-mingw32-clang++ -Wall -Wno-unused -Wno-unused-function -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -fsanitize=address -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -fno-omit-frame-pointer -g -c ./cxx//ClassSha2.cxx
In file included from ./cxx//ClassSha2.cxx:4:
In file included from ./cxx/ClassPortableExecutable.hxx:5:
In file included from ./cxx/ClassObject.hxx:5:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/c++/v1/cassert:23:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/assert.h:17:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/c++/v1/stdlib.h:94:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/stdlib.h:656:
/data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/malloc.h:85:10: fatal error: 'mm_malloc.h' file not found
   85 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
1 error generated.

What is the expected behavior?

Expect repo to have SIMD headers (such as mm_alloc.h), or to not default use those

System information

~ $ termux-info
Termux Variables:
TERMUX_EXEC__PROC_SELF_EXE=/data/data/com.termux/files/usr/bin/termux-info
TERMUX_VERSION=googleplay.2024.08.29
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://termux.net stable main
Updatable packages:
All packages up to date
termux-tools version:
3.0.8
Android version:
14
Kernel build information:
Linux localhost 5.10.198-android13-4-00050-g12f3388846c3-ab11920634 #1 SMP PREEMPT Mon Jun 3 20:51:42 UTC 2024 aarch64 Android
Device manufacturer:
Google
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
SwuduSusuwu commented 1 month ago

Ran without the debug flags, but no difference to issue;

x86_64-w64-mingw32-clang++ -c ./cxx//ClassSha2.cxx
In file included from ./cxx//ClassSha2.cxx:4:
In file included from ./cxx/ClassPortableExecutable.hxx:5:
In file included from ./cxx/ClassObject.hxx:5:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/c++/v1/cassert:23:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/assert.h:17:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/c++/v1/stdlib.h:94:
In file included from /data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/stdlib.h:656:
/data/data/com.termux/files/usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/include/malloc.h:85:10: fatal error: 'mm_malloc.h' file not found
   85 | #include <mm_malloc.h>
      |          ^~~~~~~~~~~~~
1 error generated.
SwuduSusuwu commented 1 month ago

If ./build.sh does not accept --mingw, do git pull; just pushed this

SwuduSusuwu commented 1 month ago

It is not wrong include paths (as Assistant suggests); mm_alloc.h just doesn't exist

~/SubStack $ cd ~/
~ $ find ../ | grep mm_alloc.h
~ $ find ../ | grep alloc.h
../home/boost/libs/align/include/boost/align/aligned_alloc.hpp
../home/boost/libs/align/include/boost/align/detail/aligned_alloc.hpp
../home/boost/libs/asio/include/boost/asio/detail/handler_alloc_helpers.hpp
../home/boost/libs/beast/example/http/server/fast/fields_alloc.hpp
../home/boost/libs/compute/include/boost/compute/experimental/malloc.hpp
../home/boost/libs/container/include/boost/container/detail/alloc_helpers.hpp
../home/boost/libs/container/include/boost/container/detail/dlmalloc.hpp
../home/boost/libs/container/include/boost/container/detail/node_alloc_holder.hpp
../home/boost/libs/container/include/boost/container/detail/pool_common_alloc.hpp
../home/boost/libs/pool/doc/html/header/boost/pool/pool_alloc_hpp.html
../home/boost/libs/pool/include/boost/pool/pool_alloc.hpp
../home/boost/libs/python/include/boost/python/detail/dealloc.hpp
../home/boost/libs/thread/include/boost/thread/detail/thread_heap_alloc.hpp
../home/boost/libs/thread/include/boost/thread/pthread/thread_heap_alloc.hpp
../home/boost/libs/thread/include/boost/thread/win32/thread_heap_alloc.hpp
../home/sdk-api/sdk-api-src/content/objidl/nf-objidl-imalloc-heapminimize.md
../home/sdk-api/sdk-api-src/content/shlwapi/nf-shlwapi-shallocshared.md
../home/sdk-api/sdk-api-src/content/objidlbase/nf-objidlbase-imalloc-heapminimize.md
../usr/include/bash/include/memalloc.h
../usr/include/bash/xmalloc.h
../usr/include/nettle/realloc.h
../usr/include/proc/alloc.h
../usr/include/c++/v1/__memory/aligned_alloc.h
../usr/include/malloc.h
../usr/include/linux/falloc.h
../usr/include/clang-tidy/cppcoreguidelines/NoMallocCheck.h
../usr/include/gssapi/gssapi_alloc.h
../usr/include/absl/base/internal/low_level_alloc.h
../usr/include/xen/gntalloc.h
../usr/include/pulse/xmalloc.h
../usr/lib/clang/19/include/mm_malloc.h
../usr/lib/clang/19/include/ppc_wrappers/mm_malloc.h
../usr/share/man/man3/__realloc_hook.3.gz
../usr/share/man/man3/malloc_hook.3.gz
../usr/share/man/man3/__malloc_hook.3.gz
../usr/share/man/man2/alloc_hugepages.2.gz
../usr/share/doc/zimg/example/misc/aligned_malloc.h
../usr/opt/llvm-mingw-w64/generic-w64-mingw32/include/c++/v1/__memory/aligned_alloc.h
../usr/opt/llvm-mingw-w64/generic-w64-mingw32/include/malloc.h
licy183 commented 1 month ago

mm_malloc.h is provided by clang itself, as /data/data/com.termux/files/usr/lib/clang/19/include/mm_malloc.h.

I can't reproduce it on my device with Termux on F-Droid.

Besides, this seems a bug of Termux App on Google Play Store, you should report it to github.com/termux-play-store/termux-packages.

CC: @fornwall as the maintainer of Termux on Google Play Store

fornwall commented 1 month ago

Thanks @SwuduSusuwu for a nice bug report with steps how to reproduce the problem!

This was indeed a problem specific to the updated targetSdk (with /proc/self/exe being /system/bin/linker64) of the Google Play distribution - it has now been fixed in libllvm version 19.1.1-2 - run pkg up to upgrade.

fornwall commented 1 month ago

It is not wrong include paths (as Assistant suggests); mm_alloc.h just doesn't exist

~/SubStack $ cd ~/ ~ $ find ../ | grep mm_alloc.h

For reference, note that the file name is mm_malloc.h (which is included in $PREFIX/lib/clang/19/include/mm_malloc.h as pointed out above) - the problem was instead with how clang found out how it's invoked.

SwuduSusuwu commented 1 month ago

pkg up success (fixes the mm_malloc.h error). Am now stuck on ./cxx//ClassSys.cxx:16:11: fatal error: 'shlobj_core.h' file not found; all https://www.google.com/search?q=%22%27shlobj_core.h%27+file+not+found%22 has is https://bugzilla.mozilla.org/show_bug.cgi?id=1668721 (which suggests to use #ifdef to disable such code paths for MinGW) plus https://forums.unrealengine.com/t/cannot-include-shlobj_core-not-package/457976 (which suggests to include ShlObj_core.h, but this too is not found).

$ cd ../
~ $ find ../|grep ShlObject
~ $ find ../|grep shlobject
~ $ find ../|grep shl*core
../home/sdk-api/sdk-api-src/content/shcore
../home/sdk-api/sdk-api-src/content/shcore/index.md
../home/sdk-api/sdk-api-src/content/shcore/ne-shcore-bsos_options.md
../home/sdk-api/sdk-api-src/content/shcore/nf-shcore-createrandomaccessstreamonfile.md
../home/sdk-api/sdk-api-src/content/shcore/nf-shcore-createrandomaccessstreamoverstream.md
../home/sdk-api/sdk-api-src/content/shcore/nf-shcore-createstreamoverrandomaccessstream.md
../usr/opt/llvm-mingw-w64/aarch64-w64-mingw32/lib/libshcore.a
../usr/opt/llvm-mingw-w64/armv7-w64-mingw32/lib/libshcore.a
../usr/opt/llvm-mingw-w64/generic-w64-mingw32/include/shcore.h
../usr/opt/llvm-mingw-w64/i686-w64-mingw32/lib/libshcore.a
../usr/opt/llvm-mingw-w64/x86_64-w64-mingw32/lib/libshcore.a
licy183 commented 1 month ago

shlobj_core.h is a private header of Win32 SDK. mingw doesn't provide such a header. Try including shlobj.h instead of shlobj_core.h.

SwuduSusuwu commented 1 month ago

shlobj_core.h is a private header of Win32 SDK. mingw doesn't provide such a header. Try including shlobj.h instead of shlobj_core.h.

Cool, all is success now