Re: Building GNUstep for Windows using Clang
David Chisnall <[email protected]>
| Newsgroups | gmane.comp.lib.gnustep.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, On ELF platforms, there were some issues with the ld -r invocation that -base Additions did. Can you try just adding the .m files from Additions directly to the -base project and see if that makes the problem go away? I don't think that PE/COFF linkage really has any concept that maps to how we do the subproject thing in -make. David On 19/01/2021 14:53, Frederik Seiffert wrote: > Hi all, > > Another update on the Clang MSVC ABI support front (which I’m trying to get to work in addition to MinGW + Clang)... > > I’ve been making some good progress and was able to build Base as a DLL with this setup. The necessary build system changes are on the following branches (work in progress), which I will clean up and submit as PRs when this is working: > https://github.com/gnustep/tools-make/tree/clang-msvc-support > https://github.com/gnustep/libs-base/tree/clang-msvc-support > > > However it seems that the generated gnustep-base.lib does not contain symbols for the ObjC classes. I’m getting linker errors for each ObjC class I am referencing in a test program: > >> lld-link: error: undefined symbol: $_OBJC_REF_CLASS_NSArray >>>>> referenced by C:\Dev\tools-android\test.m:16 >>>>> C:\msys64\tmp\test-aef6cd.o:(WinMain) >> >> lld-link: error: undefined symbol: __declspec(dllimport) $_OBJC_CLASS_NSConstantString >>>>> referenced by C:\msys64\tmp\test-aef6cd.o:(.objc_early_init) > > Is there some flag I need to pass to lld-link to ensure these are exported? I currently have -dll and -export-all-symbols. I also tried adding __declspec(dllexport) to the @interface declaration of these classes to no avail. > > > Regarding the previous issue: > >> However, it fails checking for objc_sync_enter with the following linker errors – any ideas what these could be about? > > I am guessing these somehow happen because referencing ObjC built-ins in a C file doesn’t work on Windows. I’m planning to skip these config checks when using this setup. > > > Thanks, > Frederik > > >> Am 12.01.2021 um 21:47 schrieb Frederik Seiffert <[email protected]>: >> >> Hi all, >> >> As a second option I’ve been working on trying to build using the MSVC ABI (i.e. without MinGW). >> >> Using the latest Clang 11 from the LLVM website and Pthreads-win32, plus removing -lm from target.make, I was able to get quite a bit further running Base configure. >> >> However, it fails checking for objc_sync_enter with the following linker errors – any ideas what these could be about? >> >>> configure:8038: checking for objc_sync_enter >>> configure:8038: /C/LLVM/bin/clang -o conftest.exe -g -I/c/GNUstep/MSVC/x64/include -I/c/GNUstep/MSVC/x64/include -I/c/GNUstep/MSVC/x64/include -I/c/GNUstep/MSVC/x64/include -x objective-c -fuse-ld=lld -L/c/GNUstep/MSVC/x64/lib -L/c/GNUstep/MSVC/x64/lib -L/c/GNUstep/MSVC/x64/lib -L/c/GNUstep/MSVC/x64/lib conftest.c -lpthread -fuse-ld=lld -pthread -fexceptions -fobjc-runtime=gnustep-2.0 -fblocks -L/home/Frederik -LSeiffert/GNUstep/Library/Libraries -L/c/GNUstep/MSVC/x64/lib -lobjc >&5 >>> conftest.c:119:6: warning: incompatible redeclaration of library function 'objc_sync_enter' [-Wincompatible-library-redeclaration] >>> char objc_sync_enter (); >>> ^ >>> conftest.c:119:6: note: 'objc_sync_enter' is a builtin with type 'int (id)' >>> 1 warning generated. >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$SEL >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$SEL >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$CLS >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$CLS >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$CLR >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$CLR >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$CAT >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$CAT >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$PCL >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$PCL >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$PCR >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$PCR >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$CAL >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$CAL >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __start_.objcrt$STR >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> >>> lld-link: error: relocation against symbol in discarded section: __stop.objcrt$STR >>>>>> referenced by C:\tmp\conftest-78a937.o:(.objc_init) >>> PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace. >>> 0. Program arguments: C:\LLVM\bin\lld-link -out:conftest.exe -defaultlib:libcmt -libpath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\lib\x64 -libpath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.28.29333\atlmfc\lib\x64 -libpath:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64 -libpath:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x64 -libpath:C:\LLVM\lib\clang\11.0.0\lib\windows -libpath:C:/GNUstep/MSVC/x64/lib -libpath:C:/GNUstep/MSVC/x64/lib -libpath:C:/GNUstep/MSVC/x64/lib -libpath:C:/GNUstep/MSVC/x64/lib -libpath:C:/msys64/home/Frederik -libpath:Seiffert/GNUstep/Library/Libraries -libpath:C:/GNUstep/MSVC/x64/lib -nologo -debug C:\tmp\conftest-76158a.o pthread.lib objc.li b >> >> >>> configure:8038: result: no >>> configure:8052: error: The objc runtime library does not appear to have synchronisation support. Try re-configuring gnustep-make with a CPPFLAGS variable containing a -L point to specify the directory containing the correct libobjc, or using the --with-objc-lib-flag=... option. >> >> >> Thanks, >> Frederik >> >> > >