Restructuring druntime

Johannes Pfau nospam at example.com
Sun Feb 26 12:54:26 PST 2012


Am Sun, 26 Feb 2012 19:30:03 +0100
schrieb "Kagamin" <spam at here.lot>:

> On Sunday, 26 February 2012 at 13:06:58 UTC, Johannes Pfau wrote:
> > still have to make sure core.* works.
> 
> That's an issue. Given the c libraries incompatibilities, what 
> functionality the core.stdc should provide? What to do with 
> functions like backtrace?

Fortunately backtrace is not part of core.stdc. core.stdc only includes
functions which are described by the C(99?) standard and C libraries
usually provide most of that functionality. It's more difficult for
core.sys.posix as 'lightweight' libcs often decide to not implement
some posix modules. If some of the basic functionality isn't supported,
there's probably nothing we can do.

For the special backtrace & backtrace_symbols case we should get rid of
backtrace and use gcc functionality (We already have access to that in
gcc.unwind). backtrace_symbols can be implemented using dladdr. dladdr
isn't standard C/Posix either, but it's supported by more C libraries.
In case dl_addr isn't available, we can always just print the addresses
instead of the function names. addr2line works better than
backtrace_symbols / dladdr anyway.

I had a look at glibc and bionic though and those C libraries provide
much more functionality than what's currently included in druntime.
Creating complete bindings is probably a waste of time as those 'extra'
functions are not portable anyway.

Maybe the simplest solution is to add a 'sublibrary' to druntime, libdc
or something, then store the normal core.stdc/core.sys modules in a
subdir for every C library and compile in only the correct modules using
the configure script:

druntime
|-core
|---atomic.d (generic files)
|---bitop.d
|---[...]
|-gc
|-gcstub
|-rt
|-libdc
|---glibc
|-----core
|-------sys
|-------stdc
|---bionic
|-----core
|-------sys
|-------stdc
|---newlib
|-----core
|-------sys
|-------stdc

The files in libc/glibc/core/stdc would be in the core.stdc package
(not glib.core.stdc), so we just have to compile the correct
subdirectory into druntime.


More information about the D.gnu mailing list