Closed Gavazzi1 closed 3 years ago
Nope, this is not on you. This is an llvm-hs problem. I hinted on how to go about this here https://github.com/PLSysSec/sys/issues/15#issuecomment-775529098. Happy to update llvm-hs dependency if you end up fixing the issue. If it's too much of a pain: if you can give me a .bc/.ll file I can take on both of these issues soon-ish
Having some trouble building llvm-hs from source but I'll keep trying some things. In the mean time here's a .bc file that's causing the error. Thanks again! failing bc file.zip
I got this fixed! It's the same problem as in this issue where llvm-hs doesn't support the NoFree attribute. The commit that fixed this hasn't been incorporated into latest version of llvm-hs in Hackage, so you have to build it from source
I hit the same error(s) .
Thinking to build llvm-hs from source in the docker image from sys community. Or do you have a fixed Version you can share?
Any tips how to build llvm-hs from source?
Sure thing! To build llvm-hs from source in the Docker image, I first cloned the llvm-hs repo into the image. Then, in the stack.yml file in Sys, I did two things:
You can look at my fork of Sys to see how I did it. After that, you should be able to call stack build
as usual.
Thank you!!!!
It seems to work, despite this error:
llvm-hs > [114 of 114] Compiling LLVM.PassManager
llvm-hs > In file included from /usr/lib/llvm-9/include/llvm/Support/Host.h:16,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/Hashing.h:48,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/StringExtras.h:16,
llvm-hs > from /usr/lib/llvm-9/include/llvm/Support/Error.h:19,
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs/ from src/LLVM/Internal/FFI/OrcJITC.cpp:5:0: error:
llvm-hs >
llvm-hs > In constructor 'llvm::StringMapEntry<ValueTy>::StringMapEntry(size_t, InitTy&& ...) [with InitTy = {llvm::JITEvaluatedSymbol}; ValueTy = llvm::JITEvaluatedSymbol]',
llvm-hs > inlined from 'static llvm::StringMapEntry<ValueTy>* llvm::StringMapEntry<ValueTy>::Create(llvm::StringRef, AllocatorTy&, InitTy&& ...) [with AllocatorTy = llvm::MallocAllocator; InitTy = {llvm::JITEvaluatedSymbol}; ValueTy = llvm::JITEvaluatedSymbol]' at /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:169:5,
llvm-hs > inlined from 'std::pair<llvm::StringMapIterator<ValueTy>, bool> llvm::StringMap<ValueTy, AllocatorTy>::try_emplace(llvm::StringRef, ArgsTy&& ...) [with ArgsTy = {llvm::JITEvaluatedSymbol}; ValueTy = llvm::JITEvaluatedSymbol; AllocatorTy = llvm::MallocAllocator]' at /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:408:32,
llvm-hs > inlined from 'std::pair<llvm::StringMapIterator<ValueTy>, bool> llvm::StringMap<ValueTy, AllocatorTy>::insert(std::pair<llvm::StringRef, ValueTy>) [with ValueTy = llvm::JITEvaluatedSymbol; AllocatorTy = llvm::MallocAllocator]' at /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:391:23,
llvm-hs > inlined from 'void llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<MemoryManagerPtrT>::buildInitialSymbolTable(const OwnedObject&) [with MemoryManagerPtrT = std::shared_ptr<llvm::RuntimeDyld::MemoryManager>]' at /usr/lib/llvm-9/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h:306:27:
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs//usr/lib/llvm-9/include/llvm/ADT/StringMap.h:133:77: error:
llvm-hs > warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
llvm-hs > 133 | : StringMapEntryBase(strLen), second(std::forward<InitTy>(InitVals)...) {}
llvm-hs > | ^
llvm-hs > |
llvm-hs > 133 | : StringMapEntryBase(strLen), second(std::forward<InitTy>(InitVals)...) {}
llvm-hs > | ^
llvm-hs > In file included from /usr/lib/llvm-9/include/llvm/ADT/SmallVector.h:20,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/STLExtras.h:20,
llvm-hs > from /usr/lib/llvm-9/include/llvm/Support/Error.h:17,
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs/ from src/LLVM/Internal/FFI/OrcJITC.cpp:5:0: error:
llvm-hs >
llvm-hs > /usr/lib/llvm-9/include/llvm/Support/MemAlloc.h: In member function 'void llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<MemoryManagerPtrT>::buildInitialSymbolTable(const OwnedObject&) [with MemoryManagerPtrT = std::shared_ptr<llvm::RuntimeDyld::MemoryManager>]':
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs//usr/lib/llvm-9/include/llvm/Support/MemAlloc.h:26:29: error:
llvm-hs > note: at offset 17 to an object with size 0 allocated by 'malloc' here
llvm-hs > 26 | void *Result = std::malloc(Sz);
llvm-hs > | ~~~~~~~~~~~^~~~
llvm-hs > |
llvm-hs > 26 | void *Result = std::malloc(Sz);
llvm-hs > | ^
llvm-hs > In file included from /usr/lib/llvm-9/include/llvm/Support/Host.h:16,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/Hashing.h:48,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/ArrayRef.h:12,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/StringExtras.h:16,
llvm-hs > from /usr/lib/llvm-9/include/llvm/Support/Error.h:19,
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs/ from src/LLVM/Internal/FFI/OrcJITC.cpp:5:0: error:
llvm-hs >
llvm-hs > In constructor 'llvm::StringMapEntry<ValueTy>::StringMapEntry(size_t, InitTy&& ...) [with InitTy = {llvm::JITEvaluatedSymbol}; ValueTy = llvm::JITEvaluatedSymbol]',
llvm-hs > inlined from 'static llvm::StringMapEntry<ValueTy>* llvm::StringMapEntry<ValueTy>::Create(llvm::StringRef, AllocatorTy&, InitTy&& ...) [with AllocatorTy = llvm::MallocAllocator; InitTy = {llvm::JITEvaluatedSymbol}; ValueTy = llvm::JITEvaluatedSymbol]' at /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:169:5,
llvm-hs > inlined from 'std::pair<llvm::StringMapIterator<ValueTy>, bool> llvm::StringMap<ValueTy, AllocatorTy>::try_emplace(llvm::StringRef, ArgsTy&& ...) [with ArgsTy = {llvm::JITEvaluatedSymbol}; ValueTy = llvm::JITEvaluatedSymbol; AllocatorTy = llvm::MallocAllocator]' at /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:408:32,
llvm-hs > inlined from 'std::pair<llvm::StringMapIterator<ValueTy>, bool> llvm::StringMap<ValueTy, AllocatorTy>::insert(std::pair<llvm::StringRef, ValueTy>) [with ValueTy = llvm::JITEvaluatedSymbol; AllocatorTy = llvm::MallocAllocator]' at /usr/lib/llvm-9/include/llvm/ADT/StringMap.h:391:23,
llvm-hs > inlined from 'void llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<MemoryManagerPtrT>::buildInitialSymbolTable(const OwnedObject&) [with MemoryManagerPtrT = std::shared_ptr<llvm::RuntimeDyld::MemoryManager>]' at /usr/lib/llvm-9/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h:306:27:
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs//usr/lib/llvm-9/include/llvm/ADT/StringMap.h:133:77: error:
llvm-hs > warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
llvm-hs > 133 | : StringMapEntryBase(strLen), second(std::forward<InitTy>(InitVals)...) {}
llvm-hs > | ^
llvm-hs > |
llvm-hs > 133 | : StringMapEntryBase(strLen), second(std::forward<InitTy>(InitVals)...) {}
llvm-hs > | ^
llvm-hs > In file included from /usr/lib/llvm-9/include/llvm/ADT/SmallVector.h:20,
llvm-hs > from /usr/lib/llvm-9/include/llvm/ADT/STLExtras.h:20,
llvm-hs > from /usr/lib/llvm-9/include/llvm/Support/Error.h:17,
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs/ from src/LLVM/Internal/FFI/OrcJITC.cpp:5:0: error:
llvm-hs >
llvm-hs > /usr/lib/llvm-9/include/llvm/Support/MemAlloc.h: In member function 'void llvm::orc::LegacyRTDyldObjectLinkingLayer::ConcreteLinkedObject<MemoryManagerPtrT>::buildInitialSymbolTable(const OwnedObject&) [with MemoryManagerPtrT = std::shared_ptr<llvm::RuntimeDyld::MemoryManager>]':
llvm-hs >
llvm-hs > /home/user/src/llvm-hs/llvm-hs//usr/lib/llvm-9/include/llvm/Support/MemAlloc.h:26:29: error:
llvm-hs > note: at offset 17 to an object with size 0 allocated by 'malloc' here
llvm-hs > 26 | void *Result = std::malloc(Sz);
llvm-hs > | ~~~~~~~~~~~^~~~
llvm-hs > |
llvm-hs > 26 | void *Result = std::malloc(Sz);
llvm-hs > | ^
llvm-hs >
llvm-hs > copy/register
llvm-hs > Installing library in /home/user/src/sys/.stack-work/install/x86_64-linux-tinfo6/9a391368bc35532e73cc42fbe265ee794a6c81ffc8f97e0ae5064cf3b83ba8a5/8.6.5/lib/x86_64-linux-ghc-8.6.5/llvm-hs-9.0.1-GdcY7lIsVQ6GWzw7sPUMKI
llvm-hs > Registering library for llvm-hs-9.0.1..
Now I only see still:
DecodeException "Unknown subclass id for DINode: MDSubclassID 26"
In my project, BUT it is waaaay better
Above seems to be a known issue: https://github.com/PLSysSec/sys/issues/15
@deian Any fix for it? You mention to use llvm-hs 9.0.1 ... but I did, got latest code from llvm-hs Git repo
P.S Sorry, never worked with Haskell :(
@Gavazzi1 @deian Hello! I am facing this issue while parsing a .ll file generated using gllvm, and I want to build llvm-hs from source, are there any steps for this using Cabal ? My project isn't a big project so it doesn't have a project file, I've done all the installation manually. I have cloned the llvm-hs repo, checked out to the llvm-9 branch (which has this fix - https://github.com/llvm-hs/llvm-hs/pull/284) but not sure what to do after this, if someone could help me with the steps, it would be great
Hi,
I'm trying to run Sys from the Docker image on a large code base I built using wllvm, but I'm getting this error when I run any of the checkers:
Not sure if this is a result of something I'm doing wrong or if llvm-hs is the problem. Any help would be greatly appreciated.
Thanks!