August 10, 2020
I am currently writing an UEFI application and ran into the problem that using the llvm_cos and llvm_sin intrinsics results in an undefined symbol during linking as they are just replaced with call to C's cosf and sinf.

Reduced test:

import ldc.intrinsics;

extern(C) export __gshared int _fltused = 0;

extern(Windows) void efi_main() {
    float a = llvm_cos(0.5f);
    double b = llvm_sin(0.5);
}

compiled with

-mtriple=x86_64-windows-coff -defaultlib= -debuglib= -code-model=large -betterC
-L/entry:efi_main -L/dll -L/subsystem:EFI_APPLICATION -L/nodefaultlib

results in

lld-link: error: undefined symbol: cosf
 referenced by D_Test\source\app.d:5
               .dub\build\application-debug-windows-x86_64-ldc_2091-8D06C0136AE698EE35D2211A74530569\d-test.obj:(efi_main)

lld-link: error: undefined symbol: sin
 referenced by D_Test\source\app.d:6
               .dub\build\application-debug-windows-x86_64-ldc_2091-8D06C0136AE698EE35D2211A74530569\d-test.obj:(efi_main)
Error: linking with LLD failed
ldc2 failed with exit code 1.

How can i tell LDC that my target does not have a C standard library? I tried to use the target triple x86_64-none-coff but that is not accepted by LLVM:

LLVM ERROR: Cannot initialize MC for non-Windows COFF object files.
ldc2 failed with exit code 1.

Interestingly sqrt works fine.
August 10, 2020
On Monday, 10 August 2020 at 08:30:52 UTC, KytoDragon wrote:
> How can i tell LDC that my target does not have a C standard library?

I don't think there's a way, plus not much LLVM can do - relying on an external library implementation for non-trivial transcendental math functions seems to make sense. Unfortunately, LLVM also doesn't seem to provide these functions in the 'builtins' compiler-rt library (ldc_rt.builtins.lib).
Phobos' std.math has some implementations, but unfortunately none for cos/sin yet.

> Interestingly sqrt works fine.

Yes, because there's a x64/SSE instruction for it.