Skip to content

ndk: define the down-call's variables outside the unnamed namespace - #413

Merged
jwinarske merged 1 commit into
mainfrom
ndk/asm-vars-external-linkage
Dec 3, 2026
Merged

jwinarske merged 1 commit into
mainfrom
ndk/asm-vars-external-linkage

Conversation

@jwinarske

Copy link
Copy Markdown
Contributor

Summary

GCC 15 does not link the arm64 build. src/ndk/bionic_runtime.cpp defined the four variables its down-call assembly reads as extern "C" inside an unnamed namespace. GCC up to 15 gives such a variable internal linkage and a mangled name, so the assembly's references to the C names stay undefined. Clang and GCC 16 use the C name. x86-64 has no such variables.

The block now closes the unnamed namespace around itself. No other change.

Found by a Yocto build (wrynose, GCC 15.2), which had to switch the arm64 build to clang. tools/pi-build.sh builds natively with g++ 14 and would not link either.

Test status

Check Result
Yocto aarch64 GCC 15.2, this file to assembly at -O2, before Four variables under mangled names; acl_ndk_tls_disp undefined
Same, after All four defined under their C names
arm64 (clang release build), i.MX 8M Plus, WebView app Library loads through the down-call; app draws
x86-64 build No warning
clang-format clean

Not done: a full arm64 link with GCC 15. The assembler in that toolchain copy did not run outside its build, so the check stops at the compiler's output.

GCC 15 does not link the arm64 build. bionic_runtime.cpp defined the
four variables its down-call assembly reads (acl_ndk_tls_disp,
acl_ndk_wrap_disp, acl_ndk_block_disp, acl_ndk_env_tbl_ptr) as
`extern "C"` inside an unnamed namespace. GCC up to 15 gives such a
variable internal linkage and a mangled name, so the assembly's
references to the C names stay undefined. Clang and GCC 16 use the C
name, which is why the clang arm64 builds link. x86-64 has no such
variables.

The block now closes the unnamed namespace around itself.

Tested:
- Yocto's aarch64 GCC 15.2, this file compiled to assembly at -O2:
  before, the four are defined under mangled names and
  acl_ndk_tls_disp is left undefined; after, all four are defined
  under their C names.
- arm64 (clang release build) on an i.MX 8M Plus: a WebView app loads
  its library through the down-call and draws.
- x86-64 builds with no warning; clang-format clean.

Signed-off-by: Joel Winarske <joel.winarske@linux.com>
@jwinarske
jwinarske merged commit d2a1230 into main Dec 3, 2026
11 checks passed
@jwinarske
jwinarske deleted the ndk/asm-vars-external-linkage branch December 3, 2026 00:52
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

Successfully merging this pull request may close these issues.

1 participant