Skip to content
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

Integrate android patches #1264

Closed
joakim-noah opened this issue Jan 27, 2016 · 3 comments
Closed

Integrate android patches #1264

joakim-noah opened this issue Jan 27, 2016 · 3 comments

Comments

@joakim-noah
Copy link
Contributor

I've uploaded my patch against ldc to build natively on Android itself. It's instructive because it has all the changes I made for the ldc cross-compiler but leaving out Kai and Dan's longdouble commits. I'm opening this issue so we can coordinate merging my patches back upstream.

There are three additional small changes for native compilation: removing some glibc-specific headers from dmd2/root/port.c, removing linker flags that aren't used on Android from driver/linker.cpp, and making PIC the default in driver/targetmachine.cpp. Otherwise, the cross-compilation patch for ldc is identical, just with the longdouble changes added in.

I can clean up and submit most of this patch, with two exceptions:

  1. The TLS section bracketing I used in driver/codegenerator.cpp is a hack: it doesn't quite work right for the tbss zero-initialized section, likely because of the _tlsend symbol. When I tried to do it differently, the symbols were getting stripped out during compilation, not sure why. If anybody knows how to quickly add those symbols similarly to dmd, I'd appreciate if you submitted a PR to do it. Otherwise, I'll pore over those llvm/ELF details more. The way I do it now causes the linker to print this warning, though it ultimately works: bin/ld.bfd: warning: section '.tbss' type changed to PROGBITS
  2. I don't know if the changes to runtime/CMakeLists.txt to add Android test-runner targets are wanted. I added those to make building Android test runners as easy as possible, but I'm not sure if they belong upstream.

Most of the druntime and phobos patches are also useful in the main repos upstream, so that's where I'll submit them. They can be merged here early or cherry-picked from upstream later.

That raises the question of timeline: should we try to get working Android support into one of the official 0.17 releases or hold off till 0.18? The update to the D frontend with 0.18 shouldn't affect this effort, as essentially nothing from the frontend directory dmd2/ is modified by my Android patch. However, this ldc patch also requires a small llvm patch to disable native TLS, so I'll need to add a flag to easily turn that on and off in llvm if we want to release a ldc built against a slightly patched llvm.

Alternately, lvm 3.8 comes with emulated TLS support, but last I used it there were two issues with that new feature: it was pulling in some non-PIC symbols somewhere, which causes a warning on Android before 6.0 and I believe would segfault on 6.0, and I need to figure out how to pass that emulated TLS data to the GC.

So, several decisions need to be made, appreciate some feedback on these.

@smolt
Copy link
Member

smolt commented Jan 27, 2016

I'll digest bit by bit as I have time.

I don't know if the changes to runtime/CMakeLists.txt to add Android test-runner targets are wanted.

I am sure they are wanted. I too have lengthy changes to runtime/CMakeLists.txt. Maybe for clarity CMakeLists can be broken up in to modules? Who has cmake experience enough to know good style?

@joakim-noah
Copy link
Contributor Author

I've submitted most of my druntime and phobos patches for Android upstream. Druntime PR #1490 and Phobos PR #3977 can be cherry-picked and merged into the ldc branches, as I doubt I'll need to modify them anymore, along with the older merged Phobos PR #3555. All require some minor backporting to be merged.

As for ldc itself, that TLS bracketing issue needs to be fixed before the linked gist can be merged.

@joakim-noah
Copy link
Contributor Author

Now that #1447 was merged, my remaining patches are fairly minimal, mostly avoiding a few remaining ldc issues or working around some older versions of Android.

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

No branches or pull requests

2 participants