[cfe-users] Issue when clang launches "ld.lld.exe" in Windows OS through "-fuse-ld=ld.lld"

Ni, Ray via cfe-users cfe-users at lists.llvm.org
Tue May 11 19:59:42 PDT 2021


Dear clang experts,
I want to build out ELF image using clang in Windows OS. But I met an issue when using "-fuse-ld=ld.lld" to ask clang launch ld.lld.exe as a linker.
Somehow clang always passes additional parameter to ld.lld: "-libpath:E:\\bin\\LLVM\\lib\\clang\\12.0.0\\lib\\windows" -nologo
I found this behavior when I pass "-v" to clang. With "-v", clang will output the complete command line about how ld.lld is invoked.

Command as below:


"E:\bin\LLVM\bin\clang" -o e:\work\edk2\Build\UefiPayloadPkgX64\DEBUG_CLANGDWARF\IA32\UefiPayloadPkg\UefiPayloadEntry\UniversalPayloadEntry\DEBUG\UniversalPayloadEntry.elf -nostdlib -Wl,-n,-q,--gc-sections -z common-page-size=0x40 -Wl,--entry,_ModuleEntryPoint -u _ModuleEntryPoint -Wl,-Map,e:\work\edk2\Build\UefiPayloadPkgX64\DEBUG_CLANGDWARF\IA32\UefiPayloadPkg\UefiPayloadEntry\UniversalPayloadEntry\DEBUG/UniversalPayloadEntry.map,--whole-archive -fuse-ld=ld.lld -flto -Wl,-melf_i386 -Wl,--format=elf @e:\work\edk2\Build\UefiPayloadPkgX64\DEBUG_CLANGDWARF\IA32\UefiPayloadPkg\UefiPayloadEntry\UniversalPayloadEntry\OUTPUT\static_library_files.lst -v

clang version 12.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: E:\bin\LLVM\bin
clang: warning: argument unused during compilation: '-u _ModuleEntryPoint' [-Wunused-command-line-argument]
"E:\\bin\\LLVM\\bin\\ld.lld" "-out:e:\\work\\edk2\\Build\\UefiPayloadPkgX64\\DEBUG_CLANGDWARF\\IA32\\UefiPayloadPkg\\UefiPayloadEntry\\UniversalPayloadEntry\\DEBUG\\UniversalPayloadEntry.elf" "-libpath:E:\\bin\\LLVM\\lib\\clang\\12.0.0\\lib\\windows" -nologo -n -q --gc-sections common-page-size=0x40 --entry _ModuleEntryPoint -Map "e:\\work\\edk2\\Build\\UefiPayloadPkgX64\\DEBUG_CLANGDWARF\\IA32\\UefiPayloadPkg\\UefiPayloadEntry\\UniversalPayloadEntry\\DEBUG/UniversalPayloadEntry.map" --whole-archive -melf_i386 --format=elf e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BasePcdLibNull/BasePcdLibNull/OUTPUT/BasePcdLibNull.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull/OUTPUT/FilterLibNull.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BaseLib/BaseLib/OUTPUT/BaseLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BaseMemoryLibRepStr/BaseMemoryLibRepStr/OUTPUT/BaseMemoryLibRepStr.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic/OUTPUT/BaseIoLibIntrinsic.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BasePciExpressLib/BasePciExpressLib/OUTPUT/BasePciExpressLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull/OUTPUT/DxeHobListLibNull.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib/OUTPUT/HobLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress/OUTPUT/BasePciLibPciExpress.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib/OUTPUT/PlatformHookLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib/OUTPUT/BaseDebugPrintErrorLevelLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BasePrintLib/BasePrintLib/OUTPUT/BasePrintLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550/OUTPUT/BaseSerialPortLib16550.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort/OUTPUT/BaseDebugLibSerialPort.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull/OUTPUT/PeCoffExtraActionLibNull.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/MdePkg/Library/BasePeCoffLib/BasePeCoffLib/OUTPUT/BasePeCoffLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib/OUTPUT/BaseUefiCpuLib.lib e:/work/edk2/Build/UefiPayloadPkgX64/DEBUG_CLANGDWARF/IA32/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry/OUTPUT/UniversalPayloadEntry.lib
ld.lld: error: unknown argument '-nologo'
ld.lld: error: unable to find library -libpath:E:\bin\LLVM\lib\clang\12.0.0\lib\windows
ld.lld: error: cannot open common-page-size=0x40: no such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Thanks,
Ray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20210512/33a49b72/attachment.html>


More information about the cfe-users mailing list