Skip to main content


i just found out that `#pragma comment(lib, ...)` works with clang on an ELF target but not on a COFF target. the

i... what? how do you even end up in this situation? i'm completely lost

in reply to ✧✦✶✷Catherine✷✶✦✧

clang -fuse-ld=lld -target x86_64-linux-gnu: of course #pragma comment(lib, "-lX11") works
clang -fuse-ld=lld -target x86_64-windows-gnu: of course #pragma comment(lib, "-lws2_32") is silently ignored

i feel like i'm in a fever dream. this is the exact opposite of what i would expect!!

This entry was edited (1 week ago)
in reply to ✧✦✶✷Catherine✷✶✦✧

oh, i figured it out

clang -target x86_64-windows-msvc puts the comment into a .drectve section.

clang -target x86_64-windows-gnu silently ignores it, presumably because mingw doesn't define anywhere to put it.

clang -target x86_64-linux-gnu puts it into an SHT_LLVM_DEPENDENT_LIBRARIES section because LLVM has defined that this is where it goes