Skip to content

Commit acb9b8f

Browse files
committed
deps: backport b096c44 from upstream V8
Original commit message: [build] Introduce an embedder version string Sometimes, the embedder might want to merge a fix to an abandoned branch or to a supported branch but the fix is not relevant to Chromium. This adds a new version string that the embedder can set at compile time and that will be appended to the official V8 version. The separator must be provided in the string. For instance, to have a full version string like "6.0.287.53-emb.1", the embedder must set V8_EMBEDDER_STRING to "-emb.1". Related Node.js issue: #9754 BUG=v8:5740 [email protected] Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Ifa2d9bd213795e6d54886436f8c3787ac6162823 Reviewed-on: https://chromium-review.googlesource.com/690475 Reviewed-by: Michael Achenbach <[email protected]> Reviewed-by: Yang Guo <[email protected]> Commit-Queue: Michaël Zasso <[email protected]> Cr-Commit-Position: refs/heads/master@{#48301} Refs: v8/v8@b096c44 PR-URL: #15785 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent 9960e53 commit acb9b8f

File tree

7 files changed

+75
-31
lines changed

7 files changed

+75
-31
lines changed

deps/v8/BUILD.gn

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ declare_args() {
3939
# Embeds the given script into the snapshot.
4040
v8_embed_script = ""
4141

42+
# Allows the embedder to add a custom suffix to the version string.
43+
v8_embedder_string = ""
44+
4245
# Sets -dENABLE_DISASSEMBLER.
4346
v8_enable_disassembler = ""
4447

@@ -217,6 +220,9 @@ config("features") {
217220

218221
defines = []
219222

223+
if (v8_embedder_string != "") {
224+
defines += [ "V8_EMBEDDER_STRING=\"$v8_embedder_string\"" ]
225+
}
220226
if (v8_enable_disassembler) {
221227
defines += [ "ENABLE_DISASSEMBLER" ]
222228
}

deps/v8/gypfiles/features.gypi

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929

3030
{
3131
'variables': {
32+
# Allows the embedder to add a custom suffix to the version string.
33+
'v8_embedder_string%': '',
34+
3235
'v8_enable_disassembler%': 0,
3336

3437
'v8_promise_internal_field_count%': 0,
@@ -79,6 +82,9 @@
7982
},
8083
'target_defaults': {
8184
'conditions': [
85+
['v8_embedder_string!=""', {
86+
'defines': ['V8_EMBEDDER_STRING="<(v8_embedder_string)"',],
87+
}],
8288
['v8_enable_disassembler==1', {
8389
'defines': ['ENABLE_DISASSEMBLER',],
8490
}],

deps/v8/include/v8-version-string.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
#define V8_CANDIDATE_STRING ""
1717
#endif
1818

19+
#ifndef V8_EMBEDDER_STRING
20+
#define V8_EMBEDDER_STRING ""
21+
#endif
22+
1923
#define V8_SX(x) #x
2024
#define V8_S(x) V8_SX(x)
2125

2226
#if V8_PATCH_LEVEL > 0
2327
#define V8_VERSION_STRING \
2428
V8_S(V8_MAJOR_VERSION) \
2529
"." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) "." V8_S( \
26-
V8_PATCH_LEVEL) V8_CANDIDATE_STRING
30+
V8_PATCH_LEVEL) V8_EMBEDDER_STRING V8_CANDIDATE_STRING
2731
#else
2832
#define V8_VERSION_STRING \
2933
V8_S(V8_MAJOR_VERSION) \

deps/v8/src/log-utils.cc

+10-3
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,16 @@ void Log::Initialize(const char* log_file_name) {
5555

5656
if (output_handle_ != nullptr) {
5757
Log::MessageBuilder msg(this);
58-
msg.Append("v8-version,%d,%d,%d,%d,%d", Version::GetMajor(),
59-
Version::GetMinor(), Version::GetBuild(), Version::GetPatch(),
60-
Version::IsCandidate());
58+
if (strlen(Version::GetEmbedder()) == 0) {
59+
msg.Append("v8-version,%d,%d,%d,%d,%d", Version::GetMajor(),
60+
Version::GetMinor(), Version::GetBuild(),
61+
Version::GetPatch(), Version::IsCandidate());
62+
} else {
63+
msg.Append("v8-version,%d,%d,%d,%d,%s,%d", Version::GetMajor(),
64+
Version::GetMinor(), Version::GetBuild(),
65+
Version::GetPatch(), Version::GetEmbedder(),
66+
Version::IsCandidate());
67+
}
6168
msg.WriteToLogFile();
6269
}
6370
}

deps/v8/src/version.cc

+10-9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ int Version::major_ = V8_MAJOR_VERSION;
2020
int Version::minor_ = V8_MINOR_VERSION;
2121
int Version::build_ = V8_BUILD_NUMBER;
2222
int Version::patch_ = V8_PATCH_LEVEL;
23+
const char* Version::embedder_ = V8_EMBEDDER_STRING;
2324
bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0);
2425
const char* Version::soname_ = SONAME;
2526
const char* Version::version_string_ = V8_VERSION_STRING;
@@ -33,12 +34,12 @@ void Version::GetString(Vector<char> str) {
3334
const char* is_simulator = "";
3435
#endif // USE_SIMULATOR
3536
if (GetPatch() > 0) {
36-
SNPrintF(str, "%d.%d.%d.%d%s%s",
37-
GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate,
38-
is_simulator);
37+
SNPrintF(str, "%d.%d.%d.%d%s%s%s",
38+
GetMajor(), GetMinor(), GetBuild(), GetPatch(), GetEmbedder(),
39+
candidate, is_simulator);
3940
} else {
40-
SNPrintF(str, "%d.%d.%d%s%s",
41-
GetMajor(), GetMinor(), GetBuild(), candidate,
41+
SNPrintF(str, "%d.%d.%d%s%s%s",
42+
GetMajor(), GetMinor(), GetBuild(), GetEmbedder(), candidate,
4243
is_simulator);
4344
}
4445
}
@@ -50,11 +51,11 @@ void Version::GetSONAME(Vector<char> str) {
5051
// Generate generic SONAME if no specific SONAME is defined.
5152
const char* candidate = IsCandidate() ? "-candidate" : "";
5253
if (GetPatch() > 0) {
53-
SNPrintF(str, "libv8-%d.%d.%d.%d%s.so",
54-
GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate);
54+
SNPrintF(str, "libv8-%d.%d.%d.%d%s%s.so", GetMajor(), GetMinor(),
55+
GetBuild(), GetPatch(), GetEmbedder(), candidate);
5556
} else {
56-
SNPrintF(str, "libv8-%d.%d.%d%s.so",
57-
GetMajor(), GetMinor(), GetBuild(), candidate);
57+
SNPrintF(str, "libv8-%d.%d.%d%s%s.so", GetMajor(), GetMinor(), GetBuild(),
58+
GetEmbedder(), candidate);
5859
}
5960
} else {
6061
// Use specific SONAME.

deps/v8/src/version.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Version {
1818
static int GetMinor() { return minor_; }
1919
static int GetBuild() { return build_; }
2020
static int GetPatch() { return patch_; }
21+
static const char* GetEmbedder() { return embedder_; }
2122
static bool IsCandidate() { return candidate_; }
2223
static uint32_t Hash() {
2324
return static_cast<uint32_t>(
@@ -38,13 +39,15 @@ class Version {
3839
static int minor_;
3940
static int build_;
4041
static int patch_;
42+
static const char* embedder_;
4143
static bool candidate_;
4244
static const char* soname_;
4345
static const char* version_string_;
4446

4547
// In test-version.cc.
4648
friend void SetVersion(int major, int minor, int build, int patch,
47-
bool candidate, const char* soname);
49+
const char* embedder, bool candidate,
50+
const char* soname);
4851
};
4952

5053
} // namespace internal

deps/v8/test/cctest/test-version.cc

+34-17
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ namespace v8 {
3737
namespace internal {
3838

3939
void SetVersion(int major, int minor, int build, int patch,
40-
bool candidate, const char* soname) {
40+
const char* embedder, bool candidate, const char* soname) {
4141
Version::major_ = major;
4242
Version::minor_ = minor;
4343
Version::build_ = build;
4444
Version::patch_ = patch;
45+
Version::embedder_ = embedder;
4546
Version::candidate_ = candidate;
4647
Version::soname_ = soname;
4748
}
@@ -50,23 +51,23 @@ void SetVersion(int major, int minor, int build, int patch,
5051
} // namespace v8
5152

5253

53-
static void CheckVersion(int major, int minor, int build,
54-
int patch, bool candidate,
54+
static void CheckVersion(int major, int minor, int build, int patch,
55+
const char* embedder, bool candidate,
5556
const char* expected_version_string,
5657
const char* expected_generic_soname) {
5758
static v8::internal::EmbeddedVector<char, 128> version_str;
5859
static v8::internal::EmbeddedVector<char, 128> soname_str;
5960

6061
// Test version without specific SONAME.
61-
SetVersion(major, minor, build, patch, candidate, "");
62+
SetVersion(major, minor, build, patch, embedder, candidate, "");
6263
Version::GetString(version_str);
6364
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
6465
Version::GetSONAME(soname_str);
6566
CHECK_EQ(0, strcmp(expected_generic_soname, soname_str.start()));
6667

6768
// Test version with specific SONAME.
6869
const char* soname = "libv8.so.1";
69-
SetVersion(major, minor, build, patch, candidate, soname);
70+
SetVersion(major, minor, build, patch, embedder, candidate, soname);
7071
Version::GetString(version_str);
7172
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
7273
Version::GetSONAME(soname_str);
@@ -88,18 +89,34 @@ TEST(VersionString) {
8889
CheckVersion(2, 5, 10, 7, false, "2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so");
8990
CheckVersion(2, 5, 10, 7, true,
9091
"2.5.10.7 (candidate) SIMULATOR", "libv8-2.5.10.7-candidate.so");
92+
CheckVersion(6, 0, 287, 0, "-emb.1", false, "6.0.287-emb.1 SIMULATOR",
93+
"libv8-6.0.287-emb.1.so");
94+
CheckVersion(6, 0, 287, 0, "-emb.1", true, "6.0.287-emb.1 (candidate) SIMULATOR",
95+
"libv8-6.0.287-emb.1-candidate.so");
96+
CheckVersion(6, 0, 287, 53, "-emb.1", false, "6.0.287.53-emb.1 SIMULATOR",
97+
"libv8-6.0.287.53-emb.1.so");
98+
CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate) SIMULATOR",
99+
"libv8-6.0.287.53-emb.1-candidate.so");
91100
#else
92-
CheckVersion(0, 0, 0, 0, false, "0.0.0", "libv8-0.0.0.so");
93-
CheckVersion(0, 0, 0, 0, true,
94-
"0.0.0 (candidate)", "libv8-0.0.0-candidate.so");
95-
CheckVersion(1, 0, 0, 0, false, "1.0.0", "libv8-1.0.0.so");
96-
CheckVersion(1, 0, 0, 0, true,
97-
"1.0.0 (candidate)", "libv8-1.0.0-candidate.so");
98-
CheckVersion(1, 0, 0, 1, false, "1.0.0.1", "libv8-1.0.0.1.so");
99-
CheckVersion(1, 0, 0, 1, true,
100-
"1.0.0.1 (candidate)", "libv8-1.0.0.1-candidate.so");
101-
CheckVersion(2, 5, 10, 7, false, "2.5.10.7", "libv8-2.5.10.7.so");
102-
CheckVersion(2, 5, 10, 7, true,
103-
"2.5.10.7 (candidate)", "libv8-2.5.10.7-candidate.so");
101+
CheckVersion(0, 0, 0, 0, "", false, "0.0.0", "libv8-0.0.0.so");
102+
CheckVersion(0, 0, 0, 0, "", true, "0.0.0 (candidate)",
103+
"libv8-0.0.0-candidate.so");
104+
CheckVersion(1, 0, 0, 0, "", false, "1.0.0", "libv8-1.0.0.so");
105+
CheckVersion(1, 0, 0, 0, "", true, "1.0.0 (candidate)",
106+
"libv8-1.0.0-candidate.so");
107+
CheckVersion(1, 0, 0, 1, "", false, "1.0.0.1", "libv8-1.0.0.1.so");
108+
CheckVersion(1, 0, 0, 1, "", true, "1.0.0.1 (candidate)",
109+
"libv8-1.0.0.1-candidate.so");
110+
CheckVersion(2, 5, 10, 7, "", false, "2.5.10.7", "libv8-2.5.10.7.so");
111+
CheckVersion(2, 5, 10, 7, "", true, "2.5.10.7 (candidate)",
112+
"libv8-2.5.10.7-candidate.so");
113+
CheckVersion(6, 0, 287, 0, "-emb.1", false, "6.0.287-emb.1",
114+
"libv8-6.0.287-emb.1.so");
115+
CheckVersion(6, 0, 287, 0, "-emb.1", true, "6.0.287-emb.1 (candidate)",
116+
"libv8-6.0.287-emb.1-candidate.so");
117+
CheckVersion(6, 0, 287, 53, "-emb.1", false, "6.0.287.53-emb.1",
118+
"libv8-6.0.287.53-emb.1.so");
119+
CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate)",
120+
"libv8-6.0.287.53-emb.1-candidate.so");
104121
#endif
105122
}

0 commit comments

Comments
 (0)