Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run the program #12

Open
zhangysh1995 opened this issue Aug 22, 2017 · 3 comments
Open

Unable to run the program #12

zhangysh1995 opened this issue Aug 22, 2017 · 3 comments

Comments

@zhangysh1995
Copy link

zhangysh1995 commented Aug 22, 2017

I git cloned this repo and followed here to build my LLVM 4.0.0.

And use this c program under folder llvm-pass-skeleton/program/test.c to test:

/* 
 * C Program to Check whether the given Integer has an Alternate 
 * Pattern 
 */
#include <stdio.h>
 
void main()
{
    int num, x, y, count = 0;
 
    printf("enter the number:");
    scanf("%d", &num);
    x = num << 1;
    y = x ^ num;
    y = y + 1;
 
    /* Checks if the number is in powers of 2 */
    while ((y / 2) != 0)
    {
        if (y % 2 != 0)
        {
            count++;
            break;
        }
        else
        {
            y = y / 2;
        }
    }
    if (count)
    {
        printf("false");
    }
    else
    {
        printf("true");
    }
}

Then I got this error:

clang -Xclang -load -Xclang build/skeleton/libSkeletonPass.so program/test.c 
error: unable to load plugin 'build/skeleton/libSkeletonPass.so': 'build/skeleton/libSkeletonPass.so:
      undefined symbol: _ZN4llvm23EnableABIBreakingChecksE'

Similar to #4, but the default path is used when building and compiling my LLVM.
This problem may be caused by LLVM version difference with reference to #11

I could use my LLVM version to run other .bc program without problem.

@sampsyo
Copy link
Owner

sampsyo commented Aug 22, 2017

Indeed, as in #11, we haven't tested this with more recent versions of LLVM. As I recommended there, please look into using the LLVM version that was current when the code was written. Or, if you find the necessary changes to work with 4.0, please submit a pull request!

@overrainbow
Copy link

I had similar error when loading the plugin.

error: unable to load plugin 'skeleton/libSkeletonPass.so': 'skeleton/libSkeletonPass.so: undefined symbol: _ZNK4llvm12FunctionPass17createPrinterPassERNS_11raw_ostreamERKSs'

I found this thread https://stackoverflow.com/questions/37366291/undefined-symbol-for-self-built-llvm-opt. It works for me by adding compiler flag in llvm-pass-skeleton/skeleton/CMakeLists.txt:

set_target_properties(SkeletonPass PROPERTIES COMPILE_FLAGS "-D__GLIBCXX_USE_CXX11_ABI=0 -fno-rtti" )

Hope it helps.

@Cjkkkk
Copy link

Cjkkkk commented Apr 15, 2020

add set(CMAKE_CXX_COMPILER "clang-9") into skeleton/CMakeList.txt solved my problem.
If remove this line, then default compiler is g++ in my case, which will cause this problem.
Hope it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants