Dear all,
the compiler binaries try to link when a -l
flag is present, even in absence of an object file to link. The GCC compilers do not do this. This breaks ./configure
scripts, e.g. when the mpicc
compiler wrapper calls nv* with the mpi libraries:
$ mpicc -show
nvc -I<some includes> -L<some library locations> -lmpi
and as consequence:
$ mpicc --version
nvc 24.9-0 64-bit target on x86-64 Linux -tp skylake-avx512
NVIDIA Compilers and Tools
Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/.../ld: /usr/lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
which will cause ./configure
(of any package checking the compiler version) to fail.
After this motivation, a simple reproducer:
$ nvc --version -lm
nvc 24.9-0 64-bit target on x86-64 Linux -tp skylake-avx512
NVIDIA Compilers and Tools
Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/.../ld: /usr/lib64/crt1.o: in function `_start':
(.text+0x1b): undefined reference to `main'
In comparison, gcc
:
$ gcc --version -lm
gcc (GCC) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This issue is present in 25.1, too:
nvc --version -lm
nvc 25.1-0 linuxarm64 target on aarch64 Linux -tp neoverse-v2
NVIDIA Compilers and Tools
Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/usr/bin/ld: /usr/lib64/crt1.o: in function `__wrap_main':
(.text+0x38): undefined reference to `main'
In 25.3:
$ ./nvc --version -lm
nvc 25.3-0 linuxarm64 target on aarch64 Linux -tp cortex-a72
NVIDIA Compilers and Tools
Copyright (c) 2025, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
/usr/bin/ld: cannot open output file a.out: Permission denied
If the behaviour could be harmonised to GCC, it would be highly appreciated.
As workaround, one could define a wrapper:
mpicc () {
mpicc_exe=<your mpi location here>/bin/mpicc
[[ --version =~ $@ && 1 -eq $# ]] && nvc --version && return 0
$mpicc_exe $@
}
Thanks for reading my rant until this point!
Cheers, Peter