Using newer gcc in /opt/netapps: Difference between revisions

From LWP-Wiki
Jump to navigation Jump to search
(The script is not generic, provide a version-specific one in the gcc/5.2 dir)
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:software-faq]]
[[Category:software-faq]]


Gcc-5.2 is in /opt/netapps/gnu/gcc/5.2. In order for you to use it, this may have to be appended to your .profile:
Gcc 13.3 is in /opt/netapps/gnu/gcc/13.3. You can use environment modules to use it:


GCCSNIPPET=/opt/netapps/gnu/gcc/5.2/sourceme
  module load /opt/netapps/gnu/gcc/13.2.0/modules/gcc-13
[ -r ${GCCSNIPPET} ] && . ${GCCSNIPPET}


Please note: /opt is *NOT* in ld.so.conf, and should not be
Please note: /opt is *NOT* in ld.so.conf, and should not be


== Later versions ==
== Later versions ==
You may find that still later versions are available. Check /opt/netapps/gnu/gcc, and alter the above script by adjusting the line
You may find that still later versions are available. Check /opt/netapps/gnu/gcc, and alter the above command accordingly.


  GCCBASE="/opt/netapps/gnu/gcc/5.2"
== Addendum ==
Programs built with this newer compiler and these newer libraries may use a
newer ABI than the regular compiler/libraries on the LWP.
(See
https://gcc.gnu.org/onlinedocs/libstdc%2B%2B/manual/using_dual_abi.html )
 
If you run such programs without the environment settings that were set
by the environment module, the dynamic linker, at run/load time, may give
you relocation errors. It is undesirable to have to set the
environment depending on which executables are going to run, even if you
can predict that at all.
 
Luckily, we can hardcode the new library paths into the executable
during building. E.g.:
  export LDFLAGS='-Wl,--rpath,/opt/netapps/gnu/gcc/5.2/lib64'
 
The weird dual-comma syntax means to tell the compiler (-Wl) to tell the
linker to use option "--rpath /opt/netapps/gnu/gcc/5.2/lib64".
 
Such an export command, used just before calling Make, will cause Make
to build an executable that '''will''' run without any special environment
settings, albeit only on the LWP, where the paths mentioned actually exist.

Latest revision as of 20:51, 3 September 2023


Gcc 13.3 is in /opt/netapps/gnu/gcc/13.3. You can use environment modules to use it:

 module load /opt/netapps/gnu/gcc/13.2.0/modules/gcc-13

Please note: /opt is *NOT* in ld.so.conf, and should not be

Later versions

You may find that still later versions are available. Check /opt/netapps/gnu/gcc, and alter the above command accordingly.

Addendum

Programs built with this newer compiler and these newer libraries may use a newer ABI than the regular compiler/libraries on the LWP. (See https://gcc.gnu.org/onlinedocs/libstdc%2B%2B/manual/using_dual_abi.html )

If you run such programs without the environment settings that were set by the environment module, the dynamic linker, at run/load time, may give you relocation errors. It is undesirable to have to set the environment depending on which executables are going to run, even if you can predict that at all.

Luckily, we can hardcode the new library paths into the executable during building. E.g.:

export LDFLAGS='-Wl,--rpath,/opt/netapps/gnu/gcc/5.2/lib64'

The weird dual-comma syntax means to tell the compiler (-Wl) to tell the linker to use option "--rpath /opt/netapps/gnu/gcc/5.2/lib64".

Such an export command, used just before calling Make, will cause Make to build an executable that will run without any special environment settings, albeit only on the LWP, where the paths mentioned actually exist.