[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).
Martin Storsjö via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 3 15:01:42 PDT 2022
mstorsjo added a comment.
In D137107#3906439 <https://reviews.llvm.org/D137107#3906439>, @zahiraam wrote:
> Here is an even smaller test case.
> lib.cpp:
> __declspec(dllexport) int val=12;
>
> t1.cpp:
> int main () {
>
> extern int _declspec(dllimport) val;
> int& val_ref = val;
> return val;
>
> }
> $ clang.exe -LD lib.cpp (this will create a.lib and a.exp)
> $ clang.exe t1.cpp -la
> $ ./a.exe
> This will result in a popup message: "The application was unable to start correctly ..."
What does `llvm-readobj --coff-imports a.exe` show here?
What environment are you running this in? `-LD` is a cl/clang-cl style option and can't be passed to the gnu-style interface of `clang.exe`.
When I try to follow these examples in cmd.exe, I get the following:
>clang.exe -LD lib.cpp
Creating library a.lib and object a.exp
LINK : fatal error LNK1561: entry point must be defined
clang: error: linker command failed with exit code 1561 (use -v to see invocation)
It looks to me like the way you're invoking the compiler here is creating the issue you're observing. This testcase works just fine for me when I build it like this:
>clang-cl -LD lib.cpp
>clang-cl t1.cpp -link lib.lib
>t1.exe
>echo %errorlevel%
12
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137107/new/
https://reviews.llvm.org/D137107
More information about the cfe-commits
mailing list