Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide co-resident gcc 8 toolchain for CUDA #867

Merged
merged 16 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,14 @@ branch: master
LAYERSERIES_COMPAT: honister


PLEASE NOTE
-----------

* CUDA 10.2 supports up through gcc 8 only. Pre-built binaries
in the BSP appear to be compatible with gcc 7 and 8 **only**.
So use only gcc 7 or gcc 8 if you intend to use CUDA.
Recipes for gcc 8 have been imported from the OE-Core warrior branch
(the last version of OE-Core to supply gcc 8) to make it easier
to use this older toolchain.

See [this wiki page](https://github.com/OE4T/meta-tegra/wiki/Using-gcc8-from-the-contrib-layer)
for information on adding the `meta-tegra/contrib` layer to your
builds and configuring them for GCC 8.
CUDA toolchain compatibility note
---------------------------------

CUDA 10.2 supports up through gcc 8 only, so recipes are included
for adding the gcc 8 toolchain to the build for CUDA use, and `cuda.bbclass`
has been updated to pass the g++ 8 compiler to nvcc for CUDA code compilation.
This is different from earlier releases/branches, which required setting
the toolchain used for all builds to a CUDA-compatible version.


Getting Help
Expand Down
8 changes: 8 additions & 0 deletions classes/cuda-gcc.bbclass
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CUDA requires gcc/g++ 8, so add that compiler and its runtime as
# dependencies, and set CC_FOR_CUDA and CXX_FOR_CUDA to point to that compiler.
DEPENDS:append:cuda = " virtual/${TARGET_PREFIX}cuda-gcc gcc-8-runtime"
CUDA_HOST_TOOLCHAIN_SUFFIX ??= ""
CUDA_HOST_TOOLCHAIN_SUFFIX:cuda = "-8.5.0"
CC_FOR_CUDA ?= "${CCACHE}${HOST_PREFIX}gcc${CUDA_HOST_TOOLCHAIN_SUFFIX} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
CXX_FOR_CUDA ?= "${CCACHE}${HOST_PREFIX}g++${CUDA_HOST_TOOLCHAIN_SUFFIX} ${HOST_CC_ARCH}${TOOLCHAIN_OPTIONS}"
PACKAGE_ARCH:cuda = "${TEGRA_PKGARCH}"
14 changes: 11 additions & 3 deletions classes/cuda.bbclass
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
inherit cuda-gcc
CUDA_ARCHITECTURES ??= ""
CUDA_NVCC_COMPAT_FLAGS ??= ""
CUDA_NVCC_PATH_FLAGS ??= "--include-path ${STAGING_DIR_HOST}/usr/local/cuda-${CUDA_VERSION}/include --library-path ${STAGING_DIR_HOST}/usr/local/cuda-${CUDA_VERSION}/${baselib}"
CUDA_NVCC_EXTRA_FLAGS ??= ""
Expand All @@ -19,12 +21,17 @@ def cuda_extract_compiler(compiler, d, prefix='-Xcompiler '):
return args[1], ' '.join([prefix + arg for arg in args[2:]])
return args[0], ' '.join([prefix + arg for arg in args[1:]])

export CUDAHOSTCXX = "${@cuda_extract_compiler('CXX', d)[0]}"
export CUDAFLAGS = "${CUDA_NVCC_FLAGS} ${@cuda_extract_compiler('CXX', d)[1]}"
export CUDAHOSTCXX = "${@cuda_extract_compiler('CXX_FOR_CUDA', d)[0]}"
export CUDAFLAGS = "${CUDA_NVCC_FLAGS} ${@cuda_extract_compiler('CXX_FOR_CUDA', d)[1]}"
OECMAKE_CUDA_COMPILER_LAUNCHER ?= "${CCACHE}"
OECMAKE_CUDA_COMPILER ?= "nvcc"
CUDA_CCACHE_COMPILERCHECK ?= "cuda-compiler-check %compiler%"

def cmake_cuda_archs(d):
archs = d.getVar('CUDA_ARCHITECTURES')
return archs if archs else "OFF"
OECMAKE_CUDA_ARCHITECTURES ?= "${@cmake_cuda_archs(d)}"

# meson uses 'CUFLAGS' for flags to pass to nvcc
# and requires all nvcc, compiler, and linker flags to be
# bundled into that one environment variable.
Expand All @@ -41,7 +48,7 @@ def cuda_meson_ldflags(d):
elif arg.startswith('--sysroot='):
linkargs.append(arg)
return '-Xlinker ' + ','.join(linkargs)
CUFLAGS = "-ccbin ${@cuda_extract_compiler('CXX', d)[0]} ${CUDAFLAGS} ${@cuda_extract_compiler('CXX', d)[1]} ${@cuda_meson_ldflags(d)}"
CUFLAGS = "-ccbin ${@cuda_extract_compiler('CXX_FOR_CUDA', d)[0]} ${CUDAFLAGS} ${@cuda_extract_compiler('CXX_FOR_CUDA', d)[1]} ${@cuda_meson_ldflags(d)}"

# The following are for the old-style FindCUDA.cmake module (pre-3.8)
CUDA_EXTRA_OECMAKE = '\
Expand Down Expand Up @@ -72,6 +79,7 @@ set(CMAKE_CUDA_TOOLKIT_TARGET_DIR "${STAGING_DIR_HOST}/usr/local/cuda-${CUDA_VER
set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "\${CMAKE_CUDA_TOOLKIT_ROOT_DIR}/include" "\${CMAKE_CUDA_TOOLKIT_TARGET_DIR}/include" CACHE PATH "" FORCE)
set(CMAKE_CUDA_COMPILER ${OECMAKE_CUDA_COMPILER})
set(CMAKE_CUDA_COMPILER_LAUNCHER ${OECMAKE_CUDA_COMPILER_LAUNCHER})
set(CMAKE_CUDA_ARCHITECTURES ${OECMAKE_CUDA_ARCHITECTURES})
EOF
}

Expand Down
1 change: 1 addition & 0 deletions conf/layer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += "\
libdrm->libdrm-nvdc \
libdrm-nvdc->tegra-libraries \
tegra-nvs-service->tegra-nvs-base \
gcc-8-cross-${TARGET_ARCH}->linux-libc-headers \
"
3 changes: 3 additions & 0 deletions conf/machine/include/tegra-common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ PREFERRED_PROVIDER_virtual/secure-os ?= "tos-prebuilt"
PREFERRED_PROVIDER_virtual/egl = "libglvnd"
PREFERRED_PROVIDER_virtual/libgles1 = "libglvnd"
PREFERRED_PROVIDER_virtual/libgles2 = "libglvnd"
PREFERRED_PROVIDER_virtual/libgles3 = "libglvnd"
PREFERRED_PROVIDER_virtual/libgl = "libglvnd"
PREFERRED_PROVIDER_libv4l = "${@'v4l-utils' if 'openembedded-layer' in d.getVar('BBFILE_COLLECTIONS').split() else 'libv4l2-minimal'}"
PREFERRED_PROVIDER_v4l-utils = "${@'v4l-utils' if 'openembedded-layer' in d.getVar('BBFILE_COLLECTIONS').split() else 'libv4l2-minimal'}"
Expand All @@ -55,6 +56,8 @@ PREFERRED_PROVIDER_virtual/xserver-xf86 = "xserver-xorg-tegra"
XSERVER = "xserver-xorg-tegra xf86-input-evdev xserver-xorg-video-nvidia xserver-xorg-tegra-module-libwfb"

CUDA_VERSION ?= "10.2"
CUDA_ARCHITECTURES ?= "${TEGRA_CUDA_ARCHITECTURE}"
CUDA_NVCC_ARCH_FLAGS ?= "--gpu-architecture=compute_${TEGRA_CUDA_ARCHITECTURE} --gpu-code=sm_${TEGRA_CUDA_ARCHITECTURE}"
# Tegra specific version of libnvidia-container
PREFERRED_VERSION_libnvidia-container-tools = "0.10.0"

Expand Down
2 changes: 1 addition & 1 deletion conf/machine/include/tegra186.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ NVIDIA_CHIP = "0x18"

TEGRA_SIGNING_ENV ?= "BOARDID=${TEGRA_BOARDID} FAB=${TEGRA_FAB}"

CUDA_NVCC_ARCH_FLAGS ?= "--gpu-architecture=compute_62 --gpu-code=sm_62"
TEGRA_CUDA_ARCHITECTURE ?= "62"

PREFERRED_PROVIDER_tos-trusty ?= "tos-prebuilt"
PREFERRED_PROVIDER_cboot ?= "cboot-t18x"
Expand Down
2 changes: 1 addition & 1 deletion conf/machine/include/tegra194.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEGRA_BUPGEN_SPECS ?= "fab=400;boardsku=0001;boardrev=H.0 \

TEGRA_SIGNING_ENV = "CHIPREV=${TEGRA_CHIPREV} BOARDID=${TEGRA_BOARDID} FAB=${TEGRA_FAB} BOARDSKU=${TEGRA_BOARDSKU} BOARDREV=${TEGRA_BOARDREV}"

CUDA_NVCC_ARCH_FLAGS ?= "--gpu-architecture=compute_72 --gpu-code=sm_72"
TEGRA_CUDA_ARCHITECTURE = "72"

PREFERRED_PROVIDER_virtual/bootloader ?= "cboot-t19x"
PREFERRED_PROVIDER_tos-trusty ?= "tos-prebuilt"
Expand Down
2 changes: 1 addition & 1 deletion conf/machine/include/tegra210.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ NVIDIA_CHIP = "0x21"

TEGRA_SIGNING_ENV ?= "BOARDID=${TEGRA_BOARDID} FAB=${TEGRA_FAB} BOARDSKU=${TEGRA_BOARDSKU} BOARDREV=${TEGRA_BOARDREV}"

CUDA_NVCC_ARCH_FLAGS ?= "--gpu-architecture=compute_53 --gpu-code=sm_53"
TEGRA_CUDA_ARCHITECTURE ?= "53"

require conf/machine/include/tegra-common.inc

Expand Down
8 changes: 0 additions & 8 deletions contrib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ Contributed recipes for meta-tegra
This layer contains recipes to support builds with
meta-tegra that are not directly part of the BSP.

## gcc 8 toolchain
The main use of this layer is to provide an older
gcc toolchain that is compatible with the version
of the CUDA toolkit for the Jetson platforms.

For more information, see
[this wiki page](https://github.com/OE4T/meta-tegra/wiki/Using-gcc8-from-the-contrib-layer).

## gstreamer 1.14 recipes
This layer also includes a port of the gstreamer 1.14
recipes from the OE-Core warrior branch. When using the
Expand Down
9 changes: 0 additions & 9 deletions contrib/conf/include/gcc-compat.conf

This file was deleted.

122 changes: 0 additions & 122 deletions contrib/recipes-devtools/gcc-7/gcc-7.3.inc

This file was deleted.

Loading