www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - annotating (object/library files) with compilation metadata to avoid

Could dmd/ldc/gdc produce user defined attributes embedded (eg as json
string) embedded in some section of the object file/static/shared library,
eg:

```
{"compiler" : "dmd", "version" : "2.072", "flags" : "-O -debug"}
```

with some way to write and read those attributes, so that tooling can give
informative warnings or errors when attempting to link together several
libraries whose attributes don't match (user defined function can decide
what matches based on those attributes), or to select which libraries to
link if there are several choices


NOTE: posted a more general question here [1] beyond just D usage

[1]
http://stackoverflow.com/questions/41240093/how-to-annotate-a-compilation-output-object-library-file-with-compiler-annotat

quote from that question:
----

Use cases:

   -

   either the linker ld or some other user defined tool could use this
   metadata to give informative warnings or errors when attempting to link
   together several libraries whose attributes don't match (eg when linking
   libraries compiles with -std=c++11 with others compiled without this)
   -

   this would provide much more user friendly error messages compared to
   the usual hard to debug undefined symbol errors, eg: undefined reference to
   llvm::Twine::str[abi:cxx11]()
   https://github.com/ldc-developers/ldc/issues/1928 or other errors that
   are due to compilation flag mismatches (eg missing -debug from
   https://github.com/rejectedsoftware/vibe.d/issues/740#issuecomment-268039416
   )
   -

   make it possible for tools to read the embedded metadata and find the
   most appropriate matching libraries to link when multiple ones are available

NOTE: the only thing I could find was
https://gcc.gnu.org/onlinedocs/gccint/LTO-object-file-layout.html but not
sure if that's relevant or how I would write (and later read) such user
defined attributes:

Command line options (.gnu.lto_.opts): This section contains the command
line options used to generate the object files
Dec 20 2016