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

Compile solc for the JVM/Java #2309

Closed
axic opened this issue May 25, 2017 · 11 comments
Closed

Compile solc for the JVM/Java #2309

axic opened this issue May 25, 2017 · 11 comments

Comments

@axic
Copy link
Member

axic commented May 25, 2017

See ethereum/EIPs#209 (comment).

(Low priority.)

@axic
Copy link
Member Author

axic commented Aug 1, 2017

@roadriverrail
Copy link
Contributor

roadriverrail commented Aug 2, 2017 via email

@axic
Copy link
Member Author

axic commented Aug 2, 2017

If someone picks up the task, yes 😉

@roadriverrail
Copy link
Contributor

roadriverrail commented Aug 2, 2017 via email

@federicobond
Copy link
Contributor

The issue discussed in the original thread was being able to compile Solidity contracts from a JVM toolchain as easily as you currently can from Node.js, right? So perhaps there is no need to provide a full JNI interface to the C++ API. As long as a JVM app can fork to a native solc executable and read it's standard JSON output (perhaps with a thin Java wrapper to make things nice) it should be fine.

I mention this because those platform-dependent Maven builds may be easier to create and maintain than a full JNI bridge.

@axic
Copy link
Member Author

axic commented Aug 2, 2017

Note, GCC-Bridge above is like Emscripten, it compiles C/C++ (actually compiles GCC's Gimple IR) to Java bytecode. It wouldn't be JNI or executing an application, rather native code.

There are two steps to this:

  • build a GCC-Bridge docker and tie it into a Travis build step
  • ensure the jsonCompiler API (at least compileStandard) is exported in Java and works (this might need a tiny wrapper to convert between native types of Java, such as String)

@roadriverrail
Copy link
Contributor

Did a little bit of a feasibility study on this tonight. I cloned Renjin and built it to get a copy of gcc-bridge. gcc-bridge appears to work in two steps. The first step transforms GCC intermediate language into JSON via a GCC plugin. The second step takes the JSON files and attempts to generate Java classes that have equivalent semantics.

I modified the CXX_FLAGS to load the plugin. Unforunately, the plugin only works for gcc 4.7 (and I think gcc 4.6). gcc 4.7 is older than gcc's full C++11 support. We can't build jsoncpp on that. Even after I modified the build system to use my usual gcc (5.4) for jsoncpp, it's not enough. We have build breaks in NameAndTypeResolver.cpp , RPCSession.cpp and AsmPrinter.cpp. The NameAndTypeResolver.cpp and RPCSession.cpp breaks are probably a simple fix, but the AsmPrinter.cpp break appears to actually be caused by using a copy of boost that wants gcc > 4.7.

Even if we elected to fix these breaks, we'd basically be forcing ourselves to stay pre-C++11 in order to keep up gcc-bridge. Unless, of course, gcc-bridge were to support newer compilers.

@roadriverrail
Copy link
Contributor

@axic asked for more detail of the errors. I guess since then there was something that changed in our json-cpp dependency, since it no longer compiles under gcc-4.7:

/home/rhett/solidity/build/deps/jsoncpp/src/jsoncpp-project/src/lib_json/json_value.cpp: In copy constructor ‘Json::Value::CZString::CZString(const Json::Value::CZString&)’:
/home/rhett/solidity/build/deps/jsoncpp/src/jsoncpp-project/src/lib_json/json_value.cpp:273:78: error: conversion to ‘unsigned char:2’ from ‘unsigned int’ may alter its value [-Werror=conversion]
/home/rhett/solidity/build/deps/jsoncpp/src/jsoncpp-project/src/lib_json/json_value.cpp: In constructor ‘Json::Value::Value(Json::ValueType)’:
/home/rhett/solidity/build/deps/jsoncpp/src/jsoncpp-project/src/lib_json/json_value.cpp:346:27: warning: declaration of ‘empty’ shadows a member of 'this' [-Wshadow]
cc1plus: some warnings being treated as errors
src/lib_json/CMakeFiles/jsoncpp_lib_static.dir/build.make:86: recipe for target 'src/lib_json/CMakeFiles/jsoncpp_lib_static.dir/json_value.cpp.o' failed
make[5]: *** [src/lib_json/CMakeFiles/jsoncpp_lib_static.dir/json_value.cpp.o] Error 1

@axic
Copy link
Member Author

axic commented Aug 15, 2017

@roadriverrail that's weird because we only use a fixed version of jsoncpp, which hasn't changed in a while.

@roadriverrail
Copy link
Contributor

roadriverrail commented Aug 15, 2017 via email

@axic axic changed the title Compile solc for the JVM Compile solc for the JVM/Java Dec 13, 2019
@axic
Copy link
Member Author

axic commented Oct 28, 2020

There weren't many asks for such a feature over the years, so I think it is safe to close it.

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

No branches or pull requests

3 participants