ispc icon indicating copy to clipboard operation
ispc copied to clipboard

Feature: Disable hardcoded 32-bit ARM builtins & remove linux asm/types.h kernel header dependency

Open 1234562026 opened this issue 4 months ago • 5 comments

Environment Info

  • Platform: Android Termux AArch64 (pure 64-bit environment, no 32-bit ARM sysroot/kernel headers)
  • Build Command: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX -G Ninja -DISPC_TARGETS="aarch64-linux" ninja

Core Problems

  1. Hardcoded 32-bit armv8a builtin generation, independent of -DISPC_TARGETS Even if I only declare aarch64-linux as target architecture, the build script unconditionally generates 32-bit armv8a bitcode via hardcoded ALL_ARCHS list in GenerateBuiltins.cmake. Pure 64-bit Termux does not carry any 32-bit system headers, causing fatal compile errors. There is zero official cache switch to skip all 32-bit ARM tasks.
  2. Unreasonable forced dependency on Linux internal kernel header <asm/types.h> The builtin source code directly references private Linux kernel header asm/types.h, which is not part of standard POSIX / libc public headers.
  • Mobile environments like Termux only provide minimal user-space libc headers, no kernel asm headers by default.
  • This header is Linux platform-specific, breaks cross-platform portability for Android/embedded AArch64 devices.
  • Standard C/C++ user-space code should never rely on internal kernel asm headers for basic type definitions.
  1. Manual script modification is error-prone To bypass the above errors, users have to manually edit CMake scripts to delete armv8a entries and drop 32-bit runtime loops. Editing nested if/else blocks easily triggers CMake syntax configure failures.

Full Compile Error Log

Expand fatal missing header error output Expected Improvements

1. Add a CMake cache option  BUILD_32BIT_ARM=OFF  to exclude armv8a from ALL_ARCHS and skip 32-bit runtime build loops. ​ 2. Refactor builtin source code: Replace dependency on non-portable  <asm/types.h>  with standard C fixed-width integer types (stdint.h, uint64_t, int32_t etc.) to eliminate Linux kernel header reliance. ​ 3. Decouple builtin architecture generation logic from hardcoded lists, respect the  -DISPC_TARGETS  filter to only build required architectures.

Temporary Working Workaround

Edit  cmake/GenerateBuiltins.cmake  before compilation:

1. Change  set(ALL_ARCHS armv8a aarch64 x86 x86_64)  →  set(ALL_ARCHS aarch64 x86_64)  ​ 2. Replace  foreach(RUNTIME 32 64)  →  foreach(RUNTIME 64)  After these two changes, all 32-bit ARM build tasks are removed, compilation proceeds normally (still requires separate fix for the asm/types.h header dependency).

1234562026 avatar Jul 20 '26 14:07 1234562026

Thanks for filing this issue, @1234562026! A maintainer will triage it soon.

To help us address it faster, please make sure your report follows the guidelines in CONTRIBUTING.

github-actions[bot] avatar Jul 20 '26 14:07 github-actions[bot]

Thanks for the issue! @azwolski, could you take care of it?

aneshlya avatar Jul 21 '26 04:07 aneshlya

Unreasonable forced dependency on Linux internal kernel header <asm/types.h> The builtin source code directly references private Linux kernel header asm/types.h, which is not part of standard POSIX / libc public headers.

Where it generates that kind of headers? Could you provide the file name/path?

Would you also be able to provide some small example/reproducer?

azwolski avatar Jul 22 '26 12:07 azwolski

Update full build failure evidence on Termux Android (musl libc):

Build log snippet: [14/300] Generating share/ispc/builtins_cpp_32_linux_armv8a.bc In file included from builtins/builtins-c-cpu.cpp:42: In file included from /data/data/com.termux/files/usr/include/unistd.h:34: In file included from /data/data/com.termux/files/usr/include/sys/types.h:37: /data/data/com.termux/files/usr/include/linux/types.h:9:10: fatal error: 'asm/types.h' file not found 9 | #include <asm/types.h> | ^~~~~~~~~~~~~

Full transitive include chain: builtins-c-cpu.cpp → unistd.h → sys/types.h → linux/types.h → asm/types.h

Key notes:

  1. All manually created fake asm/types.h headers were fully deleted before this test, this error is clean native output.
  2. Static search in ISPC source tree cannot locate direct reference of asm/types.h, this dependency is hidden transitive system header chain, only triggered during actual compilation.
  3. musl-based systems (Termux, Alpine Linux) do not ship Linux private kernel asm headers, leading to build failure on ARM64 Linux targets.

Proposed fix: Guard linux/types.h inclusion for musl environments, or replace kernel __uXX types with standard C99 stdint.h fixed-width types to drop kernel header dependency entirely. @azwolski

1234562026 avatar Jul 22 '26 12:07 1234562026

@azwolski

Minimal reproducer steps for Termux Android aarch64 (musl libc)

1. Download source code archive wget https://github.com/ispc/ispc/archive/refs/heads/main.zip unzip main.zip cd ispc-main 2. Create clean build directory mkdir build && cd build 3. Configure and build cmake .. -G Ninja ninja The compile error  fatal error: 'asm/types.h' file not found  will appear during builtins source generation.

1234562026 avatar Jul 22 '26 13:07 1234562026