Android: Don't register LLVM signal handlers#5070
Android: Don't register LLVM signal handlers#5070kinke wants to merge 2 commits intoldc-developers:masterfrom
Conversation
A little test wrt. ldc-developers#4383.
|
I was able to successfully compile this in GitHub Actions by changing the Ubuntu version to 24.04 and trying until it worked: https://github.com/robertkirkman/ldc/actions/runs/22288993543/job/64472748363 and, when I test this one, it looks like it works just slightly more than the 1.41.0 release! It prints the messages however, unfortunately, when I try to compile anything with it, it still prints |
|
Heh wow, thx a lot for the effort! - Okay then this a) doesn't seem to prevent the I'm wondering if this is just some |
|
Btw, is the |
|
|
|
FWIW, I've tried I'll try an Android LLVM build without |
|
I've installed Termux on my phone and played around a bit. I can reproduce the wild behavior, incl. this signal-handling-skipping here definitely getting LDC much further. The other bundled D binaries seem to run fine btw. Using this CI artifact here, compiling a minimal program with So it looks as if the signal handling stuff in our Android LLVM builds is seriously broken. The CMake build might need explicit options to work properly on Android; checking similar builds could help. |
|
There's a |
|
Cool - that work won't be in vain, since that's exactly how the Termux package should be built nowadays. AFAICT, you shouldn't need any extra CMake flags on Android, it hopefully just builds and works fine. After the latest results, I'm pretty positive that the problem lies in our prebuilt LLVM binaries. But if it's not the alternate-stack thing either, I'd be out of ideas. Maybe trying once more with the latest NDK. |
|
I have good news, which is that I was able to compile the newest LDC inside Termux, and also that it can now compile and run hello world when I do that! There is possibly a remaining problem that when I run the hello world program, it crashes when ending instead of ending cleanly, but overall this is good. I used 64-bit ARM Android 13. commands used# dependencies:
# approximately 'pkg install build-essential libllvm-static ldc cmake ninja termux-elf-cleaner'
git clone --recursive https://github.com/ldc-developers/ldc.git
cd ldc
mkdir build
cd build
export LDFLAGS="-lzstd"
cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PREFIX
ninja
rm /data/data/com.termux/files/usr/etc/ldc2.conf
ninja install
ldc2 --version
cat > hello.d << 'EOF'
import std.stdio;
void main() {
writeln("Hello, World!");
}
EOF
ldc2 hello.d
termux-elf-cleaner hello
./helloresultOn 64-bit ARM Android 10 I see this: I assume that this would be the API level 30 restriction for the thread-local storage that you mentioned. since this error only occurs on Android 10 and not Android 13, I assume that the other problem with hello world crashing when ending on Android 13 must be something different? Next, I will try to cross-compile the newest LDC using a similar setup, but the cross-compilation equivalent, to update the Termux |
|
Oh, finally some good news indeed!
I guess you'll have to specify
It's bizarre - the static |
I tried that in this way (on Android 13): but I seem to see the same result still. |
|
Hmm. This post is from 2018, so might be outdated, but shows how stack-protection and TLS might trip over each other on Android: https://reviews.llvm.org/D53906#1281612 |
Note that the druntime and Phobos libraries (linked into the hello-world, and also the location of the |
|
Hmm, I've tried redoing the same steps in the commands I sent earlier a few more times, and unfortunately the results seem to vary, because I'm not able to reproduce the working build of LDC 1.42.0 anymore. Now, what keeps happening whenever I build LDC and try to compile and run the hello world program, regardless of whether I use Termux packages are all built targeting API level 24, and among them are several important packages that I think could be having an effect on LDC, including |
|
Hmm - I've checked the TLS segment alignment of the cross-compiled CI dlang binaries here, and they are 64-bytes aligned, incl. the For LLVM and its C[++] dependencies, I guess they might not use any TLS stuff at all, so might not need to be compiled for higher API levels. We never compiled LLVM itself with our former custom TLS emulation (e.g., for Termux' LDC v1.30). Wrt. stack corruption for the CI binaries here (well, #5072), I'm really out of ideas. I was never able to see a meaningful stacktrace, e.g., never even saw |
Oh well, LLVM seems to have a few TLS vars - incl. for backtraces support, which can be disabled ( // If backtrace support is not enabled, compile out support for pretty stack
// traces. This has the secondary effect of not requiring thread local storage
// when backtrace support is disabled.
#if ENABLE_BACKTRACES |
A little test wrt. #4383, based on termux/termux-packages#28586 (comment).