Comments (4)
Hey, thanks for the toolchain, I found it quite useful!
Great to hear that it's useful for you!
I've encountered a few minor problems with the linker using CMake due to some differences with the original toolchain:
- Using
find_library()
withtarget_link_libraries()
function to find and link against a static or shared library in CMake leads to the following error:lld-link: error: library.dll: bad file type. Did you specify a DLL instead of an import library?
Hmm, this is tricky. LLD doesn't support passing the name of the DLL itself to the linker for linking, but needs an import library, while GNU ld allows you to provide only a DLL. So far I've only ever heard about one user running into this issue, so so far, the effort needed to implement it hasn't felt justified.
(unlike the original MinGW or MSVC, this toolchain handles only static libraries that way).
I'd be interested in looking at what CMake does for MSVC, and why it can't just do that same thing for both MSVC and MinGW setups.
- Using
target_link_libraries(application pthread)
function to link against POSIX threads leads to:lld-link: error: undefined symbol: pthread_create
while-lpthread
argument works just fine.
As I'm only moderately familiar with CMake, could you provide some small sample where I could reproduce these two issues? That'd help me looking into the issue.
from llvm-mingw.
The second problem was my mistake, I set pthread
for the wrong target... (It works fine, sorry).
As for the first one, here's a sample project: LLVM-MinGW-CMake-Test.zip
With generation from GUI:
And then just make
or mingw32-make
:
make.zip (The executable from the original MinGW toolchain).
from llvm-mingw.
Ok, so yes, if you explicitly point CMake at the DLL file, there's nothing it can do, as LLD doesn't support linking directly against a DLL, it needs an import library, just like it tells you. That's a known limitation compared to GNU binutils, with quite limited impact so far.
I was expecting an issue where CMake's find_library
chooses to use a DLL file when it automatically tries to find the library, even though an import library exists next to it.
You said that this works with CMake when using MSVC, when linking to a dyanmic library. I'm fairly sure this exact setup, where you hardcode a path to the DLL, doesn't work for MSVC either - or does it? What's the setup where it does work for MSVC but does not work for llvm-mingw?
I presume that find_library(ENET_SHARED enet)
will try to look for a library named enet
in the library search path (however that's defined in CMake). I would guess that with MSVC, it looks for libraries named enet.lib
, and for MinGW it would look for libraries named libenet.a
or libenet.dll.a
.
from llvm-mingw.
Indeed, the same behavior with MSVC, only static libraries works that way...
Dunno, why GNU linker can link directly against shared libraries while Clang with MSVC requires .lib
for definitions, weird. 🤔
Thanks for your help, gonna close this issue then, cheers.
from llvm-mingw.
Related Issues (20)
- Treat file content as command line (feature request) HOT 2
- `fcloseall()` is missing (feature request) HOT 6
- DLLs should be available via --print-file-name HOT 8
- What is the difference between this llvm distribution and the one installed from msys2 pacman? HOT 3
- adding split debug info to the release? HOT 1
- -O2 -flto -fcs-profile-generate cause undefined symbol
- Missing `windmc.exe` Message Compiler
- Missing LLVM header files in resulting zip when building with FULL_LLVM=1 HOT 1
- Supporting passing .rc and .res files on command line
- Installation HOT 8
- ld.lld.exe segfaulting HOT 4
- Cannot link executable HOT 2
- [C++20] [Modules] ld.lld: error: undefined symbol: initializer for module HOT 11
- "unable to execute command: program not executable" on Windows HOT 4
- `<triple>-c++` wrappers are provided but `<triple>-cc` are not HOT 4
- Triple naming probably unorthodox HOT 4
- typo in python buildscript HOT 1
- Regression: llvm-mingw-20240502-msvcrt i686: duplicate symbol '_time' HOT 5
- error: no member named 'join_with' in namespace 'std::ranges::views' HOT 1
- clang-tidy is missing since llvm-mingw 16 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from llvm-mingw.