do not pass -g to LLVM if we were passed -gX with low X (less than 4, which is when we do include LLVM debug info); fixes #2657

This commit is contained in:
Alon Zakai 2014-08-12 14:32:40 -07:00
Родитель a91fb06712
Коммит 70a171ee59
2 изменённых файлов: 20 добавлений и 1 удалений

6
emcc
Просмотреть файл

@ -948,7 +948,11 @@ try:
elif newargs[i].startswith('-g'):
requested_level = newargs[i][2:] or '3'
debug_level = validate_arg_level(requested_level, 4, 'Invalid debug level: ' + newargs[i])
newargs[i] = '-g' # we'll need this to get LLVM debug info
if newargs[i] != '-g':
if debug_level >= 4:
newargs[i] = '-g' # we'll need this to get LLVM debug info
else:
newargs[i] = ''
elif newargs[i] == '-profiling':
debug_level = 2
profiling = True

Просмотреть файл

@ -3928,3 +3928,18 @@ main(const int argc, const char * const * const argv)
test(['-o', 'c.html'], True)
test(['-c'], False)
def dash_g_bc(self):
def get_size(name):
return len(open(name).read())
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-o', 'a_.bc']).communicate()
sizes = { '_': get_size('a_.bc') }
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-g', '-o', 'ag.bc']).communicate()
sizes['g'] = get_size('ag.bc')
for i in range(0, 5):
Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-g' + str(i), '-o', 'a' + str(i) + '.bc']).communicate()
sizes[i] = get_size('a' + str(i) + '.bc')
print sizes
assert sizes['_'] == sizes[0] == sizes[1] == sizes[2] == sizes[3], 'no debug or <4 debug, means no llvm debug info'
assert sizes['g'] == sizes[4], '-g or -g4 means llvm debug info'
assert sizes['_'] < sizes['g'], 'llvm debug info has positive size'