From 6bc53b617f352c87a1f02897d75991458b010c05 Mon Sep 17 00:00:00 2001 From: Nathanne Isip Date: Fri, 25 Oct 2024 09:10:31 +0800 Subject: [PATCH] Small fix on build script for NVIDIA CUDA. --- build.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/build.py b/build.py index 3d9d2d3..69b45ac 100644 --- a/build.py +++ b/build.py @@ -127,14 +127,18 @@ exe_build_args += cpp_files + ['-o', OUTPUT_EXECUTABLE + '-omp'] lib_build_args += cc_files -cuda_build_args = ['nvcc'] +cuda_build_args = [ + 'nvcc', + '-lcudadevrt', + '-lcudart_static' +] if PLATFORM == 'Linux': lib_build_args.append('-fPIC') if PLATFORM == 'Windows': - cuda_build_args.append('-Xcompiler') - cuda_build_args.append('/std:c++17') + cuda_build_args.append('-Xcompiler /MT') + cuda_build_args.append('-Xcompiler /std:c++17') lib_build_args = lib_build_args + [ '-pipe', '-Ofast', '-s', '-std=c++17', @@ -145,7 +149,7 @@ ] cuda_build_args.append('-Iinclude') -cuda_build_args += cpp_files + ['-o', OUTPUT_EXECUTABLE + '-nvidia'] +cuda_build_args += cpp_files cuda_lib_args = [ 'nvcc', '--shared', '-Ilib', '-o', @@ -155,12 +159,14 @@ if PLATFORM == 'Windows': cuda_lib_args[-1] += '.dll' else: + cuda_build_args += '-Xcompiler \'-static-libstdc++ -static-libgcc -static\'' cuda_lib_args[-1] += '.so' + cuda_lib_args += [ + '-Xcompiler \'-static-libgcc -static-libstdc++\'', + '--compiler-options', '\'-fPIC\'' + ] -cuda_lib_args += [ - '--compiler-options', '-fPIC', - rt_bin -] + cc_files +cuda_lib_args += [rt_bin] + cc_files if PLATFORM == 'Windows': cuda_lib_args += ['--compiler-options', '/std:c++17'] @@ -181,6 +187,7 @@ exe_build_args.append(APP_ICON_OBJ) cuda_build_args.append(APP_ICON_OBJ) + cuda_build_args += ['-o', OUTPUT_EXECUTABLE + '-nvidia'] print("Executing:") print(' '.join(exe_build_args))