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

Problems building Julia with multiple stdc++ versions on same system #48040

Open
smartalecH opened this issue Dec 29, 2022 · 7 comments
Open

Comments

@smartalecH
Copy link

smartalecH commented Dec 29, 2022

I'm having trouble building Julia 1.8.4 on a (Centos 7) system with multiple stdc++ versions.

I have my system libstdc++.so.6, which includes up to GLIBCXX_3.4.19, and an additional version (which my internal infra requires me to load in order to use a compiler) which includes up to GLIBCXX_3.4.29. Incidentally, the glibcxxin <build-directory>/usr/lib/libstdc++.so.6 matches my default system versions (i.e. GLIBCXX_3.4.19).

Unfortunately, all of the compiled tooling (e.g. vm-config, llvm-config) appears to be built with the newer version of libstdc++ than what it tries to reference in <julia-build-directory>/usr/lib/libstdc++.so.6.

I'll note that the new version of libstdc++ is properly addressed in my linker flags... the issue seems to be that the packaged Julia libstdc++ is older than the loaded system one (which does the compiling). I thought there was a recent fix to address this (#46976), but something is not quite right.

Is this expected? Does anyone know of an easy way I can go about debugging this? Thanks!

@giordano
Copy link
Contributor

the issue seems to be that the packaged Julia libstdc++ is older than the loaded system one (which does the compiling).

That looks unlikely to be true, since Julia v1.8.4 has libstdc++ from GCC 12.1, which has the latest GLIBCXX ABI.

@smartalecH
Copy link
Author

smartalecH commented Dec 29, 2022

That looks unlikely to be true, since Julia v1.8.4 has libstdc++ from GCC 12.1, which has the latest GLIBCXX ABI.

I was surprised by this too! But sure enough, running

strings <julia-build-directory>/usr/lib/libstdc++.so.6 | grep LIBCXX 

produces the same output when I run

strings /lib64/libstdc++.so.6 | grep LIBCXX

@giordano
Copy link
Contributor

giordano commented Dec 29, 2022

root@codespaces-6067c9:/tmp/tmp.tf7ETgCe6I# curl -Lfs https://julialang-s3.julialang.org/bin/linux/x64/1.8/julia-1.8.4-linux-x86_64.tar.gz | tar xzf -
root@codespaces-6067c9:/tmp/tmp.tf7ETgCe6I# nm julia-1.8.4/lib/julia/libstdc++.so | grep ' GLIBCXX'
0000000000000000 A GLIBCXX_3.4
0000000000000000 A GLIBCXX_3.4.1
0000000000000000 A GLIBCXX_3.4.10
0000000000000000 A GLIBCXX_3.4.11
0000000000000000 A GLIBCXX_3.4.12
0000000000000000 A GLIBCXX_3.4.13
0000000000000000 A GLIBCXX_3.4.14
0000000000000000 A GLIBCXX_3.4.15
0000000000000000 A GLIBCXX_3.4.16
0000000000000000 A GLIBCXX_3.4.17
0000000000000000 A GLIBCXX_3.4.18
0000000000000000 A GLIBCXX_3.4.19
0000000000000000 A GLIBCXX_3.4.2
0000000000000000 A GLIBCXX_3.4.20
0000000000000000 A GLIBCXX_3.4.21
0000000000000000 A GLIBCXX_3.4.22
0000000000000000 A GLIBCXX_3.4.23
0000000000000000 A GLIBCXX_3.4.24
0000000000000000 A GLIBCXX_3.4.25
0000000000000000 A GLIBCXX_3.4.26
0000000000000000 A GLIBCXX_3.4.27
0000000000000000 A GLIBCXX_3.4.28
0000000000000000 A GLIBCXX_3.4.29
0000000000000000 A GLIBCXX_3.4.3
0000000000000000 A GLIBCXX_3.4.30
0000000000000000 A GLIBCXX_3.4.4
0000000000000000 A GLIBCXX_3.4.5
0000000000000000 A GLIBCXX_3.4.6
0000000000000000 A GLIBCXX_3.4.7
0000000000000000 A GLIBCXX_3.4.8
0000000000000000 A GLIBCXX_3.4.9

@smartalecH
Copy link
Author

@giordano thanks for the help! I agree, Julia ships with a newer version. But for some reason, the version that is placed in my build directory is not consistent with this...

@giordano
Copy link
Contributor

I don't know what you're doing. How did you fetch the source code? Is it a git clone (if so, is it a fresh clone or you had built Julia there before?), or you downloaded the source tarball for the v1.8.4 release?

@haampie
Copy link
Contributor

haampie commented Dec 30, 2022

It used to be so that Julia derived the libstdc++ path by inspecting gfortran's implicit link directories. So if you have a new gcc in your PATH without gfortran, the new gcc is used to compile c and c++, and the old gfortran is used to compile gfortran. The build system however assumes gfortran/gcc/g++ are all from the same version in the same prefix

@smartalecH
Copy link
Author

I don't know what you're doing. How did you fetch the source code? Is it a git clone (if so, is it a fresh clone or you had built Julia there before?), or you downloaded the source tarball for the v1.8.4 release?

I'm building from the 1.8.4 "full" release tarball (binary builder is turned off, as I don't have network access during the build process). This is on a fresh image, so no previous install of Julia.

It used to be so that Julia derived the libstdc++ path by inspecting gfortran's implicit link directories.

Ah yes, this still seems to be the case:

julia/deps/csl.mk

Lines 49 to 68 in 4d206c9

ifeq ($(USE_BINARYBUILDER_CSL),0)
define copy_csl
install-csl: | $$(build_shlibdir) $$(build_shlibdir)/$(1)
$$(build_shlibdir)/$(1): | $$(build_shlibdir)
-@SRC_LIB=$$(call pathsearch,$(1),$$(STD_LIB_PATH)); \
[ -n "$$$${SRC_LIB}" ] && cp $$$${SRC_LIB} $$(build_shlibdir)
endef
# libgfortran has multiple names; we're just going to copy any version we can find
# Since we're only looking in the location given by `$(FC)` this should only succeed for one.
$(eval $(call copy_csl,$(call versioned_libname,libgfortran,3)))
$(eval $(call copy_csl,$(call versioned_libname,libgfortran,4)))
$(eval $(call copy_csl,$(call versioned_libname,libgfortran,5)))
# These are all libraries that we should always have
$(eval $(call copy_csl,$(call versioned_libname,libquadmath,0)))
$(eval $(call copy_csl,$(call versioned_libname,libstdc++,6)))
$(eval $(call copy_csl,$(call versioned_libname,libssp,0)))
$(eval $(call copy_csl,$(call versioned_libname,libatomic,1)))
$(eval $(call copy_csl,$(call versioned_libname,libgomp,1)))

My gfortran and gcc share the same prefix, however, my sysadmins placed libstdc++.so in a different folder than the default lib folder (not sure why they did this... I'm assuming to prevent clobbering of other install recipes)

Is there an easy way to add this extra path to the list of search directories above? Or do I need to modify the csl makefile to manually include this directory? (library path definition included below)

julia/deps/csl.mk

Lines 2 to 6 in 4d206c9

STD_LIB_PATH := $(shell LANG=C $(FC) -print-search-dirs 2>/dev/null | grep '^programs: =' | sed -e "s/^programs: =//")
STD_LIB_PATH += :$(shell LANG=C $(FC) -print-search-dirs 2>/dev/null | grep '^libraries: =' | sed -e "s/^libraries: =//")
ifneq (,$(findstring CYGWIN,$(BUILD_OS))) # the cygwin-mingw32 compiler lies about it search directory paths
STD_LIB_PATH := $(shell echo '$(STD_LIB_PATH)' | sed -e "s!/lib/!/bin/!g")
endif

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

No branches or pull requests

3 participants