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

Global variable setter with a namespace #387

Closed
yukoba opened this issue Mar 28, 2020 · 4 comments
Closed

Global variable setter with a namespace #387

yukoba opened this issue Mar 28, 2020 · 4 comments
Labels

Comments

@yukoba
Copy link
Contributor

yukoba commented Mar 28, 2020

Now I'm trying to port the LLVM Polly optimizer.
The code is this.
yukoba/javacpp-presets@55d70bc

The generated jnipolly.cpp has the following setter code.

JNIEXPORT void JNICALL Java_org_bytedeco_llvm_global_polly_PollyChunkSize__I(JNIEnv* env, jclass cls, jint arg0) {
    PollyChunkSize = arg0;
}

But it must have the namespace polly like this.

JNIEXPORT void JNICALL Java_org_bytedeco_llvm_global_polly_PollyChunkSize__I(JNIEnv* env, jclass cls, jint arg0) {
    polly::PollyChunkSize = arg0;
}

Getter has the namespace polly correctly.

JNIEXPORT jint JNICALL Java_org_bytedeco_llvm_global_polly_PollyChunkSize__(JNIEnv* env, jclass cls) {
    jint rarg = 0;
    int rval = polly::PollyChunkSize;
    rarg = (jint)rval;
    return rarg;
}

If I add polly:: by hand, I can compile by this.

g++ -I/home/ubuntu/javacpp-presets/llvm/cppbuild/linux-x86_64/include/ -I/home/ubuntu/javacpp-presets/llvm/cppbuild/linux-x86_64/include/polly/ -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux /home/ubuntu/javacpp-presets/llvm/target/native/org/bytedeco/llvm/linux-x86_64/jnipolly.cpp /home/ubuntu/javacpp-presets/llvm/target/native/org/bytedeco/llvm/linux-x86_64/jnijavacpp.cpp -march=x86-64 -m64 -O3 -s -std=c++11 -Wl,-rpath,$ORIGIN/ -Wl,-z,noexecstack -Wl,-Bsymbolic -Wall -fPIC -pthread -shared -o libjnipolly.so -L/home/ubuntu/javacpp-presets/llvm/cppbuild/linux-x86_64/lib/ -Wl,-rpath,/home/ubuntu/javacpp-presets/llvm/cppbuild/linux-x86_64/lib/ -lPolly -lLTO -lLLVM-9

What should I do to add the namespace to the global variable setter?

@saudet
Copy link
Member

saudet commented Mar 28, 2020

There might be an issue with the namespace of global variables. Are you able to reproduce this with a smaller example?

In any case, if this requires the C++ API of LLVM, it hasn't been mapped yet. So if it doesn't have a C API, we may need to map the necessary classes from LLVM first...

@yukoba
Copy link
Contributor Author

yukoba commented Mar 28, 2020

The same thing happened on the small example too. I only tested on Ubuntu 18.04.
https://github.com/yukoba/javacpp-presets/tree/cppglobalvar/cppglobalvar

In any case, if this requires the C++ API of LLVM, it hasn't been mapped yet.

I know.
I have not tried, but I saw that
llvm::PassRegistry can be cast to LLVMPassRegistryRef
and llvm::legacy::PassManagerBase can be cast to LLVMPassManagerRef.
If it is true, I can use high level API. It is enough for me.

@saudet saudet added the bug label Mar 29, 2020
saudet added a commit that referenced this issue Mar 29, 2020
…hod too for global getters and setters (issue #387)
@saudet
Copy link
Member

saudet commented Mar 29, 2020

Thank you! I fixed this in the latest commit. Please give it a try with 1.5.3-SNAPSHOT.

@yukoba
Copy link
Contributor Author

yukoba commented Mar 29, 2020

OK. Thank you. I can compile Polly. Next I will run this.
I will close this issue.

@yukoba yukoba closed this as completed Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants