Skip to content

Commit

Permalink
build: syms: add support for Mach-O binaries
Browse files Browse the repository at this point in the history
Current code stolen from waf's extras, only supported 'pe' and 'elf'. OS X
uses the 'Mach-O' binary format (which waf calls 'mac-o'... go figure).

Add support for generating the global symbols file with nm and using it from
clang.
  • Loading branch information
pigoz committed Feb 19, 2014
1 parent f6ed246 commit 08170c6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion waftools/syms.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def run(self):
kw['env'] = env

else:
if self.env.DEST_BINFMT == 'pe': #gcc uses nm, and has a preceding _ on windows
if self.env.DEST_BINFMT in ('pe', 'mac-o'): #gcc uses nm, and has a preceding _ on windows and osx
re_nm = re.compile(r'T\s+_(' + self.generator.export_symbols_regex + r')\b')
else:
re_nm = re.compile(r'T\s+(' + self.generator.export_symbols_regex + r')\b')
Expand All @@ -56,6 +56,8 @@ def run(self):
self.outputs[0].write('EXPORTS\n' + '\n'.join(lsyms))
elif self.env.DEST_BINFMT == 'elf':
self.outputs[0].write('{ global:\n' + ';\n'.join(lsyms) + ";\nlocal: *; };\n")
elif self.env.DEST_BINFMT == 'mac-o':
self.outputs[0].write('\n'.join("_"+sym for sym in lsyms))
else:
raise WafError('NotImplemented')

Expand All @@ -76,6 +78,8 @@ def do_the_symbol_stuff(self):
self.link_task.inputs.append(tsk.outputs[0])
elif self.env.DEST_BINFMT == 'elf':
self.link_task.env.append_value('LINKFLAGS', ['-Wl,-version-script', '-Wl,' + tsk.outputs[0].bldpath()])
elif self.env.DEST_BINFMT == 'mac-o':
self.link_task.env.append_value('LINKFLAGS', ['-exported_symbols_list', tsk.outputs[0].bldpath()])
else:
raise WafError('NotImplemented')

0 comments on commit 08170c6

Please sign in to comment.