frida 16.2.1 → 16.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BSDmakefile +6 -0
- package/Makefile +16 -0
- package/README.md +14 -11
- package/configure +18 -0
- package/configure.bat +22 -0
- package/dist/native.js +0 -8
- package/lib/application.ts +98 -0
- package/lib/authentication.ts +3 -0
- package/lib/build.py +50 -0
- package/lib/bus.ts +30 -0
- package/lib/cancellable.ts +33 -0
- package/lib/child.ts +15 -0
- package/lib/crash.ts +11 -0
- package/lib/device.ts +329 -0
- package/lib/device_manager.ts +69 -0
- package/lib/endpoint_parameters.ts +56 -0
- package/lib/icon.ts +15 -0
- package/lib/index.ts +311 -0
- package/lib/iostream.ts +78 -0
- package/lib/meson.build +53 -0
- package/lib/native.ts +9 -0
- package/lib/portal_membership.ts +10 -0
- package/lib/portal_service.ts +105 -0
- package/lib/process.ts +57 -0
- package/lib/relay.ts +44 -0
- package/lib/script.ts +352 -0
- package/lib/session.ts +113 -0
- package/lib/signals.ts +45 -0
- package/lib/socket_address.ts +35 -0
- package/lib/spawn.ts +4 -0
- package/lib/system_parameters.ts +78 -0
- package/make.bat +23 -0
- package/meson.build +160 -0
- package/meson.options +11 -0
- package/package.json +27 -6
- package/releng/deps.py +1133 -0
- package/releng/deps.toml +391 -0
- package/releng/devkit-assets/frida-core-example-unix.c +188 -0
- package/releng/devkit-assets/frida-core-example-windows.c +197 -0
- package/releng/devkit-assets/frida-core-example.sln +28 -0
- package/releng/devkit-assets/frida-core-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-core-example.vcxproj.filters +27 -0
- package/releng/devkit-assets/frida-gum-example-unix.c +122 -0
- package/releng/devkit-assets/frida-gum-example-windows.c +132 -0
- package/releng/devkit-assets/frida-gum-example.sln +28 -0
- package/releng/devkit-assets/frida-gum-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-gum-example.vcxproj.filters +27 -0
- package/releng/devkit-assets/frida-gumjs-example-unix.c +84 -0
- package/releng/devkit-assets/frida-gumjs-example-windows.c +91 -0
- package/releng/devkit-assets/frida-gumjs-example.sln +28 -0
- package/releng/devkit-assets/frida-gumjs-example.vcxproj +157 -0
- package/releng/devkit-assets/frida-gumjs-example.vcxproj.filters +27 -0
- package/releng/devkit.py +535 -0
- package/releng/env.py +420 -0
- package/releng/env_android.py +150 -0
- package/releng/env_apple.py +176 -0
- package/releng/env_generic.py +373 -0
- package/releng/frida_version.py +69 -0
- package/releng/machine_file.py +44 -0
- package/releng/machine_spec.py +290 -0
- package/releng/meson/meson.py +27 -0
- package/releng/meson/mesonbuild/__init__.py +0 -0
- package/releng/meson/mesonbuild/_pathlib.py +63 -0
- package/releng/meson/mesonbuild/_typing.py +69 -0
- package/releng/meson/mesonbuild/arglist.py +321 -0
- package/releng/meson/mesonbuild/ast/__init__.py +23 -0
- package/releng/meson/mesonbuild/ast/interpreter.py +441 -0
- package/releng/meson/mesonbuild/ast/introspection.py +374 -0
- package/releng/meson/mesonbuild/ast/postprocess.py +109 -0
- package/releng/meson/mesonbuild/ast/printer.py +620 -0
- package/releng/meson/mesonbuild/ast/visitor.py +161 -0
- package/releng/meson/mesonbuild/backend/__init__.py +0 -0
- package/releng/meson/mesonbuild/backend/backends.py +2047 -0
- package/releng/meson/mesonbuild/backend/ninjabackend.py +3808 -0
- package/releng/meson/mesonbuild/backend/nonebackend.py +26 -0
- package/releng/meson/mesonbuild/backend/vs2010backend.py +2078 -0
- package/releng/meson/mesonbuild/backend/vs2012backend.py +35 -0
- package/releng/meson/mesonbuild/backend/vs2013backend.py +34 -0
- package/releng/meson/mesonbuild/backend/vs2015backend.py +35 -0
- package/releng/meson/mesonbuild/backend/vs2017backend.py +59 -0
- package/releng/meson/mesonbuild/backend/vs2019backend.py +54 -0
- package/releng/meson/mesonbuild/backend/vs2022backend.py +54 -0
- package/releng/meson/mesonbuild/backend/xcodebackend.py +1781 -0
- package/releng/meson/mesonbuild/build.py +3249 -0
- package/releng/meson/mesonbuild/cargo/__init__.py +5 -0
- package/releng/meson/mesonbuild/cargo/builder.py +238 -0
- package/releng/meson/mesonbuild/cargo/cfg.py +274 -0
- package/releng/meson/mesonbuild/cargo/interpreter.py +733 -0
- package/releng/meson/mesonbuild/cargo/manifest.py +227 -0
- package/releng/meson/mesonbuild/cargo/version.py +95 -0
- package/releng/meson/mesonbuild/cmake/__init__.py +28 -0
- package/releng/meson/mesonbuild/cmake/common.py +331 -0
- package/releng/meson/mesonbuild/cmake/data/__init__.py +0 -0
- package/releng/meson/mesonbuild/cmake/data/preload.cmake +82 -0
- package/releng/meson/mesonbuild/cmake/executor.py +241 -0
- package/releng/meson/mesonbuild/cmake/fileapi.py +324 -0
- package/releng/meson/mesonbuild/cmake/generator.py +186 -0
- package/releng/meson/mesonbuild/cmake/interpreter.py +1267 -0
- package/releng/meson/mesonbuild/cmake/toolchain.py +248 -0
- package/releng/meson/mesonbuild/cmake/traceparser.py +814 -0
- package/releng/meson/mesonbuild/cmake/tracetargets.py +161 -0
- package/releng/meson/mesonbuild/compilers/__init__.py +86 -0
- package/releng/meson/mesonbuild/compilers/asm.py +307 -0
- package/releng/meson/mesonbuild/compilers/c.py +788 -0
- package/releng/meson/mesonbuild/compilers/c_function_attributes.py +143 -0
- package/releng/meson/mesonbuild/compilers/compilers.py +1388 -0
- package/releng/meson/mesonbuild/compilers/cpp.py +1035 -0
- package/releng/meson/mesonbuild/compilers/cs.py +136 -0
- package/releng/meson/mesonbuild/compilers/cuda.py +806 -0
- package/releng/meson/mesonbuild/compilers/cython.py +91 -0
- package/releng/meson/mesonbuild/compilers/d.py +861 -0
- package/releng/meson/mesonbuild/compilers/detect.py +1396 -0
- package/releng/meson/mesonbuild/compilers/fortran.py +523 -0
- package/releng/meson/mesonbuild/compilers/java.py +113 -0
- package/releng/meson/mesonbuild/compilers/mixins/__init__.py +0 -0
- package/releng/meson/mesonbuild/compilers/mixins/arm.py +167 -0
- package/releng/meson/mesonbuild/compilers/mixins/ccrx.py +113 -0
- package/releng/meson/mesonbuild/compilers/mixins/clang.py +170 -0
- package/releng/meson/mesonbuild/compilers/mixins/clike.py +1330 -0
- package/releng/meson/mesonbuild/compilers/mixins/compcert.py +117 -0
- package/releng/meson/mesonbuild/compilers/mixins/elbrus.py +93 -0
- package/releng/meson/mesonbuild/compilers/mixins/emscripten.py +89 -0
- package/releng/meson/mesonbuild/compilers/mixins/gnu.py +629 -0
- package/releng/meson/mesonbuild/compilers/mixins/intel.py +167 -0
- package/releng/meson/mesonbuild/compilers/mixins/islinker.py +120 -0
- package/releng/meson/mesonbuild/compilers/mixins/metrowerks.py +279 -0
- package/releng/meson/mesonbuild/compilers/mixins/pgi.py +88 -0
- package/releng/meson/mesonbuild/compilers/mixins/ti.py +130 -0
- package/releng/meson/mesonbuild/compilers/mixins/visualstudio.py +458 -0
- package/releng/meson/mesonbuild/compilers/mixins/xc16.py +111 -0
- package/releng/meson/mesonbuild/compilers/objc.py +120 -0
- package/releng/meson/mesonbuild/compilers/objcpp.py +102 -0
- package/releng/meson/mesonbuild/compilers/rust.py +230 -0
- package/releng/meson/mesonbuild/compilers/swift.py +131 -0
- package/releng/meson/mesonbuild/compilers/vala.py +121 -0
- package/releng/meson/mesonbuild/coredata.py +1532 -0
- package/releng/meson/mesonbuild/dependencies/__init__.py +252 -0
- package/releng/meson/mesonbuild/dependencies/base.py +663 -0
- package/releng/meson/mesonbuild/dependencies/boost.py +1083 -0
- package/releng/meson/mesonbuild/dependencies/cmake.py +656 -0
- package/releng/meson/mesonbuild/dependencies/coarrays.py +80 -0
- package/releng/meson/mesonbuild/dependencies/configtool.py +163 -0
- package/releng/meson/mesonbuild/dependencies/cuda.py +295 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakeLists.txt +102 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakeListsLLVM.txt +204 -0
- package/releng/meson/mesonbuild/dependencies/data/CMakePathInfo.txt +31 -0
- package/releng/meson/mesonbuild/dependencies/data/__init__.py +0 -0
- package/releng/meson/mesonbuild/dependencies/detect.py +225 -0
- package/releng/meson/mesonbuild/dependencies/dev.py +707 -0
- package/releng/meson/mesonbuild/dependencies/dub.py +424 -0
- package/releng/meson/mesonbuild/dependencies/factory.py +146 -0
- package/releng/meson/mesonbuild/dependencies/framework.py +111 -0
- package/releng/meson/mesonbuild/dependencies/hdf5.py +168 -0
- package/releng/meson/mesonbuild/dependencies/misc.py +618 -0
- package/releng/meson/mesonbuild/dependencies/mpi.py +231 -0
- package/releng/meson/mesonbuild/dependencies/pkgconfig.py +570 -0
- package/releng/meson/mesonbuild/dependencies/platform.py +52 -0
- package/releng/meson/mesonbuild/dependencies/python.py +431 -0
- package/releng/meson/mesonbuild/dependencies/qt.py +484 -0
- package/releng/meson/mesonbuild/dependencies/scalapack.py +142 -0
- package/releng/meson/mesonbuild/dependencies/ui.py +281 -0
- package/releng/meson/mesonbuild/depfile.py +82 -0
- package/releng/meson/mesonbuild/envconfig.py +480 -0
- package/releng/meson/mesonbuild/environment.py +987 -0
- package/releng/meson/mesonbuild/interpreter/__init__.py +47 -0
- package/releng/meson/mesonbuild/interpreter/compiler.py +900 -0
- package/releng/meson/mesonbuild/interpreter/dependencyfallbacks.py +386 -0
- package/releng/meson/mesonbuild/interpreter/interpreter.py +3595 -0
- package/releng/meson/mesonbuild/interpreter/interpreterobjects.py +1096 -0
- package/releng/meson/mesonbuild/interpreter/kwargs.py +479 -0
- package/releng/meson/mesonbuild/interpreter/mesonmain.py +487 -0
- package/releng/meson/mesonbuild/interpreter/primitives/__init__.py +29 -0
- package/releng/meson/mesonbuild/interpreter/primitives/array.py +108 -0
- package/releng/meson/mesonbuild/interpreter/primitives/boolean.py +52 -0
- package/releng/meson/mesonbuild/interpreter/primitives/dict.py +88 -0
- package/releng/meson/mesonbuild/interpreter/primitives/integer.py +86 -0
- package/releng/meson/mesonbuild/interpreter/primitives/range.py +38 -0
- package/releng/meson/mesonbuild/interpreter/primitives/string.py +247 -0
- package/releng/meson/mesonbuild/interpreter/type_checking.py +853 -0
- package/releng/meson/mesonbuild/interpreterbase/__init__.py +126 -0
- package/releng/meson/mesonbuild/interpreterbase/_unholder.py +25 -0
- package/releng/meson/mesonbuild/interpreterbase/baseobjects.py +174 -0
- package/releng/meson/mesonbuild/interpreterbase/decorators.py +806 -0
- package/releng/meson/mesonbuild/interpreterbase/disabler.py +35 -0
- package/releng/meson/mesonbuild/interpreterbase/exceptions.py +22 -0
- package/releng/meson/mesonbuild/interpreterbase/helpers.py +67 -0
- package/releng/meson/mesonbuild/interpreterbase/interpreterbase.py +665 -0
- package/releng/meson/mesonbuild/interpreterbase/operator.py +32 -0
- package/releng/meson/mesonbuild/linkers/__init__.py +20 -0
- package/releng/meson/mesonbuild/linkers/base.py +39 -0
- package/releng/meson/mesonbuild/linkers/detect.py +229 -0
- package/releng/meson/mesonbuild/linkers/linkers.py +1614 -0
- package/releng/meson/mesonbuild/mcompile.py +380 -0
- package/releng/meson/mesonbuild/mconf.py +368 -0
- package/releng/meson/mesonbuild/mdevenv.py +234 -0
- package/releng/meson/mesonbuild/mdist.py +376 -0
- package/releng/meson/mesonbuild/mesondata.py +38 -0
- package/releng/meson/mesonbuild/mesonlib.py +23 -0
- package/releng/meson/mesonbuild/mesonmain.py +289 -0
- package/releng/meson/mesonbuild/minit.py +204 -0
- package/releng/meson/mesonbuild/minstall.py +864 -0
- package/releng/meson/mesonbuild/mintro.py +667 -0
- package/releng/meson/mesonbuild/mlog.py +542 -0
- package/releng/meson/mesonbuild/modules/__init__.py +270 -0
- package/releng/meson/mesonbuild/modules/cmake.py +442 -0
- package/releng/meson/mesonbuild/modules/cuda.py +377 -0
- package/releng/meson/mesonbuild/modules/dlang.py +117 -0
- package/releng/meson/mesonbuild/modules/external_project.py +306 -0
- package/releng/meson/mesonbuild/modules/fs.py +323 -0
- package/releng/meson/mesonbuild/modules/gnome.py +2215 -0
- package/releng/meson/mesonbuild/modules/hotdoc.py +487 -0
- package/releng/meson/mesonbuild/modules/i18n.py +405 -0
- package/releng/meson/mesonbuild/modules/icestorm.py +123 -0
- package/releng/meson/mesonbuild/modules/java.py +112 -0
- package/releng/meson/mesonbuild/modules/keyval.py +65 -0
- package/releng/meson/mesonbuild/modules/modtest.py +33 -0
- package/releng/meson/mesonbuild/modules/pkgconfig.py +744 -0
- package/releng/meson/mesonbuild/modules/python.py +556 -0
- package/releng/meson/mesonbuild/modules/python3.py +85 -0
- package/releng/meson/mesonbuild/modules/qt.py +621 -0
- package/releng/meson/mesonbuild/modules/qt4.py +23 -0
- package/releng/meson/mesonbuild/modules/qt5.py +23 -0
- package/releng/meson/mesonbuild/modules/qt6.py +22 -0
- package/releng/meson/mesonbuild/modules/rust.py +355 -0
- package/releng/meson/mesonbuild/modules/simd.py +114 -0
- package/releng/meson/mesonbuild/modules/sourceset.py +291 -0
- package/releng/meson/mesonbuild/modules/wayland.py +151 -0
- package/releng/meson/mesonbuild/modules/windows.py +207 -0
- package/releng/meson/mesonbuild/mparser.py +1114 -0
- package/releng/meson/mesonbuild/msetup.py +365 -0
- package/releng/meson/mesonbuild/msubprojects.py +764 -0
- package/releng/meson/mesonbuild/mtest.py +2201 -0
- package/releng/meson/mesonbuild/munstable_coredata.py +107 -0
- package/releng/meson/mesonbuild/optinterpreter.py +276 -0
- package/releng/meson/mesonbuild/programs.py +367 -0
- package/releng/meson/mesonbuild/rewriter.py +1075 -0
- package/releng/meson/mesonbuild/scripts/__init__.py +10 -0
- package/releng/meson/mesonbuild/scripts/clangformat.py +55 -0
- package/releng/meson/mesonbuild/scripts/clangtidy.py +30 -0
- package/releng/meson/mesonbuild/scripts/cleantrees.py +35 -0
- package/releng/meson/mesonbuild/scripts/cmake_run_ctgt.py +103 -0
- package/releng/meson/mesonbuild/scripts/cmd_or_ps.ps1 +17 -0
- package/releng/meson/mesonbuild/scripts/copy.py +19 -0
- package/releng/meson/mesonbuild/scripts/coverage.py +214 -0
- package/releng/meson/mesonbuild/scripts/delwithsuffix.py +27 -0
- package/releng/meson/mesonbuild/scripts/depfixer.py +495 -0
- package/releng/meson/mesonbuild/scripts/depscan.py +198 -0
- package/releng/meson/mesonbuild/scripts/dirchanger.py +20 -0
- package/releng/meson/mesonbuild/scripts/env2mfile.py +402 -0
- package/releng/meson/mesonbuild/scripts/externalproject.py +106 -0
- package/releng/meson/mesonbuild/scripts/gettext.py +86 -0
- package/releng/meson/mesonbuild/scripts/gtkdochelper.py +286 -0
- package/releng/meson/mesonbuild/scripts/hotdochelper.py +40 -0
- package/releng/meson/mesonbuild/scripts/itstool.py +77 -0
- package/releng/meson/mesonbuild/scripts/meson_exe.py +115 -0
- package/releng/meson/mesonbuild/scripts/msgfmthelper.py +29 -0
- package/releng/meson/mesonbuild/scripts/pycompile.py +54 -0
- package/releng/meson/mesonbuild/scripts/python_info.py +121 -0
- package/releng/meson/mesonbuild/scripts/regen_checker.py +55 -0
- package/releng/meson/mesonbuild/scripts/run_tool.py +58 -0
- package/releng/meson/mesonbuild/scripts/scanbuild.py +57 -0
- package/releng/meson/mesonbuild/scripts/symbolextractor.py +322 -0
- package/releng/meson/mesonbuild/scripts/tags.py +44 -0
- package/releng/meson/mesonbuild/scripts/test_loaded_modules.py +14 -0
- package/releng/meson/mesonbuild/scripts/uninstall.py +41 -0
- package/releng/meson/mesonbuild/scripts/vcstagger.py +35 -0
- package/releng/meson/mesonbuild/scripts/yasm.py +24 -0
- package/releng/meson/mesonbuild/templates/__init__.py +0 -0
- package/releng/meson/mesonbuild/templates/cpptemplates.py +143 -0
- package/releng/meson/mesonbuild/templates/cstemplates.py +90 -0
- package/releng/meson/mesonbuild/templates/ctemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/cudatemplates.py +143 -0
- package/releng/meson/mesonbuild/templates/dlangtemplates.py +109 -0
- package/releng/meson/mesonbuild/templates/fortrantemplates.py +101 -0
- package/releng/meson/mesonbuild/templates/javatemplates.py +94 -0
- package/releng/meson/mesonbuild/templates/mesontemplates.py +70 -0
- package/releng/meson/mesonbuild/templates/objcpptemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/objctemplates.py +126 -0
- package/releng/meson/mesonbuild/templates/rusttemplates.py +79 -0
- package/releng/meson/mesonbuild/templates/samplefactory.py +41 -0
- package/releng/meson/mesonbuild/templates/sampleimpl.py +160 -0
- package/releng/meson/mesonbuild/templates/valatemplates.py +82 -0
- package/releng/meson/mesonbuild/utils/__init__.py +0 -0
- package/releng/meson/mesonbuild/utils/core.py +166 -0
- package/releng/meson/mesonbuild/utils/platform.py +27 -0
- package/releng/meson/mesonbuild/utils/posix.py +32 -0
- package/releng/meson/mesonbuild/utils/universal.py +2445 -0
- package/releng/meson/mesonbuild/utils/vsenv.py +126 -0
- package/releng/meson/mesonbuild/utils/win32.py +29 -0
- package/releng/meson/mesonbuild/wrap/__init__.py +59 -0
- package/releng/meson/mesonbuild/wrap/wrap.py +846 -0
- package/releng/meson/mesonbuild/wrap/wraptool.py +198 -0
- package/releng/meson-scripts/BSDmakefile +6 -0
- package/releng/meson-scripts/Makefile +16 -0
- package/releng/meson-scripts/configure +18 -0
- package/releng/meson-scripts/configure.bat +22 -0
- package/releng/meson-scripts/make.bat +23 -0
- package/releng/meson_configure.py +506 -0
- package/releng/meson_make.py +131 -0
- package/releng/mkdevkit.py +107 -0
- package/releng/mkfatmacho.py +54 -0
- package/releng/post-process-oabi.py +97 -0
- package/releng/progress.py +14 -0
- package/releng/sync-from-upstream.py +185 -0
- package/releng/tomlkit/tomlkit/__init__.py +59 -0
- package/releng/tomlkit/tomlkit/_compat.py +22 -0
- package/releng/tomlkit/tomlkit/_types.py +83 -0
- package/releng/tomlkit/tomlkit/_utils.py +158 -0
- package/releng/tomlkit/tomlkit/api.py +308 -0
- package/releng/tomlkit/tomlkit/container.py +875 -0
- package/releng/tomlkit/tomlkit/exceptions.py +227 -0
- package/releng/tomlkit/tomlkit/items.py +1967 -0
- package/releng/tomlkit/tomlkit/parser.py +1141 -0
- package/releng/tomlkit/tomlkit/py.typed +0 -0
- package/releng/tomlkit/tomlkit/source.py +180 -0
- package/releng/tomlkit/tomlkit/toml_char.py +52 -0
- package/releng/tomlkit/tomlkit/toml_document.py +7 -0
- package/releng/tomlkit/tomlkit/toml_file.py +58 -0
- package/releng/winenv.py +140 -0
- package/scripts/adjust-version.py +19 -0
- package/scripts/detect-version.py +40 -0
- package/scripts/fetch-abi-bits.py +343 -0
- package/scripts/install.js +23 -0
- package/scripts/package.py +15 -0
- package/src/addon.cc +76 -0
- package/src/application.cc +148 -0
- package/src/application.h +31 -0
- package/src/authentication.cc +174 -0
- package/src/authentication.h +24 -0
- package/src/bus.cc +167 -0
- package/src/bus.h +33 -0
- package/src/cancellable.cc +117 -0
- package/src/cancellable.h +31 -0
- package/src/child.cc +150 -0
- package/src/child.h +32 -0
- package/src/crash.cc +122 -0
- package/src/crash.h +30 -0
- package/src/device.cc +1302 -0
- package/src/device.h +55 -0
- package/src/device_manager.cc +362 -0
- package/src/device_manager.h +35 -0
- package/src/endpoint_parameters.cc +171 -0
- package/src/endpoint_parameters.h +28 -0
- package/src/glib_context.cc +62 -0
- package/src/glib_context.h +29 -0
- package/src/glib_object.cc +25 -0
- package/src/glib_object.h +37 -0
- package/src/iostream.cc +247 -0
- package/src/iostream.h +30 -0
- package/src/meson.build +26 -0
- package/src/operation.h +94 -0
- package/src/portal_membership.cc +100 -0
- package/src/portal_membership.h +26 -0
- package/src/portal_service.cc +401 -0
- package/src/portal_service.h +40 -0
- package/src/process.cc +135 -0
- package/src/process.h +30 -0
- package/src/relay.cc +139 -0
- package/src/relay.h +31 -0
- package/src/runtime.cc +443 -0
- package/src/runtime.h +64 -0
- package/src/script.cc +301 -0
- package/src/script.h +36 -0
- package/src/session.cc +860 -0
- package/src/session.h +42 -0
- package/src/signals.cc +334 -0
- package/src/signals.h +47 -0
- package/src/spawn.cc +95 -0
- package/src/spawn.h +27 -0
- package/src/usage_monitor.h +117 -0
- package/src/uv_context.cc +118 -0
- package/src/uv_context.h +40 -0
- package/src/win_delay_load_hook.cc +63 -0
- package/subprojects/frida-core.wrap +8 -0
- package/subprojects/nan.wrap +9 -0
- package/subprojects/packagefiles/nan.patch +13 -0
- package/test/data/index.ts +13 -0
- package/test/data/unixvictim-linux-x86 +0 -0
- package/test/data/unixvictim-linux-x86_64 +0 -0
- package/test/data/unixvictim-macos +0 -0
- package/test/device.ts +27 -0
- package/test/device_manager.ts +16 -0
- package/test/labrat.ts +32 -0
- package/test/script.ts +176 -0
- package/test/session.ts +73 -0
- package/tsconfig.json +18 -0
|
@@ -0,0 +1,806 @@
|
|
|
1
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
# Copyright 2012-2017 The Meson development team
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import enum
|
|
7
|
+
import os.path
|
|
8
|
+
import string
|
|
9
|
+
import typing as T
|
|
10
|
+
|
|
11
|
+
from .. import coredata
|
|
12
|
+
from .. import mlog
|
|
13
|
+
from ..mesonlib import (
|
|
14
|
+
EnvironmentException, Popen_safe,
|
|
15
|
+
is_windows, LibType, OptionKey, version_compare,
|
|
16
|
+
)
|
|
17
|
+
from .compilers import Compiler
|
|
18
|
+
|
|
19
|
+
if T.TYPE_CHECKING:
|
|
20
|
+
from .compilers import CompileCheckMode
|
|
21
|
+
from ..build import BuildTarget
|
|
22
|
+
from ..coredata import MutableKeyedOptionDictType, KeyedOptionDictType
|
|
23
|
+
from ..dependencies import Dependency
|
|
24
|
+
from ..environment import Environment # noqa: F401
|
|
25
|
+
from ..envconfig import MachineInfo
|
|
26
|
+
from ..linkers.linkers import DynamicLinker
|
|
27
|
+
from ..mesonlib import MachineChoice
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
cuda_optimization_args: T.Dict[str, T.List[str]] = {
|
|
31
|
+
'plain': [],
|
|
32
|
+
'0': ['-G'],
|
|
33
|
+
'g': ['-O0'],
|
|
34
|
+
'1': ['-O1'],
|
|
35
|
+
'2': ['-O2', '-lineinfo'],
|
|
36
|
+
'3': ['-O3'],
|
|
37
|
+
's': ['-O3']
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
cuda_debug_args: T.Dict[bool, T.List[str]] = {
|
|
41
|
+
False: [],
|
|
42
|
+
True: ['-g']
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class _Phase(enum.Enum):
|
|
47
|
+
|
|
48
|
+
COMPILER = 'compiler'
|
|
49
|
+
LINKER = 'linker'
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class CudaCompiler(Compiler):
|
|
53
|
+
|
|
54
|
+
LINKER_PREFIX = '-Xlinker='
|
|
55
|
+
language = 'cuda'
|
|
56
|
+
|
|
57
|
+
# NVCC flags taking no arguments.
|
|
58
|
+
_FLAG_PASSTHRU_NOARGS = {
|
|
59
|
+
# NVCC --long-option, NVCC -short-option CUDA Toolkit 11.2.1 Reference
|
|
60
|
+
'--objdir-as-tempdir', '-objtemp', # 4.2.1.2
|
|
61
|
+
'--generate-dependency-targets', '-MP', # 4.2.1.12
|
|
62
|
+
'--allow-unsupported-compiler', '-allow-unsupported-compiler', # 4.2.1.14
|
|
63
|
+
'--link', # 4.2.2.1
|
|
64
|
+
'--lib', '-lib', # 4.2.2.2
|
|
65
|
+
'--device-link', '-dlink', # 4.2.2.3
|
|
66
|
+
'--device-c', '-dc', # 4.2.2.4
|
|
67
|
+
'--device-w', '-dw', # 4.2.2.5
|
|
68
|
+
'--cuda', '-cuda', # 4.2.2.6
|
|
69
|
+
'--compile', '-c', # 4.2.2.7
|
|
70
|
+
'--fatbin', '-fatbin', # 4.2.2.8
|
|
71
|
+
'--cubin', '-cubin', # 4.2.2.9
|
|
72
|
+
'--ptx', '-ptx', # 4.2.2.10
|
|
73
|
+
'--preprocess', '-E', # 4.2.2.11
|
|
74
|
+
'--generate-dependencies', '-M', # 4.2.2.12
|
|
75
|
+
'--generate-nonsystem-dependencies', '-MM', # 4.2.2.13
|
|
76
|
+
'--generate-dependencies-with-compile', '-MD', # 4.2.2.14
|
|
77
|
+
'--generate-nonsystem-dependencies-with-compile', '-MMD', # 4.2.2.15
|
|
78
|
+
'--run', # 4.2.2.16
|
|
79
|
+
'--profile', '-pg', # 4.2.3.1
|
|
80
|
+
'--debug', '-g', # 4.2.3.2
|
|
81
|
+
'--device-debug', '-G', # 4.2.3.3
|
|
82
|
+
'--extensible-whole-program', '-ewp', # 4.2.3.4
|
|
83
|
+
'--generate-line-info', '-lineinfo', # 4.2.3.5
|
|
84
|
+
'--dlink-time-opt', '-dlto', # 4.2.3.8
|
|
85
|
+
'--no-exceptions', '-noeh', # 4.2.3.11
|
|
86
|
+
'--shared', '-shared', # 4.2.3.12
|
|
87
|
+
'--no-host-device-initializer-list', '-nohdinitlist', # 4.2.3.15
|
|
88
|
+
'--expt-relaxed-constexpr', '-expt-relaxed-constexpr', # 4.2.3.16
|
|
89
|
+
'--extended-lambda', '-extended-lambda', # 4.2.3.17
|
|
90
|
+
'--expt-extended-lambda', '-expt-extended-lambda', # 4.2.3.18
|
|
91
|
+
'--m32', '-m32', # 4.2.3.20
|
|
92
|
+
'--m64', '-m64', # 4.2.3.21
|
|
93
|
+
'--forward-unknown-to-host-compiler', '-forward-unknown-to-host-compiler', # 4.2.5.1
|
|
94
|
+
'--forward-unknown-to-host-linker', '-forward-unknown-to-host-linker', # 4.2.5.2
|
|
95
|
+
'--dont-use-profile', '-noprof', # 4.2.5.3
|
|
96
|
+
'--dryrun', '-dryrun', # 4.2.5.5
|
|
97
|
+
'--verbose', '-v', # 4.2.5.6
|
|
98
|
+
'--keep', '-keep', # 4.2.5.7
|
|
99
|
+
'--save-temps', '-save-temps', # 4.2.5.9
|
|
100
|
+
'--clean-targets', '-clean', # 4.2.5.10
|
|
101
|
+
'--no-align-double', # 4.2.5.16
|
|
102
|
+
'--no-device-link', '-nodlink', # 4.2.5.17
|
|
103
|
+
'--allow-unsupported-compiler', '-allow-unsupported-compiler', # 4.2.5.18
|
|
104
|
+
'--use_fast_math', '-use_fast_math', # 4.2.7.7
|
|
105
|
+
'--extra-device-vectorization', '-extra-device-vectorization', # 4.2.7.12
|
|
106
|
+
'--compile-as-tools-patch', '-astoolspatch', # 4.2.7.13
|
|
107
|
+
'--keep-device-functions', '-keep-device-functions', # 4.2.7.14
|
|
108
|
+
'--disable-warnings', '-w', # 4.2.8.1
|
|
109
|
+
'--source-in-ptx', '-src-in-ptx', # 4.2.8.2
|
|
110
|
+
'--restrict', '-restrict', # 4.2.8.3
|
|
111
|
+
'--Wno-deprecated-gpu-targets', '-Wno-deprecated-gpu-targets', # 4.2.8.4
|
|
112
|
+
'--Wno-deprecated-declarations', '-Wno-deprecated-declarations', # 4.2.8.5
|
|
113
|
+
'--Wreorder', '-Wreorder', # 4.2.8.6
|
|
114
|
+
'--Wdefault-stream-launch', '-Wdefault-stream-launch', # 4.2.8.7
|
|
115
|
+
'--Wext-lambda-captures-this', '-Wext-lambda-captures-this', # 4.2.8.8
|
|
116
|
+
'--display-error-number', '-err-no', # 4.2.8.10
|
|
117
|
+
'--resource-usage', '-res-usage', # 4.2.8.14
|
|
118
|
+
'--help', '-h', # 4.2.8.15
|
|
119
|
+
'--version', '-V', # 4.2.8.16
|
|
120
|
+
'--list-gpu-code', '-code-ls', # 4.2.8.20
|
|
121
|
+
'--list-gpu-arch', '-arch-ls', # 4.2.8.21
|
|
122
|
+
}
|
|
123
|
+
# Dictionary of NVCC flags taking either one argument or a comma-separated list.
|
|
124
|
+
# Maps --long to -short options, because the short options are more GCC-like.
|
|
125
|
+
_FLAG_LONG2SHORT_WITHARGS = {
|
|
126
|
+
'--output-file': '-o', # 4.2.1.1
|
|
127
|
+
'--pre-include': '-include', # 4.2.1.3
|
|
128
|
+
'--library': '-l', # 4.2.1.4
|
|
129
|
+
'--define-macro': '-D', # 4.2.1.5
|
|
130
|
+
'--undefine-macro': '-U', # 4.2.1.6
|
|
131
|
+
'--include-path': '-I', # 4.2.1.7
|
|
132
|
+
'--system-include': '-isystem', # 4.2.1.8
|
|
133
|
+
'--library-path': '-L', # 4.2.1.9
|
|
134
|
+
'--output-directory': '-odir', # 4.2.1.10
|
|
135
|
+
'--dependency-output': '-MF', # 4.2.1.11
|
|
136
|
+
'--compiler-bindir': '-ccbin', # 4.2.1.13
|
|
137
|
+
'--archiver-binary': '-arbin', # 4.2.1.15
|
|
138
|
+
'--cudart': '-cudart', # 4.2.1.16
|
|
139
|
+
'--cudadevrt': '-cudadevrt', # 4.2.1.17
|
|
140
|
+
'--libdevice-directory': '-ldir', # 4.2.1.18
|
|
141
|
+
'--target-directory': '-target-dir', # 4.2.1.19
|
|
142
|
+
'--optimization-info': '-opt-info', # 4.2.3.6
|
|
143
|
+
'--optimize': '-O', # 4.2.3.7
|
|
144
|
+
'--ftemplate-backtrace-limit': '-ftemplate-backtrace-limit', # 4.2.3.9
|
|
145
|
+
'--ftemplate-depth': '-ftemplate-depth', # 4.2.3.10
|
|
146
|
+
'--x': '-x', # 4.2.3.13
|
|
147
|
+
'--std': '-std', # 4.2.3.14
|
|
148
|
+
'--machine': '-m', # 4.2.3.19
|
|
149
|
+
'--compiler-options': '-Xcompiler', # 4.2.4.1
|
|
150
|
+
'--linker-options': '-Xlinker', # 4.2.4.2
|
|
151
|
+
'--archive-options': '-Xarchive', # 4.2.4.3
|
|
152
|
+
'--ptxas-options': '-Xptxas', # 4.2.4.4
|
|
153
|
+
'--nvlink-options': '-Xnvlink', # 4.2.4.5
|
|
154
|
+
'--threads': '-t', # 4.2.5.4
|
|
155
|
+
'--keep-dir': '-keep-dir', # 4.2.5.8
|
|
156
|
+
'--run-args': '-run-args', # 4.2.5.11
|
|
157
|
+
'--input-drive-prefix': '-idp', # 4.2.5.12
|
|
158
|
+
'--dependency-drive-prefix': '-ddp', # 4.2.5.13
|
|
159
|
+
'--drive-prefix': '-dp', # 4.2.5.14
|
|
160
|
+
'--dependency-target-name': '-MT', # 4.2.5.15
|
|
161
|
+
'--default-stream': '-default-stream', # 4.2.6.1
|
|
162
|
+
'--gpu-architecture': '-arch', # 4.2.7.1
|
|
163
|
+
'--gpu-code': '-code', # 4.2.7.2
|
|
164
|
+
'--generate-code': '-gencode', # 4.2.7.3
|
|
165
|
+
'--relocatable-device-code': '-rdc', # 4.2.7.4
|
|
166
|
+
'--entries': '-e', # 4.2.7.5
|
|
167
|
+
'--maxrregcount': '-maxrregcount', # 4.2.7.6
|
|
168
|
+
'--ftz': '-ftz', # 4.2.7.8
|
|
169
|
+
'--prec-div': '-prec-div', # 4.2.7.9
|
|
170
|
+
'--prec-sqrt': '-prec-sqrt', # 4.2.7.10
|
|
171
|
+
'--fmad': '-fmad', # 4.2.7.11
|
|
172
|
+
'--Werror': '-Werror', # 4.2.8.9
|
|
173
|
+
'--diag-error': '-diag-error', # 4.2.8.11
|
|
174
|
+
'--diag-suppress': '-diag-suppress', # 4.2.8.12
|
|
175
|
+
'--diag-warn': '-diag-warn', # 4.2.8.13
|
|
176
|
+
'--options-file': '-optf', # 4.2.8.17
|
|
177
|
+
'--time': '-time', # 4.2.8.18
|
|
178
|
+
'--qpp-config': '-qpp-config', # 4.2.8.19
|
|
179
|
+
}
|
|
180
|
+
# Reverse map -short to --long options.
|
|
181
|
+
_FLAG_SHORT2LONG_WITHARGS = {v: k for k, v in _FLAG_LONG2SHORT_WITHARGS.items()}
|
|
182
|
+
|
|
183
|
+
id = 'nvcc'
|
|
184
|
+
|
|
185
|
+
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, for_machine: MachineChoice,
|
|
186
|
+
is_cross: bool,
|
|
187
|
+
host_compiler: Compiler, info: 'MachineInfo',
|
|
188
|
+
linker: T.Optional['DynamicLinker'] = None,
|
|
189
|
+
full_version: T.Optional[str] = None):
|
|
190
|
+
super().__init__(ccache, exelist, version, for_machine, info, linker=linker, full_version=full_version, is_cross=is_cross)
|
|
191
|
+
self.host_compiler = host_compiler
|
|
192
|
+
self.base_options = host_compiler.base_options
|
|
193
|
+
# -Wpedantic generates useless churn due to nvcc's dual compilation model producing
|
|
194
|
+
# a temporary host C++ file that includes gcc-style line directives:
|
|
195
|
+
# https://stackoverflow.com/a/31001220
|
|
196
|
+
self.warn_args = {
|
|
197
|
+
level: self._to_host_flags(list(f for f in flags if f != '-Wpedantic'))
|
|
198
|
+
for level, flags in host_compiler.warn_args.items()
|
|
199
|
+
}
|
|
200
|
+
self.host_werror_args = ['-Xcompiler=' + x for x in self.host_compiler.get_werror_args()]
|
|
201
|
+
|
|
202
|
+
@classmethod
|
|
203
|
+
def _shield_nvcc_list_arg(cls, arg: str, listmode: bool = True) -> str:
|
|
204
|
+
r"""
|
|
205
|
+
Shield an argument against both splitting by NVCC's list-argument
|
|
206
|
+
parse logic, and interpretation by any shell.
|
|
207
|
+
|
|
208
|
+
NVCC seems to consider every comma , that is neither escaped by \ nor inside
|
|
209
|
+
a double-quoted string a split-point. Single-quotes do not provide protection
|
|
210
|
+
against splitting; In fact, after splitting they are \-escaped. Unfortunately,
|
|
211
|
+
double-quotes don't protect against shell expansion. What follows is a
|
|
212
|
+
complex dance to accommodate everybody.
|
|
213
|
+
"""
|
|
214
|
+
|
|
215
|
+
SQ = "'"
|
|
216
|
+
DQ = '"'
|
|
217
|
+
CM = ","
|
|
218
|
+
BS = "\\"
|
|
219
|
+
DQSQ = DQ+SQ+DQ
|
|
220
|
+
quotable = set(string.whitespace+'"$`\\')
|
|
221
|
+
|
|
222
|
+
if CM not in arg or not listmode:
|
|
223
|
+
if SQ not in arg:
|
|
224
|
+
# If any of the special characters "$`\ or whitespace are present, single-quote.
|
|
225
|
+
# Otherwise return bare.
|
|
226
|
+
if set(arg).intersection(quotable):
|
|
227
|
+
return SQ+arg+SQ
|
|
228
|
+
else:
|
|
229
|
+
return arg # Easy case: no splits, no quoting.
|
|
230
|
+
else:
|
|
231
|
+
# There are single quotes. Double-quote them, and single-quote the
|
|
232
|
+
# strings between them.
|
|
233
|
+
l = [cls._shield_nvcc_list_arg(s) for s in arg.split(SQ)]
|
|
234
|
+
l = sum([[s, DQSQ] for s in l][:-1], []) # Interleave l with DQSQs
|
|
235
|
+
return ''.join(l)
|
|
236
|
+
else:
|
|
237
|
+
# A comma is present, and list mode was active.
|
|
238
|
+
# We apply (what we guess is) the (primitive) NVCC splitting rule:
|
|
239
|
+
l = ['']
|
|
240
|
+
instring = False
|
|
241
|
+
argit = iter(arg)
|
|
242
|
+
for c in argit:
|
|
243
|
+
if c == CM and not instring:
|
|
244
|
+
l.append('')
|
|
245
|
+
elif c == DQ:
|
|
246
|
+
l[-1] += c
|
|
247
|
+
instring = not instring
|
|
248
|
+
elif c == BS:
|
|
249
|
+
try:
|
|
250
|
+
l[-1] += next(argit)
|
|
251
|
+
except StopIteration:
|
|
252
|
+
break
|
|
253
|
+
else:
|
|
254
|
+
l[-1] += c
|
|
255
|
+
|
|
256
|
+
# Shield individual strings, without listmode, then return them with
|
|
257
|
+
# escaped commas between them.
|
|
258
|
+
l = [cls._shield_nvcc_list_arg(s, listmode=False) for s in l]
|
|
259
|
+
return r'\,'.join(l)
|
|
260
|
+
|
|
261
|
+
@classmethod
|
|
262
|
+
def _merge_flags(cls, flags: T.List[str]) -> T.List[str]:
|
|
263
|
+
r"""
|
|
264
|
+
The flags to NVCC gets exceedingly verbose and unreadable when too many of them
|
|
265
|
+
are shielded with -Xcompiler. Merge consecutive -Xcompiler-wrapped arguments
|
|
266
|
+
into one.
|
|
267
|
+
"""
|
|
268
|
+
if len(flags) <= 1:
|
|
269
|
+
return flags
|
|
270
|
+
flagit = iter(flags)
|
|
271
|
+
xflags = []
|
|
272
|
+
|
|
273
|
+
def is_xcompiler_flag_isolated(flag: str) -> bool:
|
|
274
|
+
return flag == '-Xcompiler'
|
|
275
|
+
|
|
276
|
+
def is_xcompiler_flag_glued(flag: str) -> bool:
|
|
277
|
+
return flag.startswith('-Xcompiler=')
|
|
278
|
+
|
|
279
|
+
def is_xcompiler_flag(flag: str) -> bool:
|
|
280
|
+
return is_xcompiler_flag_isolated(flag) or is_xcompiler_flag_glued(flag)
|
|
281
|
+
|
|
282
|
+
def get_xcompiler_val(flag: str, flagit: T.Iterator[str]) -> str:
|
|
283
|
+
if is_xcompiler_flag_glued(flag):
|
|
284
|
+
return flag[len('-Xcompiler='):]
|
|
285
|
+
else:
|
|
286
|
+
try:
|
|
287
|
+
return next(flagit)
|
|
288
|
+
except StopIteration:
|
|
289
|
+
return ""
|
|
290
|
+
|
|
291
|
+
ingroup = False
|
|
292
|
+
for flag in flagit:
|
|
293
|
+
if not is_xcompiler_flag(flag):
|
|
294
|
+
ingroup = False
|
|
295
|
+
xflags.append(flag)
|
|
296
|
+
elif ingroup:
|
|
297
|
+
xflags[-1] += ','
|
|
298
|
+
xflags[-1] += get_xcompiler_val(flag, flagit)
|
|
299
|
+
elif is_xcompiler_flag_isolated(flag):
|
|
300
|
+
ingroup = True
|
|
301
|
+
xflags.append(flag)
|
|
302
|
+
xflags.append(get_xcompiler_val(flag, flagit))
|
|
303
|
+
elif is_xcompiler_flag_glued(flag):
|
|
304
|
+
ingroup = True
|
|
305
|
+
xflags.append(flag)
|
|
306
|
+
else:
|
|
307
|
+
raise ValueError("-Xcompiler flag merging failed, unknown argument form!")
|
|
308
|
+
return xflags
|
|
309
|
+
|
|
310
|
+
def _to_host_flags(self, flags: T.List[str], phase: _Phase = _Phase.COMPILER) -> T.List[str]:
|
|
311
|
+
"""
|
|
312
|
+
Translate generic "GCC-speak" plus particular "NVCC-speak" flags to NVCC flags.
|
|
313
|
+
|
|
314
|
+
NVCC's "short" flags have broad similarities to the GCC standard, but have
|
|
315
|
+
gratuitous, irritating differences.
|
|
316
|
+
"""
|
|
317
|
+
|
|
318
|
+
xflags = []
|
|
319
|
+
flagit = iter(flags)
|
|
320
|
+
|
|
321
|
+
for flag in flagit:
|
|
322
|
+
# The CUDA Toolkit Documentation, in 4.1. Command Option Types and Notation,
|
|
323
|
+
# specifies that NVCC does not parse the standard flags as GCC does. It has
|
|
324
|
+
# its own strategy, to wit:
|
|
325
|
+
#
|
|
326
|
+
# nvcc recognizes three types of command options: boolean options, single
|
|
327
|
+
# value options, and list options.
|
|
328
|
+
#
|
|
329
|
+
# Boolean options do not have an argument; they are either specified on a
|
|
330
|
+
# command line or not. Single value options must be specified at most once,
|
|
331
|
+
# and list options may be repeated. Examples of each of these option types
|
|
332
|
+
# are, respectively: --verbose (switch to verbose mode), --output-file
|
|
333
|
+
# (specify output file), and --include-path (specify include path).
|
|
334
|
+
#
|
|
335
|
+
# Single value options and list options must have arguments, which must
|
|
336
|
+
# follow the name of the option itself by either one of more spaces or an
|
|
337
|
+
# equals character. When a one-character short name such as -I, -l, and -L
|
|
338
|
+
# is used, the value of the option may also immediately follow the option
|
|
339
|
+
# itself without being separated by spaces or an equal character. The
|
|
340
|
+
# individual values of list options may be separated by commas in a single
|
|
341
|
+
# instance of the option, or the option may be repeated, or any
|
|
342
|
+
# combination of these two cases.
|
|
343
|
+
#
|
|
344
|
+
# One strange consequence of this choice is that directory and filenames that
|
|
345
|
+
# contain commas (',') cannot be passed to NVCC (at least, not as easily as
|
|
346
|
+
# in GCC). Another strange consequence is that it is legal to supply flags
|
|
347
|
+
# such as
|
|
348
|
+
#
|
|
349
|
+
# -lpthread,rt,dl,util
|
|
350
|
+
# -l pthread,rt,dl,util
|
|
351
|
+
# -l=pthread,rt,dl,util
|
|
352
|
+
#
|
|
353
|
+
# and each of the above alternatives is equivalent to GCC-speak
|
|
354
|
+
#
|
|
355
|
+
# -lpthread -lrt -ldl -lutil
|
|
356
|
+
# -l pthread -l rt -l dl -l util
|
|
357
|
+
# -l=pthread -l=rt -l=dl -l=util
|
|
358
|
+
#
|
|
359
|
+
# *With the exception of commas in the name*, GCC-speak for these list flags
|
|
360
|
+
# is a strict subset of NVCC-speak, so we passthrough those flags.
|
|
361
|
+
#
|
|
362
|
+
# The -D macro-define flag is documented as somehow shielding commas from
|
|
363
|
+
# splitting a definition. Balanced parentheses, braces and single-quotes
|
|
364
|
+
# around the comma are not sufficient, but balanced double-quotes are. The
|
|
365
|
+
# shielding appears to work with -l, -I, -L flags as well, for instance.
|
|
366
|
+
#
|
|
367
|
+
# Since our goal is to replicate GCC-speak as much as possible, we check for
|
|
368
|
+
# commas in all list-arguments and shield them with double-quotes. We make
|
|
369
|
+
# an exception for -D (where this would be value-changing) and -U (because
|
|
370
|
+
# it isn't possible to define a macro with a comma in the name).
|
|
371
|
+
|
|
372
|
+
if flag in self._FLAG_PASSTHRU_NOARGS:
|
|
373
|
+
xflags.append(flag)
|
|
374
|
+
continue
|
|
375
|
+
|
|
376
|
+
# Handle breakup of flag-values into a flag-part and value-part.
|
|
377
|
+
if flag[:1] not in '-/':
|
|
378
|
+
# This is not a flag. It's probably a file input. Pass it through.
|
|
379
|
+
xflags.append(flag)
|
|
380
|
+
continue
|
|
381
|
+
elif flag[:1] == '/':
|
|
382
|
+
# This is ambiguously either an MVSC-style /switch or an absolute path
|
|
383
|
+
# to a file. For some magical reason the following works acceptably in
|
|
384
|
+
# both cases.
|
|
385
|
+
wrap = '"' if ',' in flag else ''
|
|
386
|
+
xflags.append(f'-X{phase.value}={wrap}{flag}{wrap}')
|
|
387
|
+
continue
|
|
388
|
+
elif len(flag) >= 2 and flag[0] == '-' and flag[1] in 'IDULlmOxmte':
|
|
389
|
+
# This is a single-letter short option. These options (with the
|
|
390
|
+
# exception of -o) are allowed to receive their argument with neither
|
|
391
|
+
# space nor = sign before them. Detect and separate them in that event.
|
|
392
|
+
if flag[2:3] == '': # -I something
|
|
393
|
+
try:
|
|
394
|
+
val = next(flagit)
|
|
395
|
+
except StopIteration:
|
|
396
|
+
pass
|
|
397
|
+
elif flag[2:3] == '=': # -I=something
|
|
398
|
+
val = flag[3:]
|
|
399
|
+
else: # -Isomething
|
|
400
|
+
val = flag[2:]
|
|
401
|
+
flag = flag[:2] # -I
|
|
402
|
+
elif flag in self._FLAG_LONG2SHORT_WITHARGS or \
|
|
403
|
+
flag in self._FLAG_SHORT2LONG_WITHARGS:
|
|
404
|
+
# This is either -o or a multi-letter flag, and it is receiving its
|
|
405
|
+
# value isolated.
|
|
406
|
+
try:
|
|
407
|
+
val = next(flagit) # -o something
|
|
408
|
+
except StopIteration:
|
|
409
|
+
pass
|
|
410
|
+
elif flag.split('=', 1)[0] in self._FLAG_LONG2SHORT_WITHARGS or \
|
|
411
|
+
flag.split('=', 1)[0] in self._FLAG_SHORT2LONG_WITHARGS:
|
|
412
|
+
# This is either -o or a multi-letter flag, and it is receiving its
|
|
413
|
+
# value after an = sign.
|
|
414
|
+
flag, val = flag.split('=', 1) # -o=something
|
|
415
|
+
# Some dependencies (e.g., BoostDependency) add unspaced "-isystem/usr/include" arguments
|
|
416
|
+
elif flag.startswith('-isystem'):
|
|
417
|
+
val = flag[8:].strip()
|
|
418
|
+
flag = flag[:8]
|
|
419
|
+
else:
|
|
420
|
+
# This is a flag, and it's foreign to NVCC.
|
|
421
|
+
#
|
|
422
|
+
# We do not know whether this GCC-speak flag takes an isolated
|
|
423
|
+
# argument. Assuming it does not (the vast majority indeed don't),
|
|
424
|
+
# wrap this argument in an -Xcompiler flag and send it down to NVCC.
|
|
425
|
+
if flag == '-ffast-math':
|
|
426
|
+
xflags.append('-use_fast_math')
|
|
427
|
+
xflags.append('-Xcompiler='+flag)
|
|
428
|
+
elif flag == '-fno-fast-math':
|
|
429
|
+
xflags.append('-ftz=false')
|
|
430
|
+
xflags.append('-prec-div=true')
|
|
431
|
+
xflags.append('-prec-sqrt=true')
|
|
432
|
+
xflags.append('-Xcompiler='+flag)
|
|
433
|
+
elif flag == '-freciprocal-math':
|
|
434
|
+
xflags.append('-prec-div=false')
|
|
435
|
+
xflags.append('-Xcompiler='+flag)
|
|
436
|
+
elif flag == '-fno-reciprocal-math':
|
|
437
|
+
xflags.append('-prec-div=true')
|
|
438
|
+
xflags.append('-Xcompiler='+flag)
|
|
439
|
+
else:
|
|
440
|
+
xflags.append('-Xcompiler='+self._shield_nvcc_list_arg(flag))
|
|
441
|
+
# The above should securely handle GCC's -Wl, -Wa, -Wp, arguments.
|
|
442
|
+
continue
|
|
443
|
+
|
|
444
|
+
assert val is not None # Should only trip if there is a missing argument.
|
|
445
|
+
|
|
446
|
+
# Take care of the various NVCC-supported flags that need special handling.
|
|
447
|
+
flag = self._FLAG_LONG2SHORT_WITHARGS.get(flag, flag)
|
|
448
|
+
|
|
449
|
+
if flag in {'-include', '-isystem', '-I', '-L', '-l'}:
|
|
450
|
+
# These flags are known to GCC, but list-valued in NVCC. They potentially
|
|
451
|
+
# require double-quoting to prevent NVCC interpreting the flags as lists
|
|
452
|
+
# when GCC would not have done so.
|
|
453
|
+
#
|
|
454
|
+
# We avoid doing this quoting for -D to avoid redefining macros and for
|
|
455
|
+
# -U because it isn't possible to define a macro with a comma in the name.
|
|
456
|
+
# -U with comma arguments is impossible in GCC-speak (and thus unambiguous
|
|
457
|
+
#in NVCC-speak, albeit unportable).
|
|
458
|
+
if len(flag) == 2:
|
|
459
|
+
xflags.append(flag+self._shield_nvcc_list_arg(val))
|
|
460
|
+
elif flag == '-isystem' and val in self.host_compiler.get_default_include_dirs():
|
|
461
|
+
# like GnuLikeCompiler, we have to filter out include directories specified
|
|
462
|
+
# with -isystem that overlap with the host compiler's search path
|
|
463
|
+
pass
|
|
464
|
+
else:
|
|
465
|
+
xflags.append(flag)
|
|
466
|
+
xflags.append(self._shield_nvcc_list_arg(val))
|
|
467
|
+
elif flag == '-O':
|
|
468
|
+
# Handle optimization levels GCC knows about that NVCC does not.
|
|
469
|
+
if val == 'fast':
|
|
470
|
+
xflags.append('-O3')
|
|
471
|
+
xflags.append('-use_fast_math')
|
|
472
|
+
xflags.append('-Xcompiler')
|
|
473
|
+
xflags.append(flag+val)
|
|
474
|
+
elif val in {'s', 'g', 'z'}:
|
|
475
|
+
xflags.append('-Xcompiler')
|
|
476
|
+
xflags.append(flag+val)
|
|
477
|
+
else:
|
|
478
|
+
xflags.append(flag+val)
|
|
479
|
+
elif flag in {'-D', '-U', '-m', '-t'}:
|
|
480
|
+
xflags.append(flag+val) # For style, keep glued.
|
|
481
|
+
elif flag in {'-std'}:
|
|
482
|
+
xflags.append(flag+'='+val) # For style, keep glued.
|
|
483
|
+
else:
|
|
484
|
+
xflags.append(flag)
|
|
485
|
+
xflags.append(val)
|
|
486
|
+
|
|
487
|
+
return self._merge_flags(xflags)
|
|
488
|
+
|
|
489
|
+
def needs_static_linker(self) -> bool:
|
|
490
|
+
return False
|
|
491
|
+
|
|
492
|
+
def thread_link_flags(self, environment: 'Environment') -> T.List[str]:
|
|
493
|
+
return self._to_host_flags(self.host_compiler.thread_link_flags(environment), _Phase.LINKER)
|
|
494
|
+
|
|
495
|
+
def sanity_check(self, work_dir: str, env: 'Environment') -> None:
|
|
496
|
+
mlog.debug('Sanity testing ' + self.get_display_language() + ' compiler:', ' '.join(self.exelist))
|
|
497
|
+
mlog.debug('Is cross compiler: %s.' % str(self.is_cross))
|
|
498
|
+
|
|
499
|
+
sname = 'sanitycheckcuda.cu'
|
|
500
|
+
code = r'''
|
|
501
|
+
#include <cuda_runtime.h>
|
|
502
|
+
#include <stdio.h>
|
|
503
|
+
|
|
504
|
+
__global__ void kernel (void) {}
|
|
505
|
+
|
|
506
|
+
int main(void){
|
|
507
|
+
struct cudaDeviceProp prop;
|
|
508
|
+
int count, i;
|
|
509
|
+
cudaError_t ret = cudaGetDeviceCount(&count);
|
|
510
|
+
if(ret != cudaSuccess){
|
|
511
|
+
fprintf(stderr, "%d\n", (int)ret);
|
|
512
|
+
}else{
|
|
513
|
+
for(i=0;i<count;i++){
|
|
514
|
+
if(cudaGetDeviceProperties(&prop, i) == cudaSuccess){
|
|
515
|
+
fprintf(stdout, "%d.%d\n", prop.major, prop.minor);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
fflush(stderr);
|
|
520
|
+
fflush(stdout);
|
|
521
|
+
return 0;
|
|
522
|
+
}
|
|
523
|
+
'''
|
|
524
|
+
binname = sname.rsplit('.', 1)[0]
|
|
525
|
+
binname += '_cross' if self.is_cross else ''
|
|
526
|
+
source_name = os.path.join(work_dir, sname)
|
|
527
|
+
binary_name = os.path.join(work_dir, binname + '.exe')
|
|
528
|
+
with open(source_name, 'w', encoding='utf-8') as ofile:
|
|
529
|
+
ofile.write(code)
|
|
530
|
+
|
|
531
|
+
# The Sanity Test for CUDA language will serve as both a sanity test
|
|
532
|
+
# and a native-build GPU architecture detection test, useful later.
|
|
533
|
+
#
|
|
534
|
+
# For this second purpose, NVCC has very handy flags, --run and
|
|
535
|
+
# --run-args, that allow one to run an application with the
|
|
536
|
+
# environment set up properly. Of course, this only works for native
|
|
537
|
+
# builds; For cross builds we must still use the exe_wrapper (if any).
|
|
538
|
+
self.detected_cc = ''
|
|
539
|
+
flags = []
|
|
540
|
+
|
|
541
|
+
# Disable warnings, compile with statically-linked runtime for minimum
|
|
542
|
+
# reliance on the system.
|
|
543
|
+
flags += ['-w', '-cudart', 'static', source_name]
|
|
544
|
+
|
|
545
|
+
# Use the -ccbin option, if available, even during sanity checking.
|
|
546
|
+
# Otherwise, on systems where CUDA does not support the default compiler,
|
|
547
|
+
# NVCC becomes unusable.
|
|
548
|
+
flags += self.get_ccbin_args(env.coredata.options)
|
|
549
|
+
|
|
550
|
+
# If cross-compiling, we can't run the sanity check, only compile it.
|
|
551
|
+
if env.need_exe_wrapper(self.for_machine) and not env.has_exe_wrapper():
|
|
552
|
+
# Linking cross built apps is painful. You can't really
|
|
553
|
+
# tell if you should use -nostdlib or not and for example
|
|
554
|
+
# on OSX the compiler binary is the same but you need
|
|
555
|
+
# a ton of compiler flags to differentiate between
|
|
556
|
+
# arm and x86_64. So just compile.
|
|
557
|
+
flags += self.get_compile_only_args()
|
|
558
|
+
flags += self.get_output_args(binary_name)
|
|
559
|
+
|
|
560
|
+
# Compile sanity check
|
|
561
|
+
cmdlist = self.exelist + flags
|
|
562
|
+
mlog.debug('Sanity check compiler command line: ', ' '.join(cmdlist))
|
|
563
|
+
pc, stdo, stde = Popen_safe(cmdlist, cwd=work_dir)
|
|
564
|
+
mlog.debug('Sanity check compile stdout: ')
|
|
565
|
+
mlog.debug(stdo)
|
|
566
|
+
mlog.debug('-----\nSanity check compile stderr:')
|
|
567
|
+
mlog.debug(stde)
|
|
568
|
+
mlog.debug('-----')
|
|
569
|
+
if pc.returncode != 0:
|
|
570
|
+
raise EnvironmentException(f'Compiler {self.name_string()} cannot compile programs.')
|
|
571
|
+
|
|
572
|
+
# Run sanity check (if possible)
|
|
573
|
+
if env.need_exe_wrapper(self.for_machine):
|
|
574
|
+
if not env.has_exe_wrapper():
|
|
575
|
+
return
|
|
576
|
+
else:
|
|
577
|
+
cmdlist = env.exe_wrapper.get_command() + [binary_name]
|
|
578
|
+
else:
|
|
579
|
+
cmdlist = self.exelist + ['--run', '"' + binary_name + '"']
|
|
580
|
+
mlog.debug('Sanity check run command line: ', ' '.join(cmdlist))
|
|
581
|
+
pe, stdo, stde = Popen_safe(cmdlist, cwd=work_dir)
|
|
582
|
+
mlog.debug('Sanity check run stdout: ')
|
|
583
|
+
mlog.debug(stdo)
|
|
584
|
+
mlog.debug('-----\nSanity check run stderr:')
|
|
585
|
+
mlog.debug(stde)
|
|
586
|
+
mlog.debug('-----')
|
|
587
|
+
pe.wait()
|
|
588
|
+
if pe.returncode != 0:
|
|
589
|
+
raise EnvironmentException(f'Executables created by {self.language} compiler {self.name_string()} are not runnable.')
|
|
590
|
+
|
|
591
|
+
# Interpret the result of the sanity test.
|
|
592
|
+
# As mentioned above, it is not only a sanity test but also a GPU
|
|
593
|
+
# architecture detection test.
|
|
594
|
+
if stde == '':
|
|
595
|
+
self.detected_cc = stdo
|
|
596
|
+
else:
|
|
597
|
+
mlog.debug('cudaGetDeviceCount() returned ' + stde)
|
|
598
|
+
|
|
599
|
+
def has_header_symbol(self, hname: str, symbol: str, prefix: str,
|
|
600
|
+
env: 'Environment', *,
|
|
601
|
+
extra_args: T.Union[None, T.List[str], T.Callable[[CompileCheckMode], T.List[str]]] = None,
|
|
602
|
+
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
|
|
603
|
+
if extra_args is None:
|
|
604
|
+
extra_args = []
|
|
605
|
+
fargs = {'prefix': prefix, 'header': hname, 'symbol': symbol}
|
|
606
|
+
# Check if it's a C-like symbol
|
|
607
|
+
t = '''{prefix}
|
|
608
|
+
#include <{header}>
|
|
609
|
+
int main(void) {{
|
|
610
|
+
/* If it's not defined as a macro, try to use as a symbol */
|
|
611
|
+
#ifndef {symbol}
|
|
612
|
+
{symbol};
|
|
613
|
+
#endif
|
|
614
|
+
return 0;
|
|
615
|
+
}}'''
|
|
616
|
+
found, cached = self.compiles(t.format_map(fargs), env, extra_args=extra_args, dependencies=dependencies)
|
|
617
|
+
if found:
|
|
618
|
+
return True, cached
|
|
619
|
+
# Check if it's a class or a template
|
|
620
|
+
t = '''{prefix}
|
|
621
|
+
#include <{header}>
|
|
622
|
+
using {symbol};
|
|
623
|
+
int main(void) {{
|
|
624
|
+
return 0;
|
|
625
|
+
}}'''
|
|
626
|
+
return self.compiles(t.format_map(fargs), env, extra_args=extra_args, dependencies=dependencies)
|
|
627
|
+
|
|
628
|
+
_CPP14_VERSION = '>=9.0'
|
|
629
|
+
_CPP17_VERSION = '>=11.0'
|
|
630
|
+
_CPP20_VERSION = '>=12.0'
|
|
631
|
+
|
|
632
|
+
def get_options(self) -> 'MutableKeyedOptionDictType':
|
|
633
|
+
cpp_stds = ['none', 'c++03', 'c++11']
|
|
634
|
+
if version_compare(self.version, self._CPP14_VERSION):
|
|
635
|
+
cpp_stds += ['c++14']
|
|
636
|
+
if version_compare(self.version, self._CPP17_VERSION):
|
|
637
|
+
cpp_stds += ['c++17']
|
|
638
|
+
if version_compare(self.version, self._CPP20_VERSION):
|
|
639
|
+
cpp_stds += ['c++20']
|
|
640
|
+
|
|
641
|
+
return self.update_options(
|
|
642
|
+
super().get_options(),
|
|
643
|
+
self.create_option(coredata.UserComboOption,
|
|
644
|
+
OptionKey('std', machine=self.for_machine, lang=self.language),
|
|
645
|
+
'C++ language standard to use with CUDA',
|
|
646
|
+
cpp_stds,
|
|
647
|
+
'none'),
|
|
648
|
+
self.create_option(coredata.UserStringOption,
|
|
649
|
+
OptionKey('ccbindir', machine=self.for_machine, lang=self.language),
|
|
650
|
+
'CUDA non-default toolchain directory to use (-ccbin)',
|
|
651
|
+
''),
|
|
652
|
+
)
|
|
653
|
+
|
|
654
|
+
def _to_host_compiler_options(self, options: 'KeyedOptionDictType') -> 'KeyedOptionDictType':
|
|
655
|
+
"""
|
|
656
|
+
Convert an NVCC Option set to a host compiler's option set.
|
|
657
|
+
"""
|
|
658
|
+
|
|
659
|
+
# We must strip the -std option from the host compiler option set, as NVCC has
|
|
660
|
+
# its own -std flag that may not agree with the host compiler's.
|
|
661
|
+
host_options = {key: options.get(key, opt) for key, opt in self.host_compiler.get_options().items()}
|
|
662
|
+
std_key = OptionKey('std', machine=self.for_machine, lang=self.host_compiler.language)
|
|
663
|
+
overrides = {std_key: 'none'}
|
|
664
|
+
return coredata.OptionsView(host_options, overrides=overrides)
|
|
665
|
+
|
|
666
|
+
def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
|
667
|
+
args = self.get_ccbin_args(options)
|
|
668
|
+
# On Windows, the version of the C++ standard used by nvcc is dictated by
|
|
669
|
+
# the combination of CUDA version and MSVC version; the --std= is thus ignored
|
|
670
|
+
# and attempting to use it will result in a warning: https://stackoverflow.com/a/51272091/741027
|
|
671
|
+
if not is_windows():
|
|
672
|
+
key = OptionKey('std', machine=self.for_machine, lang=self.language)
|
|
673
|
+
std = options[key]
|
|
674
|
+
if std.value != 'none':
|
|
675
|
+
args.append('--std=' + std.value)
|
|
676
|
+
|
|
677
|
+
return args + self._to_host_flags(self.host_compiler.get_option_compile_args(self._to_host_compiler_options(options)))
|
|
678
|
+
|
|
679
|
+
def get_option_link_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
|
680
|
+
args = self.get_ccbin_args(options)
|
|
681
|
+
return args + self._to_host_flags(self.host_compiler.get_option_link_args(self._to_host_compiler_options(options)), _Phase.LINKER)
|
|
682
|
+
|
|
683
|
+
def get_soname_args(self, env: 'Environment', prefix: str, shlib_name: str,
|
|
684
|
+
suffix: str, soversion: str,
|
|
685
|
+
darwin_versions: T.Tuple[str, str]) -> T.List[str]:
|
|
686
|
+
return self._to_host_flags(self.host_compiler.get_soname_args(
|
|
687
|
+
env, prefix, shlib_name, suffix, soversion, darwin_versions), _Phase.LINKER)
|
|
688
|
+
|
|
689
|
+
def get_compile_only_args(self) -> T.List[str]:
|
|
690
|
+
return ['-c']
|
|
691
|
+
|
|
692
|
+
def get_no_optimization_args(self) -> T.List[str]:
|
|
693
|
+
return ['-O0']
|
|
694
|
+
|
|
695
|
+
def get_optimization_args(self, optimization_level: str) -> T.List[str]:
|
|
696
|
+
# alternatively, consider simply redirecting this to the host compiler, which would
|
|
697
|
+
# give us more control over options like "optimize for space" (which nvcc doesn't support):
|
|
698
|
+
# return self._to_host_flags(self.host_compiler.get_optimization_args(optimization_level))
|
|
699
|
+
return cuda_optimization_args[optimization_level]
|
|
700
|
+
|
|
701
|
+
def sanitizer_compile_args(self, value: str) -> T.List[str]:
|
|
702
|
+
return self._to_host_flags(self.host_compiler.sanitizer_compile_args(value))
|
|
703
|
+
|
|
704
|
+
def sanitizer_link_args(self, value: str) -> T.List[str]:
|
|
705
|
+
return self._to_host_flags(self.host_compiler.sanitizer_link_args(value))
|
|
706
|
+
|
|
707
|
+
def get_debug_args(self, is_debug: bool) -> T.List[str]:
|
|
708
|
+
return cuda_debug_args[is_debug]
|
|
709
|
+
|
|
710
|
+
def get_werror_args(self) -> T.List[str]:
|
|
711
|
+
device_werror_args = ['-Werror=cross-execution-space-call,deprecated-declarations,reorder']
|
|
712
|
+
return device_werror_args + self.host_werror_args
|
|
713
|
+
|
|
714
|
+
def get_warn_args(self, level: str) -> T.List[str]:
|
|
715
|
+
return self.warn_args[level]
|
|
716
|
+
|
|
717
|
+
def get_include_args(self, path: str, is_system: bool) -> T.List[str]:
|
|
718
|
+
if path == '':
|
|
719
|
+
path = '.'
|
|
720
|
+
return ['-isystem=' + path] if is_system else ['-I' + path]
|
|
721
|
+
|
|
722
|
+
def get_compile_debugfile_args(self, rel_obj: str, pch: bool = False) -> T.List[str]:
|
|
723
|
+
return self._to_host_flags(self.host_compiler.get_compile_debugfile_args(rel_obj, pch))
|
|
724
|
+
|
|
725
|
+
def get_link_debugfile_args(self, targetfile: str) -> T.List[str]:
|
|
726
|
+
return self._to_host_flags(self.host_compiler.get_link_debugfile_args(targetfile), _Phase.LINKER)
|
|
727
|
+
|
|
728
|
+
def get_depfile_suffix(self) -> str:
|
|
729
|
+
return 'd'
|
|
730
|
+
|
|
731
|
+
def get_optimization_link_args(self, optimization_level: str) -> T.List[str]:
|
|
732
|
+
return self._to_host_flags(self.host_compiler.get_optimization_link_args(optimization_level), _Phase.LINKER)
|
|
733
|
+
|
|
734
|
+
def build_rpath_args(self, env: 'Environment', build_dir: str, from_dir: str,
|
|
735
|
+
rpath_paths: T.Tuple[str, ...], build_rpath: str,
|
|
736
|
+
install_rpath: str) -> T.Tuple[T.List[str], T.Set[bytes]]:
|
|
737
|
+
(rpath_args, rpath_dirs_to_remove) = self.host_compiler.build_rpath_args(
|
|
738
|
+
env, build_dir, from_dir, rpath_paths, build_rpath, install_rpath)
|
|
739
|
+
return (self._to_host_flags(rpath_args, _Phase.LINKER), rpath_dirs_to_remove)
|
|
740
|
+
|
|
741
|
+
def linker_to_compiler_args(self, args: T.List[str]) -> T.List[str]:
|
|
742
|
+
return args
|
|
743
|
+
|
|
744
|
+
def get_pic_args(self) -> T.List[str]:
|
|
745
|
+
return self._to_host_flags(self.host_compiler.get_pic_args())
|
|
746
|
+
|
|
747
|
+
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str],
|
|
748
|
+
build_dir: str) -> T.List[str]:
|
|
749
|
+
return []
|
|
750
|
+
|
|
751
|
+
def get_output_args(self, target: str) -> T.List[str]:
|
|
752
|
+
return ['-o', target]
|
|
753
|
+
|
|
754
|
+
def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]:
|
|
755
|
+
if version_compare(self.version, '>= 10.2'):
|
|
756
|
+
# According to nvcc Documentation, `-MD` option is added after 10.2
|
|
757
|
+
# Reference: [CUDA 10.1](https://docs.nvidia.com/cuda/archive/10.1/cuda-compiler-driver-nvcc/index.html#options-for-specifying-compilation-phase-generate-nonsystem-dependencies)
|
|
758
|
+
# Reference: [CUDA 10.2](https://docs.nvidia.com/cuda/archive/10.2/cuda-compiler-driver-nvcc/index.html#options-for-specifying-compilation-phase-generate-nonsystem-dependencies)
|
|
759
|
+
return ['-MD', '-MT', outtarget, '-MF', outfile]
|
|
760
|
+
else:
|
|
761
|
+
return []
|
|
762
|
+
|
|
763
|
+
def get_std_exe_link_args(self) -> T.List[str]:
|
|
764
|
+
return self._to_host_flags(self.host_compiler.get_std_exe_link_args(), _Phase.LINKER)
|
|
765
|
+
|
|
766
|
+
def find_library(self, libname: str, env: 'Environment', extra_dirs: T.List[str],
|
|
767
|
+
libtype: LibType = LibType.PREFER_SHARED, lib_prefix_warning: bool = True) -> T.Optional[T.List[str]]:
|
|
768
|
+
return ['-l' + libname] # FIXME
|
|
769
|
+
|
|
770
|
+
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]:
|
|
771
|
+
return self._to_host_flags(self.host_compiler.get_crt_compile_args(crt_val, buildtype))
|
|
772
|
+
|
|
773
|
+
def get_crt_link_args(self, crt_val: str, buildtype: str) -> T.List[str]:
|
|
774
|
+
# nvcc defaults to static, release version of msvc runtime and provides no
|
|
775
|
+
# native option to override it; override it with /NODEFAULTLIB
|
|
776
|
+
host_link_arg_overrides = []
|
|
777
|
+
host_crt_compile_args = self.host_compiler.get_crt_compile_args(crt_val, buildtype)
|
|
778
|
+
if any(arg in {'/MDd', '/MD', '/MTd'} for arg in host_crt_compile_args):
|
|
779
|
+
host_link_arg_overrides += ['/NODEFAULTLIB:LIBCMT.lib']
|
|
780
|
+
return self._to_host_flags(host_link_arg_overrides + self.host_compiler.get_crt_link_args(crt_val, buildtype), _Phase.LINKER)
|
|
781
|
+
|
|
782
|
+
def get_target_link_args(self, target: 'BuildTarget') -> T.List[str]:
|
|
783
|
+
return self._to_host_flags(super().get_target_link_args(target), _Phase.LINKER)
|
|
784
|
+
|
|
785
|
+
def get_dependency_compile_args(self, dep: 'Dependency') -> T.List[str]:
|
|
786
|
+
return self._to_host_flags(super().get_dependency_compile_args(dep))
|
|
787
|
+
|
|
788
|
+
def get_dependency_link_args(self, dep: 'Dependency') -> T.List[str]:
|
|
789
|
+
return self._to_host_flags(super().get_dependency_link_args(dep), _Phase.LINKER)
|
|
790
|
+
|
|
791
|
+
def get_ccbin_args(self, options: 'KeyedOptionDictType') -> T.List[str]:
|
|
792
|
+
key = OptionKey('ccbindir', machine=self.for_machine, lang=self.language)
|
|
793
|
+
ccbindir = options[key].value
|
|
794
|
+
if isinstance(ccbindir, str) and ccbindir != '':
|
|
795
|
+
return [self._shield_nvcc_list_arg('-ccbin='+ccbindir, False)]
|
|
796
|
+
else:
|
|
797
|
+
return []
|
|
798
|
+
|
|
799
|
+
def get_profile_generate_args(self) -> T.List[str]:
|
|
800
|
+
return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_generate_args()]
|
|
801
|
+
|
|
802
|
+
def get_profile_use_args(self) -> T.List[str]:
|
|
803
|
+
return ['-Xcompiler=' + x for x in self.host_compiler.get_profile_use_args()]
|
|
804
|
+
|
|
805
|
+
def get_assert_args(self, disable: bool) -> T.List[str]:
|
|
806
|
+
return self.host_compiler.get_assert_args(disable)
|