Skip to content

Commit 811d2e5

Browse files
committed
Also warn the user about stripping out dead stuff from libs.
1 parent e66d1de commit 811d2e5

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

driver/utils.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,10 @@ def __init__(self, inputList, exactMatches={}, patternMatches={}):
189189
'-nodefaultlibs' : (0, ArgumentListFilter.linkUnaryCallback),
190190
# darwin flags
191191
'-dynamiclib' : (0, ArgumentListFilter.linkUnaryCallback),
192-
# need to warn the darwin user that this one will rain on their parade
193-
'-fvisibility=hidden' : (0, ArgumentListFilter.darwinWarningCallback),
192+
# need to warn the darwin user that these flags will rain on their parade
193+
# (otool is a bit single minded)
194+
'-fvisibility=hidden' : (0, ArgumentListFilter.darwinWarningCompilerUnaryCallback),
195+
'-Wl,-dead_strip' : (0, ArgumentListFilter.darwinWarningLinkUnaryCallback),
194196

195197
}
196198

@@ -320,13 +322,20 @@ def linkUnaryCallback(self, flag):
320322
def compileUnaryCallback(self, flag):
321323
self.compileArgs.append(flag)
322324

323-
def darwinWarningCallback(self, flag):
325+
def darwinWarningCompileUnaryCallback(self, flag):
324326
if sys.platform.startswith('darwin'):
325327
_logger.warning('The flag "{0}" cannot be used with this tool'.format(flag))
326328
sys.exit(1)
327329
else:
328330
self.compileArgs.append(flag)
329331

332+
def darwinWarningLinkUnaryCallback(self, flag):
333+
if sys.platform.startswith('darwin'):
334+
_logger.warning('The flag "{0}" cannot be used with this tool'.format(flag))
335+
sys.exit(1)
336+
else:
337+
self.linkArgs.append(flag)
338+
330339
def defaultBinaryCallback(self, flag, arg):
331340
_logger.warning('Ignoring compiler arg pair: "{0} {1}"'.format(flag, arg))
332341

test/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ archive: objects
3030
dylib: objects
3131
${CC} -dynamiclib foo.o bar.o baz.o -o libfoo.dylib
3232

33+
deadstrip: objects
34+
${CC} -dynamiclib -Wl,-dead_strip foo.o bar.o baz.o -o libfoo.dylib
35+
3336

3437
link_with_archive:: archive
3538
$(CC) main.o libfoo.a -o main.arch

0 commit comments

Comments
 (0)