Windows: Fix crash when AVX instructions are not supported (issue #1999)

This commit is contained in:
Marshall Greenblatt 2016-10-27 12:04:25 -04:00
parent be15daa844
commit f7a4102978
2 changed files with 77 additions and 0 deletions

View File

@ -7,6 +7,7 @@ from gclient_util import *
from gn_args import GetAllPlatformConfigs, GetConfigFileContents from gn_args import GetAllPlatformConfigs, GetConfigFileContents
from file_util import make_dir, write_file from file_util import make_dir, write_file
import os, sys import os, sys
import issue_1999
# The CEF directory is the parent directory of _this_ script. # The CEF directory is the parent directory of _this_ script.
cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir)) cef_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
@ -132,3 +133,5 @@ for dir, config in configs.items():
if 'GN_ARGUMENTS' in os.environ.keys(): if 'GN_ARGUMENTS' in os.environ.keys():
cmd.extend(os.environ['GN_ARGUMENTS'].split(' ')) cmd.extend(os.environ['GN_ARGUMENTS'].split(' '))
RunAction(src_dir, cmd) RunAction(src_dir, cmd)
if platform == 'windows':
issue_1999.apply(out_path)

74
tools/issue_1999.py Normal file
View File

@ -0,0 +1,74 @@
# Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
# reserved. Use of this source code is governed by a BSD-style license that
# can be found in the LICENSE file.
#
# Resort order of object files in libcef.ninja file.
#
# See: https://bitbucket.org/chromiumembedded/cef/issues/1999
#
# Usage:
# import issue_1999
# issue_1999.apply(output_path)
#
import sys
import os
module_order = [
"_sse", "-sse", "_ssse", "-ssse",
"_sse2", "-sse2", "_ssse2", "-ssse2",
"_sse3", "-sse3", "_ssse3", "-ssse3",
"_sse4", "-sse4", "_ssse4", "-ssse4",
"_avx", "-avx", "_savx", "-savx",
"_avx1", "-avx1", "_savx1", "-savx1",
"_avx2", "-avx2", "_savx2", "-savx2",
]
def get_obj_class(item):
item = item.lower()
for i in range(len(module_order) - 1, -1, -1):
x = module_order[i]
if x in item:
return 1 + i
return 0
def obj_compare(x, y):
xc = get_obj_class(x)
yc = get_obj_class(y)
if xc < yc: return -1
elif xc > yc: return 1
else: return 0
def process_line(line):
if line.startswith("build ./libcef.dll ./libcef.dll.lib: solink "):
index = line.find("solink")
if index >= 0:
part1 = line[0:index + 6]
part2 = line[index + 6:]
stampsIndex = part2.find("||")
stamps = part2[stampsIndex:]
objects = part2[:stampsIndex]
objects_list = objects.split()
objects_list = sorted(objects_list, cmp = obj_compare)
return part1 + " " + " ".join(objects_list) + " " + stamps
return line
def process_file(path):
print "Issue #1999: " + path
with open(path) as f:
content = f.read().splitlines()
result = []
for line in content:
result.append(process_line(line))
with open(path, "w") as f:
f.write("\n".join(result))
f.write("\n")
def apply(confpath):
process_file(os.path.join(confpath, "obj/cef/libcef.ninja"))