Skip to content

libstdcxx version-bounds #243

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

Merged
merged 8 commits into from
Nov 20, 2022
Merged

libstdcxx version-bounds #243

merged 8 commits into from
Nov 20, 2022

Conversation

samtkaplan
Copy link
Contributor

@samtkaplan samtkaplan commented Nov 8, 2022

Hello,

We have run into a problem when using PythonCall with newer versions of TensorFlow. In particular, TensorFlow requires newer versions of libstdc++ than what is bundled with Julia. To partially solve this problem, we replace the bundled version of libstdc++ with the system (Ubuntu 22.04) version of libstdc++.

When using PythonCall and CondaPkg, PythonCall injects a version bound for libstdc++ into the conda operations. The version bound is determined by the version of libstdc++ bundled in Julia. In this PR, we find the bound at runtime, and allow the user to specify the version bound via an environment variable: JULIA_CONDAPKG_LIBSTDCXX_VERSION_BOUNDJULIA_PYTHONCALL_LIBSTDCXX_VERSION_BOUND. For example, set the version bound via:

ENV["JULIA_PYTHONCALL_LIBSTDCXX_VERSION_BOUND"] = ">=3.4,<=12"

Many thanks!

Fixes #237

samtkaplan and others added 3 commits November 11, 2022 11:16
Co-authored-by: Elliot Saba <staticfloat@gmail.com>
28 => v"9.3.0",
29 => v"11.1.0",
30 => v"12.1.0",
31 => v"13.1.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at https://gcc.gnu.org/develop.html#timeline there are more versions of GCC than in that other linked page. If I understand right, I think it means that we could bump the mappings to 28 => 9.5.0, 29 => 11.3.0, 30 => 12.2.0.

Copy link
Contributor Author

@samtkaplan samtkaplan Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and applied you suggestion. But, it isn't clear to me if the libstdc++ version is constant from, say, gcc 9.3.0->9.5.0

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ABI Policy page says "If a particular release is not listed, it has the same version labels as the preceding release." I take that to mean that all releases >=9.3.0 and <10.1.0 have the same version labels.

31 => v"13.1.0",
)
# Get the libstdcxx version that is currently loaded in this Julia process
loaded_libstdcxx_version = Base.BinaryPlatforms.detect_libstdcxx_version()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to gracefully handle the possibility that this returns nothing or a version other than 3.4.*.

Copy link
Contributor Author

@samtkaplan samtkaplan Nov 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some code in the last commit (e7c8dac) that attempts to address this, but I'm not sure what the best solution is. In particular, if Julia is not able to detect the version, then we try to get the version bound from the user environment variable, and if the user has not set a variable, then do not inject a version bound. Hopefully the last case will be rare. Note that if the version is not 3.4.*, then detect_libstdcxx_version returns nothing (if I understood the code correctly).

# the highest GCC version we know about, which should be a fairly safe choice.
max_version = get(vers_mapping, loaded_libstdcxx_version.patch, vers_mapping[maximum(keys(vers_mapping))])
cxx_version = ">=3.4,<=$(max_version.major).$(max_version.minor)"
get(ENV, "JULIA_CONDAPKG_LIBSTDCXX_VERSION_BOUND", cxx_version)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is an option to PythonCall, please rename the env var to JULIA_PYTHONCALL_....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed. thanks.

@cjdoris
Copy link
Collaborator

cjdoris commented Nov 17, 2022

This is really cool, I didn't know you could query the libstdc++ version like this!

@cjdoris cjdoris mentioned this pull request Nov 17, 2022
@cjdoris cjdoris merged commit 5047f00 into JuliaPy:main Nov 20, 2022
@cjdoris
Copy link
Collaborator

cjdoris commented Nov 20, 2022

Great, thank you!

@cjdoris
Copy link
Collaborator

cjdoris commented Dec 2, 2022

@samtkaplan FYI I have moved this functionality into CondaPkg, so that PythonCall doesn't need to hackily add a new dependency at run-time - it instead depends on libstdcxx_ng at a special version "<=julia" which is now replaced by CondaPkg with an appropriate version (or removed entirely if not on Linux). The end result is the same.

JuliaPy/CondaPkg.jl@cd53c00

66355c5

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

Successfully merging this pull request may close these issues.

libstdcxx-ng versioning
3 participants