there is no documentation about building only demangler code as dll in windows.
can anyone give me steps of building.
i want to use demangler in python using ctypes. i searched whole github but not found any code that does it.
the only solution currently exist is run swift_demangler.exe as a process and give it mangled name as argument. this is a slow approach .so i want a dll file so i can call it from python using ctypes more faster
(iam now a intern at swiftsafe ,so they asked me to build a ipa file vulnerability scanner. to build it i need demangler to normalize functions contained in macho binary of ipa file)
We do distribute swiftDemangle.dll as part of the toolchain already as well as the import library. I don't remember off hand if we distribute the headers for the library.
hi this is the error iam getting.when building. can you tell me whats wrong
PS C:\Users\user\Pictures\rz-libswift-0.6.0> meson setup build --wipe
The Meson build system
Version: 1.5.1
Source dir: C:\Users\user\Pictures\rz-libswift-0.6.0
Build dir: C:\Users\user\Pictures\rz-libswift-0.6.0\build
Build type: native build
Project name: libswift
Project version: 0.4.0
C++ compiler for the host machine: g++ (gcc 13.2.0 "g++ (GCC) 13.2.0")
C++ linker for the host machine: g++ ld.bfd 2.41
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C++ supports arguments -Wno-maybe-uninitialized: YES
Compiler for C++ supports arguments -Wc++20-extensions: YES
Compiler for C++ supports arguments -Wc++20-extensions: YES (cached)
Compiler for C++ supports arguments -fvisibility=hidden: YES
Compiler for C++ supports arguments /EHsc: NO
Build targets in project: 1
Found ninja-1.12.1 at "C:\Program Files\Meson\ninja.EXE"
PS C:\Users\user\Pictures\rz-libswift-0.6.0> ninja -C build
ninja: Entering directory build' [11/11] Linking target libswift.dll FAILED: libswift.dll "g++" -o libswift.dll libswift.dll.p/src_libswift.cpp.obj libswift.dll.p/src_Context.cpp.obj libswift.dll.p/src_Demangler.cpp.obj libswift.dll.p/src_ManglingUtils.cpp.obj libswift.dll.p/src_NodeDumper.cpp.obj libswift.dll.p/src_NodePrinter.cpp.obj libswift.dll.p/src_OldDemangler.cpp.obj libswift.dll.p/src_OldRemangler.cpp.obj libswift.dll.p/src_Punycode.cpp.obj libswift.dll.p/src_Remangler.cpp.obj "-Wl,--allow-shlib-undefined" "-shared" "-Wl,--start-group" "-Wl,--out-implib=libswift.dll.a" "-lkernel32" "-luser32" "-lgdi32" "-lwinspool" "-lshell32" "-lole32" "-loleaut32" "-luuid" "-lcomdlg32" "-ladvapi32" "-Wl,--end-group" C:/Users/user/Downloads/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libswift.dll.p/src_libswift.cpp.obj: in function swift::Demangle::demangleSymbolAsString(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, swift::Demangle::DemangleOptions const&)':
C:\Users\user\Pictures\rz-libswift-0.6.0\build/../src/swift/Demangling/Demangle.h:520:(.text$_ZN5swift8Demangle22demangleSymbolAsStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS0_15DemangleOptionsE[_ZN5swift8Demangle22demangleSymbolAsStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKNS0_15DemangleOptionsE]+0x47): undefined reference to swift::Demangle::demangleSymbolAsString[abi:cxx11](char const*, unsigned long long, swift::Demangle::DemangleOptions const&)' C:/Users/user/Downloads/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libswift.dll.p/src_libswift.cpp.obj:libswift.cpp:(.rdata$.refptr._ZN5swift8Demangle20genericParameterNameB5cxx11Eyy[.refptr._ZN5swift8Demangle20genericParameterNameB5cxx11Eyy]+0x0): undefined reference to swift::Demangle::genericParameterName[abi:cxx11](unsigned long long, unsigned long long)'
C:/Users/user/Downloads/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libswift.dll.p/src_Demangler.cpp.obj: in function swift::Demangle::failAssert(char const*, unsigned int, swift::Demangle::Node*, char const*)': C:\Users\user\Pictures\rz-libswift-0.6.0\build/../src/Demangler.cpp:106:(.text+0x258): undefined reference to swift::Demangle::fatal(unsigned int, char const*, ...)'
C:/Users/user/Downloads/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libswift.dll.p/src_Demangler.cpp.obj: in function swift::Demangle::NodeFactory::popCheckpoint(swift::Demangle::NodeFactory::Checkpoint)': C:\Users\user\Pictures\rz-libswift-0.6.0\build/../src/Demangler.cpp:528:(.text+0x1957): undefined reference to swift::Demangle::fatal(unsigned int, char const*, ...)'
C:/Users/user/Downloads/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\Pictures\rz-libswift-0.6.0\build/../src/Demangler.cpp:534:(.text+0x199f): undefined reference to swift::Demangle::fatal(unsigned int, char const*, ...)' C:/Users/user/Downloads/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\user\Pictures\rz-libswift-0.6.0\build/../src/Demangler.cpp:574:(.text+0x1acf): undefined reference to swift::Demangle::fatal(unsigned int, char const*, ...)'
C:/Users/user/Downloads/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: libswift.dll.p/src_OldDemangler.cpp.obj: in function getDependentGenericParamType': C:\Users\user\Pictures\rz-libswift-0.6.0\build/../src/OldDemangler.cpp:1403:(.text+0x6650): undefined reference to swift::Demangle::genericParameterName[abi:cxx11](unsigned long long, unsigned long long)'
collect2.exe: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
You are using the wrong compiler and thus ABI. The GNU compiler is incompatible, you must use cl or clang-cl to ensure that you are using the MSVC ABI.
can you provide steps to compile only demangler from official source code.
i can build code written by izinorg/rz-libswift
but i dont trust their code because when i uploaded to virus total i noticed some suspicious behaviour.
I don't have that on hand as I usually am building the full toolchain. It might require some amount of tweaking to the build system to get that build unless that is a routinely built configuration.
FWIW, it's possible to run swift-demangle.exe in a pipe and feed it strings to demangle that way; this will be a lot faster than running it once per string, particularly on Windows. Not quite as fast as calling the demangling functions directly, but still pretty quick and it avoids you having to build or link anything extra.
thanks everyone . i solved it. there is already a function exist for demangling using swiftdemangle.dll file of official swift binary.i used ctypes to acccess it. its working