Repository: youtube/cobalt
Pull request #5166: Add support to build cobalt/starboard using an external RDK toolchain
Author: login: andrunko
Labels: name: runtest
description: Trigger presubmit workflows
Created: 2025-03-24T23:02:59Z | Merged: 2025-04-11T16:16:59Z

b/402053134

This is a work in progress to add support for building cobalt using an external RDK toolchain. The actual integration expects the RDK starboard implementation to be located under `starboard/contrib/rdk` and won't work without it - this will be done (likely as a git subtree) once the RDK starboard changes are integrated into https://cobalt.googlesource.com/ (proposed changes currently under review) where they live.


Diff:
diff --git a/docker-compose.yml b/docker-compose.yml
index e921835a51f9..2356c84a3e5f 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -24,6 +24,12 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    # TODO(b/402053134): Mounting HOME and RDK_SDK is only needed to be able to access the
+    #                    RDK sysroot inside the container, once the RDK sysroot is publicly available
+    #                    these should be removed and the SDK extracted directly from the docker
+    #                    container (as done for e.g. raspi)
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
     - ${COBALT_SRC:-.}:/code/
     - android-debug-keystore:/root/.android/
     - ${CCACHE_DIR:-container-ccache}:/root/ccache
@@ -325,6 +331,27 @@ services:
       CONFIG: ${CONFIG:-debug}
       SB_API_VERSION: ${SB_API_VERSION}
 
+  build-rdk:
+    <<: *build-common-definitions
+    build:
+      context: ./docker/linux/rdk
+      dockerfile: ./Dockerfile
+    image: cobalt-build-rdk
+    environment:
+      <<: *shared-build-env
+
+  rdk:
+    <<: *build-common-definitions
+    build:
+      context: ./docker/linux/rdk
+      dockerfile: ./Dockerfile
+    image: cobalt-build-rdk
+    environment:
+      <<: *shared-build-env
+      PLATFORM: ${PLATFORM:-rdk-arm}
+      CONFIG: ${CONFIG:-debug}
+      SB_API_VERSION: ${SB_API_VERSION}
+
   # Define common build container for Evergreen
   build-evergreen:
     <<: *build-common-definitions
diff --git a/docker/linux/rdk/Dockerfile b/docker/linux/rdk/Dockerfile
new file mode 100644
index 000000000000..4c5c28d5c9fb
--- /dev/null
+++ b/docker/linux/rdk/Dockerfile
@@ -0,0 +1,37 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM cobalt-build-base
+
+ARG rdk_home=/root/rdk-home
+
+# Required by the gyp build system.
+ENV RDK_HOME=${rdk_home}
+
+RUN apt update -qqy \
+    && apt install -qqy --no-install-recommends \
+        g++-multilib \
+        bzip2 \
+        libxml2 \
+        binutils-aarch64-linux-gnu \
+        binutils-arm-linux-gnueabi \
+        libglib2.0-dev \
+        pkg-config \
+    && /opt/clean-after-apt.sh
+
+# TODO(b/402053134): fetch and extract the RDK sysroot at $RDK_HOME, once the sysroot is public available
+
+# TODO(b/402053134): for now we only build evergreen targets, once modular builds are working this needs to updated to build modular by default
+CMD gn gen ${OUTDIR}/${PLATFORM}${SB_API_VERSION:+-sbversion-$SB_API_VERSION}_${CONFIG:-debug} --args="target_platform=\"${PLATFORM}\" build_type=\"${CONFIG:-debug}\" target_cpu=\"arm\" target_os=\"linux\" is_clang=false using_old_compiler=true rdk_build_with_yocto=false rdk_starboard_root=\"//starboard/contrib/rdk/src\" rdk_enable_securityagent=false ${SB_API_VERSION:+sb_api_version=$SB_API_VERSION}" && \
+    ninja -v -j ${NINJA_PARALLEL} -C out/${PLATFORM}_${CONFIG:-debug} loader_app_install native_target/crashpad_handler elf_loader_sandbox_install
diff --git a/starboard/build/config/linux/rdk/starboard_rdk_path.gni b/starboard/build/config/linux/rdk/starboard_rdk_path.gni
new file mode 100644
index 000000000000..fe09c603e49d
--- /dev/null
+++ b/starboard/build/config/linux/rdk/starboard_rdk_path.gni
@@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "/"
+}
diff --git a/starboard/build/platforms.py b/starboard/build/platforms.py
index 3d01892d753d..d949ee370714 100644
--- a/starboard/build/platforms.py
+++ b/starboard/build/platforms.py
@@ -36,7 +36,7 @@
     'android-x86': 'starboard/android/x86',
     'raspi-2': 'starboard/raspi/2',
     'raspi-2-skia': 'starboard/raspi/2/skia',
-    'rdk': 'starboard/rdk',
+    'rdk-arm': 'starboard/contrib/rdk/src/third_party/starboard/rdk/arm',
     'evergreen-x64': 'starboard/evergreen/x64',
     'evergreen-arm-hardfp': 'starboard/evergreen/arm/hardfp',
     'evergreen-arm-softfp': 'starboard/evergreen/arm/softfp',
diff --git a/starboard/build/toolchain/cobalt_toolchains.gni b/starboard/build/toolchain/cobalt_toolchains.gni
index d0f7449f41ca..6fb2419e502a 100644
--- a/starboard/build/toolchain/cobalt_toolchains.gni
+++ b/starboard/build/toolchain/cobalt_toolchains.gni
@@ -22,6 +22,8 @@ template("cobalt_clang_toolchain") {
                              "native_linker_path",
                              "executable_extension",
                              "tail_lib_dependencies",
+                             "extra_cflags",
+                             "extra_cxxflags",
                            ])
     if (defined(invoker.shlib_extension)) {
       shlib_extension = invoker.shlib_extension


Reviews:
user: login: jonastsai
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-07T05:59:28Z
user: login: niranjanyardi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-07T22:11:38Z
user: login: niranjanyardi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-07T22:17:58Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T00:34:22Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T00:36:27Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T00:37:17Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T00:39:45Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T00:47:37Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T01:27:51Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T01:28:33Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-09T01:29:47Z
user: login: niranjanyardi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T18:11:00Z
user: login: niranjanyardi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T18:12:05Z
user: login: niranjanyardi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T18:15:40Z
user: login: niranjanyardi
state: APPROVED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T18:23:11Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-10T18:37:23Z
user: login: niranjanyardi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-10T19:22:17Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-10T19:37:50Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-11T02:14:56Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-11T02:15:06Z
user: login: andrunko
state: COMMENTED
author_association: COLLABORATOR
submitted_at: 2025-04-11T02:16:05Z
user: login: niranjanyardi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-11T16:15:07Z

Review comments:
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: jonastsai
body: I need `- ${RDK_SDK:-.}:${RDK_SDK}` after this line. Otherwise the gcc cannot find the interpreter. 
created_at: 2025-04-07T05:57:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: jonastsai
body: what is the difference between RDK_SDK and RDK_HOME in RDK starboard change? Can we use only one argument to specify the root of the SDK?
created_at: 2025-04-07T05:59:15Z
author_association: CONTRIBUTOR
diff_hunk: @@ -44,7 +44,7 @@ declare_args() {
   enable_iamf_decode = false
 }
 
-_is_on_pythonpath = exec_script("//starboard/build/is_on_path.py", [], "json")
+_is_on_pythonpath = exec_script("//starboard/build/is_on_path.py", ["{}"], "json")
path: starboard/build/config/BUILDCONFIG.gn
user: login: niranjanyardi
body: what error caused this ?  (this works for all team members currently) 
created_at: 2025-04-07T22:11:38Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: niranjanyardi
body: we should move this file under rdk folder: src/third_party/starboard/rdk/arm/platform_configuration/starboard_root_path.gni

this is rdk specific code and it's good if it remains under the rdk folder.

created_at: 2025-04-07T22:17:58Z
author_association: CONTRIBUTOR
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: andrunko
body: I believe the problem here is RDK_SDK is extracted outside your $HOME and when extracting the sysroot it adds some hardcoded paths (rpath?) to the place you extract it, so you end up having to have it mounted in the same location you extracted it to make the interpreter work.

I think we can drop $HOME and add $RDK_SDK, this should solve your issue and work for sysroots extracted outside $HOME as well.

I will give it a try and update here.
created_at: 2025-04-09T00:34:22Z
author_association: COLLABORATOR
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: andrunko
body: We can't use the same var unfortunately because one points to the place you extracted the SDK outside the container (RDK_SDK) and the other points to the place it is located inside the container (RDK_HOME). We will end up getting rid of RDK_SDK and keep only RDK_HOME once we manage to have the sysroot uploaded somewhere we can grab and extract directly from the container when building it.
created_at: 2025-04-09T00:36:27Z
author_association: COLLABORATOR
diff_hunk: @@ -44,7 +44,7 @@ declare_args() {
   enable_iamf_decode = false
 }
 
-_is_on_pythonpath = exec_script("//starboard/build/is_on_path.py", [], "json")
+_is_on_pythonpath = exec_script("//starboard/build/is_on_path.py", ["{}"], "json")
path: starboard/build/config/BUILDCONFIG.gn
user: login: andrunko
body: Let me try reverting it, I did get a "invalid json" error at some point which the above fixed, but I was experimenting with other things, I will try without it and update accordingly.
created_at: 2025-04-09T00:37:17Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: andrunko
body: Unfortunately we can't, as explained to @niranjanyardi we need this var to be available on src/third_party/starboard/rdk/shared/platform_configuration/configuration.gni, which uses it to define some config paths (pedantic, speed, etc), and if we put it under "arm" that would be platform specific. 

The best place I found was under starboard/build/config, which already have some custom configs for windows/mac/etc. 

Let me know if you have other suggestions.
created_at: 2025-04-09T00:39:45Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: andrunko
body: I tried putting it under shared as well, but then I would need the var to be available under `src/third_party/starboard/rdk/arm/platform_configuration/configuration.gni` as well, which is the first file included from the RDK's $platform_path and if we'd put it under `src/third_party/starboard/rdk/shared/platform_configuration/configuration.gni`, we would have to know in advance the root path to the shared folder from the arm folder, which I could not find a way (unless we can include relative files (e.g. from "arm/platform_configuration/..." we'd include "../shared/platform_configuration/...").
created_at: 2025-04-09T00:47:37Z
author_association: COLLABORATOR
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: andrunko
body: Done, also dropped mounting $HOME.
created_at: 2025-04-09T01:27:51Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: andrunko
body: Not changed, couldnt find a way to do it under the rdk starboard code, please let me know if you have some idea.
created_at: 2025-04-09T01:28:33Z
author_association: COLLABORATOR
diff_hunk: @@ -44,7 +44,7 @@ declare_args() {
   enable_iamf_decode = false
 }
 
-_is_on_pythonpath = exec_script("//starboard/build/is_on_path.py", [], "json")
+_is_on_pythonpath = exec_script("//starboard/build/is_on_path.py", ["{}"], "json")
path: starboard/build/config/BUILDCONFIG.gn
user: login: andrunko
body: Removed this change, no longer hitting the issue with latest changes.
created_at: 2025-04-09T01:29:47Z
author_association: COLLABORATOR
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: niranjanyardi
body: can you please a todo in there there so that it's tracked https://google.github.io/styleguide/cppguide.html#TODO_Comments
created_at: 2025-04-10T18:11:00Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,35 @@
+# Copyright 2021-2025 The Cobalt Authors. All Rights Reserved.
path: docker/linux/rdk/Dockerfile
user: login: niranjanyardi
body: Copyright 2025
created_at: 2025-04-10T18:12:05Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: niranjanyardi
body: thanks for the offline explanation. Can we please move this file under a folder and rename it starboard/build/config/linux/rdk/starboard_rdk_path?

starboard/build/config is an OS level abstraction

also base_configuration.gni is a core GN file ( and has some implicit meaning associated with it)  so starboard_rdk_path.gni would be a better name.

sg ?

created_at: 2025-04-10T18:15:39Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: andrunko
body: Sounds good, just to clarify and avoid redoing it - do you mean to put it under starboard/build/config/linux/rdk/starboard_rdk_path.gni or under starboard/build/config/linux/rdk/starboard_rdk_path/ directory?
created_at: 2025-04-10T18:37:23Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: niranjanyardi
body: starboard/build/config/linux/rdk/starboard_rdk_path.gni 
created_at: 2025-04-10T19:22:17Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,35 @@
+# Copyright 2021-2025 The Cobalt Authors. All Rights Reserved.
path: docker/linux/rdk/Dockerfile
user: login: andrunko
body: I copied this copyright header from the RPI Dockerfile which this one was based on and just added 2025, but will update.
created_at: 2025-04-10T19:37:49Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,35 @@
+# Copyright 2021-2025 The Cobalt Authors. All Rights Reserved.
path: docker/linux/rdk/Dockerfile
user: login: andrunko
body: Done.
created_at: 2025-04-11T02:14:55Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,17 @@
+# Copyright 2025 The Cobalt Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+  rdk_starboard_root = "//starboard/contrib/rdk/src"
path: starboard/build/config/rdk/base_configuration.gni
user: login: andrunko
body: Done.
created_at: 2025-04-11T02:15:06Z
author_association: COLLABORATOR
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: andrunko
body: Added a TODO but using HOME for now, can update again if needed.
created_at: 2025-04-11T02:16:05Z
author_association: COLLABORATOR
diff_hunk: @@ -24,6 +24,8 @@ x-common-definitions: &common-definitions
 
 x-build-volumes: &build-volumes
   volumes:
+    - ${HOME:-.}:${HOME}
+    - ${RDK_SDK:-.}:/root/rdk-home/
path: docker-compose.yml
user: login: niranjanyardi
body: ty
created_at: 2025-04-11T16:15:07Z
author_association: CONTRIBUTOR

PR comments:
user: login: andrunko
created_at: 2025-03-24T23:08:10Z
body: Note that these changes currently disable .rsp files as it breaks the build when using the external RDK toolchain - looking into it.
author_association: COLLABORATOR
user: login: niranjanyardi
created_at: 2025-04-07T22:18:37Z
body: apart from the the open comments lgtm!
author_association: CONTRIBUTOR
user: login: niranjanyardi
created_at: 2025-04-10T18:24:33Z
body: @andrunko can you see why the required checks are failing . maybe rerun the failing checks to ensure there's no flakes.
author_association: CONTRIBUTOR
user: login: andrunko
created_at: 2025-04-10T21:23:34Z
body: > @andrunko can you see why the required checks are failing . maybe rerun the failing checks to ensure there's no flakes.

The failures seem to be caused by this line on docker-compose.yml:
```
    - ${RDK_SDK:-.}:${RDK_SDK}
```

This was added to support users extracting the SDK anywhere, as the SDK executables expect their path to be the same as the one where they got extracted to, so we need to mount the SDK in the same place inside the container where it was extracted outside the container.

I was  initially mounting $HOME:$HOME here, but this would only work if the SDK is extracted somewhere inside $HOME outside the container as well. I changed it after https://github.com/youtube/cobalt/pull/5166#discussion_r2030501232, which would solve the issue when mounting outside $HOME, but would also require all containers to have `RDK_SDK` set.

Note we only need that until we get the sysroot uploaded somewhere public, then we can extract it directly from the docker container anywhere and set the env vars accordingly.

For now, the options I can see:
- mount $HOME and ask any user trying to build for RDK to extract the sysroot inside their $HOME as well
  -  this considers CI has $HOME set, which is likely
- always set RDK_SDK for all CI jobs

Thoughts?
author_association: COLLABORATOR
user: login: niranjanyardi
created_at: 2025-04-10T21:25:59Z
body: > > @andrunko can you see why the required checks are failing . maybe rerun the failing checks to ensure there's no flakes.
> 
> The failures seem to be caused by this line on docker-compose.yml:
> 
> ```
>     - ${RDK_SDK:-.}:${RDK_SDK}
> ```
> 
> This was added to support users extracting the SDK anywhere, as the SDK executables expect their path to be the same as the one where they got extracted to, so we need to mount the SDK in the same place inside the container where it was extracted outside the container.
> 
> I was initially mounting $HOME:$HOME here, but this would only work if the SDK is extracted somewhere inside $HOME outside the container as well. I changed it after [#5166 (comment)](https://github.com/youtube/cobalt/pull/5166#discussion_r2030501232), which would solve the issue when mounting outside $HOME, but would also require all containers to have `RDK_SDK` set.
> 
> Note we only need that until we get the sysroot uploaded somewhere public, then we can extract it directly from the docker container anywhere and set the env vars accordingly.
> 
> For now, the options I can see:
> 
> * mount $HOME and ask any user trying to build for RDK to extract the sysroot inside their $HOME as well
>   
>   * this considers CI has $HOME set, which is likely
> * always set RDK_SDK for all CI jobs
> 
> Thoughts?

@oxve  thoughts? the HOME option sounds like what we would use currently
author_association: CONTRIBUTOR
user: login: jonastsai
created_at: 2025-04-11T01:38:40Z
body: if possible, try not to ask the user to install the SDK in $HOME. On some partner environment, they have very limited disc quota at $HOME because it is system disc.  but they have large shared work space mounted on other paths. And engineers from the same partner can share the installed SDK if it is installed in system folder. Having a symbolic link in $HOME might not solve the issue but it is not straightforward. 

Can we set the RDK_SDK using ENV in Dockerfile which point to the default value we expected to be installed? And partner can overwrite it if they specifically set the value in bash env?   
author_association: CONTRIBUTOR
user: login: jonastsai
created_at: 2025-04-11T01:39:19Z
body: the rest of changes look good to me
author_association: CONTRIBUTOR
user: login: andrunko
created_at: 2025-04-11T02:13:42Z
body: > if possible, try not to ask the user to install the SDK in $HOME. On some partner environment, they have very limited disc quota at $HOME because it is system disc. but they have large shared work space mounted on other paths. And engineers from the same partner can share the installed SDK if it is installed in system folder. Having a symbolic link in $HOME might not solve the issue but it is not straightforward.
> 
> Can we set the RDK_SDK using ENV in Dockerfile which point to the default value we expected to be installed? And partner can overwrite it if they specifically set the value in bash env?

We cant use ENV as the sysroot needs to be mounted inside the container exactly in the same location it was extracted outside the container. I've updated the PR again to use HOME for now (which in theory should solve the checks here), but another option would be to have a fixed location where the sysroot needs to be extracted (outside the container), and then we mount this hardcoded location in the same place inside the container - e.g. `/opt/rdk-sysroot` or something like that.

Please let me know what you think and if you decide on a hardcoded path, which one we should use here.
author_association: COLLABORATOR
user: login: andrunko
created_at: 2025-04-11T02:21:23Z
body: > > if possible, try not to ask the user to install the SDK in $HOME. On some partner environment, they have very limited disc quota at $HOME because it is system disc. but they have large shared work space mounted on other paths. And engineers from the same partner can share the installed SDK if it is installed in system folder. Having a symbolic link in $HOME might not solve the issue but it is not straightforward.
> > Can we set the RDK_SDK using ENV in Dockerfile which point to the default value we expected to be installed? And partner can overwrite it if they specifically set the value in bash env?
> 
> We cant use ENV as the sysroot needs to be mounted inside the container exactly in the same location it was extracted outside the container. I've updated the PR again to use HOME for now (which in theory should solve the checks here), but another option would be to have a fixed location where the sysroot needs to be extracted (outside the container), and then we mount this hardcoded location in the same place inside the container - e.g. `/opt/rdk-sysroot` or something like that.
> 
> Please let me know what you think and if you decide on a hardcoded path, which one we should use here.

Using a hardcoded path could also make the checks here fail, e.g. if we try to mount /opt/rdk-sysroot:/opt/rdk-sysroot but this dir doesnt exist outside the container (on CI), the checks will likely fail.

Tbh the best I can think atm is to use $HOME until we get the public sysroot available, then we get rid of all this.
author_association: COLLABORATOR
user: login: andrunko
created_at: 2025-04-11T02:40:56Z
body: The new CI failures seem unrelated?
```
Post job cleanup.
/usr/local/bin/docker exec  5a6448ea877[2](https://github.com/youtube/cobalt/actions/runs/14394116159/job/40367256156?pr=5166#step:30:2)49e4e732fbba93873e66026e230ab1b9b8c4691aec1452b4f5df sh -c "cat /etc/*release | grep ^ID"
/__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__e/node20/bin/node)
```
author_association: COLLABORATOR