Special behaviour for _Dmodule_ref and _d_run_main?

Denis Feklushkin feklushkin.denis at gmail.com
Mon May 11 16:06:01 UTC 2020


On Monday, 11 May 2020 at 15:58:13 UTC, David Nadlinger wrote:
> On 11 May 2020, at 16:44, Denis Feklushkin via 
> digitalmars-d-ldc wrote:
>> I use clang for linking and it calls ld.lld for this purpose.
>
> Could you please create an issue on GitHub with instructions to 
> reproduce, or at least the full compiler/linker command lines? 
> This discussion is getting quite hard to follow…

Yes, but it will not be fast - the project is quite large, 
discussed command line is huge size (generated by Meson)

Linking comand line (LFs added to convient reading):

clang  -o firmware.elf
   'firmware.elf at exe/meson-generated_gpio.d.o'
   'firmware.elf at exe/meson-generated_freertos.d.o'
   [... huge amount of obj files skip ...]
   'firmware.elf at exe/subprojects_freertos_timers.c.o'
   'firmware.elf at exe/subprojects_libunwind_src_Unwind-seh.cpp.o'
   
'firmware.elf at exe/subprojects_libunwind_src_UnwindRegistersSave.S.o'
   -L/usr/lib/gcc/arm-none-eabi/8.3.1/thumb/v7-m/nofp/ 
-Wl,--as-needed -Wl,--no-undefined
   -Xlinker --fatal-warnings -flto=thin -target 
thumbv7m-unknown-none-eabi
   --no-standard-libraries -Wl,
   --start-group subprojects/picolibc/semihost/libsemihost.a 
d/libdruntime.a
   subprojects/libopencm3/libopencm3_stm32f1.a 
subprojects/libopencm3/libreset_handler.a
   -Xlinker --script=linker_script.ld -lgcc -Wl,--end-group
   
'-Wl,-rpath,$ORIGIN/subprojects/picolibc/semihost:$ORIGIN/d:$ORIGIN/subprojects/libopencm3'
   
-Wl,-rpath-link,/home/denizzz/Dev/d_c_arm_test/builddir/subprojects/picolibc/semihost
   -Wl,-rpath-link,/home/denizzz/Dev/d_c_arm_test/builddir/d
   
-Wl,-rpath-link,/home/denizzz/Dev/d_c_arm_test/builddir/subprojects/libopencm3
ld.lld: error: undefined symbol: _Dmodule_ref
>>> referenced by gpio.d
>>>               lto.tmp:(.text._D4gpio16__moduleinfoCtorZ+0x0)
>>> referenced by gpio.d
>>>               lto.tmp:(_D4gpio16__moduleinfoCtorZ)
>>> referenced by freertos.d
>>>               
>>> lto.tmp:(.text._D8freertos16__moduleinfoCtorZ+0x0)
>>> referenced by freertos.d
>>>               lto.tmp:(_D8freertos16__moduleinfoCtorZ)
>>> referenced by app.d
>>>               lto.tmp:(.text._D3app16__moduleinfoCtorZ+0x0)
>>> referenced by app.d
>>>               lto.tmp:(_D3app16__moduleinfoCtorZ)

ld.lld: error: undefined symbol: _d_run_main
>>> referenced by entrypoint.d:35 
>>> (/usr/lib/ldc/x86_64-linux-gnu/include/d/core/internal/entrypoint.d:35)
>>>               lto.tmp:(main)
clang: error: ld.lld command failed with exit code 1 (use -v to 
see invocation)



More information about the digitalmars-d-ldc mailing list