Skip to content

Commit

Permalink
Cherry pick PR #1695: Enable modular build for clang 3.9 (#2274)
Browse files Browse the repository at this point in the history
Refer to the original PR: #1695

b/265873566

Co-authored-by: y4vor <[email protected]>
  • Loading branch information
niranjanyardi and y4vor authored Jan 24, 2024
1 parent c0376df commit 61fe23c
Show file tree
Hide file tree
Showing 12 changed files with 135 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/config/linux-clang-3-9.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"name":"clang-3-9",
"platform":"linux-x64x11-clang-3-9",
"target_platform":"linux-x64x11-clang-3-9",
"extra_gn_arguments":"using_old_compiler=true"
"extra_gn_arguments":"using_old_compiler=true build_with_separate_cobalt_toolchain=true"
}
]
}
1 change: 1 addition & 0 deletions .github/workflows/linux_24.lts.1+.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
with:
platform: linux-clang-3-9
nightly: ${{ github.event.inputs.nightly }}
modular: true
linux-gcc-6-3:
uses: ./.github/workflows/main.yaml
permissions:
Expand Down
5 changes: 5 additions & 0 deletions starboard/build/config/base_configuration.gni
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ declare_args() {

# Enable WASM and install WebAssembly global.
v8_enable_webassembly = false

# Set this to true if the modular toolchain linker doesn't strip
# all unused symbols and nplb fails to link.
# TODO: b/297808555 Remove this flag after nplb is fixed
sb_has_unused_symbol_issue = false
}

if (current_toolchain == starboard_toolchain &&
Expand Down
54 changes: 29 additions & 25 deletions starboard/configuration_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,86 +21,87 @@
#ifndef STARBOARD_CONFIGURATION_CONSTANTS_H_
#define STARBOARD_CONFIGURATION_CONSTANTS_H_

#include "starboard/export.h"
#include "starboard/types.h"

// Determines the threshold of allocation size that should be done with mmap
// (if available), rather than allocated within the core heap.
extern const size_t kSbDefaultMmapThreshold;
SB_EXPORT extern const size_t kSbDefaultMmapThreshold;

// The current platform's maximum length of the name of a single directory
// entry, not including the absolute path.
extern const int32_t kSbFileMaxName;
SB_EXPORT extern const int32_t kSbFileMaxName;

// The current platform's maximum number of files that can be opened at the
// same time by one process.
extern const uint32_t kSbFileMaxOpen;
SB_EXPORT extern const uint32_t kSbFileMaxOpen;

// The current platform's alternate file path component separator character.
// This is like SB_FILE_SEP_CHAR, except if your platform supports an alternate
// character, then you can place that here. For example, on windows machines,
// the primary separator character is probably '\', but the alternate is '/'.
extern const char kSbFileAltSepChar;
SB_EXPORT extern const char kSbFileAltSepChar;

// The string form of SB_FILE_ALT_SEP_CHAR.
extern const char* kSbFileAltSepString;
SB_EXPORT extern const char* kSbFileAltSepString;

// The current platform's maximum length of an absolute path.
extern const uint32_t kSbFileMaxPath;
SB_EXPORT extern const uint32_t kSbFileMaxPath;

// The current platform's file path component separator character. This is the
// character that appears after a directory in a file path. For example, the
// absolute canonical path of the file "/path/to/a/file.txt" uses '/' as a path
// component separator character.
extern const char kSbFileSepChar;
SB_EXPORT extern const char kSbFileSepChar;

// The string form of SB_FILE_SEP_CHAR.
extern const char* kSbFileSepString;
SB_EXPORT extern const char* kSbFileSepString;

#if SB_API_VERSION < 15
// Allow ac3 and ec3 support
extern const bool kSbHasAc3Audio;
SB_EXPORT extern const bool kSbHasAc3Audio;
#endif

// Specifies whether this platform has webm/vp9 support. This should be set to
// non-zero on platforms with webm/vp9 support.
extern const bool kSbHasMediaWebmVp9Support;
SB_EXPORT extern const bool kSbHasMediaWebmVp9Support;

// Whether the current platform supports thread priorities.
extern const bool kSbHasThreadPrioritySupport;
SB_EXPORT extern const bool kSbHasThreadPrioritySupport;

// Determines the alignment that allocations should have on this platform.
extern const size_t kSbMallocAlignment;
SB_EXPORT extern const size_t kSbMallocAlignment;

// The maximum number of thread local storage keys supported by this platform.
// This comes from _POSIX_THREAD_KEYS_MAX. The value of PTHREAD_KEYS_MAX is
// higher, but unit tests show that the implementation doesn't support nearly
// as many keys.
extern const uint32_t kSbMaxThreadLocalKeys;
SB_EXPORT extern const uint32_t kSbMaxThreadLocalKeys;

// The maximum length of the name for a thread, including the NULL-terminator.
extern const int32_t kSbMaxThreadNameLength;
SB_EXPORT extern const int32_t kSbMaxThreadNameLength;

// Defines the path where memory debugging logs should be written to.
extern const char* kSbMemoryLogPath;
SB_EXPORT extern const char* kSbMemoryLogPath;

// The maximum audio bitrate the platform can decode. The following value
// equals to 5M bytes per seconds which is more than enough for compressed
// audio.
extern const uint32_t kSbMediaMaxAudioBitrateInBitsPerSecond;
SB_EXPORT extern const uint32_t kSbMediaMaxAudioBitrateInBitsPerSecond;

// The maximum video bitrate the platform can decode. The following value
// equals to 8M bytes per seconds which is more than enough for compressed
// video.
extern const uint32_t kSbMediaMaxVideoBitrateInBitsPerSecond;
SB_EXPORT extern const uint32_t kSbMediaMaxVideoBitrateInBitsPerSecond;

// Specifies how video frame buffers must be aligned on this platform.
extern const uint32_t kSbMediaVideoFrameAlignment;
SB_EXPORT extern const uint32_t kSbMediaVideoFrameAlignment;

// The memory page size, which controls the size of chunks on memory that
// allocators deal with, and the alignment of those chunks. This doesn't have to
// be the hardware-defined physical page size, but it should be a multiple of
// it.
extern const size_t kSbMemoryPageSize;
SB_EXPORT extern const size_t kSbMemoryPageSize;

// Specifies the network receive buffer size in bytes, set via
// SbSocketSetReceiveBufferSize().
Expand All @@ -114,17 +115,17 @@ extern const size_t kSbMemoryPageSize;
//
// If your platform does not have a good TCP auto-tuning mechanism,
// a setting of (128 * 1024) here is recommended.
extern const uint32_t kSbNetworkReceiveBufferSize;
SB_EXPORT extern const uint32_t kSbNetworkReceiveBufferSize;

// Defines the maximum number of simultaneous threads for this platform. Some
// platforms require sharing thread handles with other kinds of system handles,
// like mutexes, so we want to keep this manageable.
extern const uint32_t kSbMaxThreads;
SB_EXPORT extern const uint32_t kSbMaxThreads;

// Specifies the preferred byte order of color channels in a pixel. Refer to
// starboard/configuration.h for the possible values. EGL/GLES platforms should
// generally prefer a byte order of RGBA, regardless of endianness.
extern const int kSbPreferredRgbaByteOrder;
SB_EXPORT extern const int kSbPreferredRgbaByteOrder;

// The current platform's search path component separator character. When
// specifying an ordered list of absolute paths of directories to search for a
Expand All @@ -134,20 +135,23 @@ extern const int kSbPreferredRgbaByteOrder;
#ifdef __cplusplus
extern "C" {
#endif
extern const char kSbPathSepChar;
SB_EXPORT extern const char kSbPathSepChar;
#ifdef __cplusplus
} // extern "C"
#endif

// The string form of SB_PATH_SEP_CHAR.
extern const char* kSbPathSepString;
SB_EXPORT extern const char* kSbPathSepString;

#if SB_API_VERSION < 16
// The maximum number of users that can be signed in at the same time.
extern const uint32_t kSbUserMaxSignedIn;
SB_EXPORT extern const uint32_t kSbUserMaxSignedIn;
#endif // SB_API_VERSION < 16

#if SB_API_VERSION >= 14
// The maximum size the cache directory is allowed to use in bytes.
extern const uint32_t kSbMaxSystemPathCacheDirectorySize;
SB_EXPORT extern const uint32_t kSbMaxSystemPathCacheDirectorySize;
#endif

#endif // STARBOARD_CONFIGURATION_CONSTANTS_H_
10 changes: 9 additions & 1 deletion starboard/linux/shared/cobalt/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,19 @@
],
}

# Tracked by b/294070803
if os.getenv('MODULAR_BUILD', '0') == '1':
# Tracked by b/294070803
_FILTERED_TESTS['layout_tests'] = [
'CobaltSpecificLayoutTests/Layout.Test/platform_object_user_properties_survive_gc', # pylint: disable=line-too-long
]
# TODO: b/303260272 Re-enable these tests.
_FILTERED_TESTS['blackbox'] = [
'cancel_sync_loads_when_suspended',
'preload_font',
'preload_launch_parameter',
'preload_visibility',
'suspend_visibility',
]


class CobaltLinuxConfiguration(cobalt_configuration.CobaltConfiguration):
Expand Down
6 changes: 6 additions & 0 deletions starboard/linux/x64x11/clang/3.9/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ static_library("starboard_platform") {

configs += [ "//starboard/build/config:starboard_implementation" ]
}

if (build_with_separate_cobalt_toolchain) {
group("starboard_platform_with_main") {
deps = [ "//starboard/linux/x64x11:starboard_platform_with_main" ]
}
}
1 change: 1 addition & 0 deletions starboard/linux/x64x11/clang/3.9/args.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ target_platform = "linux-x64x11-clang-3-9"
target_os = "linux"
target_cpu = "x64"
using_old_compiler = true
build_with_separate_cobalt_toolchain = true
22 changes: 15 additions & 7 deletions starboard/linux/x64x11/clang/3.9/platform_configuration/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ config("compiler_flags") {
cflags = []
cflags_c = []
cflags_cc = []
ldflags = []
defines = []

ldflags = [
# Cleanup unused sections
"-Wl,-gc-sections",
]
cflags += [
"-Werror",
"-fcolor-diagnostics",
Expand Down Expand Up @@ -180,10 +183,15 @@ config("no_pedantic_warnings") {
}

config("platform_configuration") {
configs = [
"//starboard/linux/shared/platform_configuration",
"//starboard/linux/x64x11/shared/platform_configuration:libraries",
"//starboard/build/config/sabi",
":compiler_flags",
]
if (current_toolchain == default_toolchain &&
build_with_separate_cobalt_toolchain) {
configs = [ "//starboard/evergreen/x64/platform_configuration" ]
} else {
configs = [
"//starboard/linux/shared/platform_configuration",
"//starboard/linux/x64x11/shared/platform_configuration:libraries",
"//starboard/build/config/sabi",
":compiler_flags",
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,48 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import("//starboard/build/config/base_configuration.gni")
if (current_toolchain == default_toolchain &&
build_with_separate_cobalt_toolchain) {
import("//starboard/evergreen/x64/platform_configuration/configuration.gni")
platform_tests_path =
"//starboard/linux/shared:starboard_platform_tests($starboard_toolchain)"
cobalt_font_package = "standard"

nasm_exists = true
sb_has_unused_symbol_issue = true
} else {
import("//starboard/build/config/base_configuration.gni")

sb_static_contents_output_data_dir = "$root_out_dir/content"
nasm_exists = true

sb_enable_benchmark = true
sb_static_contents_output_data_dir = "$root_out_dir/content"

install_target_path = "//starboard/build/install/install_target.gni"
sb_enable_benchmark = true

sb_enable_opus_sse = false
install_target_path = "//starboard/build/install/install_target.gni"

speed_config_path = "//starboard/linux/shared/platform_configuration:speed"
size_config_path = "//starboard/linux/shared/platform_configuration:size"
sb_enable_opus_sse = false

pedantic_warnings_config_path =
"//starboard/linux/shared/platform_configuration:pedantic_warnings"
no_pedantic_warnings_config_path = "//starboard/linux/x64x11/clang/3.9/platform_configuration:no_pedantic_warnings"
speed_config_path = "//starboard/linux/shared/platform_configuration:speed"
size_config_path = "//starboard/linux/shared/platform_configuration:size"

sb_widevine_platform = "linux"
pedantic_warnings_config_path =
"//starboard/linux/shared/platform_configuration:pedantic_warnings"
no_pedantic_warnings_config_path = "//starboard/linux/x64x11/clang/3.9/platform_configuration:no_pedantic_warnings"

platform_tests_path = "//starboard/linux/shared:starboard_platform_tests"
sb_widevine_platform = "linux"

enable_in_app_dial = true
platform_tests_path = "//starboard/linux/shared:starboard_platform_tests"

sabi_path = "//starboard/sabi/x64/sysv/sabi-v$sb_api_version.json"
enable_in_app_dial = true

gl_type = "angle"
sb_angle_enable_gl = true
sabi_path = "//starboard/sabi/x64/sysv/sabi-v$sb_api_version.json"

cobalt_v8_emit_builtins_as_inline_asm = true
gl_type = "angle"
sb_angle_enable_gl = true

sb_enable_cpp17_audit = false
cobalt_v8_emit_builtins_as_inline_asm = true

v8_enable_webassembly = false
sb_enable_cpp17_audit = false

v8_enable_webassembly = false
}
19 changes: 19 additions & 0 deletions starboard/linux/x64x11/clang/3.9/starboard_loader.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.

#include "starboard/event.h"

int main(int argc, char** argv) {
return SbRunStarboardMain(argc, argv, SbEventHandle);
}
17 changes: 17 additions & 0 deletions starboard/linux/x64x11/clang/3.9/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
# limitations under the License.

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

_target_llvm_3_9_bin_dir = "/usr/lib/llvm-3.9/bin"

cobalt_clang_toolchain("cobalt") {
native_linker_path = "${_target_llvm_3_9_bin_dir}/clang++"
}

overridable_gcc_toolchain("target") {
cc = "${_target_llvm_3_9_bin_dir}/clang"
cxx = "${_target_llvm_3_9_bin_dir}/clang++"
Expand All @@ -27,3 +33,14 @@ overridable_gcc_toolchain("target") {
is_clang = true
}
}

overridable_gcc_toolchain("starboard") {
cc = "${_target_llvm_3_9_bin_dir}/clang"
cxx = "${_target_llvm_3_9_bin_dir}/clang++"
ld = cxx
ar = "ar"

toolchain_args = {
is_clang = true
}
}
4 changes: 2 additions & 2 deletions starboard/nplb/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ target(gtest_target_type, "nplb") {
cflags = [ "-Wno-enum-constexpr-conversion" ]
}

# TODO: b/297808555 - Add these tests for windows based platform modular builds.
if (sb_is_modular && !sb_is_evergreen && is_host_win) {
# TODO: b/297808555 - Add these tests for all modular builds.
if (sb_has_unused_symbol_issue) {
sources -= [
"maximum_player_configuration_explorer.cc",
"maximum_player_configuration_explorer.h",
Expand Down

0 comments on commit 61fe23c

Please sign in to comment.