-
Notifications
You must be signed in to change notification settings - Fork 63
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
C++ BMI modules not compiled/linked with the same runtime as ngen likely won't work. #440
Comments
Documentation label covers only part of this issue, but there is a documentation part. |
Since I'm coming through doing triage... yes, we encountered this in passing when we found we had to switch to the legacy ABI (use I don't particularly like the recommendation to use C linkage for C++ models, though this is always an option for any implementer. While this is kind of a job hazard for C++ development generally, it's worth noting in the documentation for C++ models, perhaps citing this switch as an example case. |
Just adding a deeper explanatory note about the considerations here, since I came across this by chance. UpshotFor the particular case we care about, of Deeper discussion follows. Feel free to glaze your eyes and stop reading here. CompilersIn practice, all C++ compilers in use on any given platform do agree on the language-level ABI where it goes beyond C (e.g. name mangling, dynamic dispatch, exception unwinding, argument passing, etc). I think there's one or two rare cases where there have been changes, and the compilers involved emit warnings on the platforms involved when they see code that would potentially be affected. C++ Standard library and compiler runtime libraryThe bigger differences have been within and across implementations of
Language standard of course has to actually be in strict agreement, and different compilers may quietly cause disagreements between different modules because of diverging default settings. None of those that have happened are recent enough to impact us. [1] The language support library and C++ standard library are generally less problematic. Typical configuration on most systems and package manager environment is that every compiler will default to referencing the host system's main installation unless told otherwise on the command line.
|
The C++ adapter interface to use a c++ compiled, dynamically linked (shared) library requires that the library and ngen share a compatible c++ ABI, which isn't exactly trivial (see this post for a good description, as well as this for some additional context).
Current behavior
Compile a C++ bmi dynamic library module with different compiler than ngen is built with. Load the model with ngen, and it will likely fail to even initialize, as the C++ BMI interface passes a
std::string
value to theInitialize
function. The model library won't get the correct string, and/or may seg fault.Expected behavior
Must either document C++ compatability/building for C++ based models, and ensure that builds are ABI compatible (built with the same compiler, flags, runtime, ect...)
OR
Use a C style linkage for the API and pass all the C++
std::string
variables aschar *
for compatibility between dynamic boundaries. This will require an adaptation of "C++ BMI" to provide a header with this interface that would be used for dynamic linking.Steps to replicate behavior (include URLs)
test_bmi_c++
with clang (specifically reproducible with clang-1316.0.21.2.5)Run
test/test_bmi_cpp
and all tests will fail to setup becauseInitialize
fails to get a valid config string.The text was updated successfully, but these errors were encountered: