@@ -30,6 +30,31 @@ function _atpyexit()
3030 return
3131end
3232
33+ # By default, ensure libstdc++ in the Conda environment is compatible with
34+ # the one linked in Julia. This is platform/version dependent, so needs to
35+ # occur at runtime.
36+ #
37+ # Allow the user to override the default. This is useful when the version
38+ # of libstdcxx linked in Julia is customized in the local installation of
39+ # Julia.
40+ #
41+ # To figure out cxx_version for a given Julia version, run
42+ # strings /path/to/julia/lib/julia/libstdc++.so.6 | grep GLIBCXX
43+ # then look at
44+ # https://gcc.gnu.org/onlinedocs/gcc-12.1.0/libstdc++/manual/manual/abi.html
45+ # for the highest GCC version compatible with the highest GLIBCXX version.
46+ function get_libstdcxx_version_bound ()
47+ if Base. VERSION <= v " 1.6.2"
48+ # GLIBCXX_3.4.26
49+ cxx_version = " >=3.4,<9.2"
50+ else
51+ # GLIBCXX_3.4.29
52+ # checked up to v1.8.0
53+ cxx_version = " >=3.4,<11.4"
54+ end
55+ get (ENV , " JULIA_CONDAPKG_LIBSTDCXX_VERSION_BOUND" , cxx_version)
56+ end
57+
3358function init_context ()
3459
3560 CTX. is_embedded = haskey (ENV , " JULIA_PYTHONCALL_LIBPTR" )
@@ -60,23 +85,7 @@ function init_context()
6085 exe_path:: String
6186 else
6287 if Sys. islinux ()
63- # Ensure libstdc++ in the Conda environment is compatible with the one
64- # linked in Julia. This is platform/version dependent, so needs to occur at
65- # runtime.
66- #
67- # To figure out cxx_version for a given Julia version, run
68- # strings /path/to/julia/lib/julia/libstdc++.so.6 | grep GLIBCXX
69- # then look at
70- # https://gcc.gnu.org/onlinedocs/gcc-12.1.0/libstdc++/manual/manual/abi.html
71- # for the highest GCC version compatible with the highest GLIBCXX version.
72- if Base. VERSION <= v " 1.6.2"
73- # GLIBCXX_3.4.26
74- cxx_version = " >=3.4,<9.2"
75- else
76- # GLIBCXX_3.4.29
77- # checked up to v1.8.0
78- cxx_version = " >=3.4,<11.4"
79- end
88+ cxx_version = get_libstdcxx_version_bound ()
8089 CondaPkg. add (" libstdcxx-ng" , version= cxx_version, channel= " conda-forge" , temp= true , file= joinpath (@__DIR__ , " .." , " .." , " CondaPkg.toml" ), resolve= false )
8190 end
8291 # By default, we use Python installed by CondaPkg.
0 commit comments