Special behaviour for _Dmodule_ref and _d_run_main?
Denis Feklushkin
feklushkin.denis at gmail.com
Mon May 11 13:29:51 UTC 2020
On Monday, 11 May 2020 at 12:48:20 UTC, David Nadlinger wrote:
> How are you currently invoking the linker, especially regarding
> ordering of libraries/object files on the command line?
I run lld from clang by Meson. But I don’t think that this should
influence anything: all discussed symbols are external in C
format:
sections_ldc.d:
extern (C) __gshared ModuleReference* _Dmodule_ref; // start of
linked list
dmain2.d:
extern (C) int _d_run_main(int argc, char** argv, MainFunc
mainFunc)
And also all works ok if "-flto" isn't used.
If I start linking by ldc2 it throws error at first passed object
file:
firmware.elf at exe/meson-generated_gpio.d.o: file not recognized:
file format not recognized
llvm-nm-9 confirms that this is object file.
This issues occurs only if -flto= enabled.
> LDC doesn't have any special handling for druntime (beyond the
> defaultlib selection logic).
It's good. I tried define some external(C) symbol near of
_Dmodule_ref and then use it from main() - linking with this
symbol works ok. So, this problem only with "hidden" calls
invoked by compiler.
More information about the digitalmars-d-ldc
mailing list