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

Building GCC 12.2 with spack #7

Open
balston opened this issue Nov 28, 2022 · 14 comments
Open

Building GCC 12.2 with spack #7

balston opened this issue Nov 28, 2022 · 14 comments

Comments

@balston
Copy link

balston commented Nov 28, 2022

GCC 12.x is required for the latest CP2K version.

@balston
Copy link
Author

balston commented Nov 28, 2022

After running:

spack install gcc@12.2.0

on Young. I have:

 spack find
-- linux-rhel7-cascadelake / gcc@11.2.1 -------------------------
autoconf@2.69                gcc@12.2.0       m4@1.4.19       tar@1.34
autoconf-archive@2022.02.11  gdbm@1.23        mpc@1.2.1       texinfo@6.8
automake@1.16.5              gettext@0.21.1   mpfr@4.1.0      xz@5.2.7
berkeley-db@18.1.40          gmp@6.2.1        ncurses@6.3     zlib@1.2.13
binutils@2.38                libiconv@1.16    perl@5.36.0     zstd@1.5.2
bzip2@1.0.8                  libsigsegv@2.13  pigz@2.7
diffutils@3.8                libtool@2.4.7    pkgconf@1.8.0
gawk@5.1.1                   libxml2@2.10.3   readline@8.1.2
==> 29 installed packages
[ccaabaa@login01 spack-test]$

and there is a module file:

module avail gcc
- /lustre/scratch/ccaabaa/apps/spack-test/spack/share/spack/modules/linux-rhel7-cascadelake -
gcc-12.2.0-gcc-11.2.1-oklbzl5

The build took several hours to run on Young's login node.

@balston
Copy link
Author

balston commented Nov 28, 2022

module load gcc-12.2.0-gcc-11.2.1-oklbzl5
gcc -v

gives:

Reading specs from /lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m/lib/gcc/x86_64-pc-linux-gnu/12.2.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m/libexec/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /home/ccaabaa/.spack/spack-stage/spack-stage-gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m/spack-src/configure --prefix=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m --with-pkgversion='Spack GCC' --with-bugurl=https://github.com/spack/spack/issues --disable-multilib --enable-languages=c,c++,fortran --disable-nls --disable-canonical-system-headers --with-system-zlib --with-zstd-include=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/zstd-1.5.2-va734fjurxmd2s3gqne2vswuhvl3ddxg/include --with-zstd-lib=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/zstd-1.5.2-va734fjurxmd2s3gqne2vswuhvl3ddxg/lib --with-gnu-ld --with-ld=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/binutils-2.38-55mvr2mkuctqx6epk6shlrbc27hmn2ah/bin/ld --with-gnu-as --with-as=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/binutils-2.38-55mvr2mkuctqx6epk6shlrbc27hmn2ah/bin/as --enable-bootstrap --with-mpfr-include=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpfr-4.1.0-xhdvtvpjxulm4qn2ibw6iz3dnsla3lza/include --with-mpfr-lib=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpfr-4.1.0-xhdvtvpjxulm4qn2ibw6iz3dnsla3lza/lib --with-gmp-include=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gmp-6.2.1-ka7cqvgbfgkbocmf6zyrc6qsnld2lkle/include --with-gmp-lib=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gmp-6.2.1-ka7cqvgbfgkbocmf6zyrc6qsnld2lkle/lib --with-mpc-include=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpc-1.2.1-vczwqci6gdyqhptjdw65v26hvqpmulvn/include --with-mpc-lib=/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpc-1.2.1-vczwqci6gdyqhptjdw65v26hvqpmulvn/lib --without-isl --with-stage1-ldflags='-Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m/lib64 -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/binutils-2.38-55mvr2mkuctqx6epk6shlrbc27hmn2ah/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gmp-6.2.1-ka7cqvgbfgkbocmf6zyrc6qsnld2lkle/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpc-1.2.1-vczwqci6gdyqhptjdw65v26hvqpmulvn/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpfr-4.1.0-xhdvtvpjxulm4qn2ibw6iz3dnsla3lza/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/zlib-1.2.13-lej632pnwjfslbmbdu3yawwx3gn2erys/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/zstd-1.5.2-va734fjurxmd2s3gqne2vswuhvl3ddxg/lib' --with-boot-ldflags='-Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gcc-12.2.0-oklbzl53opxjovn2x3itkvs2xscuaz5m/lib64 -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/binutils-2.38-55mvr2mkuctqx6epk6shlrbc27hmn2ah/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/gmp-6.2.1-ka7cqvgbfgkbocmf6zyrc6qsnld2lkle/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpc-1.2.1-vczwqci6gdyqhptjdw65v26hvqpmulvn/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/mpfr-4.1.0-xhdvtvpjxulm4qn2ibw6iz3dnsla3lza/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/zlib-1.2.13-lej632pnwjfslbmbdu3yawwx3gn2erys/lib -Wl,-rpath,/lustre/scratch/ccaabaa/apps/spack-test/spack/opt/spack/linux-rhel7-cascadelake/gcc-11.2.1/zstd-1.5.2-va734fjurxmd2s3gqne2vswuhvl3ddxg/lib -static-libstdc++ -static-libgcc' --with-build-config=spack
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Spack GCC)

and g++ and gfortran both show similar.

Now to try building something - our Pi example ...

@balston
Copy link
Author

balston commented Nov 28, 2022

The module file doesn't do everything you might expect. eg doesn't set LD_LIBRARY_PATH so when I do make in pi/c+f90_mix_openmp_dir it finds the wrong gfortran library!

@giordano
Copy link
Member

What exactly is finding the wrong gfortran library? Also, does spack load --sh gcc@12.2.0 show the setting for LD_LIBRARY_PATH?

@giordano
Copy link
Member

giordano commented Nov 28, 2022

Also, if you're using Spack v0.19 you could try setting in the spack environment

spack config add config:shared_linking:bind:true

so that LD_LIBRARY_PATH won't be necessary at all.

Related: #2 (comment)

Edit: on a second thought, this will likely not help here, since you aren't building the pi program through spack. But honestly I'd expect spack's gcc to set rpath automatically for its runtime libraries.

@heatherkellyucl
Copy link
Collaborator

heatherkellyucl commented Nov 29, 2022

We will need to sort out what the modules are doing, since we are going to be expecting users to be interacting with modules rather than spack commands most of the time. (Although with respect to LD_LIBRARY_PATH this affects spack load <anylib> as well).

There's a thing in the Slack saying that they recently stopped setting LD_LIBRARY_PATH by default (because everything is rpathed and it breaks system binaries when they find spack dependencies instead of their own ones).

There is info at https://spack.readthedocs.io/en/latest/module_file_support.html#customize-environment-modifications - which says it is better set per-package rather than globally. And https://spack.readthedocs.io/en/latest/module_file_support.html#overide-api-calls-in-package-py

So we probably want a list of packages where this is necessary?

@balston
Copy link
Author

balston commented Dec 16, 2022

On Myriad I'm trying a build of GCC 12 with something like:

def setup_run_environment(self, env):
env.prepend_path("LD_LIBRARY_PATH", join_path(self.prefix, "lib-path"))

defined in GCC's package.py. need to find out what lib-path should be.

@balston
Copy link
Author

balston commented Dec 16, 2022

lib-path needs to be: "lib", "lib64" I think. Also should probably set LIBRARY_PATH like this as well.

@balston
Copy link
Author

balston commented Dec 16, 2022

The GCC 12 build on Myriad was going really well until I blew my HOME quota!

@balston
Copy link
Author

balston commented Dec 16, 2022

Fixed and restarted.

@balston
Copy link
Author

balston commented Dec 23, 2022

I've finally got LD_LIBRARY_PATH set in the GCC module by doing:

spack edit gcc

and adding:

        env.prepend_path("LD_LIBRARY_PATH", join_path(self.prefix, "lib64"))
        env.prepend_path("LIBRARY_PATH", join_path(self.prefix, "lib64"))

to def setup_run_environment(self, env):.

@balston
Copy link
Author

balston commented Dec 23, 2022

I will test if this module now works in the new year.

@balston
Copy link
Author

balston commented Jan 9, 2023

Now doing the following:

. load_scls.sh 
. setup-spack.sh
module load gcc-12.2.0-gcc-11.2.1-vr5mseu

in my Spack test directory following by building our Fortran PI example from https://github.com/UCL-RITS/pi_examples.git
works:

cd ../c+f90_mix_openmp_dir/
make -f Makefile.gnu
gfortran -O3 -fopenmp -c pi.f90
gcc -O3  -c pi_mytime.c
gfortran -o pi -O3 -fopenmp pi.o pi_mytime.o
[ccaabaa@login12 c+f90_mix_openmp_dir]$ ./pi
Calculating PI using:
                        1000000000 slices
                                36 OpenMP threads
Obtained value of PI: 3.1415926536
Time taken:                0.12853 seconds

Adding my change to my Young Spack setup.

@balston
Copy link
Author

balston commented Jan 9, 2023

Running:

spack compiler find

adds GCC 12 to Spacks available compilers.

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