www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - First module

reply Cecil Ward <cecil cecilward.com> writes:
I’ve written my first non-trivial module in D. See other thread. 
https://forum.dlang.org/thread/pfjpqcywxrmxwsncyxeq forum.dlang.org

I’d like to set up something to call it from other modules, and 
specifically I’d like to see if inlining works across module 
boundaries - I have no idea whether it does or not as I don’t 
understand fully in detail how module imports work.

How do I go about setting up such a test harness with LDC (or 
GDC) on either OSX/ARM or Linux Debian x86-64? I’m not sure what 
tools I need.

Note that I cannot use DMD, this code is LDC/GDC-specific. LDC 
would be my preference as that is what it is ultimately aimed at.
Jul 06 2023
parent reply Cecil Ward <cecil cecilward.com> writes:
On Thursday, 6 July 2023 at 21:10:39 UTC, Cecil Ward wrote:
 I’ve written my first non-trivial module in D. See other 
 thread. 
 https://forum.dlang.org/thread/pfjpqcywxrmxwsncyxeq forum.dlang.org

 I’d like to set up something to call it from other modules, and 
 specifically I’d like to see if inlining works across module 
 boundaries - I have no idea whether it does or not as I don’t 
 understand fully in detail how module imports work.

 How do I go about setting up such a test harness with LDC (or 
 GDC) on either OSX/ARM or Linux Debian x86-64? I’m not sure 
 what tools I need.

 Note that I cannot use DMD, this code is LDC/GDC-specific. LDC 
 would be my preference as that is what it is ultimately aimed 
 at.
Do I just provide two filenames as inputs to the compiler ? I’m wondering if the compiler resolves the import statements rather than the linker - is that right? I only have a vague understanding of how the import statement works - pulling in digested intermediate-code or something? Will in-line functions be inlined even if the called routine is across a module boundary?
Jul 07 2023
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
1. Compiler reads in source code provided on cli
2. It gets parsed
3. imports get looked up, if not already read in, looks in the 
directories provided by -I based upon the full module + package import 
statement
4. Finish compilation
5. Linker gets passed object files to produce some artifact like an 
executable

Very rough idea of how it works, but will do for what you are asking about.

As long as you compile all at once, assume inlining will work if it 
thinks it should. Modules will not affect it.
Jul 07 2023
parent Cecil Ward <cecil cecilward.com> writes:
On Friday, 7 July 2023 at 14:18:35 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
 1. Compiler reads in source code provided on cli
 2. It gets parsed
 3. imports get looked up, if not already read in, looks in the 
 directories provided by -I based upon the full module + package 
 import statement
 4. Finish compilation
 5. Linker gets passed object files to produce some artifact 
 like an executable

 Very rough idea of how it works, but will do for what you are 
 asking about.

 As long as you compile all at once, assume inlining will work 
 if it thinks it should. Modules will not affect it.
Brilliant, thanks Rikki.
Jul 07 2023