Potential of a compiler that creates the executable at once
John Colvin
john.loughran.colvin at gmail.com
Sat Feb 12 10:00:15 UTC 2022
On Thursday, 10 February 2022 at 22:52:45 UTC, Walter Bright
wrote:
> On 2/10/2022 2:06 PM, Dave P. wrote:
>> Undefined symbols for architecture arm64:
>> "__D7example9some_funcFiZi", referenced from:
>> __D7example3fooFiZi in example.o
>> __D7example3barFiZi in example.o
>> __D7example3bazFiZi in example.o
>> __D7example3quxFiZi in example.o
>> __Dmain in example.o
>> ld: symbol(s) not found for architecture arm64
>
> Things I have never been able to explain, even to long time
> professional programmers:
>
> 1. what "undefined symbol" means
>
> 2. what "multiply defined symbol" means
>
> 3. how linkers resolve symbols
>
> Our own runtime library illustrates this bafflement. In
> druntime, there are these "hooks" where one can replace the
> default function that deals with assertion errors.
>
> Such hooks are entirely unnecessary.
>
> To override a symbol in a library, just write your own function
> with the same name and link it in before the library.
>
> I have never been able to explain these to people. I wonder if
> it is because it is so simple, people think "that can't be
> right". With the hook thing, they'll ask me to re-explain it
> several times, then they'll say "are you sure?" and they still
> don't believe it.
I absolutely don’t want my executable defined by the order things
happen to appear on the linker command line. I don’t want that
incidentally and I don’t want to do it deliberately. The boat
sailed on this long ago, I just want everything to be in the
executable please with errors on duplicates, unless it’s dead
code.
Same goes for import paths btw. I don’t want imports selected
based on the order of import paths, I want hard errors on any
duplication of fully-qualified modules.
D has amazing compile-time features for deciding what to compile
or not, what to call and not. I want to use those, not rely on
the details of how I cobble together my build (or how some
automated tool does it for me).
More information about the Digitalmars-d
mailing list