llvm-project/lld/test/COFF/imports-static-lib-indirect.test
Alexandre Ganea c75eac7c03
[LLD][COFF] Don't dllimport from static libraries (#134443)
This reverts commit 6a1bdd9 and re-instate behavior that matches what
MSVC link.exe does, that is, error out when trying to dllimport a symbol
from a static library.

A hint is now displayed in stdout, mentioning that we should rather dllimport the symbol
from a import library.

Fixes https://github.com/llvm/llvm-project/issues/131807
2025-04-07 11:34:24 -04:00

27 lines
685 B
Plaintext

# REQUIRES: x86
# Pulling in on both a dllimport symbol and a static symbol should only warn.
# RUN: split-file %s %t.dir
# RUN: llvm-mc --filetype=obj -triple=x86_64-windows-msvc %t.dir/other.s -o %t.other.obj
# RUN: llvm-mc --filetype=obj -triple=x86_64-windows-msvc %t.dir/main.s -o %t.main.obj
# RUN: llvm-lib %t.other.obj -out:%t.other.lib
# RUN: lld-link %t.other.lib %t.main.obj -out:%t.dll -dll 2>&1 | FileCheck %s
CHECK: warning: {{.*}} locally defined symbol imported: foo {{.*}} [LNK4217]
#--- other.s
.text
.globl other
.globl foo
other:
ret
foo:
ret
#--- main.s
.text
.global _DllMainCRTStartup
_DllMainCRTStartup:
call *other(%rip)
call *__imp_foo(%rip)
ret