Closed qmfrederik closed 4 months ago
I don't where does the issue come from, those are set by default by CMake, they shouldn't be added at all.
My best guess is that this is because the CMake project declares itself as a OBJC/OBJCXX project, and CMake may not have sensible defaults for Objective-C on MSYS2/MINGW and friends.
My best guess is that this is because the CMake project declares itself as a OBJC/OBJCXX project, and CMake may not have sensible defaults for Objective-C on MSYS2/MINGW and friends.
We should add support for MinGW for OBJC/OBJCXX to CMake. I will try to patch CMake and upstream.
@qmfrederik Do you know which clang library has objc_alloc, objc_alloc_init and objc_allocWithZone symbols?
Do you know which clang library has objc_alloc, objc_alloc_init and objc_allocWithZone symbols?
These are not provided by clang, they are provided by libobjc2.
Do you know which clang library has objc_alloc, objc_alloc_init and objc_allocWithZone symbols?
These are not provided by clang, they are provided by libobjc2.
I am trying to support OBJ/OBJCXX on CMake, but It fails with undefined reference to those symbols! Looks like they weren't exported.
@MehdiChinoune Have you got a small repo? libobjc2 does export those symbols. You also need to make sure you use the right clang parameters -- e.g. -fobjc-runtime=gnustep-2.0
if you you use the libobjc2.0 runtime.
@MehdiChinoune Have you got a small repo? libobjc2 does export those symbols. You also need to make sure you use the right clang parameters -- e.g.
-fobjc-runtime=gnustep-2.0
if you you use the libobjc2.0 runtime.
It's about this repo, I am testing your PR in MinGW-package
Those symbols won’t be exported from anywhere until libobjc2 is built…
Those symbols won’t be exported from anywhere until libobjc2 is built…
The issue appears when building tests, but that occurs with LLVM/Clang 18.1.0-rc2. It builds successfully with 17.0.6
@MehdiChinoune Thanks for your patches for cmake (https://github.com/msys2/MINGW-packages/pull/20028). I've removed the the hard-coded values for CMAKE_IMPORT_LIBRARY_SUFFIX
, CMAKE_LINK_LIBRARY_SUFFIX
, and CMAKE_SHARED_LIBRARY_PREFIX
and the the shared library and linker library now get installed as bin/libobjc.dll
and lib/libobjc.dll.a
.
Can you confirm this is what you had in mind?
Yes, fixing shared/import libraries suffix/prefix was the intention.
before you merge this PR, could you try setting LINKER_LANGUAGE
(https://cmake.org/cmake/help/latest/prop_tgt/LINKER_LANGUAGE.html) to CXX
and see if it fixes the required LDFLAGS.
@MehdiChinoune I tried:
_DLINKER_LANGUAGE=CXX
but that variable is not used: "CMake Warning: Manually-specified variables were not used by the project: LINKER_LANGUAGE"CMAKE_OBJC_IMPLICIT_LINK_LIBRARIES
to CMAKE_CXX_IMPLICIT_LINK_LIBRARIES
. That causes the code to link with a bunch of other libraries, too (including mingwex
and mingw32
) which causes the exception handling tests to failLong story short, I would leave it at this for now -- we can always revisit later and try to optimize things.
@davidchisnall I think this is ready now -- long story short: there was a workaround to manually set the library prefix/suffix, but this is no longer needed as CMake in MSYS2 now knows about ObjC. Do you agree?
Build looks green for MinGW CI, and I'm in favour of removing complexity from the build system if it is not essential.
@MehdiChinoune I tried:
- Setting
_DLINKER_LANGUAGE=CXX
but that variable is not used: "CMake Warning: Manually-specified variables were not used by the project: LINKER_LANGUAGE"
LINKER_LANGUAGE is a target property, It couldn't be passed by command.
@MehdiChinoune Do you know which clang library has objc_alloc, objc_alloc_init and objc_allocWithZone symbols?
You were right, they weren't being exported on Windows. I've included a fix for that in #280.
We no longer need to manually set these suffixes/prefixes as CMake in MSYS2 now knows about Objective C.
See https://github.com/msys2/MINGW-packages/pull/20028 See https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9244 See https://github.com/msys2/MINGW-packages/pull/20024#issuecomment-1938493481
/cc @MehdiChinoune