aboutsummaryrefslogtreecommitdiff
path: root/ports/v8/build.patch
blob: 7394c6591205a5fbd09c110b508be8ec0bfabdf6 (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
diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn
index 5a0984f54..4f301517b 100644
--- a/config/compiler/BUILD.gn
+++ b/config/compiler/BUILD.gn
@@ -1473,6 +1473,8 @@ 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
+      "-Wno-range-loop-construct",
     ]
   }

@@ -1887,11 +1889,21 @@ 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 = [
+  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).
   ]
+
   if (!is_asan) {
     common_optimize_on_cflags += [
       # Put data in separate COMDATs. This allows the linker
diff --git a/config/linux/pkg-config.py b/config/linux/pkg-config.py
index 5adf70cc3..1438c365b 100644
--- a/config/linux/pkg-config.py
+++ b/config/linux/pkg-config.py
@@ -41,7 +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):
   """Set the PKG_CONFIG_LIBDIR environment variable.
@@ -105,11 +109,29 @@ 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."""
+  if 'win32' not in sys.platform:
+    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

@@ -122,12 +144,15 @@ def main():
   parser.add_option('-a', action='store', dest='arch', type='string')
   parser.add_option('--system_libdir', action='store', dest='system_libdir',
                     type='string', default='lib')
+  parser.add_option('--pkg_config_libdir', action='store', dest='pkg_config_libdir',
+                    type='string')
   parser.add_option('--atleast-version', action='store',
                     dest='atleast_version', type='string')
   parser.add_option('--libdir', action='store_true', dest='libdir')
   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('--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 +169,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 +232,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 +249,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 +269,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.")