-
-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TLS-related issue in Termux LDC 1.21.0-1 release #3461
Comments
|
What ld linker are you using, and can you try with the others? - See #3350 (comment). |
|
Btw thx for letting me know it actually works; I've never tested the Termux stuff. With v1.22, Termux won't need any special patches anymore; someone else (who's actually using it) taking over Termux maintenance would be great. ;) |
The problem is not that my code when compiled on Termux crashes, the problem is that LDC itself crashes, so I have no control over the linker - LDC has already been compiled and linked by Termux ;)
It has been at least a year since I have built successfully LDC from source on Termux. Before I did it from the P.S. I bought a phone with 12GB of RAM and 512GB of UFS 3.0 storage, specifically so I could natively build D code like LDC on it :P |
|
Oh, I see now. Can you list the sections of the Edit: I've checked the sections for the official Android/AArch64 package; the sections are contiguous: |
|
Here's what I get: |
|
I'll try to build master from source and see if so get something different. |
|
Thx, so here we have the reason, the sections are quite far apart. Seems like Termux tampers with the linker scripts, as the official package is created with the default settings of Android NDK r21. Unfortunately, there's no quick fix, as our custom TLS emulation relies on a single base address. Supporting non-contiguous ranges like here would significantly bloat the per-thread TLS data (by all regular non-TLS static data). Edit: That should be what previous LDC releases did - not being much of an issue for single-threaded LDC, but user code. Edit2: Even worse, the pre-1.21 scheme relied on |
|
Petar, please try the official package (I haven't gotten any feedback whether that one works either yet), and try linking a little program with TLS data (zero and non-zero initialized) with different (Termux) linkers by playing with |
|
The problem is that the official ldc package (as provided by the termux) is not working, sorry if that wasn't clear. I can't do anything with it, as even These days, I'm quite busy so I wasn't actually planning on building llvm+ldc myself, as so far the official package was working fine for me. |
|
I'm talking about the official package on GitHub (built by CI). That doesn't involve any Termux at all, and that's the one I've inspected above and so should basically work, unless there are some .so dependencies. Termux is a completely separate build, although similar (cross-compilation of LLVM + LDC from x86, but inside their special environment). [The official package is meant to be used inside something like Termux, as it still depends on |
|
I just finished build LLVM: Argh I actuall can't build LDC, because I don't have a bootstrap compiler... |
Ah ok then, I'll try it soon. |
|
I just downloaded 1.22.0-beta2 and it compiles fine hello world betterc: extern (C) int main()
{
import core.stdc.stdio : puts;
puts("hello world");
return 0;
}Phobos hello world also run well: So I think it's safe to say that the issue is entirely related to the way Termux handles the building of the 1.21 release. P.S. I'd happy to run any other tests on my device, if you find it useful :) |
|
Honestly, installing ldc from Termux was just a matter of convenience for me, as the prebuilt android releases were a recent addition on your side. I'd much rather use the real "official" releases that you provide, as a I have much higher trust in you :P And also I don't like when package managers meddle with upstream software :D All I need to do, is find time to integrate this into the dlang |
Yeah, unfortunately I am playing the role of the package manager in this case (if you don't do it yourself...), flying completely blind (I just can't be bothered to try anything out on my old phone). But the official packages were completely untested from my side too, so... :] - Thanks a lot for testing, good to know the stuff actually works as it should.
Yeah, please try all available linkers and check the sections for adjacency, as mentioned earlier. If we can pinpoint it to some linker (script), the Termux build might be fixable. |
|
Oh and a tiny little dub check would be nice as well, because of #3170. It'll probably require some libcurl, would be interesting to see whether it hangs because of that etc. |
Yeah, I remember following your PRs for Termux some time ago, though because of this msg:
I thought that someone else made changes on the Termux side that you were unaware of.
I'm more than happy to help!
Sure, here you go:
|
|
Thx for the slightly worrying results (the Android NDK aims at defaulting to LLD in future versions). They seem to contradict the results in #3350 (comment), where gold worked fine (for code with a non-empty Edit: Also, none of these section layouts match the ldc2 layout you posted above, so possibly the Termux linker scripts diverge between cross-compilation build environment on x86 and the actual Android environments... |
I guess it's possible that the two versions of
Yeah, that also seems to be the case to me. |
|
BTW, now that I have build LLVM 10 from source and I have a working LDC that I can use for bootstrapping, I could test your PRs locally, in case that help. Just ping me on the dlang Slack, as I generally can't keep up with email notifications from GitHub.
Dub itself seems to work fine, though I have only been able to test it with Edit: you find the result's of running Dub's test suite here: #3170 (comment)
#!/usr/bin/env dub
/+ dub.sdl:
dependency "vibe-d" version="~>0.8.0"
+/
void main()
{
import vibe.d;
listenHTTP(":8080", (req, res) {
res.writeBody("Hello, World: " ~ req.path);
});
runApplication();
} |
|
The issue is that |
|
Argh, here the reason is apparently some padding bytes inbetween, for alignment purposes. Speaking of which, the alignment would be violated by the current TLS emulation scheme, as the |
…etween .tdata/.tbss sections Wrt. ldc-developers#3461 and the encountered issue with the rdmd executable.
…etween .tdata/.tbss sections Wrt. ldc-developers#3461 and the encountered issue with the rdmd executable.
Wrt. ldc-developers#3461 and the encountered issue with the rdmd executable.
Wrt. ldc-developers#3461 and the encountered issue with the rdmd executable.
Wrt. ldc-developers#3461 and the encountered issue with the rdmd executable.
Wrt. ldc-developers#3461 and the encountered issue with the rdmd executable.
Wrt. ldc-developers#3461 and the encountered issue with the rdmd executable.
|
I've tested the aforementioned artifact on my termux environment and it compiles, links and runs successfully my code. |
|
Thanks for checking - could you please recheck with the latest version? https://dev.azure.com/ldc-developers/ldc/_build/results?buildId=1796&view=artifacts&type=publishedArtifacts (note: [Running all executables - with |
|
Yep the binaries works. The old artifact didn't required |
|
Perfect, thank you very much - LDC v1.22 final will probably be released this evening then. :) |
|
The Termux package was upgraded to v1.22.0 (termux/termux-packages#5413) - please check. |
|
Thanks, it works. |
|
Thanks a lot @kinke I can also confirm that the 1.22 release from Termux works well. I've just tested running the DCD test suite and all of the tests pass via TCP (Unix Domain Scokets don't work for some reason, though I haven't had the chance to investigate - it's possible that they're simply not supported on Android). See: https://asciinema.org/a/IUJZbxpHwEInNLBF6XDDMh7B5 What's notable about this is that those tests stress many parts of the toolchain: dub, rdmd, LDC, Phobos, dsymbol, msgpack-d, libdparse, stdx-allocator, emsi_containers and DCD TCP client and server. And everything seems to be working fine out of the box! |
|
Great, thx for the feedback. |

Hi @kinke I have been using LDC 1.20 release in Termux for while without any issues. Recently I updated to LDC 1.21, and when I tried it I noticed that it doesn't work anymore.
Steps to reproduce:
pkg install ldcldc2 --help(The
contiguousfishartifact in the output is because of a missing newline and because I'm using Fish shell. But the issue is same if I use bash.)The text was updated successfully, but these errors were encountered: