Building cmake from source on linux Fedora 37

Hi there,
I need to have multiple versions of gnu/cuda toolchain on a machine, handled through environment-modules, and I have run into two issues.
------ Issue 1 -------------
When building the GNU compilers I had to install the static libstdc++ to work around some bootstrap issues.
When I then try to use the default installation cmake cmake-3.25.2-1.fc37.x86_64
I get the following error:
cmake: /opt/gnu/9.5.0/lib64/libstdc++.so.6: version `GLIBCXX_3.4.29’ not found (required by cmake)
which is exactly the reason why I installed the static libstdc++ to bootstrap the GNU compiler.
Any workaround?

----- Issue 2 ----------
I tried to solve issue 1 by rebuilding my own version of cmake with the 9.5.0 GNU compiler set; I tried both 3.25.2 and 3.24.3, bootstraps OK and then I get:
[ 38%] Building C object Utilities/cmlibarchive/libarchive/CMakeFiles/cmlibarchive.dir/archive_read_disk_posix.c.o
In file included from /usr/include/linux/fs.h:19,
from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:56:
/usr/include/linux/mount.h:95:6: error: nested redefinition of ‘enum fsconfig_command’
95 | enum fsconfig_command {
| ^~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:95:6: error: redeclaration of ‘enum fsconfig_command’
In file included from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:38:
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:249:6: note: originally defined here
249 | enum fsconfig_command
| ^~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:96:2: error: redeclaration of enumerator ‘FSCONFIG_SET_FLAG’
96 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value /
| ^~~~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:251:3: note: previous definition of ‘FSCONFIG_SET_FLAG’ was here
251 | FSCONFIG_SET_FLAG = 0, /
Set parameter, supplying no value /
| ^~~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:97:2: error: redeclaration of enumerator ‘FSCONFIG_SET_STRING’
97 | FSCONFIG_SET_STRING = 1, /
Set parameter, supplying a string value /
| ^~~~~~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:253:3: note: previous definition of ‘FSCONFIG_SET_STRING’ was here
253 | FSCONFIG_SET_STRING = 1, /
Set parameter, supplying a string value /
| ^~~~~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:98:2: error: redeclaration of enumerator ‘FSCONFIG_SET_BINARY’
98 | FSCONFIG_SET_BINARY = 2, /
Set parameter, supplying a binary blob value /
| ^~~~~~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:255:3: note: previous definition of ‘FSCONFIG_SET_BINARY’ was here
255 | FSCONFIG_SET_BINARY = 2, /
Set parameter, supplying a binary blob value /
| ^~~~~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:99:2: error: redeclaration of enumerator ‘FSCONFIG_SET_PATH’
99 | FSCONFIG_SET_PATH = 3, /
Set parameter, supplying an object by path /
| ^~~~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:257:3: note: previous definition of ‘FSCONFIG_SET_PATH’ was here
257 | FSCONFIG_SET_PATH = 3, /
Set parameter, supplying an object by path /
| ^~~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:100:2: error: redeclaration of enumerator ‘FSCONFIG_SET_PATH_EMPTY’
100 | FSCONFIG_SET_PATH_EMPTY = 4, /
Set parameter, supplying an object by (empty) path /
| ^~~~~~~~~~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:259:3: note: previous definition of ‘FSCONFIG_SET_PATH_EMPTY’ was here
259 | FSCONFIG_SET_PATH_EMPTY = 4, /
Set parameter, supplying an object by (empty) path /
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:101:2: error: redeclaration of enumerator ‘FSCONFIG_SET_FD’
101 | FSCONFIG_SET_FD = 5, /
Set parameter, supplying an object by fd /
| ^~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:261:3: note: previous definition of ‘FSCONFIG_SET_FD’ was here
261 | FSCONFIG_SET_FD = 5, /
Set parameter, supplying an object by fd /
| ^~~~~~~~~~~~~~~
/usr/include/linux/mount.h:102:2: error: redeclaration of enumerator ‘FSCONFIG_CMD_CREATE’
102 | FSCONFIG_CMD_CREATE = 6, /
Invoke superblock creation /
| ^~~~~~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:263:3: note: previous definition of ‘FSCONFIG_CMD_CREATE’ was here
263 | FSCONFIG_CMD_CREATE = 6, /
Invoke superblock creation /
| ^~~~~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:103:2: error: redeclaration of enumerator ‘FSCONFIG_CMD_RECONFIGURE’
103 | FSCONFIG_CMD_RECONFIGURE = 7, /
Invoke superblock reconfiguration /
| ^~~~~~~~~~~~~~~~~~~~~~~~
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:265:3: note: previous definition of ‘FSCONFIG_CMD_RECONFIGURE’ was here
265 | FSCONFIG_CMD_RECONFIGURE = 7, /
Invoke superblock reconfiguration */
| ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/linux/fs.h:19,
from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:56:
/usr/include/linux/mount.h:129:8: error: redefinition of ‘struct mount_attr’
129 | struct mount_attr {
| ^~~~~~~~~~
In file included from /data/travel/SOFTWARE/GENERAL/CMAKE/cmake-3.24.3/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c:38:
/opt/gnu/9.5.0/lib/gcc/x86_64-pc-linux-gnu/9.5.0/include-fixed/sys/mount.h:219:8: note: originally defined here
219 | struct mount_attr
| ^~~~~~~~~~

Any help and/or workaround greatly appreciated

Salvatore

Hello, Salvatore,
The Fedora upstream package doesn’t use the bundled cmlibarchive in favour of upstream libarchive (see RPM package spec here: Tree - rpms/cmake - src.fedoraproject.org)

You may try the --no-system-libs flag for boostrap script, like it was done in the same spec (it also has the rpm condition about boostrap mode)…

Hope this helps.
Best regards,
Alex.

Thanks Alex.
Unfortunately, this is not sufficient, since I still get a bunch of “redeclaration error”
Any further insight? Anything from my side that could be useful?
Thanks
Salvatore

It looks like the compiler is not built properly. It has its own mount.h but is also finding the system mount.h as well, possibly in another context.

That’s interesting: to bootstrap the compiler I was told on the gcc forum to use “–disable-libsanitizer” to handle the same kind of error.
Looks like the build environment in Fedora 27 has some deep issues.
S.

or, at least, there are deeper issues with trying to build older compilers…