Previously, the logic gave up early if semantic3 was run for the
function to be inlined, either because the function is going to be
codegen'd in some root module, or because sema3 was already run for an
available_externally 'copy' in a previous compilation unit.
This restricted a function to being defined in at most one compilation
unit per ldc2 invocation.
So e.g. a little `pragma(inline, true)` wrapper in druntime wasn't
inlined into other druntime modules, because the whole lib is built in a
single cmdline by default, and sema3 was obviously run for the actual
emission in the corresponding object file.
When later compiling Phobos in a single cmdline, only the first object
file referencing the wrapper got lucky, running sema3 manually and
getting an available_externally 'copy'.
This patch gives new option which avoids the PLT and lazy binding while
making external calls.
Implementation inspired by `-fno-plt` support to Clang.
Clang's patch: https://reviews.llvm.org/D39079
Their IrParameter isn't created as part of DtoDeclareFunction(). Before
being able to handle that later in defineParameters() (as part of
defining the function), DtoCreateNestedContextType() steps in and
creates an IrLocal if not already created.
1) Create an IrParameter in that case in DtoCreateNestedContextType().
2) Handle these new value-less (no LL param) IrParameters in
defineParameters().
3) Fix the iOS AArch64 ABI, as apparently not all empty structs are
ignored for parameter passing, but only POD ones.
Also don't ignore anything passed by reference.
Emulation for @weak global variables is still left out but should be
analogous.
The test adaptations are mostly a revert of 3893840f. The testcase has
shown that @weak hasn't worked properly for ELF (linker apparently
prefers the version in the 1st object file, independent of whether it's
weak or not), because the functions are emitted in COMDATs.
clang emits COMDATs for templates and inline functions only, not for
regular functions.
* Extend the error message, closely following DMD. Tested by
fail_compilation/fail5634.d.
* Check across all compiled modules, not on a per-object-file basis.
That's what DMD does too.
* Apply the implicit `return 0` / void -> int return type promotion to
all D/C main functions, not just the first one. This prevents some
potential follow-up crashes.
E.g., this disables it for __entrypoint.d (the C main function(s) in
there), which is required.
A wmain on Windows is not detected as FuncDeclaration.isCMain() yet,
that should be fixed too.
As we do for IrFuncTyArg. We'll need access to the front-end linkage for
the Posix ABIs too in order to implement indirect-by-value passing of
non-PODs for `extern(C++)`.
Not all type declarations yet (e.g., some TypeInfo subtypes are still
accessed directly), but those already wrapped as LazyType in the
gen/runtime.cpp module (with check and proper error msg in case object.d
doesn't contain a required declaration).