aboutsummaryrefslogtreecommitdiff
path: root/ports/v8/build.patch
blob: 15fede3fe87c31d95bad382ee9619b87fd586b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn
index 1904a2559..e66586c88 100644
--- a/config/compiler/BUILD.gn
+++ b/config/compiler/BUILD.gn
@@ -1571,6 +1571,7 @@ config("default_warnings") {
       # Disables.
       "-Wno-missing-field-initializers",  # "struct foo f = {0};"
       "-Wno-unused-parameter",  # Unused function parameters.
+      "-Wno-invalid-offsetof", # Use of "conditionally-supported" offsetof in c++17
     ]
   }
 
@@ -1987,8 +1988,17 @@ config("no_incompatible_pointer_warnings") {
 # Shared settings for both "optimize" and "optimize_max" configs.
 # IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
 if (is_win) {
-  common_optimize_on_cflags = [
-    "/Ob2",  # Both explicit and auto inlining.
+  common_optimize_on_cflags = []
+  if(is_clang) {
+    common_optimize_on_cflags += [
+     "/Ob2",  # Both explicit and auto inlining.
+    ]
+  } else {
+    common_optimize_on_cflags += [
+      "/Ob3",  # Both explicit and auto inlining.
+    ]
+  }
+  common_optimize_on_cflags += [
     "/Oy-",  # Disable omitting frame pointers, must be after /O2.
     "/Zc:inline",  # Remove unreferenced COMDAT (faster links).
   ]
diff --git a/config/linux/pkg-config.py b/config/linux/pkg-config.py
index 5adf70cc3..dab159f98 100755
--- a/config/linux/pkg-config.py
+++ b/config/linux/pkg-config.py
@@ -41,6 +41,11 @@ from optparse import OptionParser
 # Additionally, you can specify the option --atleast-version. This will skip
 # the normal outputting of a dictionary and instead print true or false,
 # depending on the return value of pkg-config for the given package.
+#
+# --pkg_config_libdir=<path> allows direct override
+# of the PKG_CONFIG_LIBDIR environment library.
+#
+# --full-path-libs causes lib names to include their full path.
 
 
 def SetConfigPath(options):
@@ -105,11 +110,32 @@ def RewritePath(path, strip_prefix, sysroot):
     return path
 
 
+flag_regex = re.compile("(-.)(.+)")
+
+
+def FlagReplace(matchobj):
+  if matchobj.group(1) == '-I':
+     return matchobj.group(1) + subprocess.check_output([u'cygpath',u'-w',matchobj.group(2)]).strip().decode("utf-8")
+  if matchobj.group(1) == '-L':
+     return matchobj.group(1) + subprocess.check_output([u'cygpath',u'-w',matchobj.group(2)]).strip().decode("utf-8")
+  if matchobj.group(1) == '-l':
+     return matchobj.group(1) + matchobj.group(2) + '.lib'
+  return matchobj.group(0)
+
+
+def ConvertGCCToMSVC(flags):
+  """Rewrites GCC flags into MSVC flags."""
+  # need a better way to determine mingw vs msvc build
+  if 'win32' not in sys.platform or "GCC" in sys.version:
+    return flags
+  return [ flag_regex.sub(FlagReplace,flag) for flag in flags]
+
+
 def main():
   # If this is run on non-Linux platforms, just return nothing and indicate
   # success. This allows us to "kind of emulate" a Linux build from other
   # platforms.
-  if "linux" not in sys.platform:
+  if "linux" not in sys.platform and 'win32' not in sys.platform:
     print("[[],[],[],[],[]]")
     return 0
 
@@ -128,6 +154,9 @@ def main():
   parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir')
   parser.add_option('--version-as-components', action='store_true',
                     dest='version_as_components')
+  parser.add_option('--pkg_config_libdir', action='store', dest='pkg_config_libdir',
+                    type='string')
+  parser.add_option('--full-path-libs', action='store_true', dest='full_path_libs')
   (options, args) = parser.parse_args()
 
   # Make a list of regular expressions to strip out.
@@ -144,6 +173,10 @@ def main():
   else:
     prefix = ''
 
+  # Override PKG_CONFIG_LIBDIR
+  if options.pkg_config_libdir:
+    os.environ['PKG_CONFIG_LIBDIR'] = options.pkg_config_libdir
+
   if options.atleast_version:
     # When asking for the return value, just run pkg-config and print the return
     # value, no need to do other work.
@@ -203,7 +236,7 @@ def main():
   # For now just split on spaces to get the args out. This will break if
   # pkgconfig returns quoted things with spaces in them, but that doesn't seem
   # to happen in practice.
-  all_flags = flag_string.strip().split(' ')
+  all_flags = ConvertGCCToMSVC(flag_string.strip().split(' '))
 
 
   sysroot = options.sysroot
@@ -220,7 +253,10 @@ def main():
       continue;
 
     if flag[:2] == '-l':
-      libs.append(RewritePath(flag[2:], prefix, sysroot))
+      library = RewritePath(flag[2:], prefix, sysroot)
+      # Skip math library on MSVC
+      if library != 'm.lib':
+        libs.append(library)
     elif flag[:2] == '-L':
       lib_dirs.append(RewritePath(flag[2:], prefix, sysroot))
     elif flag[:2] == '-I':
@@ -237,6 +273,14 @@ def main():
     else:
       cflags.append(flag)
 
+  if options.full_path_libs:
+    full_path_libs = []
+    for lib_dir in lib_dirs:
+      for lib in libs:
+        if os.path.isfile(lib_dir+"/"+lib):
+          full_path_libs.append(lib_dir+"/"+lib)
+    libs = full_path_libs
+
   # Output a GN array, the first one is the cflags, the second are the libs. The
   # JSON formatter prints GN compatible lists when everything is a list of
   # strings.
diff --git a/config/linux/pkg_config.gni b/config/linux/pkg_config.gni
index 428e44ac0..a0d2175ee 100644
--- a/config/linux/pkg_config.gni
+++ b/config/linux/pkg_config.gni
@@ -45,6 +45,9 @@ declare_args() {
   # in similar fashion by setting the `system_libdir` variable in the build's
   # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture.
   system_libdir = "lib"
+
+  # Allow directly overriding the PKG_CONFIG_LIBDIR enviroment variable
+  pkg_config_libdir = ""
 }
 
 pkg_config_script = "//build/config/linux/pkg-config.py"
@@ -87,6 +90,17 @@ if (host_pkg_config != "") {
   host_pkg_config_args = pkg_config_args
 }
 
+if (pkg_config_libdir != "") {
+  pkg_config_args += [
+    "--pkg_config_libdir",
+    pkg_config_libdir,
+  ]
+  host_pkg_config_args += [
+    "--pkg_config_libdir",
+    pkg_config_libdir,
+  ]
+}
+
 template("pkg_config") {
   assert(defined(invoker.packages),
          "Variable |packages| must be defined to be a list in pkg_config.")
diff --git a/util/lastchange.py b/util/lastchange.py
index 02a36642b..78934f1b0 100755
--- a/util/lastchange.py
+++ b/util/lastchange.py
@@ -192,7 +192,10 @@ def GetGitTopDirectory(source_dir):
   Returns:
     The output of "git rev-parse --show-toplevel" as a string
   """
-  return _RunGitCommand(source_dir, ['rev-parse', '--show-toplevel'])
+  directory = _RunGitCommand(source_dir, ['rev-parse', '--show-toplevel'])
+  if "GCC" in sys.version and sys.platform=='win32':
+    return subprocess.check_output(["cygpath", "-w", directory]).strip(b"\n").decode()
+  return directory
 
 
 def WriteIfChanged(file_name, contents):