Skip to content

Commit 6a7aa65

Browse files
committed
deps: introduce embedder version string for V8
Sometimes upstream V8 may not want to merge a fix to their stable branches, but we might. This adds a new version string that the embedder can set independently of the official V8 version to avoid running into conflicts. Refs: nodejs#9730
1 parent 61d6293 commit 6a7aa65

File tree

6 files changed

+68
-33
lines changed

6 files changed

+68
-33
lines changed

deps/v8/gypfiles/features.gypi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
# Enable compiler warnings when using V8_DEPRECATE_SOON apis.
6565
'v8_imminent_deprecation_warnings%': 0,
6666

67+
'v8_embedder_string%': '',
68+
6769
# Set to 1 to enable DCHECKs in release builds.
6870
'dcheck_always_on%': 0,
6971

@@ -105,6 +107,9 @@
105107
['v8_use_snapshot=="true" and v8_use_external_startup_data==1', {
106108
'defines': ['V8_USE_EXTERNAL_STARTUP_DATA',],
107109
}],
110+
['v8_embedder_string', {
111+
'defines': ['V8_EMBEDDER_STRING="<(v8_embedder_string)"',],
112+
}],
108113
['dcheck_always_on!=0', {
109114
'defines': ['DEBUG',],
110115
}],

deps/v8/include/v8-version.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#define V8_BUILD_NUMBER 500
1414
#define V8_PATCH_LEVEL 44
1515

16+
#ifndef V8_EMBEDDER_STRING
17+
#define V8_EMBEDDER_STRING ""
18+
#endif // V8_EMBEDDER_STRING
19+
1620
// Use 1 for candidates and 0 otherwise.
1721
// (Boolean macro values are not supported by all preprocessors.)
1822
#define V8_IS_CANDIDATE_VERSION 0

deps/v8/src/log-utils.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,17 @@ void Log::Initialize(const char* log_file_name) {
5656

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

deps/v8/src/version.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#if V8_PATCH_LEVEL > 0
2525
#define VERSION_STRING \
2626
S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) "." S( \
27-
V8_PATCH_LEVEL) CANDIDATE_STRING
27+
V8_PATCH_LEVEL) V8_EMBEDDER_STRING CANDIDATE_STRING
2828
#else
2929
#define VERSION_STRING \
3030
S(V8_MAJOR_VERSION) "." S(V8_MINOR_VERSION) "." S(V8_BUILD_NUMBER) \
@@ -38,6 +38,7 @@ int Version::major_ = V8_MAJOR_VERSION;
3838
int Version::minor_ = V8_MINOR_VERSION;
3939
int Version::build_ = V8_BUILD_NUMBER;
4040
int Version::patch_ = V8_PATCH_LEVEL;
41+
const char* Version::embedder_ = V8_EMBEDDER_STRING;
4142
bool Version::candidate_ = (V8_IS_CANDIDATE_VERSION != 0);
4243
const char* Version::soname_ = SONAME;
4344
const char* Version::version_string_ = VERSION_STRING;
@@ -51,9 +52,9 @@ void Version::GetString(Vector<char> str) {
5152
const char* is_simulator = "";
5253
#endif // USE_SIMULATOR
5354
if (GetPatch() > 0) {
54-
SNPrintF(str, "%d.%d.%d.%d%s%s",
55-
GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate,
56-
is_simulator);
55+
SNPrintF(str, "%d.%d.%d.%d%s%s%s",
56+
GetMajor(), GetMinor(), GetBuild(), GetPatch(), GetEmbedder(),
57+
candidate, is_simulator);
5758
} else {
5859
SNPrintF(str, "%d.%d.%d%s%s",
5960
GetMajor(), GetMinor(), GetBuild(), candidate,
@@ -68,8 +69,9 @@ void Version::GetSONAME(Vector<char> str) {
6869
// Generate generic SONAME if no specific SONAME is defined.
6970
const char* candidate = IsCandidate() ? "-candidate" : "";
7071
if (GetPatch() > 0) {
71-
SNPrintF(str, "libv8-%d.%d.%d.%d%s.so",
72-
GetMajor(), GetMinor(), GetBuild(), GetPatch(), candidate);
72+
SNPrintF(str, "libv8-%d.%d.%d.%d%s%s.so",
73+
GetMajor(), GetMinor(), GetBuild(), GetPatch(), GetEmbedder(),
74+
candidate);
7375
} else {
7476
SNPrintF(str, "libv8-%d.%d.%d%s.so",
7577
GetMajor(), GetMinor(), GetBuild(), candidate);

deps/v8/src/version.h

Lines changed: 4 additions & 1 deletion
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

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ 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,
41+
const char* soname) {
4142
Version::major_ = major;
4243
Version::minor_ = minor;
4344
Version::build_ = build;
4445
Version::patch_ = patch;
46+
Version::embedder_ = embedder;
4547
Version::candidate_ = candidate;
4648
Version::soname_ = soname;
4749
}
@@ -51,22 +53,22 @@ void SetVersion(int major, int minor, int build, int patch,
5153

5254

5355
static void CheckVersion(int major, int minor, int build,
54-
int patch, bool candidate,
56+
int patch, const char* embedder, bool candidate,
5557
const char* expected_version_string,
5658
const char* expected_generic_soname) {
5759
static v8::internal::EmbeddedVector<char, 128> version_str;
5860
static v8::internal::EmbeddedVector<char, 128> soname_str;
5961

6062
// Test version without specific SONAME.
61-
SetVersion(major, minor, build, patch, candidate, "");
63+
SetVersion(major, minor, build, patch, embedder, candidate, "");
6264
Version::GetString(version_str);
6365
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
6466
Version::GetSONAME(soname_str);
6567
CHECK_EQ(0, strcmp(expected_generic_soname, soname_str.start()));
6668

6769
// Test version with specific SONAME.
6870
const char* soname = "libv8.so.1";
69-
SetVersion(major, minor, build, patch, candidate, soname);
71+
SetVersion(major, minor, build, patch, embedder, candidate, soname);
7072
Version::GetString(version_str);
7173
CHECK_EQ(0, strcmp(expected_version_string, version_str.start()));
7274
Version::GetSONAME(soname_str);
@@ -76,30 +78,41 @@ static void CheckVersion(int major, int minor, int build,
7678

7779
TEST(VersionString) {
7880
#ifdef USE_SIMULATOR
79-
CheckVersion(0, 0, 0, 0, false, "0.0.0 SIMULATOR", "libv8-0.0.0.so");
80-
CheckVersion(0, 0, 0, 0, true,
81+
CheckVersion(0, 0, 0, 0, "", false, "0.0.0 SIMULATOR", "libv8-0.0.0.so");
82+
CheckVersion(0, 0, 0, 0, "", true,
8183
"0.0.0 (candidate) SIMULATOR", "libv8-0.0.0-candidate.so");
82-
CheckVersion(1, 0, 0, 0, false, "1.0.0 SIMULATOR", "libv8-1.0.0.so");
83-
CheckVersion(1, 0, 0, 0, true,
84+
CheckVersion(1, 0, 0, 0, "", false, "1.0.0 SIMULATOR", "libv8-1.0.0.so");
85+
CheckVersion(1, 0, 0, 0, "", true,
8486
"1.0.0 (candidate) SIMULATOR", "libv8-1.0.0-candidate.so");
85-
CheckVersion(1, 0, 0, 1, false, "1.0.0.1 SIMULATOR", "libv8-1.0.0.1.so");
86-
CheckVersion(1, 0, 0, 1, true,
87-
"1.0.0.1 (candidate) SIMULATOR", "libv8-1.0.0.1-candidate.so");
88-
CheckVersion(2, 5, 10, 7, false, "2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so");
89-
CheckVersion(2, 5, 10, 7, true,
90-
"2.5.10.7 (candidate) SIMULATOR", "libv8-2.5.10.7-candidate.so");
87+
CheckVersion(1, 0, 0, 1, "", false,
88+
"1.0.0.1 SIMULATOR", "libv8-1.0.0.1.so");
89+
CheckVersion(1, 0, 0, 1, "", true, "1.0.0.1 (candidate) SIMULATOR",
90+
"libv8-1.0.0.1-candidate.so");
91+
CheckVersion(2, 5, 10, 7, "", false,
92+
"2.5.10.7 SIMULATOR", "libv8-2.5.10.7.so");
93+
CheckVersion(2, 5, 10, 7, "", true, "2.5.10.7 (candidate) SIMULATOR",
94+
"libv8-2.5.10.7.0-candidate.so");
95+
CheckVersion(2, 5, 10, 7, ".emb.1", false,
96+
"2.5.10.7.emb.1 SIMULATOR", "libv8-2.5.10.7.emb.1.so");
97+
CheckVersion(2, 5, 10, 7, ".emb.1", true,
98+
"2.5.10.7.emb.1 (candidate) SIMULATOR",
99+
"libv8-2.5.10.7.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,
101+
CheckVersion(0, 0, 0, 0, "", false, "0.0.0", "libv8-0.0.0.so");
102+
CheckVersion(0, 0, 0, 0, "", true,
94103
"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,
104+
CheckVersion(1, 0, 0, 0, "", false, "1.0.0", "libv8-1.0.0.so");
105+
CheckVersion(1, 0, 0, 0, "", true,
97106
"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,
107+
CheckVersion(1, 0, 0, 1, "", false, "1.0.0.1", "libv8-1.0.0.1.so");
108+
CheckVersion(1, 0, 0, 1, "", true,
109+
"1.0.0.1.0 (candidate)", "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,
103112
"2.5.10.7 (candidate)", "libv8-2.5.10.7-candidate.so");
113+
CheckVersion(2, 5, 10, 7, ".emb.1", false, "2.5.10.7.emb.1",
114+
"libv8-2.5.10.7.emb.1.so");
115+
CheckVersion(2, 5, 10, 7, ".emb.1", true, "2.5.10.7.emb.1 (candidate)",
116+
"libv8-2.5.10.7.emb.1-candidate.so");
104117
#endif
105118
}

0 commit comments

Comments
 (0)