How to fully disable cuda during the build

Reports of bugs or unexpected behavior MUST include:

  1. QE version: https://github.com/QEF/q-e/archive/refs/tags/qe-6.8.tar.gz
  2. Main hardware and compilation information: x86_64
  3. input data and pseudopotential files, or (better) links to them: none 3.1. Optionally, output file(s), especially if execution time is long or if they contain useful information: none
  4. ALL information needed to reproduce the problem.

I'm looking for a way to fully disable cuda during qe compilation.

The packaging process on Fedora disables downloads of external files during builds. The https://gitlab.com/QEF/q-e/-/blob/9da20ff7781d568ad0995385fa31ee695f2efeb7/install/extlibs_makefile#L96 downloads a source code from https://gitlab.com/max-centre/components/devicexlib and therefore fails due to network access blocked (related issue #331 (closed)). See the compilation log at https://koji.fedoraproject.org/koji/taskinfo?taskID=73203828

cd install ; /usr/bin/make -f extlibs_makefile libcuda
make[1]: Entering directory '/builddir/build/BUILD/q-e-qe-6.8/install'
cd ../external/devxlib; \
    if test ! -e configure; then \
    wget "https://gitlab.com/max-centre/components/devicexlib/-/archive/master/devicexlib-master.tar.gz" -O devxlib.tar.gz || curl "https://gitlab.com/max-centre/components/devicexlib/-/archive/master/devicexlib-master.tar.gz" -o devxlib.tar.gz ; \
    tar xzf devxlib.tar.gz --strip-components=1 -C . ; \
    rm devxlib.tar.gz ; \
    fi; \
    touch make.inc; \
    /usr/bin/make clean; \
    export F90FLAGS="-fPIC "; \
    ./configure FC=gfortran CC=cc \
                --with-cuda=no \
                --with-cuda-cc= \
                --with-cuda-runtime= \
                --disable-parallel \
                --enable-cuda-env-check=no; \
    make all
/bin/sh: line 3: wget: command not found
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (6) Could not resolve host: gitlab.com
tar (child): devxlib.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
rm: cannot remove 'devxlib.tar.gz': No such file or directory

Attempts to disable cuda with, for example

sed -i 's| libcuda||' install/extlibs_makefile
sed -i 's/try_dflags -D__CUDA/try_dflags/' install/configure

are insufficient https://koji.fedoraproject.org/koji/taskinfo?taskID=73202298

gfortran -fallow-argument-mismatch -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused-variable -Wno-conversion -Wno-unused-dummy-argument -Wno-character-truncation -Wno-missing-include-dirs -Wno-unused-function -Wno-maybe-unitialized -cpp -D__FFTW3 -fallow-argument-mismatch -DEXX -I/builddir/build/BUILD/q-e-qe-6.8//external/devxlib/src -I/builddir/build/BUILD/q-e-qe-6.8//include -I/builddir/build/BUILD/q-e-qe-6.8//FoX/finclude  -I../UtilXlib -I../external/devxlib/src -c init_us_2_base_gpu.f90
f951: Warning: Nonexistent include directory '/builddir/build/BUILD/q-e-qe-6.8//external/devxlib/src' [-Wmissing-include-dirs]
f951: Warning: Nonexistent include directory '../external/devxlib/src' [-Wmissing-include-dirs]
f951: Warning: '-Werror=' argument '-Werror=format-security' is not valid for Fortran
init_us_2_base_gpu.f90:24:7:
   24 |   USE device_fbuff_m,   ONLY : dev_buf
      |       1
Fatal Error: Cannot open module file 'device_fbuff_m.mod' for reading at (1): No such file or directory
compilation terminated.
make[1]: Leaving directory '/builddir/build/BUILD/q-e-qe-6.8/upflib'
make[1]: *** [../make.inc:16: init_us_2_base_gpu.o] Error 1
make: *** [Makefile:205: libupf] Error 1

On the other hand, bundling the https://gitlab.com/max-centre/components/devicexlib/-/tree/a6b89ef77b1ceda48e967921f1f5488d2df9226d source results in https://koji.fedoraproject.org/koji/taskinfo?taskID=73205570

make[2]: Entering directory '/builddir/build/BUILD/q-e-qe-6.8/external/devxlib'
if test -d src/ ; then \
( cd src/ ; make ) ; fi
make[3]: Entering directory '/builddir/build/BUILD/q-e-qe-6.8/external/devxlib/src'
gfortran -fPIC     -I./ -I/builddir/build/BUILD/q-e-qe-6.8/external/devxlib//include -I../include/  -c device_auxfunc_mod.f90
device_auxfunc_mod.f90:12:2:
   12 | #if defined(_CUDA)
      |  1
Warning: Illegal preprocessor directive
device_auxfunc_mod.f90:13:2:
   13 | #  define __CUDA
      |  1
Warning: Illegal preprocessor directive
device_auxfunc_mod.f90:14:2:
   14 | #endif
      |  1
Warning: Illegal preprocessor directive
device_auxfunc_mod.f90:19:2:
   19 | #include<device_auxfunc_interf.f90>
      |  1
Warning: Illegal preprocessor directive
gfortran -fPIC     -I./ -I/builddir/build/BUILD/q-e-qe-6.8/external/devxlib//include -I../include/  -c device_fbuff.f90
...
Warning: Illegal preprocessor directive
device_fbuff.f90:11:7:
   11 |   use cudafor
      |       1
Fatal Error: Cannot open module file 'cudafor.mod' for reading at (1): No such file or directory
compilation terminated.
make[3]: *** [../make.inc:16: device_fbuff.o] Error 1
make[2]: *** [Makefile:47: libsrc] Error 2
make[1]: *** [extlibs_makefile:94: libcuda_devxlib] Error 2
make: *** [Makefile:230: libcuda] Error 2
Edited by Marcin Dulak