Not all type declarations yet (e.g., some TypeInfo subtypes are still
accessed directly), but those already wrapped as LazyType in the
gen/runtime.cpp module (with check and proper error msg in case object.d
doesn't contain a required declaration).
Tie the state to an LLVM module/object file instead of having a global
one. And finalize it once per LLVM module instead of once per D module
(previously, as part of ModuleInfo generation).
Fixes issue #2388.
Postpone the destruction of replaced global variables, register them in
`IRState::globalsToReplace` and perform a second replacement pass when
finalizing the IR module. The globals will be destroyed in that 2nd pass,
so there may still be dangling pointers in `IrGlobal::value`, but now only
after writing the module.
The nicer thing would be replacing IrGlobal::value by IrGlobal::getValue()
which could look it up in IRState, but that's not feasible due to the
field being inherited from IrVar and IrGlobal apparently quite often being
used as IrVar (via pointers union), so the cached field is currently
required.
So the feasible options to me were either registering each IrGlobal with
its mangled name and replacing their values when swapping out the global
variable, or performing this second replacement pass right before
finalizing the IR module to make sure we really replace all occurrences.
I went for the latter as it's both easier and safer (from the LL
perspective as the old global might be cached somewhere else too).
* Fix LLVM 5.0 compilation.
* Fix adding linker option metadata to LLVM module.
See https://reviews.llvm.org/D31349
* Version the SPIRV cache dir on travis.
Just before writing the object file. Module::deleteObjFile() deletes the
doc file too, and generating the docs happens in a prior pass before
codegen.
deleteObjFile() is already called in mars.d, after reading the source
file, before the generate-doc pass.
Fixes dmd-testsuite's runnable/test_switches.sh.
Make sure the overall order corresponds to the user's command-line order
of object and source files. The only exception being singleObj builds,
for which the single object file for all source files is always the first
entry in the object files list (which is forwarded to the linker in that
order). This is done so that we can easily get hold of the name when
emitting the single object file later in the `ldc::CodeGenerator` dtor.
It should also clearly define the linking order (affecting comdat
selections etc.) for special singleObj builds.
Also reuse some more code (wrt. output filenames) from DMD's main().
This reduces the size of a statically linked Phobos-based
Hello World by 11 kB on Linux x86_64.
Also creates a header file for gen/module.cpp, which has been
renamed to "modules" such as not to conflict with the frontend
header file.
We had switched to a somewhat simplified implementation Martin
came up with for DMD based on our old one. Unfortunately, that
turned out not to work for certain ld.bfd versions on Linux
(e.g. 2.26.0.20160501), where the .bss section from other shared
objects would be picked up instead.
This reverts commit 08ad4fddb5.
GitHub: Fixes#1534.
Also adds the CMake infrastructure to compile and link the D source files.
The build is partially broken:
- A few files in Phobos and druntime do not build
- MSVC build is broken because of unresolved symbols involving reals
This PR replaces the few uses of global.params.is<OS> with
global.params.targetTriple.isOS<OS>(). This avoids adding a new
boolean for each supported OS.
It also defines all xBSD-type OS as using the dso-registry.
In case of a singleobj build and a provided output file (.exe or .obj).
The dmd-testsuite tests used to produce lots of .o files while expecting
.obj ones as specified in the command line.