(fix:cuda) CUDA portability improved\nbuild system now checks for valid compiler compatible with nvcc and fails if that is not found and cuda is selected. Further, compiler choices are propegated throughout build along with CFLAGS and CXXFLAGS

This commit is contained in:
2026-09-07 10:51:34 -04:00
parent 323555b722
commit 7c99debf2f
6 changed files with 365 additions and 36 deletions

View File

@@ -273,6 +273,57 @@ endif
mfem_consumer_cpp_std = (
mfem_features.get('raja') or mfem_features.get('umpire')
) ? 'c++20' : 'c++17'
cc_command = cc.cmd_array()
cxx_command = cpp.cmd_array()
known_compiler_launchers = ['ccache', 'sccache', 'distcc']
cc_executable = ''
cc_launchers = []
cc_fixed_args = []
foreach command_part : cc_command
if cc_executable == '' and fs.name(command_part) in known_compiler_launchers
cc_launchers += [command_part]
elif cc_executable == ''
cc_executable = command_part
else
cc_fixed_args += [command_part]
endif
endforeach
cxx_executable = ''
cxx_launchers = []
cxx_fixed_args = []
foreach command_part : cxx_command
if cxx_executable == '' and fs.name(command_part) in known_compiler_launchers
cxx_launchers += [command_part]
elif cxx_executable == ''
cxx_executable = command_part
else
cxx_fixed_args += [command_part]
endif
endforeach
if cc_executable == '' or cxx_executable == ''
error('Could not identify the C/C++ compiler executables in Meson compiler commands.')
endif
cuda_compiler_path = ''
if mfem_has_cuda
cuda_compiler_path = dependency_has_nvcc ? (dependency_prefix / 'bin' / 'nvcc') : nvcc_program.full_path()
cuda_check = files('../../tools/check_cuda_toolchain.py')
cuda_check_args = []
foreach arg : cc_fixed_args + get_option('c_args') + platform_c_args
cuda_check_args += ['--c-arg=' + arg]
endforeach
foreach arg : cxx_fixed_args + get_option('cpp_args') + platform_cpp_args
cuda_check_args += ['--cxx-arg=' + arg]
endforeach
cuda_check_result = run_command(
python_build, cuda_check, '--nvcc', cuda_compiler_path,
'--cc', cc_executable, '--cxx', cxx_executable,
'--standard', mfem_consumer_cpp_std.substring(3), cuda_check_args, check: false,
)
if cuda_check_result.returncode() != 0
error(cuda_check_result.stdout() + cuda_check_result.stderr())
endif
message(cuda_check_result.stdout().strip())
endif
system_mfem = disabler()
mfem_provider = 'source bundle'
if effective_allow_preinstalled
@@ -428,37 +479,7 @@ else
mfem_runtime_prefix = meson.current_build_dir() / bundle_output_name
bundle_work_dir = meson.current_build_dir() / '_bundle' / 'work'
bundle_builder = files('../../tools/build_mfem_bundle.py')
bundle_auxiliary_files = files('../../tools/ceed_jit_source_root_relocatable.c')
cc_command = cc.cmd_array()
cxx_command = cpp.cmd_array()
known_compiler_launchers = ['ccache', 'sccache', 'distcc']
cc_executable = ''
cc_launchers = []
cc_fixed_args = []
foreach command_part : cc_command
if cc_executable == '' and fs.name(command_part) in known_compiler_launchers
cc_launchers += [command_part]
elif cc_executable == ''
cc_executable = command_part
else
cc_fixed_args += [command_part]
endif
endforeach
cxx_executable = ''
cxx_launchers = []
cxx_fixed_args = []
foreach command_part : cxx_command
if cxx_executable == '' and fs.name(command_part) in known_compiler_launchers
cxx_launchers += [command_part]
elif cxx_executable == ''
cxx_executable = command_part
else
cxx_fixed_args += [command_part]
endif
endforeach
if cc_executable == '' or cxx_executable == ''
error('Could not identify the C/C++ compiler executables in Meson compiler commands.')
endif
bundle_auxiliary_files = files('../../tools/ceed_jit_source_root_relocatable.c', '../../tools/check_cuda_toolchain.py')
bundle_command = [
python_build,
bundle_builder,
@@ -473,6 +494,7 @@ else
'--host-system', host_machine.system(),
'--cross-build', meson.is_cross_build() ? 'true' : 'false',
'--library-kind', is_wasm ? 'static' : 'shared',
'--cuda-compiler', cuda_compiler_path,
'--cuda-arch', get_option('mfem_cuda_arch'),
'--hip-arch', get_option('mfem_hip_arch'),
'--precision', get_option('mfem_precision'),