-
Notifications
You must be signed in to change notification settings - Fork 48
Conversation
In the meantime, we should probably raise a PR upstream to add overflow detection. |
Oh, I forgot, it is impossible to overflow! Here's a working implementation. |
|
@ibuclaw Did you see this post: http://forum.dlang.org/post/nhsug0$2k9u$1@digitalmars.com ? |
caee8e8
to
ce8cca0
Compare
Yeah, keeping components of Druntime optional is the way to go.
Stack variables are referenced as the vars in a BIND_EXPR. The best order to do things so that existing code is reused would be: Though having a quick look at the area where this would go, you'd have to see if you can reorder how you generate the parts of the function somehow.
Does this differ from the testsuite somehow? I'd have to look at what it is doing be honest.
Aiming for running the entire testsuite and unittests linking against a shared library would be the target to go for. |
|
Compiler support looks simple enough, which is what I hoped for. Will try to fit in a proper review tomorrow. Thanks! :-) |
Yes, but that's not really a big problem. I can simply overwrite the function body tree in the WrappedExp. But I didn't know how to use
It tests loading & linking shared libraries. This does not really fit well in the test suite framework so there is an extra Makefile for these tests. I guess we could just add a
OK. Shared library only or shared & static library?
Sounds great, thanks! Most changes are in druntime in the BTW: I forgot to mention that this currently removes the |
Turns out I can't use these functions directly, as they rely on other functions to initialize some globals (start_function, ...). I just 'inlined' the relevant parts of these functions. |
|
Something completely unrelated, but I just realized that make check-d does not run the |
|
So I had another look at the library versioning, ping @Dicebot DMD: LDC: Here's what we can do with libtools:
Because of the SONAME restrictions we can't implement the DMD scheme. The LDC scheme can be implemented with both And here's an example (first value: file name; second value: soname):
The starting release number is arbitrary (though we should start at 0 once we have ABI compatible releases). As you can see the TLDR: I think we can & should use the For now we can simply bump the
The |
| @@ -20,7 +20,7 @@ | |||
| ## with this library; see the file COPYING3. If not see | |||
| ## <http://www.gnu.org/licenses/>. | |||
|
|
|||
| SUBDIRS = libdruntime src | |||
| SUBDIRS = libdruntime src test | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe name the directory testsuite?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
|
We should be able to reliably use the For phobos, according to the libtool docs, you can force each release to be binary incompatible using the https://www.gnu.org/software/automake/faq/libtool.html#Release-numbers |
|
Using |
I wouldn't do that. The libtool docs are quite clear that breaking ABI changes must always increment the first (current number). So I think we should use
Yes, that's certainly possible and maybe the best solution, but @Dicebot mentioned he would prefer a more DMD/LDC compatible versioning.
I don't think we should base our versions on the GCC release. The GCC backend does not break ABI so druntime version |
I don't think the point release should be included. Unless there's any examples of adding/removing interfaces between 2.xxx.0 and 2.xxx.1. |
You're right, the point release should not be included if we use |
|
Yeah, I'd move the two into the version number. It's been years since D1, it should go. |
Done. Also changed to use |
|
@jpf91 - Any last things holding up? (Apart from changelog, rebase) |
|
I'd say merge this yourself when you are ready. There are some re-factorings that need doing for the D conversion that are waiting on this. |
This function does not output the generated function to allow further modification.
For now, only do error reporting. Theoretically we could also
fall back to the _Dmodule_ref model in such cases by simply
not defining the _d_dso_registry function:
static if (Minfo_Bracketing)
{
_d_dso_registry...
}
else
{
void* _Dmodule_ref...;
}
This reverts commit 9e9f49a.
The new ModuleInfo emission otherwise loads rt/sections.d. sections.d depends on rt.deh which depends on gcc.unwind which depends on gcc.config. But gcc.config is generated by the druntime configure script and not available yet when running GDC tests in configure.
For dynamic library loading support
From druntime master
Calling Runtime.unloadLibrary(h) in assert() breaks the test when compiled with -frelease
Sounds interesting ;-) Merged. |
OK, I've now rewritten the shared library support in a DMD/LDC compatible way.
high level overview
This function is useful for the shared library / ModuleInfo emission code so I made it a global function.
Like
build_simple_function, but do not calltoObjfile. This allows further adjustments on the GCC tree (such as settingVISIBILITY=HIDDENor callingd_comdat_linkage)This commit contains the real compiler work.
ModuleInfointo aminfosection, or the old approach using_Dmodule_ref. I chose a solution which does not require changes to upstream druntime code but also does not hardcode the targets like DMD does: We try to loadrt/sections. If the module is not found, we do not emit any ModuleInfo. If it is found, try to find the_Dmodule_ref,CompilerDSODataand_d_dso_registrysymbols. Ignore permissions, as these declarations are private. If_d_dso_registryandCompilerDSODataexist, use the new approach. Otherwise if_Dmodule_refexists, use the old approach. Otherwise do not emit ModuleInfo. Nice side-effect: Small runtimes don't have to provide_Dmodule_reffake declarations anymore.minfosection. LDC uses.minfobut we need to avoid leading dots to use this feature: https://sourceware.org/binutils/docs-2.26/ld/Orphan-Sections.html Binutils will the provide__start_minfoand__stop_minfosymbols bracketing the section.gdc_dso_ctorand a destructorgdc_dso_dtor(one per object file). We want one of these per library, so we set them as comdat decls and visibility=hidden. However, GCC doesn't allow setting the references in the.ctorssection as comdat. We end up with one ctor/dtor function per library but it is calledntimes, werenis the number of modules in the library.gdc_dso_initializedvariable.CompilerDSODataconstant, useaggregate_find_fieldand the symbol fromrt.sections. This way there'll never be a compiler/runtime mismatch, the debug info is nice & useful etc.__start_minfoand__stop_minfosymbols to find the ModuleInfos. If these are marked as hidden the linker will make them per-library. Took some time to figure out I have to setDECL_VISIBILITY_SPECIFIEDas well. Anyway, it's now working nicely.Simply copy code unmodified from upstream.
Start building shared libraries.
We have some disabled tests in the static unittests. Also disable these for shared library unittests.
Update to 2.068.2
The new ModuleInfo emission otherwise loads rt/sections.d. sections.d depends on rt.deh which depends on gcc.unwind which depends on gcc.config. But gcc.config is generated by the druntime configure script and not available yet when running GDC tests in configure.
Object files going into the shared druntime need to be compiled with version=Shared. This implementation is a bit of a hack, as it uses the PIC flag to detect whether a object will be part of the shared library. Theoretically the static lib could also contain PIC objects, so this is incorrect. However, the libtool maintainers always used the same hack in C/C++ and even define DLL_EXPORT depending on the PIC mode (windows doesn't even have PIC mode...) so this should be OK.
All proper solutions add lots of bloat to the Makefiles. We could add a second library definition for the static library, (
libgdruntime_s.la) but we still need libtool to linklibbacktrace.la. Then we'd have to handle (un)installation manually to renamelibgdruntime_s.atolibgdruntime.aand even then, thelibgdruntime.lafile would still only refer to the shared library.-shared-libphobos flagMake static linking the default for now.
-static-libphobosis also available.Testing so far
--disable-staticand--disable-sharedmake installTODO list
gdc_dso_ctorandgdc_dso_dtorfunctionsEmit ModuleInfo references into minfo section if necessarycommit.configuretest for druntime to check whether the linker actually supports adding the__start_minfoand__stop_minfosymbols. Output this information togcc.configand add astatic assert(HaveMinfoBracketing)tort.sectionsfor shared elf code.--disable-static--disable-sharedThis is ready for review.