Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

First Android/x86 patch that produces a working D executable #734

Merged
merged 2 commits into from
Mar 12, 2014
Merged

First Android/x86 patch that produces a working D executable #734

merged 2 commits into from
Mar 12, 2014

Conversation

joakim-noah
Copy link
Contributor

This is the first patch where I was able to build actual D Android/x86 executables that use the core of druntime, cleaned up a bit since. I tried to follow the existing naming conventions in druntime, like sigaction_t and stat_t. There were two unnecessary uses of version(Posix) that I removed. FD_(CLR|SET|ISSET|ZERO) are defined in assembly in bionic. I didn't bother translating them, since they aren't used anywhere but the unit tests. This patch alone can't actually be used to build executables, as it needs a sections_android.d and mak/SRCS needs to be trimmed to only include these files. Those patches will come next.

@MartinNowak
Copy link
Member

Only had a short glance, but LGTM.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 3, 2014

Except for the blah blah Android == Linux that I mentioned in the other pull. But IIRC these pulls are not supposed to actually work and just references?

@joakim-noah
Copy link
Contributor Author

They work. I've built small Android/x86 command-line executables using this patch and a lightly modified sections_solaris.d, which I repurposed for Android. It is incomplete as there is still missing stuff like TLS, which I'm working on now. But yeah, this versioning scheme isn't set in stone, we can still rearrange it later.

I'm not sure exactly what interface you need for GDC. Right now, linux represents the linux kernel + glibc, while Android represents the linux kernel + bionic. I know that you'd prefer to split it up as linux, glibc, and bionic, but you also mentioned a couple times that "the place where Android is pre-defined in the backend is pulled in by all the headers where linux is pre-defined." I don't know what that means: does the backend automatically define Android and linux? Based on what? I'm unclear on exactly what GDC is doing and why the predefined globals its backend is generating can't be overridden if necessary.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 4, 2014

@joakim-noah - Android and linux are defined in the places where Android and linux are expected to be defined (otherwise you may not get either in some target configurations). When the target is Android, the config setup pull in the linux headers too, thus both get defined. This is quite deliberate on GCC's part as Android is a target switch that falls under the GNU/Linux options category.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 4, 2014

As stated on the manpage: http://manpages.ubuntu.com/manpages/trusty/en/man1/gcc.1.html

@joakim-noah
Copy link
Contributor Author

Thanks for the link, I didn't know gcc had such android flags. However, the fact remains that code generation for linux/x86 and Android/x86 is essentially the same, perhaps a couple of well-known, non-Android-specific compiler/linker flags difference and TLS will probably have to be handled differently. So there's not much of a difference in GDC x86 codegen for linux vs. Android, we're only talking here about how to handle predefined globals supplied by GDC when it builds druntime and phobos.

Presumably you can patch GDC to override whatever it currently defines. If you are reluctant to do so, we need to know exactly what it does provide and what they mean. I think you're saying GDC will compile druntime with the predefined globals linux and Android for Android and only linux for linux. Is that right?

Such a scheme would be problematic however, as it doesn't provide a good way to differentiate between glibc and bionic in druntime. I suppose we could take linux to mean linux kernel, Android to represent bionic, and linux && !Android to represent glibc, but that seems like a hack. Better to only define linux for linux builds and Android for Android builds, until we can split up along glibc, linux, and bionic.

@ibuclaw
Copy link
Member

ibuclaw commented Mar 4, 2014

The idea is that you shouldn't have bionic and glibc in the same sources.

@joakim-noah
Copy link
Contributor Author

Perhaps that is possible under your proposed platform reorg of druntime being discussed in pull #732, but it's not the way druntime is organized today. My android pulls will just be provisional for now, for early devs and testers to bang on. We'll reorganize them once you guys iron out the details of the druntime platform reorg.

@MartinNowak
Copy link
Member

Rest is OK.

@andralex
Copy link
Member

andralex commented Mar 9, 2014

lgtm, @ibuclaw to pull

@ibuclaw
Copy link
Member

ibuclaw commented Mar 9, 2014

Thanks @andralex

@MartinNowak
Copy link
Member

Auto-merge toggled on

MartinNowak added a commit that referenced this pull request Mar 12, 2014
First Android/x86 patch that produces a working D executable
@MartinNowak MartinNowak merged commit b5ef120 into dlang:master Mar 12, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants