Skip to content

Commit

Permalink
Create intermediate cobalt toolchain for native linker modular builds (
Browse files Browse the repository at this point in the history
…#1516)

b/294450490

Make an intermediate cobalt toolchain template which can be used for
native linker modular builds.

(cherry picked from commit e8a8ca6)
  • Loading branch information
niranjanyardi authored and anonymous1-me committed Sep 23, 2023
1 parent 188d1a0 commit c84d12d
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 18 deletions.
2 changes: 1 addition & 1 deletion starboard/build/config/BUILDCONFIG.gn
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ if (target_cpu == "x86" || target_cpu == "arm") {
host_toolchain = "//starboard/build/toolchain/$host_os:$_host_toolchain_cpu"

if (build_with_separate_cobalt_toolchain) {
cobalt_toolchain = "//starboard/build/toolchain:clang"
cobalt_toolchain = "//$starboard_path/toolchain:cobalt"
starboard_toolchain = "//$starboard_path/toolchain:starboard"
} else {
cobalt_toolchain = "//$starboard_path/toolchain:target"
Expand Down
52 changes: 52 additions & 0 deletions starboard/build/toolchain/cobalt_toolchains.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright 2023 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.

import("//build/config/win/visual_studio_version.gni")
import("//build/toolchain/gcc_toolchain.gni")

template("cobalt_clang_toolchain") {
gcc_toolchain(target_name) {
forward_variables_from(invoker.variables,
[
"native_linker_path",
"executable_extension",
"shlib_extension",
])
assert(defined(native_linker_path),
"native_linker_path has to be defined by the platform")
if (!is_host_win) {
prefix = rebase_path("$clang_base_path/bin", root_build_dir)
cc = "$prefix/clang"
cxx = "$prefix/clang++"
ld = native_linker_path
readelf = "readelf"
ar = "${prefix}/llvm-ar"
nm = "nm"
} else {
prefix = llvm_clang_path
cc = "$prefix/clang.exe"
cxx = "$prefix/clang++.exe"
ld = native_linker_path
readelf = "$prefix/llvm-readobj.exe"
ar = "${prefix}/llvm-ar.exe"
nm = "${prefix}/llvm-nm.exe"
}
toolchain_args = {
if (defined(invoker.toolchain_args)) {
forward_variables_from(invoker.toolchain_args, "*")
}
is_clang = true
}
}
}
7 changes: 7 additions & 0 deletions starboard/linux/x64x11/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
# limitations under the License.

import("//build/config/clang/clang.gni")
import("//starboard/build/toolchain/cobalt_toolchains.gni")
import("//starboard/shared/toolchain/overridable_gcc_toolchain.gni")

overridable_clang_toolchain("starboard") {
clang_base_path = clang_base_path
}

cobalt_clang_toolchain("cobalt") {
variables = {
native_linker_path = "$clang_base_path/bin/clang++"
}
}

overridable_clang_toolchain("target") {
clang_base_path = clang_base_path
}
Expand Down
7 changes: 7 additions & 0 deletions starboard/raspi/2/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,15 @@
# limitations under the License.

import("//build/toolchain/gcc_toolchain.gni")
import("//starboard/build/toolchain/cobalt_toolchains.gni")
import("//starboard/raspi/shared/toolchain/raspi_shared_toolchain.gni")

cobalt_clang_toolchain("cobalt") {
variables = {
native_linker_path = gcc_toolchain_cxx
}
}

gcc_toolchain("starboard") {
cc = gcc_toolchain_cc
cxx = gcc_toolchain_cxx
Expand Down
17 changes: 0 additions & 17 deletions starboard/raspi/2/toolchain/variables.gni

This file was deleted.

0 comments on commit c84d12d

Please sign in to comment.