Skip to content

Commit 2780f01

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 33b2b10 commit 2780f01

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
@@ -40,6 +40,9 @@ declare_args() {
4040
# Embeds the given script into the snapshot.
4141
v8_embed_script = ""
4242

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

@@ -224,6 +227,9 @@ config("features") {
224227

225228
defines = []
226229

230+
if (v8_embedder_string != "") {
231+
defines += [ "V8_EMBEDDER_STRING=\"$v8_embedder_string\"" ]
232+
}
227233
if (v8_enable_disassembler) {
228234
defines += [ "ENABLE_DISASSEMBLER" ]
229235
}

deps/v8/gypfiles/features.gypi

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
'v8_target_arch%': '<(target_arch)',
3434
},
3535

36+
# Allows the embedder to add a custom suffix to the version string.
37+
'v8_embedder_string%': '',
38+
3639
'v8_enable_disassembler%': 0,
3740

3841
'v8_promise_internal_field_count%': 0,
@@ -86,6 +89,9 @@
8689
},
8790
'target_defaults': {
8891
'conditions': [
92+
['v8_embedder_string!=""', {
93+
'defines': ['V8_EMBEDDER_STRING="<(v8_embedder_string)"',],
94+
}],
8995
['v8_enable_disassembler==1', {
9096
'defines': ['ENABLE_DISASSEMBLER',],
9197
}],

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
@@ -52,9 +52,16 @@ void Log::Initialize(const char* log_file_name) {
5252

5353
if (output_handle_ != nullptr) {
5454
Log::MessageBuilder msg(this);
55-
msg.Append("v8-version,%d,%d,%d,%d,%d", Version::GetMajor(),
56-
Version::GetMinor(), Version::GetBuild(), Version::GetPatch(),
57-
Version::IsCandidate());
55+
if (strlen(Version::GetEmbedder()) == 0) {
56+
msg.Append("v8-version,%d,%d,%d,%d,%d", Version::GetMajor(),
57+
Version::GetMinor(), Version::GetBuild(),
58+
Version::GetPatch(), Version::IsCandidate());
59+
} else {
60+
msg.Append("v8-version,%d,%d,%d,%d,%s,%d", Version::GetMajor(),
61+
Version::GetMinor(), Version::GetBuild(),
62+
Version::GetPatch(), Version::GetEmbedder(),
63+
Version::IsCandidate());
64+
}
5865
msg.WriteToLogFile();
5966
}
6067
}

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
@@ -35,32 +35,33 @@ namespace v8 {
3535
namespace internal {
3636

3737
void SetVersion(int major, int minor, int build, int patch,
38-
bool candidate, const char* soname) {
38+
const char* embedder, bool candidate, const char* soname) {
3939
Version::major_ = major;
4040
Version::minor_ = minor;
4141
Version::build_ = build;
4242
Version::patch_ = patch;
43+
Version::embedder_ = embedder;
4344
Version::candidate_ = candidate;
4445
Version::soname_ = soname;
4546
}
4647

47-
static void CheckVersion(int major, int minor, int build,
48-
int patch, bool candidate,
48+
static void CheckVersion(int major, int minor, int build, int patch,
49+
const char* embedder, bool candidate,
4950
const char* expected_version_string,
5051
const char* expected_generic_soname) {
5152
static v8::internal::EmbeddedVector<char, 128> version_str;
5253
static v8::internal::EmbeddedVector<char, 128> soname_str;
5354

5455
// Test version without specific SONAME.
55-
SetVersion(major, minor, build, patch, candidate, "");
56+
SetVersion(major, minor, build, patch, embedder, candidate, "");
5657
Version::GetString(version_str);
5758
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
5859
Version::GetSONAME(soname_str);
5960
CHECK_EQ(0, strcmp(expected_generic_soname, soname_str.start()));
6061

6162
// Test version with specific SONAME.
6263
const char* soname = "libv8.so.1";
63-
SetVersion(major, minor, build, patch, candidate, soname);
64+
SetVersion(major, minor, build, patch, embedder, candidate, soname);
6465
Version::GetString(version_str);
6566
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
6667
Version::GetSONAME(soname_str);
@@ -82,19 +83,35 @@ TEST(VersionString) {
8283
CheckVersion(2, 5, 10, 7, false, "2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so");
8384
CheckVersion(2, 5, 10, 7, true,
8485
"2.5.10.7 (candidate) SIMULATOR", "libv8-2.5.10.7-candidate.so");
86+
CheckVersion(6, 0, 287, 0, "-emb.1", false, "6.0.287-emb.1 SIMULATOR",
87+
"libv8-6.0.287-emb.1.so");
88+
CheckVersion(6, 0, 287, 0, "-emb.1", true, "6.0.287-emb.1 (candidate) SIMULATOR",
89+
"libv8-6.0.287-emb.1-candidate.so");
90+
CheckVersion(6, 0, 287, 53, "-emb.1", false, "6.0.287.53-emb.1 SIMULATOR",
91+
"libv8-6.0.287.53-emb.1.so");
92+
CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate) SIMULATOR",
93+
"libv8-6.0.287.53-emb.1-candidate.so");
8594
#else
86-
CheckVersion(0, 0, 0, 0, false, "0.0.0", "libv8-0.0.0.so");
87-
CheckVersion(0, 0, 0, 0, true,
88-
"0.0.0 (candidate)", "libv8-0.0.0-candidate.so");
89-
CheckVersion(1, 0, 0, 0, false, "1.0.0", "libv8-1.0.0.so");
90-
CheckVersion(1, 0, 0, 0, true,
91-
"1.0.0 (candidate)", "libv8-1.0.0-candidate.so");
92-
CheckVersion(1, 0, 0, 1, false, "1.0.0.1", "libv8-1.0.0.1.so");
93-
CheckVersion(1, 0, 0, 1, true,
94-
"1.0.0.1 (candidate)", "libv8-1.0.0.1-candidate.so");
95-
CheckVersion(2, 5, 10, 7, false, "2.5.10.7", "libv8-2.5.10.7.so");
96-
CheckVersion(2, 5, 10, 7, true,
97-
"2.5.10.7 (candidate)", "libv8-2.5.10.7-candidate.so");
95+
CheckVersion(0, 0, 0, 0, "", false, "0.0.0", "libv8-0.0.0.so");
96+
CheckVersion(0, 0, 0, 0, "", true, "0.0.0 (candidate)",
97+
"libv8-0.0.0-candidate.so");
98+
CheckVersion(1, 0, 0, 0, "", false, "1.0.0", "libv8-1.0.0.so");
99+
CheckVersion(1, 0, 0, 0, "", true, "1.0.0 (candidate)",
100+
"libv8-1.0.0-candidate.so");
101+
CheckVersion(1, 0, 0, 1, "", false, "1.0.0.1", "libv8-1.0.0.1.so");
102+
CheckVersion(1, 0, 0, 1, "", true, "1.0.0.1 (candidate)",
103+
"libv8-1.0.0.1-candidate.so");
104+
CheckVersion(2, 5, 10, 7, "", false, "2.5.10.7", "libv8-2.5.10.7.so");
105+
CheckVersion(2, 5, 10, 7, "", true, "2.5.10.7 (candidate)",
106+
"libv8-2.5.10.7-candidate.so");
107+
CheckVersion(6, 0, 287, 0, "-emb.1", false, "6.0.287-emb.1",
108+
"libv8-6.0.287-emb.1.so");
109+
CheckVersion(6, 0, 287, 0, "-emb.1", true, "6.0.287-emb.1 (candidate)",
110+
"libv8-6.0.287-emb.1-candidate.so");
111+
CheckVersion(6, 0, 287, 53, "-emb.1", false, "6.0.287.53-emb.1",
112+
"libv8-6.0.287.53-emb.1.so");
113+
CheckVersion(6, 0, 287, 53, "-emb.1", true, "6.0.287.53-emb.1 (candidate)",
114+
"libv8-6.0.287.53-emb.1-candidate.so");
98115
#endif
99116
}
100117

0 commit comments

Comments
 (0)